Skip to content

make every dialog close on ctrl+c, twice exits#2583

Merged
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/tui-ctrl-c-dialog-close-and-exit-21d8bf66
Apr 28, 2026
Merged

make every dialog close on ctrl+c, twice exits#2583
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/tui-ctrl-c-dialog-close-and-exit-21d8bf66

Conversation

@dgageot
Copy link
Copy Markdown
Member

@dgageot dgageot commented Apr 28, 2026

Pressing ctrl+c on any TUI dialog now opens the exit-confirmation dialog instead of quitting immediately (via HandleQuit / dialog-specific handlers). A second ctrl+c on the exit-confirmation exits, matching the existing two-press flow when no dialog is shown.

If the user cancels exit (N/Esc), the original dialog is restored — the exit-confirmation is stacked on top of it, not replacing it, so blocking dialogs (tool confirmation, elicitation, max iterations) don't leave the agent stuck waiting.

Behavior

State 1st ctrl+c 2nd ctrl+c
no dialog opens exit confirmation exits
any other dialog stacks exit confirmation on top exits
exit confirmation exits

Implementation

  • pkg/tui/tui.gohandleKeyPress intercepts ctrl+c before forwarding to the dialog manager. If the exit confirmation is already on top, the key is forwarded so it can exit via its own Yes binding; otherwise the exit-confirmation dialog is pushed onto the stack.
  • pkg/tui/dialog/dialog.go — added Manager.TopIsExitConfirmation() so the top-level handler can route the key correctly.
  • pkg/tui/dialog/elicitation.go — removed the now-redundant special-case that declined the elicitation and called tea.Quit on ctrl+c.
  • pkg/tui/tui_ctrlc_test.go — three unit tests covering the table above.
@dgageot dgageot requested a review from a team as a code owner April 28, 2026 19:03
@dgageot dgageot force-pushed the board/tui-ctrl-c-dialog-close-and-exit-21d8bf66 branch from 31b994d to 466a0b4 Compare April 28, 2026 19:20
@dgageot dgageot merged commit 3ca24c7 into docker:main Apr 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants