feat: add new session confirmation dialog with Esc-to-back and state preservation#38
feat: add new session confirmation dialog with Esc-to-back and state preservation#38huang-hf wants to merge 2 commits into
Conversation
Two improvements to the new session confirmation dialog: 1. Esc on the confirmation screen now returns to the form instead of closing the entire dialog. Previously, DialogProvider's keyboard handler would intercept Esc and pop DialogNew off the stack entirely. 2. Form state is no longer lost when navigating back from confirmation. Previously, dialog.push() caused DialogNew to unmount, so all signal values were reset on re-mount. Now all form signals are saved to a module-level variable before pushing the confirmation dialog, and restored when DialogNew re-mounts after dialog.pop(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| const projectPathHistory = new HistoryManager("dialog-new:project-paths", 15) | ||
| const branchNameHistory = new HistoryManager("dialog-new:branch-names", 15) | ||
|
|
||
| // Persists form state across dialog.push/pop cycles (confirmation dialog) |
There was a problem hiding this comment.
Cool! wdyt about moving the dialog to a multi step dialog in the same way shift+N (remote session) dialog works?
I think it will be much more convenient and in this way users won't create session accidently.
There was a problem hiding this comment.
Thanks for the suggestion! I considered the multi-step dialog approach (like the Shift+N remote session flow), but the local session form has highly interdependent fields that make a linear wizard awkward:
- The worktree checkbox only appears when the project path is a git repo
- The branch input only appears when worktree is checked
- Resume/Skip Permissions options only appear when Claude is selected as the tool
For the remote session dialog, each step is independent (host → av path → tool → path → title), so the wizard pattern fits naturally. But for local sessions, users benefit from seeing all relevant options at once and navigating with Tab — it's more of
a configuration panel than a sequential flow.
The current implementation uses a module-level variable to preserve form state across the dialog.push()/dialog.pop() cycle, so state preservation works correctly without restructuring the UX.
That said, happy to reconsider if you feel strongly about consistency with the remote session pattern!
Summary
Changes
New: Confirmation dialog before session creation
When the user presses Enter to create a session, a confirmation screen is shown with a summary of the current configuration (tool, title, path, branch, etc.). The session is only created after the user confirms.
Fix: Esc returns to form
Pressing Esc on the confirmation screen now returns to the form for further editing, rather than closing the entire new session dialog.
Root cause:
DialogProvider's keyboard handler fires beforeDialogNew's, so Esc was poppingDialogNewitself off the stack entirely.Fix: Form state preserved on back
All form values (tool, title, path, branch, worktree options, etc.) are fully restored when navigating back from the confirmation screen.
Root cause:
dialog.push()unmountsDialogNew(only the top stack item is rendered byDialogProvider). Whendialog.pop()is called, a newDialogNewinstance is created with default signal values, losing all user input.Solution: Before calling
dialog.push(), all form signal values are saved to a module-level_savedFormStatevariable. WhenDialogNewmounts, it reads and restores from this variable, then clears it.Test plan
🤖 Generated with Claude Code