Skip to content

873 update system prompt when source or target language is changed#1017

Open
Luke-Bilhorn wants to merge 10 commits into
mainfrom
873-update-system-prompt-when-source-or-target-language-is-changed
Open

873 update system prompt when source or target language is changed#1017
Luke-Bilhorn wants to merge 10 commits into
mainfrom
873-update-system-prompt-when-source-or-target-language-is-changed

Conversation

@Luke-Bilhorn

@Luke-Bilhorn Luke-Bilhorn commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

I made this so that the user is asked to regenerate (or edit) their system prompt if they change the source or target language (see issue). Made it so that it does not give a warning against changing it, since in this case the user almost certainly does need to change this. Also made sure that the other use cases of system prompt editing have not broken, and changed the button colors to match throughout.

Test Checklist

Changing the TARGET language (from Project Manager)

  • Open a project that already has AI translation instructions set.
  • Change the target language to a different language.
  • Confirm the normal "Target language set to ___" message appears.
  • Confirm a new window titled "Review AI Translation Instructions" opens.
  • The window shows a yellow warning banner explaining that you changed the target language, and naming the new direction (e.g. "English → Spanish").
  • The window shows your current instructions in an editable text box.

Changing the SOURCE language (from Project Manager)

  • Change the source language to a different language.
  • Confirm the review window opens with a banner that mentions the source language changed.

Picking the SAME language again (no change)

  • Change the target (or source) language but pick the same language it already was.
  • Confirm the review window does NOT open. (It should only appear when the language actually changes.)

The buttons inside the review window

  • "Regenerate" button is the highlighted/primary button when the window first opens.
  • Click Regenerate → button shows a spinner and "Generating…", then the text box fills with freshly generated instructions matching the new languages.
  • After regenerating (or after you type/edit the text yourself), the "Save" button becomes the highlighted button instead.
  • Click Save → the window closes, and the new instructions are actually saved (check Copilot Settings → System Message to confirm).
  • Regenerating should not show an "are you sure you want to overwrite?" warning — it just regenerates.

The "I don't need to change this" button

  • Open the review window again (change a language).
  • Click "I don't need to change this".
  • Confirm a warning message appears reminding you to make sure the instructions match.
  • Confirm the window closes and your instructions are left unchanged.

Closing the window with the X (without using any button)

  • Change a language to open the review window.
  • Close the window using the X / close tab (don't click Save or Dismiss).
  • Confirm a progress notification appears: "Regenerating AI translation instructions".
  • Confirm a success message: "Your AI translation instructions were regenerated to match the new language."
  • Check Copilot Settings → System Message and confirm the instructions were automatically regenerated (so nothing is left stale).

Changing both languages back-to-back (no duplicate windows)

  • Change the target language (review window opens).
  • Without closing it, change the source language too.
  • Confirm only one review window exists (no duplicate windows pile up).
  • Confirm the banner updates to mention that both languages changed.

Changing language from the Startup / New Project flow

  • In the Startup Flow (project setup wizard), change the source or target language.
  • Confirm the same "Review AI Translation Instructions" window appears (and only when the language actually changed).

Copilot Settings — Generate button polish

  • Open Copilot Settings.
  • Click Generate / Regenerate instructions.
  • While it's working: the button shows a spinning icon and "Generating…", the text box is greyed out / locked, and Save is disabled — so you can't double-click or edit mid-generation.
  • When it finishes: everything unlocks and the new text appears.
  • If generation fails (e.g. bad/missing API key): confirm the buttons and text box unlock again instead of staying stuck in the "Generating…" state, and an error message is shown.

Edge cases / safety checks

  • If source or target language is somehow missing when closing the window with X, confirm you get a plain reminder warning instead of a crash or broken regeneration.
  • Confirm regenerated/saved instructions clearly reflect the new language pair, not the old one.
  • Confirm nothing breaks (no error popups) when changing languages in a project that had no AI instructions set yet.
  • change the project language and make sure the flow of updating the system prompt is good
  • go to edit the system prompt in copilot settings and verify it looks good
  • create a new project and verify that the system prompt flow there is unchanged

The component is consumed outside StartupFlow already (NewSourceUploader),
and an upcoming SystemMessageReview webview will reuse it too. Move it to
the shared components directory so its location reflects its scope.

No behavior change.
…mMessageStep

These let consumers reuse the component in non-walkthrough contexts (e.g.
the upcoming system-message review prompt after a language change), where
a contextual banner and an explicit "I don't need to change this" dismiss
button are needed.

Defaults preserve current behavior in NewSourceUploader.
A standalone React app that hosts the shared SystemMessageStep with a
language-change warning banner and an "I don't need to change this"
dismiss button. Will be opened after a project source/target language
change to prompt the user to review their AI translation instructions.

Wired into the build pipeline alongside the other webview apps. Not yet
opened from anywhere; provider wiring follows in subsequent commits.
Adds openSystemMessageReview(reason) and registers
codex-editor-extension.promptSystemMessageReview as a thin wrapper. The
panel hosts the SystemMessageReview webview and handles the
generate / save / dismiss flow against MetadataManager.

If the panel is closed without the user addressing the prompt (save,
regenerate, or "I don't need to change this"), the AI translation
instructions are regenerated automatically so they don't stay stale
relative to the new language. Concurrent triggers reuse a single panel
so back-to-back source+target changes don't spawn duplicate windows.

Not yet triggered from anywhere; wiring follows in the next commit.
Wires the codex-editor-extension.promptSystemMessageReview command into
both paths that can change a project's source or target language after
initial setup:

- codex-project-manager.changeSourceLanguage / changeTargetLanguage
  (MainMenu and project settings entry points)
- StartupFlowProvider.handleProjectChange (pre-open project edit screen)

The prompt is only shown when the selected language tag differs from
the existing one, so re-confirming the same language is a no-op. The
initial project-creation flow remains untouched.

Closes #873.
…ning per context

- Simplify the Generate/Save button internals: drop the hand-rolled
  margin/padding offsets that produced uneven icon spacing in favor of
  a single inline-flex wrapper with a uniform gap. Fixes the wonky-
  looking sparkle icon on the Generate button.
- Add generateLabel + skipOverwriteWarning props to SystemMessageStep.
- The new SystemMessageReview panel now shows "Regenerate" and skips
  the overwrite-confirmation dialog (regenerating is the expected next
  step of that flow).
- Trim the overwrite warning copy to "Generating a new message will
  overwrite your current text." since the Cancel / Overwrite and
  Generate buttons make the rest self-explanatory.
The review panel's "Save Translation Instructions" label was long enough
to wrap inside the fixed-min-width button, producing a visually broken
multi-line label. Shorten the review label to "Save" and add
white-space: nowrap to the button content wrappers so future labels
can't wrap either.
In the language-change review flow the expectation is that the user
*changes* their translation instructions, so Regenerate should be the
primary call-to-action and Save should be demoted. Once the user has
either regenerated or edited the text manually, swap them so Save is
the highlighted next step.

Behavior is gated behind a new emphasizeGenerateUntilEdited prop so the
existing project-creation flow (where Save is always primary) is
unaffected.
In the Copilot Settings system-message editor:
- The Regenerate button keeps its layout but swaps the sparkle icon for
  a spinning loader while a generation is in flight, and disables itself
  to prevent re-entry.
- The textarea, the empty-state Generate button, and the "Save All
  Settings" button are also disabled during generation so the user
  can't edit or save half-state. Cancel stays available as an escape.
- The provider now posts generateError when generation throws, so the
  webview can recover its UI state instead of staying stuck on the
  spinner.
@Luke-Bilhorn Luke-Bilhorn linked an issue Jun 1, 2026 that may be closed by this pull request
@Luke-Bilhorn

Copy link
Copy Markdown
Contributor Author

We still could go back and make sure all the "Regenerate" buttons have the same rounding.

@LeviXIII LeviXIII left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • Pressing Enter in the language selection field when the full word isn't typed out will cause the warning message to display [your source language] instead of the selected language.
  • "I don't need to change this" -> "Cancel". Also change toast to modal directing user to Co-pilot settings to change system message if they still need to
  • "Target" language doesn't change when selecting a new language
  • Clicking "x" in the change system message webview automatically changes the system message

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.

Update system prompt when source or target language is changed.

2 participants