Repository navigation
feat(terminal): search match count + Cmd+F focus parity - #9035
Conversation
…earch Bring the terminal search bar to parity with the editor find bars: - Show a live match indicator (0/0, current/total, "No results", or <count>+ past the highlight limit) driven by the xterm SearchAddon onDidChangeResults event. - A repeat Cmd+F while the search is open now re-focuses and selects the query instead of toggling the panel closed; Esc remains the close path. Adds unit coverage for the indicator states and the toggle decision.
📝 WalkthroughWalkthrough
Priority: ⬇️ Low Merge Risk: 🔵 Low · up to When focus is in the terminal search field, repeating Cmd/Ctrl+F can invoke browser find instead of selecting the terminal query. Fix this shortcut path before merge. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 11.76% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 18 files. (5 skipped: 5 unsupported.) Full details: Description checkExplanation The description covers the user impact, implementation, rationale, visual proof, testing, AI disclosure, review notes, and known validation limits. However, the required Linked Issue is missing; the description explicitly states that no issue was supplied.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 4b5a53f9-e9df-42c9-8941-109660ca5caa
📒 Files selected for processing (10)
src/renderer/src/components/TerminalSearch.test.tsxsrc/renderer/src/components/TerminalSearch.tsxsrc/renderer/src/components/terminal-pane/TerminalPane.tsxsrc/renderer/src/components/terminal-pane/keyboard-handlers.test.tssrc/renderer/src/components/terminal-pane/keyboard-handlers.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.json
…ablyai#9035) Replace the hand-written "noResults" i18n key with the SHA1-based auto key (auto.components.TerminalSearch.10e039b591) to match the repo's auto-keying convention, and sync the key across all locale catalogs. Addresses CodeRabbit review feedback.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/terminal-pane/terminal-keyboard-event-handlers.ts (1)
181-181: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winAllow the repeated search shortcut in the terminal search input.
If
isEditableTarget()classifies this input as editable, this return runs beforeresolveShortcutEvent()createstoggleSearch. Cmd/Ctrl+F then does not callfocusSearchInput()and does not prevent the browser find action. Confirm that the predicate excludes the terminal search input. Otherwise, handletoggleSearchbefore this return only for that input.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: a151fed1-e91c-4301-9d3c-a014e7def61b
📒 Files selected for processing (23)
src/renderer/src/components/TerminalSearch.test.tsxsrc/renderer/src/components/TerminalSearch.tsxsrc/renderer/src/components/terminal-pane/TerminalPaneSurface.tsxsrc/renderer/src/components/terminal-pane/expand-collapse-render-stability.test.tssrc/renderer/src/components/terminal-pane/keyboard-handlers-ime-composing-chord.test.tsxsrc/renderer/src/components/terminal-pane/keyboard-handlers-ime-enter-keyup.test.tsxsrc/renderer/src/components/terminal-pane/keyboard-handlers-ime.test.tsxsrc/renderer/src/components/terminal-pane/keyboard-handlers.test.tssrc/renderer/src/components/terminal-pane/keyboard-handlers.tssrc/renderer/src/components/terminal-pane/terminal-keyboard-action-dispatch.tssrc/renderer/src/components/terminal-pane/terminal-keyboard-dependencies.tssrc/renderer/src/components/terminal-pane/terminal-keyboard-event-handlers-focus.test.tssrc/renderer/src/components/terminal-pane/terminal-keyboard-event-handlers.tssrc/renderer/src/components/terminal-pane/terminal-keyboard-hook.tssrc/renderer/src/components/terminal-pane/terminal-keyboard-search-dispatch.test.tssrc/renderer/src/components/terminal-pane/terminal-keyboard-shortcut-matching.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-foundation.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-global-listeners.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.json
🚧 Files skipped from review as they are similar to previous changes (3)
- src/renderer/src/i18n/locales/en.json
- src/renderer/src/i18n/locales/ja.json
- src/renderer/src/i18n/locales/zh.json
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
The count alone was not the pin: the flattened order is hashed too. The new order is the old one with useRef and useCallback inserted at the foundation stage and nothing else moved (diffed before and after #9035). Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
* test(terminal): bump the pane hook-order parity pin past #9035 #9035 added a useRef and a useCallback to use-terminal-pane-foundation (search input ref, focus-search-input) without moving the parity pin, and its own PR run never executed the shard that holds it. Every PR opened since fails `tests node 24 7/8` on `expected 211 to have a length of 209`. The two hooks are in order behind the existing ones and useMemo stays at 8. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * test(terminal): re-pin the hook-order hash for the two #9035 hooks The count alone was not the pin: the flattened order is hashed too. The new order is the old one with useRef and useCallback inserted at the foundation stage and nothing else moved (diffed before and after #9035). Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
* feat(terminal): show search match count and keep Cmd+F from closing search Bring the terminal search bar to parity with the editor find bars: - Show a live match indicator (0/0, current/total, "No results", or <count>+ past the highlight limit) driven by the xterm SearchAddon onDidChangeResults event. - A repeat Cmd+F while the search is open now re-focuses and selects the query instead of toggling the panel closed; Esc remains the close path. Adds unit coverage for the indicator states and the toggle decision. * Use auto-generated localization key for TerminalSearch no-results (stablyai#9035) Replace the hand-written "noResults" i18n key with the SHA1-based auto key (auto.components.TerminalSearch.10e039b591) to match the repo's auto-keying convention, and sync the key across all locale catalogs. Addresses CodeRabbit review feedback. * test(terminal): cover search dispatch after keyboard module split * fix(terminal): refocus search from its input and verify real matches * test(terminal): use portable echo commands for search proof * refactor(terminal): keep search subscription and cleanup together --------- Co-authored-by: Neil <[email protected]>
stablyai#21276) * test(terminal): bump the pane hook-order parity pin past stablyai#9035 stablyai#9035 added a useRef and a useCallback to use-terminal-pane-foundation (search input ref, focus-search-input) without moving the parity pin, and its own PR run never executed the shard that holds it. Every PR opened since fails `tests node 24 7/8` on `expected 211 to have a length of 209`. The two hooks are in order behind the existing ones and useMemo stays at 8. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * test(terminal): re-pin the hook-order hash for the two stablyai#9035 hooks The count alone was not the pin: the flattened order is hashed too. The new order is the old one with useRef and useCallback inserted at the foundation stage and nothing else moved (diffed before and after stablyai#9035). Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
ELI5
Terminal Find now tells you which match you are on. Pressing Cmd/Ctrl+F again selects the current query so you can replace it; Escape closes Find.
What Changed
Use xterm's existing result event for the match count, including no results and the highlight limit. Route repeated Find from both terminal content and the search input through the existing shortcut policy. Use the shared button variants and theme colors for the search bar.
Why
The terminal lacked the count shown by editor Find, and repeated Find closed the panel. The first implementation also skipped its refocus action when the search input owned focus. Handling that editable target fixes the missing route without adding a second shortcut system. The review removed the redundant open/refocus helper and a redundant result-state reset. The final elegance pass keeps subscription setup and cleanup in one effect and trims redundant comments (11 fewer lines).
Linked Issue
No linked issue was supplied with the original PR. The missing count was reproduced in hidden Electron using the pre-PR search component; the input-refocus defect was reproduced on the submitted head.
Visual Proof
Before/after captures from real hidden Electron renderers on macOS. The before run substitutes the merge-base search component into the PR build; the after run uses the final code. The test confirms three actual output matches, next-match navigation, and selected query text after repeated Find.
Testing
ORCA_BACKGROUND_LAUNCH=1.Final elegance head
6901865afa9: 35 focused unit tests passed across search results, shortcut matching/dispatch, and pane ownership.pnpm tc:web, changed-code quality, andgit diff --checkpassed. A fresh Electron/CLI E2E build andterminal-search-results.spec.tspassed, exercising three real matches, navigation, repeat Find from the input, no results, and Escape. The submitted head failed query-selection verification before the routing fix. The pre-PR component failed count verification.One baseline setup attempt timed out during heavy machine load; the subsequent baseline run reached the UI and reproduced the missing count. Full repository tests, packaged releases, Windows/Linux runtime, real SSH, and paired-web runtime were not run. The unit shortcut tests cover both Cmd and Ctrl policy.
AI Disclosure
Original author implementation; subsequent Codex-assisted review, fixes, and verification.
Review
No unresolved proven defect from the completed review. The count reuses one disposed addon subscription; no new polling, subprocesses, networking, persistence, or dependencies. Existing bounded query and safe-search paths remain in use. No native mobile-facing surface touched; paired web shares renderer code, with no protocol or minimum-version change. SSH/local, folder/git workspace, and git-provider behavior use the same existing pane path.
Agent skill upstream boundary
Notes
User-visible trade-offs: the panel is 40 pixels wider (bounded by its container), and repeated Find now selects the query instead of closing the panel. Escape and the close button remain available. Native platform and paired-host runtime coverage remains a validation gap.
Checklist