Skip to content

Conversation

@Kitenite
Copy link
Contributor

@Kitenite Kitenite commented Sep 24, 2025

Description

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Release
  • Refactor
  • Other (please describe):

Testing

Screenshots (if applicable)

Additional Notes


Important

Refactor prompt files into a constants directory and update related imports, with minor prompt content updates for clarity.

  • Refactor:
    • Move prompt files to constants directory in packages/ai/src/prompt/.
    • Update imports in provider.ts, onlook-instructions.ts, and suggestion.ts to reflect new paths.
  • Prompt Updates:
    • Update filesContentPrefix and highlightPrefix in context.ts for clarity.
    • Modify SYSTEM_PROMPT in system.ts to emphasize not altering data-oid attributes.
  • Misc:
    • Add index.ts in constants directory to export all constants.

This description was created by Ellipsis for 700c721. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • Documentation

    • Updated in-app guidance text: shorter file context intro, clearer highlight instructions with line numbers, and an explicit trust warning.
    • Strengthened guidance language around attribute handling.
  • Refactor

    • Consolidated AI prompt constants into a single entry point and streamlined imports across modules.
    • Simplified public API exposure for prompt utilities to reduce fragmentation and improve maintainability.

@vercel
Copy link

vercel bot commented Sep 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
web Ready Ready Preview Comment Sep 24, 2025 8:09pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Sep 24, 2025 8:09pm

@supabase
Copy link

supabase bot commented Sep 24, 2025

This pull request has been ignored for the connected project wowaemfasoptxrdjhilu because there are no changes detected in apps/backend/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai
Copy link

coderabbitai bot commented Sep 24, 2025

Walkthrough

Consolidates imports around a new constants entry point, updates prompt text in context and system constants, adds a constants barrel export, adjusts the prompt package’s public exports, and updates dependent import paths. One web API router merges imports. No runtime control-flow changes.

Changes

Cohort / File(s) Summary of edits
Prompt constants text updates
packages/ai/src/prompt/constants/context.ts, packages/ai/src/prompt/constants/system.ts
Revised user-facing strings: simplified filesContentPrefix; expanded highlightPrefix guidance and trust warning; strengthened SYSTEM_PROMPT prohibition on handling data-oid attributes.
Constants barrel and public surface
packages/ai/src/prompt/constants/index.ts, packages/ai/src/prompt/index.ts
Added constants barrel re-exporting multiple modules; updated prompt public API to export from ./constants and stop exporting create, onlook, summary.
Import consolidation to constants
packages/ai/src/prompt/provider.ts, packages/ai/src/tools/classes/onlook-instructions.ts
Replaced multiple individual imports with a single import from ./constants; updated ONLOOK_INSTRUCTIONS import path accordingly. No logic changes.
Web router import aggregation
apps/web/client/src/server/api/routers/chat/suggestion.ts
Merged two @onlook/ai imports into one combined import line.

Sequence Diagram(s)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

A nibble of imports, tidy and neat,
New constants burrow where modules meet.
Prompts now warn with firmer tone,
“Leave data-oid seeds alone!”
I thump approval—ears held high,
Barrel exports hop on by.
Carrots compiled; we ship. Goodbye! 🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description retains the template headings but leaves all sections blank and does not provide any substantive information within the required template fields, relying instead on an Ellipsis-generated summary that is not integrated into the template. Please fill in each section of the PR template with clear details: add a concise description of your changes under “Description,” link related issues, select the appropriate type of change, describe testing steps, and include any relevant screenshots or additional notes.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title “fix: update prompts” is related to the changes since it indicates prompt updates, but it is overly broad and does not clearly summarize the primary refactor of moving prompts to a constants directory and reorganizing imports.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/contexts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
apps/web/client/src/server/api/routers/chat/suggestion.ts (2)

13-19: Block user-supplied system-role messages (prompt injection vector).

Allowing clients to send role: "system" after your own system prompt can override it. Restrict roles to user/assistant and filter out any incoming system messages.

Apply these diffs:

-            messages: z.array(z.object({
-                role: z.enum(['user', 'assistant', 'system']),
+            messages: z.array(z.object({
+                role: z.enum(['user', 'assistant']),
                 content: z.string(),
             })),
-                    ...convertToModelMessages(input.messages.map((m) => ({
+                    ...convertToModelMessages(
+                        input.messages
+                            .filter((m) => m.role !== 'system')
+                            .map((m) => ({
                         role: m.role,
                         parts: [{ type: 'text', text: m.content }],
-                    }))),
+                    }))),

Also applies to: 34-37


47-49: Restrict suggestion update to current project
Add a predicate on conversations.projectId to match ctx.session.projectId and import and:

-import { eq } from 'drizzle-orm';
+import { and, eq } from 'drizzle-orm';-    await ctx.db.update(conversations).set({
-        suggestions,
-    }).where(eq(conversations.id, input.conversationId));
+    await ctx.db.update(conversations).set({ suggestions }).where(
+        and(
+            eq(conversations.id, input.conversationId),
+            eq(conversations.projectId, ctx.session.projectId)
+        )
+    );
🧹 Nitpick comments (2)
packages/ai/src/prompt/constants/context.ts (2)

1-1: Minor copy edit (optional).

Consider making the prefix more direct; current copy is fine if intentionally conversational.


24-24: Brand capitalization nit (optional).

Use “Next.js” and “Tailwind CSS” for consistency.

-const projectContextPrefix = `This is a Nextjs project with TailwindCSS`;
+const projectContextPrefix = `This is a Next.js project with Tailwind CSS`;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5fec6d9 and 700c721.

📒 Files selected for processing (7)
  • apps/web/client/src/server/api/routers/chat/suggestion.ts (1 hunks)
  • packages/ai/src/prompt/constants/context.ts (1 hunks)
  • packages/ai/src/prompt/constants/index.ts (1 hunks)
  • packages/ai/src/prompt/constants/system.ts (1 hunks)
  • packages/ai/src/prompt/index.ts (1 hunks)
  • packages/ai/src/prompt/provider.ts (1 hunks)
  • packages/ai/src/tools/classes/onlook-instructions.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Do not use the any type unless necessary

Files:

  • packages/ai/src/prompt/index.ts
  • packages/ai/src/prompt/constants/index.ts
  • apps/web/client/src/server/api/routers/chat/suggestion.ts
  • packages/ai/src/prompt/constants/context.ts
  • packages/ai/src/prompt/constants/system.ts
  • packages/ai/src/prompt/provider.ts
  • packages/ai/src/tools/classes/onlook-instructions.ts
{apps,packages}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Avoid using the any type unless absolutely necessary

Files:

  • packages/ai/src/prompt/index.ts
  • packages/ai/src/prompt/constants/index.ts
  • apps/web/client/src/server/api/routers/chat/suggestion.ts
  • packages/ai/src/prompt/constants/context.ts
  • packages/ai/src/prompt/constants/system.ts
  • packages/ai/src/prompt/provider.ts
  • packages/ai/src/tools/classes/onlook-instructions.ts
apps/web/client/src/server/api/routers/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

apps/web/client/src/server/api/routers/**/*.ts: Place tRPC routers under apps/web/client/src/server/api/routers/**
Use publicProcedure/protectedProcedure from apps/web/client/src/server/api/trpc.ts and validate inputs with Zod
Return plain objects/arrays; rely on SuperJSON for serialization in tRPC procedures

apps/web/client/src/server/api/routers/**/*.ts: Place tRPC routers under src/server/api/routers/**
Use publicProcedure/protectedProcedure from src/server/api/trpc.ts and validate inputs with Zod
Return plain objects/arrays; rely on SuperJSON for serialization

Files:

  • apps/web/client/src/server/api/routers/chat/suggestion.ts
apps/web/client/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

apps/web/client/src/**/*.{ts,tsx}: Use path aliases @/* and ~/* for imports that map to apps/web/client/src/*
Avoid hardcoded user-facing text; use next-intl messages/hooks instead

Use path aliases @/* and ~/* for imports mapping to src/*

Files:

  • apps/web/client/src/server/api/routers/chat/suggestion.ts
🔇 Additional comments (7)
apps/web/client/src/server/api/routers/chat/suggestion.ts (2)

1-1: Import consolidation LGTM

Single-source import from @onlook/ai improves clarity and aligns with the new public surface.


43-44: Verify token limit option name and right-sizing.

For OpenRouter via the ai SDK, the option is typically maxTokens, not maxOutputTokens. 10k is excessive for 3 brief suggestions.

Consider:

-                maxOutputTokens: 10000,
+                maxTokens: 512,

If your ai package expects maxOutputTokens, keep it; otherwise switch to maxTokens. Please confirm against your installed ai SDK.

packages/ai/src/tools/classes/onlook-instructions.ts (1)

4-4: Import path update LGTM

Switching ONLOOK_INSTRUCTIONS to the constants barrel matches the new public surface.

packages/ai/src/prompt/constants/system.ts (1)

14-14: Directive tightening LGTM

Stronger guidance around data-oid handling is clear and unambiguous.

packages/ai/src/prompt/provider.ts (1)

10-10: Barrel import consolidation LGTM

Reduces import churn and centralizes prompt sourcing.

packages/ai/src/prompt/constants/index.ts (1)

1-11: New constants barrel LGTM

Centralized re-exports simplify consumption and align with related import changes.

packages/ai/src/prompt/index.ts (1)

1-1: No stale imports remain. Search across the codebase found no references to prompt/create, prompt/onlook, or prompt/summary. Public surface change is safe.

@Kitenite Kitenite merged commit b616f66 into main Sep 24, 2025
8 checks passed
@Kitenite Kitenite deleted the fix/contexts branch September 24, 2025 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants