Skip to content

feat(mobile): search inside workspace files from the Files explorer - #51243

Merged
AmoabaKelvin merged 1 commit into
mainfrom
mobile-files-content-search
Nov 28, 2026
Merged

AmoabaKelvin merged 1 commit into
mainfrom
mobile-files-content-search

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

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.

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)

@AmoabaKelvin
AmoabaKelvin force-pushed the mobile-files-content-search branch 2 times, most recently from 6e62d0d to 5a5d915 Compare November 28, 2026 03:41
@AmoabaKelvin
AmoabaKelvin changed the base branch from mobile-edit-workspace-files to main November 28, 2026 05:02
@AmoabaKelvin
AmoabaKelvin force-pushed the mobile-files-content-search branch from 5a5d915 to 61252d9 Compare November 28, 2026 05:02
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

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: Passed 4

Check name Status Explanation
Title check Passed 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 Passed 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 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.
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.

Share

@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: 2

Review info

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: b205ada0-084c-476d-98dd-0b9acb6acd1e
Commits

Reviewing files that changed from the base of the PR and between 963b836 and 61252d9.

Files selected for processing: 17

  • mobile/src/files/explorer/MobileFileExplorerPanel.tsx
  • mobile/src/files/explorer/file-content-search-operations.ts
  • mobile/src/files/explorer/file-tree.ts
  • mobile/src/files/explorer/mobile-file-explorer-content-hit-row.tsx
  • mobile/src/files/explorer/mobile-file-explorer-row.tsx
  • mobile/src/files/explorer/mobile-file-explorer-rows.tsx
  • mobile/src/files/explorer/use-mobile-file-content-search.ts
  • mobile/src/i18n/locales/en.json
  • src/main/runtime/rpc/methods/files/files-mobile-search-supersession.test.ts
  • src/main/runtime/rpc/methods/files/files-mobile-search-supersession.ts
  • src/main/runtime/rpc/methods/files/files-search-methods.ts
  • src/main/runtime/rpc/methods/files/files.ts
  • src/main/runtime/rpc/server/runtime-rpc-mobile-method-routing.ts
  • src/renderer/src/components/right-sidebar/file-explorer/content-search/SearchResultItems.tsx
  • src/shared/file-access/files-runtime-capabilities.ts
  • src/shared/file-search/mobile-file-content-search.ts
  • src/shared/file-search/search-match-line-parts.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

// While the next answer is out, the last one stays only if the new text narrows it, as name results do,
// and only its lines that still hold the text (the host's default search ignores case).
const held =
searchable && result && result.scope === scope && query.startsWith(result.query) ? result : null

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.

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.

}
const needle = query.toLowerCase()
const files = result.files.flatMap((file) => {
const matches = file.matches.filter((match) => match.lineContent.toLowerCase().includes(needle))

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.

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.
@AmoabaKelvin
AmoabaKelvin force-pushed the mobile-files-content-search branch from 61252d9 to 5ef0c6c Compare November 28, 2026 05:23
@AmoabaKelvin
AmoabaKelvin merged commit d2bc408 into main Nov 28, 2026
58 checks passed
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.

1 participant