Skip to content

feat(tui): exit on Ctrl+D when input is empty - #60

Merged
Blankeos merged 1 commit into
mainfrom
fix/ctrl-d-exit
Oct 3, 2026
Merged

Blankeos merged 1 commit into
mainfrom
fix/ctrl-d-exit

Conversation

@Blankeos

@Blankeos Blankeos commented Oct 3, 2026

Copy link
Copy Markdown
Owner

Fixes #58.

Summary

Adds EOF-style Ctrl+D exit (like opencode) at the App::handle_keys seam, keeping quit locality with existing double-Ctrl+C / WhichKey / /exit paths.

Design (codebase-design)

  • Seam: early handle_keys intercept alongside Ctrl+P/F/T/X, guarded to OverlayFocus::None | SuggestionsPopup.
  • Depth/leverage: one guard covers Home + Chat, empty-draft quit; non-empty falls through to tui-textarea emacs delete-forward (delete_next_char).
  • Locality: respects existing Ctrl+D dialog actions — ConnectDialog disconnect, sessions search/item-menu swallow, generic dialog search editing — by not firing when any other overlay is focused.
  • Draft guard: uses input.has_draft_content() (text + image + paste placeholders), mirroring submit-time !text.is_empty() || !images.is_empty(), so attachments are not lost on quit.
  • Rejected: putting quit inside Input::handle_event (shallow, spreads app lifecycle into input module).

Tests

  • New app::tests regressions via existing handle_keys interface:
    • ctrl_d_quits_when_input_empty
    • ctrl_d_does_not_quit_when_input_has_text (preserves delete-forward)
    • ctrl_d_does_not_quit_when_connect_dialog_focused
    • ctrl_d_does_not_quit_when_sessions_dialog_focused
    • ctrl_d_quits_when_suggestions_popup_open_and_input_empty
  • Outcomes:
    • cargo test ctrl_d: 6 passed (5 new + existing sessions search guard)
    • cargo test app::tests: 169 passed
    • cargo test sessions_dialog: 37 passed; connect_dialog: 2 passed; input: 106 passed
  • cargo fmt --all clean; diff is +98 lines in src/app.rs only.

Caveats

  • Quits even while streaming (same as double Ctrl+C); no confirm prompt.
  • Whitespace-only input counts as a draft (no quit) since guard is strict-empty + attachments.
  • No footer hint added to keep the change narrow.

Fixes #58. Adds EOF-style quit (like opencode): Ctrl+D quits from
chat-level focus only when there is no draft content. Non-empty input
keeps tui-textarea emacs delete-forward. ConnectDialog disconnect,
sessions search/item-menu, and other dialog Ctrl+D actions unchanged.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-03T18:43:20.031001Z 8babd5e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying crabcode with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8babd5e
Status: ✅  Deploy successful!
Preview URL: https://7b1fd68f.crabcode.pages.dev
Branch Preview URL: https://fix-ctrl-d-exit.crabcode.pages.dev

View logs

@Blankeos Blankeos left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

lgtm

@Blankeos
Blankeos merged commit 867a1d3 into main Oct 3, 2026
7 checks passed
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.

Exit with ctrl+D

1 participant