Repository navigation
fix(tui): Esc clears a kept list filter before exiting - #2693
Merged
Merged
Conversation
Once a `/` filter was kept with Enter, the next Esc fell through to App's exit accelerator and quit the TUI. A kept filter now claims Esc while its list has the keyboard: the first Esc clears it, the second exits. useListFilter reports the claim through a new onEscapeClaimChange effect (withdrawn on clear, focus loss, modal or unmount, like onEditingChange), the four list tabs pass it through, and App skips exit() only for Esc — the other accelerators keep working on the narrowed list. The `?` help and the kept-filter hint say so. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
The longer wording truncated at 80 columns. The original text is now accurate for a kept filter too, and the global Esc row states the order. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The Escape ownership lifecycle is correctly scoped and covered by focused regression tests.
0 open findings
What changed in this PR
Fixes TUI Escape handling so a focused, kept list filter is cleared before the application exits.
Changes:
- Adds Escape-claim reporting and handling across all filterable tabs.
- Updates filter hints and shortcut help.
- Adds hook, component, and application-level regression tests.
| File | Description |
|---|---|
clients/tui/src/utils/keybindings.ts |
Updates Escape help text. |
clients/tui/src/hooks/useListFilter.ts |
Clears kept filters and reports Escape ownership. |
clients/tui/src/components/ToolsTab.tsx |
Forwards the Escape claim. |
clients/tui/src/components/SkillsTab.tsx |
Forwards the Escape claim. |
clients/tui/src/components/ResourcesTab.tsx |
Forwards the Escape claim. |
clients/tui/src/components/PromptsTab.tsx |
Forwards the Escape claim. |
clients/tui/src/components/ListFilterBar.tsx |
Shows the focused kept-filter hint. |
clients/tui/src/App.tsx |
Defers exit while a filter owns Escape. |
clients/tui/__tests__/useListFilter.test.tsx |
Tests claim lifecycle and Escape consumption. |
clients/tui/__tests__/ToolsTab.test.tsx |
Updates the focused hint expectation. |
clients/tui/__tests__/ListFilterBar.test.tsx |
Tests the new hint. |
clients/tui/__tests__/App.test.tsx |
Covers the reported end-to-end interaction. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Member
Author
|
Copilot review loop closed: round 1 (review 5494607889) was clean. It had no inline comments, no suppressed findings, and its headline recommended approval. Per the PR flow, one clean round ends the loop. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2647
Problem
In a TUI list filter (#2430), Esc while typing cleared the filter. But once the filter was kept with Enter, the next Esc went to App's exit accelerator and quit the whole TUI. That's a lossy result for one keystroke when the user only wanted to undo the filter.
Change
A kept filter now claims Esc while its list has the keyboard. The first Esc clears it and the second exits.
useListFilter: when not editing and the query is non-empty, Esc clears it and is consumed. The hook reports the claim through a newonEscapeClaimChangeoption. LikeonEditingChange, it's an effect with a cleanup, so the claim is withdrawn on every way it can end: the query is cleared, the pane loses focus, a modal opens, or the tab unmounts. That means App can never be left unable to exit.onFilterEscapeClaimChange.Appskipsexit()on Esc while the claim is held. Only Esc stands down. A filter is kept so that the other accelerators work on the narrowed list, so they stay live. (Editing still mutes everything, as before.)?help overlay (TUI has no in-app shortcut/keybinding help screen #2436), as the issue asks: the global row now readsExit (Esc closes a dialog or clears a kept filter first). The/row's existingFilter the list (Enter keeps it, Esc clears it)is now true of a kept filter as well, so it stays as is. A longer wording truncated in an 80-column overlay (f16ef79).(/ edit · Esc clear). An unfocused list keeps(/ to edit), because Esc doesn't clear it there.Scope note: the claim exists only while the list pane has the keyboard, the same condition under which
/works. If you Tab away to the details pane, the filter stays kept and Esc exits as before.Tests
useListFilter.test.tsx: Esc clears a kept filter and withdraws the claim, and the second Esc is left unconsumed for the app. Editing never claims. The claim is withdrawn, and Esc no longer clears, when the list loses the keyboard.App.test.tsx: the issue's repro (t, Tab,/dpt, Enter, Esc) clears the filter (Tools (1/2)→Tools (2)) and the app still answersd. I checked that this test fails with App's guard removed.ListFilterBar.test.tsx/ToolsTab.test.tsx: the focused kept-filter hint.npm run local:gatepassed on 4fdf2d6. f16ef79 only reverts one help string to its pre-PR text. For that commit I re-ran thekeybindingsandHelpOverlaysuites andprettier --check, but not the full gate.Screenshots (text captures)
These are ANSI-stripped Ink frames of the real
App(80 columns), produced by the samerenderTuihelper the tests use, as on #2592. The 80-column test terminal truncates the hint in the narrow list pane. The full text is(/ edit · Esc clear).Before: after
t, Tab,/,dpt, Enter, then Esc, the TUI exited (exit 0). There's no frame to show.After: filter kept (
/dpt, Enter):After: first Esc clears the filter, and the TUI is still running:
?help overlay, the changed global row:🤖 Generated with Claude Code