Skip to content

[Follow-up] Add append/replace system prompt modes and immutable workspace prompt snapshots#494

Merged
benjaminfh merged 6 commits intomasterfrom
codex/2026-02-20/github-mention-fr]-user-defined-system-prompts
Feb 20, 2026
Merged

[Follow-up] Add append/replace system prompt modes and immutable workspace prompt snapshots#494
benjaminfh merged 6 commits intomasterfrom
codex/2026-02-20/github-mention-fr]-user-defined-system-prompts

Conversation

@benjaminfh
Copy link
Owner

Motivation

  • Provide users a per-account custom system prompt with two modes (append / replace) to influence assistant behaviour.
  • Ensure workspace stability by snapping the effective system prompt at project creation so existing workspaces keep deterministic context.
  • Surface controls in the Profile UI with a clear note that changes apply only to new workspaces.

Description

  • Add a system prompt domain helper with buildDefaultSystemPrompt and resolveSystemPrompt to centralize default prompt construction and append/replace resolution (src/server/systemPrompt.ts).
  • Extend the profile API to read/write user prompt settings (systemPrompt, systemPromptMode) and wire RPC adapters for persistence (app/api/profile/route.ts, src/store/pg/userSystemPrompt.ts, src/store/pg/userLlmKeys.ts).
  • Add profile UI controls for mode toggling, editable prompt textarea, clear action, save button, and Cmd/Ctrl+Enter submission; also display the note that changes affect new workspaces only (src/components/profile/ProfilePageClient.tsx).
  • Snapshot the resolved effective system prompt when creating a project and persist it to both PG and local git metadata; always use the stored project prompt for chat/edit context (app/api/projects/route.ts, src/store/pg/projects.ts, src/git/projects.ts, src/server/context.ts).
  • Add local PG RPC adapter and Supabase migration updates to support user settings and project system_prompt columns and updated RPC signatures (src/store/pg/localAdapter.ts, supabase/migrations/20260220145436_user_system_prompt_modes.sql).

Testing

  • Ran type/lint and RPC consistency checks with npm run lint, which completed successfully.
  • Started the dev server (npm run dev) and observed Next.js start (local smoke run), but full E2E Playwright screenshot attempt failed due to the Playwright/Chromium process crashing in this environment (SIGSEGV), so no UI screenshot artifact was produced.

Codex Task

Implement profile-level custom system prompt settings with append/replace behavior, and persist immutable effective prompts on project creation so existing workspaces remain stable.

- add a dedicated system prompt helper module for default prompt construction and append/replace resolution

- extend profile API + PG adapters with user system prompt mode/content read/write support

- add profile UI controls for mode toggle, editable prompt text, clear action, save button, and cmd/ctrl+Enter submission

- snapshot the effective system prompt at project creation and store it for both PG and git metadata paths

- update chat context construction to use per-project immutable system prompts when present

- add supabase migration for user settings columns, project system_prompt column, and updated/recreated RPC functions
@vercel
Copy link

vercel bot commented Feb 20, 2026

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

Project Deployment Actions Updated (UTC)
threds Ready Ready Preview, Comment Feb 20, 2026 4:47pm

@supabase
Copy link

supabase bot commented Feb 20, 2026

Updates to [Preview Branch (codex/2026-02-20/github-mention-fr]-user-defined-system-prompts) ↗︎](https://supabase.com/dashboard/project/kciyvgodwmgosahrqpna)

Deployments Status Updated
Database Fri, 20 Feb 2026 16:47:05 UTC
Services Fri, 20 Feb 2026 16:47:05 UTC
APIs Fri, 20 Feb 2026 16:47:05 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations Fri, 20 Feb 2026 16:47:05 UTC
Migrations Fri, 20 Feb 2026 16:47:06 UTC
Seeding Fri, 20 Feb 2026 16:47:06 UTC
Edge Functions Fri, 20 Feb 2026 16:47:06 UTC

View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d5c1f8ce3f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…eturn-type rules

Resolve the Supabase migration failure by explicitly dropping and recreating the key-status RPC before changing its OUT columns. Also restore explicit execute grants after recreation to preserve access semantics.

- add  before redefining the function with new OUT parameters

- add revoke/grant statements for  after recreation to keep authenticated execution permissions explicit
Prevent profile PUT requests from unintentionally clearing prompt text or resetting mode when clients send only one of the system prompt fields.

- fetch current user system prompt settings before applying partial updates

- merge incoming systemPrompt/systemPromptMode fields with existing values instead of coercing missing fields

- keep explicit clear behavior when systemPrompt is provided as null/empty
Align server/store tests with the new project system prompt and profile prompt-setting behavior, and restore deterministic mocks where new RPC reads were introduced.

- mock rtGetProjectShadowV1 in context tests to prevent unintended Supabase client initialization during pg-mode unit coverage

- mock rtGetUserSystemPromptV1 in projects route tests and assert the new p_system_prompt wiring in rt_create_project calls

- update pg store/local adapter tests for the expanded rt_create_project signature including p_system_prompt

- update user key status mapping assertions to include systemPrompt/systemPromptMode fields
@benjaminfh
Copy link
Owner Author

@codex, review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dcf7d9f9c2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@benjaminfh
Copy link
Owner Author

smoke tested a replace system prompt - working

…lity

Ensure project-creation prompt snapshots use the same canvas tool gating as runtime context construction so workspaces do not persist tool-available instructions in git mode.

- change getCurrentEffectiveSystemPrompt to accept store mode and gate canvas tools on store.mode === 'pg' plus RT_CANVAS_TOOLS

- pass the resolved store mode from POST before computing the effective snapshot prompt
@benjaminfh
Copy link
Owner Author

@codex, final review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f862c236d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…efresh errors

Reduce metadata exposure in list APIs and make profile saves resilient to transient post-save refresh failures so successful writes are not misreported as failed.

- strip systemPrompt from git-mode project summaries returned by listProjects while keeping full prompt available via getProject for runtime context

- make loadProfile after successful profile PUT best-effort in token/system-prompt save flows and keep success notices even when refresh fails

- add regression coverage verifying listProjects omits systemPrompt while getProject retains the snapshot
@benjaminfh benjaminfh merged commit 885d6c0 into master Feb 20, 2026
6 checks passed
@benjaminfh benjaminfh deleted the codex/2026-02-20/github-mention-fr]-user-defined-system-prompts branch February 20, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant