Skip to content

fix: guard unsaved prompt-stage edits when switching stages (#6021) - #6126

Merged
atomantic merged 1 commit into
mainfrom
claim/issue-6021
Sep 3, 2026
Merged

fix: guard unsaved prompt-stage edits when switching stages (#6021)#6126
atomantic merged 1 commit into
mainfrom
claim/issue-6021

Conversation

@atomantic

Copy link
Copy Markdown
Owner

Summary

Editing a prompt stage's template, model tier, or timeout override and then clicking another stage in the Stages list silently discarded the edits: the click called setSelectedStage directly, and the selectedStage effect immediately re-fetched and overwrote the editor. Prompt templates run to hundreds of lines, so a mis-tap in the 120+ row stage list destroyed real work with no warning and no undo.

The Stages tab now uses the same unsaved-edit guard the Job Skills tab has had since #3939:

  • savedStageTemplate / savedStageConfig hold the last server-confirmed values (set when getPrompt resolves and after a successful save), so an edit undone back to the original stops counting as dirty.
  • A dirty editor shows an "Unsaved changes" note under the stage heading and an "Unsaved" badge on its list row.
  • Clicking a different stage parks it in pendingStage and turns that row into an InlineConfirmRow ("Discard" / "Keep editing") instead of switching — the URL, the fetch, and the typed text all hold. No window.confirm, per client/src/AGENTS.md.
  • Confirming discards and switches; cancelling, undoing the edit, or saving clears the prompt. Re-clicking the already-open stage backs out of the question.
  • Saving re-baselines only while the same stage is still open, so a PUT that lands after the user moved on can't stamp the outgoing stage's text onto the incoming one.

Deep linking is untouched — selection still lives entirely in the ?stage= param.

Test plan

  • client/src/pages/PromptManager.test.jsx gains a PromptManager stage unsaved-edit guard suite (10 cases): dirty on template edit, dirty on config-only change, revert-to-clean, arming the confirm row without switching, "Keep editing", "Discard", no prompt after a save, disarm on undo, back-out on re-click, and no prompt from a clean editor. 9 of the 10 fail against main (the 10th is the clean-switch regression guard).
  • cd client && npm test — 834 files / 10230 tests pass.
  • cd client && npx vite build — clean.

Closes #6021

https://claude.ai/code/session_01VjkWVTfzKyRuAv3HEsspwN

Editing a prompt stage's template, model tier, or timeout override and then
clicking another stage in the list silently threw the edits away — the click
updated the URL, which re-fetched and overwrote the editor with no warning.
Prompt templates run to hundreds of lines, so a mis-tap in the 120+ row stage
list could destroy real work with no undo.

The Stages tab now tracks the loaded template/config as a saved baseline and
adopts the same inline discard confirmation the Job Skills tab has had since
badge on its list row, and clicking a different stage parks that stage and
turns its list slot into a "Discard / Keep editing" row instead of switching.
Undoing the edit or saving clears the prompt on its own.

Claude-Session: https://claude.ai/code/session_01VjkWVTfzKyRuAv3HEsspwN
@atomantic
atomantic merged commit 46586e3 into main Sep 3, 2026
7 checks passed
@atomantic
atomantic deleted the claim/issue-6021 branch September 3, 2026 22:30
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.

PromptManager: Stages tab silently discards unsaved template and config edits when switching stages

1 participant