Skip to content

feat(terminal): search match count + Cmd+F focus parity - #9035

Merged
nwparker merged 7 commits into
stablyai:mainfrom
shaharmor:feat/terminal-search-match-count
Sep 17, 2026
Merged

nwparker merged 7 commits into
stablyai:mainfrom
shaharmor:feat/terminal-search-match-count

Conversation

@shaharmor

@shaharmor shaharmor commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

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.

Terminal Find before and after

Testing

  • Exercised the rendered application locally through Playwright, with ORCA_BACKGROUND_LAUNCH=1.
  • Automated regression coverage added.

Final elegance head 6901865afa9: 35 focused unit tests passed across search results, shortcut matching/dispatch, and pane ownership. pnpm tc:web, changed-code quality, and git diff --check passed. A fresh Electron/CLI E2E build and terminal-search-results.spec.ts passed, 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

  • Not applicable; no upstream skill source was copied.

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

  • This PR is small and focused.
  • Explained the before/after, mechanism, and ELI5.
  • Before/after visual proof attached.
  • Reviewed correctness, security, and performance.
  • Cross-platform, SSH/remote, folder-workspace, and provider impact considered.
  • Full lint, typecheck, test, and build suite passes; scoped results and limits are listed above.

…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.
@coderabbitai

coderabbitai Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

TerminalSearch now subscribes to search-addon result changes and displays empty, current/total, no-results, and thresholded match statuses. It exposes and clears an input ref through TerminalPane. Repeated Cmd/Ctrl+F refocuses an open search instead of closing it. Keyboard dependencies and handlers carry the focus callback through the shortcut pipeline. Tests cover result updates, cleanup, disposal, ref behavior, shortcut dispatch, and repeat events. Locales add the noResults key.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 7338b

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning 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 d… Add the required linked issue reference under Linked Issue, such as Fixes #123``, before merging.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely identifies the two main changes: terminal search match counts and Cmd+F focus behavior.
Full details: Docstring Coverage

Explanation

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 check

Explanation

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.

  • Fix all pre-merge checks with AI

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4b5a53f9-e9df-42c9-8941-109660ca5caa

📥 Commits

Reviewing files that changed from the base of the PR and between ef23b67 and 262bc83.

📒 Files selected for processing (10)
  • src/renderer/src/components/TerminalSearch.test.tsx
  • src/renderer/src/components/TerminalSearch.tsx
  • src/renderer/src/components/terminal-pane/TerminalPane.tsx
  • src/renderer/src/components/terminal-pane/keyboard-handlers.test.ts
  • src/renderer/src/components/terminal-pane/keyboard-handlers.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/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.
@AmethystLiang AmethystLiang assigned OrcaWin and unassigned Jinwoo-H Jul 20, 2026
@AmethystLiang
AmethystLiang requested review from OrcaWin and removed request for Jinwoo-H July 20, 2026 18:36
@nwparker nwparker added the enhancement New feature or request label Jul 27, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 win

Allow the repeated search shortcut in the terminal search input.

If isEditableTarget() classifies this input as editable, this return runs before resolveShortcutEvent() creates toggleSearch. Cmd/Ctrl+F then does not call focusSearchInput() and does not prevent the browser find action. Confirm that the predicate excludes the terminal search input. Otherwise, handle toggleSearch before 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

📥 Commits

Reviewing files that changed from the base of the PR and between b9b326c and 7338bd1.

📒 Files selected for processing (23)
  • src/renderer/src/components/TerminalSearch.test.tsx
  • src/renderer/src/components/TerminalSearch.tsx
  • src/renderer/src/components/terminal-pane/TerminalPaneSurface.tsx
  • src/renderer/src/components/terminal-pane/expand-collapse-render-stability.test.ts
  • src/renderer/src/components/terminal-pane/keyboard-handlers-ime-composing-chord.test.tsx
  • src/renderer/src/components/terminal-pane/keyboard-handlers-ime-enter-keyup.test.tsx
  • src/renderer/src/components/terminal-pane/keyboard-handlers-ime.test.tsx
  • src/renderer/src/components/terminal-pane/keyboard-handlers.test.ts
  • src/renderer/src/components/terminal-pane/keyboard-handlers.ts
  • src/renderer/src/components/terminal-pane/terminal-keyboard-action-dispatch.ts
  • src/renderer/src/components/terminal-pane/terminal-keyboard-dependencies.ts
  • src/renderer/src/components/terminal-pane/terminal-keyboard-event-handlers-focus.test.ts
  • src/renderer/src/components/terminal-pane/terminal-keyboard-event-handlers.ts
  • src/renderer/src/components/terminal-pane/terminal-keyboard-hook.ts
  • src/renderer/src/components/terminal-pane/terminal-keyboard-search-dispatch.test.ts
  • src/renderer/src/components/terminal-pane/terminal-keyboard-shortcut-matching.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-foundation.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-global-listeners.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/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.

@nwparker
nwparker merged commit de15227 into stablyai:main Sep 17, 2026
Jinwoo-H added a commit that referenced this pull request Sep 17, 2026
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
Jinwoo-H added a commit that referenced this pull request Sep 17, 2026
* 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
@pullfrog pullfrog Bot mentioned this pull request Sep 17, 2026
8 of 9 tasks
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
* 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]>
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants