You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(mobile): search inside workspace files from the Files explorer - #51243
The phone's Files search only found file names. Now, when you type in the same search field, it also looks inside the files and lists the matching lines under "In files". Tap a line and the file opens at that line.
Files
Added
Deleted
Net
Test
1
$\color{#1a7f37}{\Huge{\mathbf{+}}}$24
0
$\color{#1a7f37}{\Huge{\mathbf{+}}}$24
Prod
16
$\color{#1a7f37}{\Huge{\mathbf{+}}}$468
$\color{#cf222e}{\Huge{\mathbf{−}}}$66
$\color{#1a7f37}{\Huge{\mathbf{+}}}$402
What Changed
Before: the explorer's bottom search bar matched file and folder names across the workspace. To find where API_KEY is set you had to guess the file.
After: the same search also shows an In files section under the name matches: each file with a hit, then its matching lines with the line number and the match in bold. Tapping a line opens the preview at that line and column. Queries of one character search names only.
Mechanism:
The phone calls the host's existing files.search (the same ripgrep search desktop's Search panel uses), added to the phone allowlist on the execution-host route. Hosts advertise files.mobile-content-search.v1, and the phone searches contents only when the route's host has it (and the relaying desktop, for a server workspace).
The phone debounces 300 ms, asks for at most 200 matches, keeps one search per connection in flight, and sends only the newest text typed meanwhile. Requests made while disconnected fail at once instead of replaying after reconnect; a reconnect or connection change asks again.
The host now ends a phone's earlier search when the same device sends a newer one. The host otherwise stops a search only when its socket closes, and each phone screen is its own page, so without this a reopened explorer could start a second scan beside the first.
The desktop's match-line slicing (keep a little context before the hit) moved to src/shared/file-search/search-match-line-parts.ts, and both desktop and phone use it.
Why
The host already searches file contents for desktop clients, with its own limits (15 s timeout, ripgrep, reply trimmed to the phone's content budget). Reusing it gives the phone the same matching rules as desktop. Putting the hits under the existing name results keeps one search field instead of adding a mode switch. Ending a superseded search on the host is the layer that owns the process; the phone alone can't, because each screen gets a fresh page and client.
Linked Issue
#17580 asks for a better path from mobile file previews to editing; with #21513's editing in the stack below, content search is the remaining "find it on the phone" gap in the Files explorer.
Visual Proof
iOS simulator, Orca 0.0.71 shell, page and host built from this branch (before: page built from main). Query values matches src/values.ts by name and a line in README.md.
Before
After
Dark
Light
Hits inside a file, and tapping line 45 opens the file there:
Hits
Opened at the line
Testing
Phone → desktop → runtime: server, with a throwaway e2e spec on real processes: files.search reaches the server workspace and returns src.ts line 2 column 14 for the planted text, and both the server and the relaying desktop advertise files.mobile-content-search.v1.
The hook with real React and a fake client: empty and one-character queries send nothing and leave no timer; superseded text is never sent (aa, aab, aabc sends aa then aabc); a connection change with the same text asks again; nothing is sent offline and reconnecting asks again; a second explorer on the same connection waits for the running search.
files-mobile-search-supersession.test.ts: a newer search from a device ends its earlier one, the earlier one's cleanup keeps the newer one, devices don't affect each other, and a closed socket ends the search.
iOS simulator against a headless serve built from this branch: search a word in a git workspace and a folder workspace, tap a hit, the preview opens at that line; light and dark.
pnpm check:changed passes.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
Each admitted query runs one ripgrep on the host, capped at 200 matches and the host's 15 s timeout, at human typing rate: a 300 ms debounce, two or more characters, one search per phone connection, and a newer search from the same device ends the older one on the host. Nothing runs while the search field is empty, and nothing runs per worktree, agent or terminal. The host's existing lookup of the worktree's git options walks the worktree list once per search (about a millisecond at 7,500 worktrees); that helper predates this PR.
Risk
The new host method lets a paired phone run the same content search a paired desktop can, inside workspaces it can already read. Older hosts and relaying desktops don't advertise the capability, so the phone keeps name-only search there. Older phones never call it. Ending a phone's earlier search applies only to phone callers; desktop and runtime callers are unchanged. OTA page change plus host allowlist, capability and handler; no store build needed. A plain revert backs it out.
Level: Low
AI Disclosure
Review
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Stacked on the edit-files PR (#51241); merge that first.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
Review was skipped as selected files did not have any reviewable changes.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: c60b2636-343c-4b75-a5da-1fda29ffa5af
Commits
Reviewing files that changed from the base of the PR and between 61252d9 and 5ef0c6c.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
Walkthrough
Mobile file-content search now uses the files.search RPC method, with per-device request cancellation and client-specific result limits. The mobile file explorer displays content matches alongside path results, opens files at a match location, and includes content-search activity in its loading state. Mobile and desktop search results use a shared helper to format matched lines.
Merge Risk: Low · previous review 61252
Mobile file-content search works end to end. Two small display glitches can briefly show stale or misplaced highlights right after a connection switch or when the query is extended. They are safe to fix as a follow-up, so this is mergeable with owner awareness.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "feat(mobile): search inside workspace files from the Files explorer" matches the main change. The PR adds content search to the mobile Files explorer search field, with an "In files" sectio…
Description check
The description follows the repository template and fills in every required section. It has an ELI5, a before/after What Changed section with the mechanism, Why with the alternatives, a Linked Issue (…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "feat(mobile): search inside workspace files from the Files explorer" matches the main change. The PR adds content search to the mobile Files explorer search field, with an "In files" section that opens matching lines. The title is specific and concise, and it follows a conventional commit style. It does not cover the host-side supersession or the shared match-line refactor, which is expected.
Full details: Description check
Explanation
The description follows the repository template and fills in every required section. It has an ELI5, a before/after What Changed section with the mechanism, Why with the alternatives, a Linked Issue (#17580, with the stacked #21513 context), Visual Proof with before/after images, Testing with a checklist, a Performance statement, and a Risk section with level and revert path. The Linked Issue wording is loose: it says the issue is related to the work but does not use the 'Fixes #' form. Also, the AI Disclosure section is empty, and the lint/typecheck/test/build checklist item is unchecked. The author does not state whether the PR is outside-contributor or maintainer, so the AI Disclosure omission cannot be judged. These gaps are minor and do not make the description largely incomplete.
Resolution
Optional: confirm the linked issue is an actual issue that the PR addresses. Fill in the AI Disclosure section if an AI model was used. Mark the lint, typecheck, test, and build item once those commands pass, or state that CI covers them.
Finishing Touches
Fix failing CI checks
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Include client identity in result ownership.
When client A changes to client B, both clients can have the same worktree ID and generation. The effect starts a new request, but this condition still accepts A's stored answer. The explorer displays A's hits and reports pending: false until B replies.
Store the producing client with the result and require the current client to match. Keep the existing worktree and generation checks.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Validate the retained match position against the new query.
For query ab, a result for ab then abc can point to the first ab. If the user extends the query to abc, this filter retains that result because abc occurs elsewhere on the line. The row still highlights the first two characters at the old position.
Retain only matches whose recorded position matches the new query. Update the highlight length and display coordinates, or hide retained hits until the new answer arrives. Preserve the unchanged-query fast path.
The explorer's search matched file names only. With a host that allows it, the same search now also lists matching lines inside files under "In files"; tapping one opens the file at that line. A phone keeps one content search per connection, and the host ends a device's older search when its newer one arrives, since it otherwise stops a search only when the socket closes. The desktop's match-line slicing moved to src/shared so both use it.
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
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.
ELI5
The phone's Files search only found file names. Now, when you type in the same search field, it also looks inside the files and lists the matching lines under "In files". Tap a line and the file opens at that line.
What Changed
API_KEYis set you had to guess the file.files.search(the same ripgrep search desktop's Search panel uses), added to the phone allowlist on the execution-host route. Hosts advertisefiles.mobile-content-search.v1, and the phone searches contents only when the route's host has it (and the relaying desktop, for a server workspace).src/shared/file-search/search-match-line-parts.ts, and both desktop and phone use it.Why
The host already searches file contents for desktop clients, with its own limits (15 s timeout, ripgrep, reply trimmed to the phone's content budget). Reusing it gives the phone the same matching rules as desktop. Putting the hits under the existing name results keeps one search field instead of adding a mode switch. Ending a superseded search on the host is the layer that owns the process; the phone alone can't, because each screen gets a fresh page and client.
Linked Issue
#17580 asks for a better path from mobile file previews to editing; with #21513's editing in the stack below, content search is the remaining "find it on the phone" gap in the Files explorer.
Visual Proof
iOS simulator, Orca 0.0.71 shell, page and host built from this branch (before: page built from
main). Queryvaluesmatchessrc/values.tsby name and a line inREADME.md.Hits inside a file, and tapping line 45 opens the file there:
Testing
Phone → desktop →
runtime:server, with a throwaway e2e spec on real processes:files.searchreaches the server workspace and returnssrc.tsline 2 column 14 for the planted text, and both the server and the relaying desktop advertisefiles.mobile-content-search.v1.The hook with real React and a fake client: empty and one-character queries send nothing and leave no timer; superseded text is never sent (
aa,aab,aabcsendsaathenaabc); a connection change with the same text asks again; nothing is sent offline and reconnecting asks again; a second explorer on the same connection waits for the running search.files-mobile-search-supersession.test.ts: a newer search from a device ends its earlier one, the earlier one's cleanup keeps the newer one, devices don't affect each other, and a closed socket ends the search.iOS simulator against a headless serve built from this branch: search a word in a git workspace and a folder workspace, tap a hit, the preview opens at that line; light and dark.
pnpm check:changedpasses.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
Each admitted query runs one ripgrep on the host, capped at 200 matches and the host's 15 s timeout, at human typing rate: a 300 ms debounce, two or more characters, one search per phone connection, and a newer search from the same device ends the older one on the host. Nothing runs while the search field is empty, and nothing runs per worktree, agent or terminal. The host's existing lookup of the worktree's git options walks the worktree list once per search (about a millisecond at 7,500 worktrees); that helper predates this PR.
Risk
The new host method lets a paired phone run the same content search a paired desktop can, inside workspaces it can already read. Older hosts and relaying desktops don't advertise the capability, so the phone keeps name-only search there. Older phones never call it. Ending a phone's earlier search applies only to phone callers; desktop and runtime callers are unchanged. OTA page change plus host allowlist, capability and handler; no store build needed. A plain revert backs it out.
Level: Low
AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Stacked on the edit-files PR (#51241); merge that first.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)