Skip to content

Standardize keyboard shortcuts: use Esc for cancel, reserve q for quit - #26

Open
clobrano wants to merge 5 commits into
mainfrom
claude/vibrant-shannon-0m22f9
Open

clobrano wants to merge 5 commits into
mainfrom
claude/vibrant-shannon-0m22f9

Conversation

@clobrano

@clobrano clobrano commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Summary

This PR standardizes keyboard navigation across the TUI by establishing Esc as the uniform "cancel/back" key across all dialogs and views, while reserving 'q' exclusively for quitting the application from the list view. This prevents accidental application termination when users press 'q' out of muscle memory while in dialogs.

Key Changes

  • Dialog Components: Removed 'q' as a cancel key from ConfirmModel, SelectorModel, and MultiSelectorModel. Now only Esc cancels dialogs.
  • Main App Navigation:
    • Removed 'q' as a back key in detail view (only Esc goes back now)
    • Moved help overlay input handling to a dedicated block that captures Esc and '?' to close help, while still allowing Ctrl+C to quit
    • Updated help text to indicate both Esc and '?' close the help view
  • Documentation: Updated README to reflect that only Esc (not 'q') returns to list from detail view
  • Test Coverage: Added tests to verify that 'q' does NOT cancel dialogs in ConfirmModel, SelectorModel, and MultiSelectorModel

Implementation Details

The key insight is that dialogs should not respond to 'q' since it's reserved for application-level quit functionality. This prevents users from accidentally quitting the app when they meant to cancel a dialog. The help overlay now has explicit input handling that closes on Esc or '?', ensuring consistent behavior across the application.

https://claude.ai/code/session_01JdFBtn5iLbiaZ4Tc693pVz

Several views (YAML/JSON detail, selector, multi-selector, confirm)
accepted both Esc and q to go back/cancel, while only Esc was shown in
the hints. Because q is also the application quit key in the list view,
this dual meaning was both inconsistent and risky: muscle memory built
up on q-to-go-back could quit the whole app unexpectedly.

Make Esc the single, uniform "back / cancel / close" key everywhere, and
reserve q exclusively for quitting the application from the list view:

- Detail view: remove q-to-go-back; Esc returns to the list.
- Selector / multi-selector / confirm dialogs: remove q as a cancel key;
  Esc cancels (n/N still answer "No" in the confirm dialog).
- Help overlay: Esc (or ?) now closes it, and the overlay captures input
  so list actions no longer fire behind it. Ctrl+C still quits anywhere.
- Add an "[Esc] cancel" hint to the confirm dialog for consistency, and
  update the help footer and README to reflect Esc as the back key.

Add regression tests asserting q no longer cancels the dialogs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JdFBtn5iLbiaZ4Tc693pVz
Removing q as a back key exposed a latent bug: the detail view (YAML/JSON,
describe, logs, and the "Delete Result" / "Rollout Restart" screens) could
become impossible to leave with Esc.

Two causes:

1. Esc in the detail view only cleared an active search query on the first
   press instead of exiting, so a confirmed search made Esc appear dead
   (the old q handler exited unconditionally, masking this). Esc now returns
   to the list in a single press; an *open* search bar is still closed first
   by the IsSearching() branch.

2. detail.SetContent did not reset search state, so a leftover query or open
   search bar from a previous view leaked into the next one (e.g. the reused
   detail model behind "Delete Result") and absorbed every key, stranding the
   user. SetContent now clears all search state.

Also reset the stuck loading flag when showing the delete/rollout result.

Add regression tests covering single-press Esc exit and search-state reset;
all three fail against the previous code.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JdFBtn5iLbiaZ4Tc693pVz
My previous change removed q as a back key to make Esc the single uniform
exit. That regressed badly: in terminals and multiplexers where a lone Esc
is delayed or swallowed (e.g. tmux's default escape-time), Esc is unreliable
in TUIs — which is exactly why the original report was "the hint says Esc but
the real key is q". Removing q left result windows (e.g. "Delete Result")
with no working exit at all.

Key point: in the detail/result views and dialogs, q never quit the
application — it only goes back/cancels. It quits *only* from the list view.
So keeping q there is safe and gives a reliable exit alongside Esc.

- Detail/result views: Esc and q both return to the list in one press.
- Confirm / selector / copy dialogs: Esc and q both cancel.
- Help overlay: Esc, q or ? closes it (q does not quit while it is open).
- List view: q / Ctrl+C still quit (unchanged).

Esc reliability fixes from the previous commit are kept: SetContent resets
search state so a stale query/open search bar can't absorb Esc, and the
delete/rollout result paths clear the stuck loading flag.

Update hints (now "[Esc/q]") and tests accordingly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JdFBtn5iLbiaZ4Tc693pVz
Lowercase q and Esc now always mean "go back / cancel" and never close the
application. Only capital Q (the configurable quit key, default "Q") and
Ctrl+C quit telekube. This removes the risk of a stray q killing the app
while keeping q/Esc as reliable, safe back keys — including in terminals
where a lone Esc is delayed (e.g. tmux).

- Default keybinding quit changed from "q" to "Q".
- List view: Q / Ctrl+C quit; lowercase q does nothing.
- Detail/result views: Esc / q go back, Q / Ctrl+C quit.
- Help overlay: Esc / q / ? close it; Q / Ctrl+C quit.
- The list-view and help quit paths use the configured quit key.

Made it explicit in the UI and docs:
- Footer now shows "[Q]uit" (uses the configured key).
- Detail header shows "[Q]uit" alongside "[Esc/q] Back".
- Help overlay distinguishes "Esc / q  Go back (never quits)" from
  "Q / Ctrl+C  Quit the application".
- README gains a callout explaining back vs quit, updated shortcut tables,
  and the config example now shows quit: "Q".

Tests updated: Q quits from list and detail, lowercase q does not quit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JdFBtn5iLbiaZ4Tc693pVz
…n-0m22f9

# Conflicts:
#	internal/tui/app_test.go
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