fix: keep a saved prompt variable open and guard unsaved edits (#6023) - #6136
Merged
Conversation
Saving a prompt variable in the Variables tab deselected it, dropped `?var=` from the URL, and blanked every field — with no toast — so a successful save looked exactly like a crash, and checking what had just been written meant hunting the variable down in the list and clicking it again. Creating one landed the same blank form instead of opening what was created, and a delete finished in silence. Saving now leaves the variable open on what was saved and confirms it with a toast; creating adopts the new key as the URL selection once the refreshed list holds it (so the "variable could not be found" panel can't flash on the way); deleting says which variable went. Switching variables also stopped being destructive. Variable content runs to paragraphs of instructions, and clicking another row — or the "+" — used to overwrite the editor with no warning. The tab now tracks the loaded form as a saved baseline, badges the open row and editor "Unsaved", and turns the requested slot into a "Discard / Keep editing" row instead of switching. The "+" question takes the top of the list since it has no row of its own. Undoing the edit back to the saved values clears the prompt on its own. Same inline-confirmation shape the Stages (#6021) and Job Skills (#3939) tabs already use — no window.confirm. Claude-Session: https://claude.ai/code/session_01RA3pD5YM2dukQwbZ3pC6WA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Prompt Manager's Variables tab treated a successful save like a reset.
saveVariablecleared?var=from the URL and blanked every field with{ silent: true }suppressing the only feedback, so editingTone Guideand clicking Save dropped the user into an empty "New Variable" form with no toast — indistinguishable from a crash. Verifying what had just been written meant finding the variable in the list and clicking it again. Creating a variable landed the same blank form instead of opening what was created, and deleting one finished in silence.Separately, the list was destructive: variable content runs to paragraphs of prompt instructions, and clicking another row (or the "+") overwrote
varFormimmediately, with no way back.What changed (
client/src/pages/PromptManager.jsx)Save / create / delete feedback
Variable "<name>" saved. The post-saveloadData()cannot re-hydrate over it —varHydratedRefstill holds the open key.Variable "<key>" createdand adopts the new key as?var=<key>— after the refreshed list holds it, so the "variable could not be found" panel can't flash on the way in.Variable "<name>" deleted.Unsaved-edit guard
savedVarFormtracks the last server-confirmed form as a full copy (not a boolean), so typing an edit and undoing it stops counting as dirty.Unsavedbadge /Unsaved changesnote while dirty.pendingVarand turns that slot into aDiscard / Keep editingInlineConfirmRowinstead of switching. The "+" has no row of its own, so its question takes the top of the list.This is the same inline-confirmation shape the Stages (#6021) and Job Skills (#3939) tabs already use. No
window.confirm; selection stays in the URL.Test plan
client/src/pages/PromptManager.test.jsx— newPromptManager variable editingsuite (8 tests). All 8 verified failing against the pre-fix component (swapped inorigin/main'sPromptManager.jsx, ran the suite, restored):?var=<key>with its content intactFull client suite:
832 passed | 1 skipped. The one intermittent failure seen on one run wassrc/components/ui/PageSkeleton.test.jsx(getAllByRole('status')[0]/aria-busy), which passes in isolation across repeated runs and is untouched by this diff.npx biome checkclean on both changed files.Closes #6023
https://claude.ai/code/session_01RA3pD5YM2dukQwbZ3pC6WA