Skip to content

fix(remote-files): cap search replies, say when a diff is too large, and measure a 100 MB read on WSL - #34882

Merged
nwparker merged 1 commit into
mainfrom
nwparker/remote-large-file-followups
Oct 28, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/remote-large-file-followups

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​154 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​154
Prod 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​120 $\color{#cf222e}{\Huge{\mathbf{−}}}$​28 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​92

ELI5

Three follow-ups from auditing large files on WSL hosts:

  1. Searching a remote project with a huge number of matching lines could fail outright. Now it returns as many results as fit and says the list was cut short.
  2. Opening a diff of a text file over 10 MB said "Binary file changed", which is wrong. It now says the file is too large to diff.
  3. The real-WSL CI lane now times reading a 100 MB file through a WSL host and records the server's peak memory, to give us real numbers.

What Changed

  • Search (files.search RPC, new src/shared/search-result-transport-budget.ts):
    • Before: a search whose reply passed the remote reply cap (about 4 MiB) failed as a whole with reply_too_large.
    • After: the host keeps the whole files that fit the request's budget, marks the result truncated: true and recounts totalMatches for what it kept. This matches what files.listAll and quick-open search already do. Local (in-process) callers stay uncapped.
  • Diff too large (git-blob-read.ts, diff-result.ts, the diff builders, DiffTooLargeNotice):
    • Before: a side past the 10 MiB read cap came back as isBinary, so the diff said "Binary file changed".
    • After:
      • The blob read marks it tooLarge, and the binary diff result carries an optional tooLarge.
      • Both diff views show "File too large to diff — one version of this file is over 10 MB…".
      • An image over the cap shows that message too, instead of an empty image compare.
    • buildDiffResult now builds its binary sides without a type cast.
  • Lane measurement (wsl-orcad-real-distro-lane.test.ts, plain distro only):
    • After the shared control connection is up, it writes a 100 MB file, resets orcad's peak RSS (clear_refs), and pages the file with files.readChunk in the editor's 384 KiB chunks over that same socket.
    • It records the time, chunk count and VmHWM in the receipt.
    • Record-only: it asserts nothing, and any failure is written into the receipt.

Why

  • Search: truncating is the existing contract (truncated is already in SearchResult and the UI shows it), so a big search degrades instead of failing.
  • Too large vs binary: the diff result is wire data that paired clients read. A new optional field is safe: older clients ignore it and keep the binary view, which they showed before.
  • Measuring first: the read path is chunked and capped by design. The lane will show whether the time and orcad's memory are acceptable before anything is changed.

Linked Issue

N/A (internal).

Visual Proof

N/A: the too-large message is static copy in the existing binary-diff layout. There is no new interaction.

Testing

  • search-result-transport-budget.test.ts:
    • a result that fits, or an uncapped local one, is unchanged;
    • an oversized one keeps a prefix of whole files, under the budget, marked truncated with matching counts.
  • diff-too-large-real-git.test.ts (real Git): an 11 MB text file is marked tooLarge (and still binary) from the working tree and from the index; a real binary is not marked.
  • pnpm tc, check:code-quality:changed, the localization checks, and the max-lines, flaky-test and test-runner checks pass. The source-control, diff, files RPC and editor diff suites pass locally. One unrelated real-Git staging test timed out at load 172 and passed on rerun.
  • The WSL lane runs in CI (this PR touches src/main/wsl/**).

Review

Self-reviewed.

Agent skill upstream boundary

  • Not applicable.

Notes

…and measure a 100 MB read on WSL

Follow-ups from the large-file audit (E7):

- files.search had no byte budget: a result past the remote reply cap failed outright with
  reply_too_large. It now keeps the whole files that fit and marks the result truncated, as
  files.listAll and searchPaths already do. Local callers stay uncapped.
- A diff side past the 10 MiB read cap came back as binary, so the diff said "Binary file
  changed" for a large text file. Blob reads mark it `tooLarge`, the binary diff result carries an
  optional `tooLarge`, and both diff views say "File too large to diff". Older clients ignore the
  field and keep the binary view. buildDiffResult builds its binary sides without a cast.
- The real-WSL lane pages a 100 MB file over the plain distro's shared control socket in the
  editor's 384 KiB chunks and records the time, chunk count and orcad's VmHWM. Record-only: it
  asserts nothing, and a failure is recorded in the receipt.
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

Git diff results now identify oversized blobs separately from binary content, and the renderer displays a dedicated notice for those results. The files.search RPC limits results using the requesting client's remote content budget. The WSL lane adds a chunked 100 MiB file-read measurement for non-systemd distros.

Priority: Normal

Merge Risk: Low · up to 8b767

The change is mergeable with bounded follow-up: measurement receipts can be inaccurate, and a truncated search can misleadingly say there are no results.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the three main changes: capping remote search replies, reporting oversized diffs, and measuring large WSL reads. It is specific and related to the changeset.
Description check Passed The description covers the required user impact, implementation details, rationale, testing, visual proof, compatibility, and review notes. It marks the issue as internal and explains why visual proof…
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: Description check

Explanation

The description covers the required user impact, implementation details, rationale, testing, visual proof, compatibility, and review notes. It marks the issue as internal and explains why visual proof is not applicable. The repository checklist is not included, but the description is otherwise substantially complete.

Full details: Docstring Coverage

Explanation

Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 13 functions across 15 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • 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

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: 3


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: ab99b0c8-40c0-4467-923e-40255d72e983
Commits

Reviewing files that changed from the base of the PR and between 0a349b3 and 8b7672a.

Files selected for processing: 16
  • src/main/git/source-control/branch-diff.ts
  • src/main/git/source-control/commit-diff.ts
  • src/main/git/source-control/diff-result.ts
  • src/main/git/source-control/diff-too-large-real-git.test.ts
  • src/main/git/source-control/file-diff.ts
  • src/main/git/source-control/git-blob-read.ts
  • src/main/git/source-control/submodule-diff.ts
  • src/main/runtime/rpc/methods/files.ts
  • src/main/wsl/wsl-orcad-real-distro-lane.test.ts
  • src/renderer/src/components/editor/DiffSectionBody.tsx
  • src/renderer/src/components/editor/DiffTooLargeNotice.tsx
  • src/renderer/src/components/editor/EditorDiffFileSurface.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/shared/git-diff-compare-types.ts
  • src/shared/search-result-transport-budget.test.ts
  • src/shared/search-result-transport-budget.ts

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

Comment on lines +178 to 194
handler: async (params, { runtime, clientKind, requestId, signal }) =>
limitSearchResultToContentBudget(
await runtime.searchRuntimeFiles(
params.worktree,
{
query: params.query,
caseSensitive: params.caseSensitive,
wholeWord: params.wholeWord,
useRegex: params.useRegex,
includePattern: params.includePattern,
excludePattern: params.excludePattern,
maxResults: params.maxResults
},
{ signal }
),
remoteFileContentBudget(clientKind, requestId)
)

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

Supported by static analysis

Script executed:

rg -n 'files.search|totalMatches|truncated' src/renderer/src src/main/runtime/rpc/methods/files.ts src/shared/search-result-transport-budget.ts

Repository: stablyai/orca

Length of output: 41435


Script executed:

set -e
printf '%s\n' '--- budget helper ---'
nl -ba src/shared/search-result-transport-budget.ts
printf '%s\n' '--- files RPC ---'
nl -ba src/main/runtime/rpc/methods/files.ts | sed -n '1,215p'
printf '%s\n' '--- runtime search client ---'
nl -ba src/renderer/src/runtime/runtime-file-search-client.ts | sed -n '1,310p'
printf '%s\n' '--- search result types and references ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'interface SearchResult' -e 'type SearchResult' -e 'SearchResult =' -e 'useFileSearchPanel' -e 'SearchResultsPane' src/renderer/src src/shared src/main
printf '%s\n' '--- search panel hook ---'
nl -ba src/renderer/src/components/right-sidebar/useFileSearchPanel.ts 2>/dev/null || true
printf '%s\n' '--- results pane ---'
nl -ba src/renderer/src/components/right-sidebar/SearchResultsPane.tsx

Repository: stablyai/orca

Length of output: 41481


Script executed:

set -e
nl -ba src/shared/search-result-transport-budget.ts
nl -ba src/main/runtime/rpc/methods/files.ts | sed -n '165,205p'
nl -ba src/renderer/src/components/right-sidebar/SearchResultsPane.tsx | sed -n '70,175p'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'useFileSearchPanel' -e 'SearchResult' src/renderer/src/components/right-sidebar src/renderer/src/runtime | head -80

Repository: stablyai/orca

Length of output: 18145


Suppress the no-results state for truncated searches.

When the first matching file exceeds the remote budget, the RPC returns files: [], totalMatches: 0, and truncated: true. SearchResultsPane displays the truncation label, but its separate totalMatches === 0 branch also displays “No results,” which incorrectly suggests that the search found no matches. Render that state only when the result is not truncated.

Suggested fix
-        {!error && hasCommittedResults && results?.totalMatches === 0 && !loading && (
+        {!error &&
+          hasCommittedResults &&
+          results?.totalMatches === 0 &&
+          results?.truncated !== true &&
+          !loading && (

)
).trim()
// Reset the peak, so VmHWM is this read's.
await asRoot(distro, `echo 5 > /proc/${orcadPid}/clear_refs`)

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

Check whether the peak reset succeeded.

asRoot returns a nonzero exit code instead of throwing. If the write to clear_refs fails, the receipt can report an earlier process peak as the read's peak. Check the exit code and record an error when the reset fails. (kernel.org)

const started = performance.now()
let chunks = 0
for (let offset = 0; offset < LARGE_FILE_BYTES; offset += LARGE_FILE_CHUNK_BYTES) {
await control.request(

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

Check each chunk response before recording success.

control.request resolves RPC failures as responses with ok: false; it does not throw them. (raw.githubusercontent.com) A failed or short read therefore still produces a receipt claiming that all 100 MiB were read. Check ok, advance by bytesRead, and record an error for an incomplete read.

@nwparker
nwparker merged commit d6918c7 into main Oct 28, 2026
64 of 65 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