fix(desktop): reset seeded new-workspace draft when the modal is dismissed
Fixes #5372
Problem
Clicking Configure on the "Setup scripts" sidebar card opens the New Workspace modal seeded with a setup-script prompt. If you dismiss the modal (Esc / outside click) without creating a workspace, that prompt stays in the draft. The next time you click + / New Workspace, the composer still opens pre-filled with it — even though you never asked to configure setup scripts.
Root cause
Every seed path (V2SetupScriptCard, GitHub issue/PR flows) does resetDraft() + updateDraft(...) before opening the modal — but the dismiss path (closeModal) only flipped isOpen. The seeded prompt remained in the draft store, so the next plain "New Workspace" open consumed it as if the user had typed it.
Fix
closeModal now also resets the draft store. Since every seed path already resets before seeding, the dismiss becomes the single cleanup point:
- Esc / outside click / any close → draft wiped
- seeded flows (Configure, issue, PR) are unaffected — they re-seed after their own reset
- a plain "New Workspace" always opens empty, as before 1.17.0
Validation
new-workspace-modal.test.ts — 2 unit tests:
- dismissing the modal clears a seeded draft prompt (exact #5372 repro);
- a fresh open after dismiss starts with an empty prompt.
bun test: 2/2 pass · tsc --noEmit: 0 errors · Biome: clean.
Summary by cubic
Clears any seeded New Workspace draft on modal dismiss and preserves it only during the /new-workspace handoff. Previously dismiss left the seed in place; now dismiss wipes it, handoff keeps it, and leaving /new-workspace clears it (fixes #5372).
- Changes
closeModal(options?: { resetDraft?: boolean })now resets the draft by default; passresetDraft: falsefor the/new-workspacehandoff (used byDashboardNewWorkspaceModalbefore navigation).- Adds
resetNewWorkspaceDraftOnRouteLeaveand hooks it to the/new-workspacerouteonLeaveto clear the preserved seed on route leave. - Adds tests for dismiss cleanup, empty reopen, handoff preservation, and route-leave cleanup.
Summary by CodeRabbit
-
Bug Fixes
- Closing the new workspace modal now clears previously entered setup prompts.
- Reopening the modal starts with an empty draft.
- Moving from the modal to the full-page workspace setup preserves the entered prompt.
- Drafts are cleared after leaving the full-page workspace setup flow.
-
Tests
- Added coverage for draft clearing, reopening behavior, and prompt preservation.