Skip to content

feat: add new session confirmation dialog with Esc-to-back and state preservation#38

Open
huang-hf wants to merge 2 commits into
Frayo44:mainfrom
huang-hf:fix/confirm-dialog-ux-v2
Open

feat: add new session confirmation dialog with Esc-to-back and state preservation#38
huang-hf wants to merge 2 commits into
Frayo44:mainfrom
huang-hf:fix/confirm-dialog-ux-v2

Conversation

@huang-hf
Copy link
Copy Markdown
Contributor

@huang-hf huang-hf commented Mar 9, 2026

Summary

  • Add a confirmation step before creating a new session
  • Fix: Esc on confirmation screen returns to form instead of closing the dialog
  • Fix: Form state is preserved when navigating back from confirmation

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 before DialogNew's, so Esc was popping DialogNew itself 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() unmounts DialogNew (only the top stack item is rendered by DialogProvider). When dialog.pop() is called, a new DialogNew instance 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 _savedFormState variable. When DialogNew mounts, it reads and restores from this variable, then clears it.

Test plan

  • Fill in the new session form (tool, title, path, branch, etc.)
  • Press Enter → confirmation dialog appears with correct config summary
  • Press Esc → returns to form with all values intact
  • Press Enter again → confirm creates the session successfully
  • Press Esc on the main form → closes the entire dialog (unchanged behavior)

🤖 Generated with Claude Code

huang-hf and others added 2 commits March 9, 2026 17:10
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)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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!

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.

2 participants