Skip to content

Fix ripgrep result completeness, filename handling, and search errors - #25156

Merged
nwparker merged 4 commits into
mainfrom
nwparker/ripgrep-search-correctness
Oct 4, 2026
Merged

nwparker merged 4 commits into
mainfrom
nwparker/ripgrep-search-correctness

Conversation

@nwparker

@nwparker nwparker commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 34 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1475 $\color{#cf222e}{\Huge{\mathbf{−}}}$​107 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1368
Prod 38 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​785 $\color{#cf222e}{\Huge{\mathbf{−}}}$​254 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​531

ELI5

Search should find the right files, highlight the right characters, and tell you when it could not finish. Several edge cases currently look like successful searches with missing or incorrect results. This change fixes the shared ripgrep inputs and output decoding used by desktop and remote searches.

What Changed

  • Isolate searches from a user's shell ripgrep configuration. Repository ignore files still apply.
  • Frame filename lists with NUL separators so a newline in a filename stays part of that filename. Reject unsupported filename encodings instead of inventing a different path.
  • Search from the workspace directory using . so includes such as src/** match correctly.
  • Convert ripgrep's UTF-8 byte offsets to editor UTF-16 columns, including decoded non-UTF-8 content.
  • Remove a silent 100-matching-line limit and retain the requested matches from dense lines using the existing streaming JSON library. Keep global result, file-size, timeout, output-frame, nesting, and context budgets.
  • Surface failed searches in the desktop panel, retain partial results as incomplete, and clear the error on retry. A stale request cannot replace a newer result.
  • Preserve host filename identity through Explorer listing, filtering, reveal, Markdown classification, and watcher-to-editor routing, including filesystem-root workspaces.
  • Resolve Windows relay fallback from the environment used to launch it, with an effective-PATH cache and retryable misses. Absolute executable resolution remains required.

Why

These are correctness fixes, not a claim that every search becomes faster. Shared builders, parsers, and diagnostics keep the desktop, runtime, and SSH implementations consistent. The ordinary JSON path remains simple; only dense records use bounded projection instead of constructing every submatch object. Repeated prefix decoding was rejected because it makes Unicode column conversion quadratic.

Measurements

Native macOS arm64, Node 24.20.0, bundled ripgrep 15.0.0. Parser measurements run serially in separate Node processes; ten samples, first two excluded. Ordinary records use 1,000 iterations per sample. These timings exclude subprocess startup and are parser-only.

Fixture Before After
10 ASCII matches / 549-byte record 10 matches, 0.0037 ms 10 matches, 0.0042 ms
10,000 matches / 499 KB record 0 matches, falsely complete; 0.49 ms 2,000 matches, incomplete; 15.56 ms
100,000 matches / 5.19 MB record 0 matches, falsely complete; 0.51 ms 2,000 matches, incomplete; 148.02 ms
150 matching lines in one file silently stops at 100 all 150 returned

The dense parser costs more because it now processes results previously discarded. A separate conversion benchmark compared two correct implementations: 2,000 Unicode offsets took about 0.041 ms with the monotonic reader versus 17.18 ms with repeated prefix decoding. This is not a speedup claim against the old incorrect byte offsets.

Strict filename decoding was also measured serially on 40,000 Unicode filenames / 1,188,890 bytes, delivered in 64 KiB chunks. Ten counterbalanced samples after two warmups: replacement decoding median 1.45 ms, strict decoding 0.53 ms, exact valid-output parity. This microbenchmark excludes process startup and does not establish end-to-end search speed.

The separate Markdown optimization was merged in #25148: identical 293 documents with 99.46% less filename stdout. No blanket thread tuning was adopted; a single scanning thread was slower in that measured checkout.

Linked Issue

N/A — maintainer-requested complete usage audit.

Visual Proof

Hidden Electron validation used an isolated profile and the current worktree. Entering an invalid regex displays the actual error; retrying with needle clears the error and displays one result.

Invalid regular expression:

Search error

Successful retry:

Search recovered No visible window or OS activation was used.

Testing

After rebasing onto main at b1b78b4d20b3: 591 tests passed across 59 suites, with two platform-only cases skipped on macOS. All typecheck projects (Node, renderer, CLI and configured siblings), diff whitespace checks, and the changed-code quality gate pass. The first CI run caught an ESM-only test import under the CLI CommonJS project; that import now loads dynamically and the complete typecheck command passes. The search-failure localization key is now registered; both catalog and extraction gates pass locally. Actual bundled-binary fixtures cover Unicode columns, anchored globs, dense matches, per-file completeness and invalid regex.

  • Manually exercised the actual desktop search panel in a hidden Electron instance
  • Automated regressions cover the changed behavior

Review

Proposals received adversarial agent review before implementation. Repeated three-agent review rounds covered parsers, subprocess lifecycle, renderer consumers, remote boundaries and platform paths, with independent review after fixes. Findings fixed with regressions include U+FEFF stripped inside strings by the streaming JSON dependency, POSIX backslashes collapsed in Explorer consumers, Windows-client classification of POSIX Markdown names, watcher updates routed to the wrong similarly named tab, and truncated relative names at filesystem roots. The final independent reviews are clean. The unused normalization helper was removed.

Independent parser validation includes 64 ESM/CJS Unicode/buffer-boundary probes and 23,000 differential cases. The dependency fix is six decoder-option changes in the existing pnpm patch mechanism, verified against the clean npm tarball and tested against the other session-stream consumers. The final consumer review also traces actual editor event indexing and filesystem mutation routing.

Agent skill upstream boundary

  • Not applicable; no upstream skill material copied.

Audit coverage

Execution Reviewed boundary
filesystem-list-files.ts Full and capped Quick Open inventory, cancellation, partial exits
filesystem-search-file-paths.ts Ranked filename collection, framing, output bounds
markdown-documents.ts Extension filtering, ignore policy, path identity, framing
filesystem-search-handlers.ts Desktop text search, WSL translation, request lifecycle
runtime-file-commands-search-local-runtime-files.ts Runtime-owned search and file opening
relay/fs-handler-list-files.ts Host-owned listing and unavailable-binary recovery
relay/fs-handler-utils.ts Host-owned text search and unavailable-binary recovery
ripgrep-process-availability.ts Failure-only, bounded version probes; version mode does not read rg configuration

Binary/resource resolution, WSL architecture selection, SSH upload and reference-based cache collection, desktop six-platform packaging, target-specific orcad packaging, and the CI xprop readiness invocation were also reviewed. No additional application rg execution sites were found. Configuration isolation is applied in shared argument builders; no new local git/readdir fallback was added. Default thread selection is retained because measured single-thread scans were slower.

Deliberately retained policies

  • Remote Markdown discovery uses the remote inventory's existing ignore policy. Aligning it with local Markdown visibility needs a separate compatibility decision.
  • Legacy filename-list APIs may return partial arrays after a permission error; they do not have an incomplete field. This change does not silently change that wire contract.
  • Unsupported byte filenames cannot be represented losslessly by the current string APIs: text results mark incomplete; listing calls reject explicitly. WSL literal-backslash filenames receive the same honest treatment because UNC translation cannot represent them.
  • The path fixes cover search/list/open paths. They are not a claim that every unrelated Git or presentation path helper now supports every unusual filename.

Notes

All seven application execution sites and the failure-only version probe were audited, along with binary resolution, WSL routing, SSH upload/cache collection, desktop and orcad packaging, and the small CI-only invocation. No new wire fields or opcodes are introduced. Old remote hosts retain their own search behavior until updated; old clients may not show the new detailed error display.

Live host validation used orca host list and a dedicated background terminal on the paired awin environment. The final production helpers were bundled from this worktree and exercised on macOS arm64 (Node24.20.0), Windows x64 (Node24.18.0), and Ubuntu24.04 under WSL/Linux x64 (Node24.0.0). Each ripgrep binary matched the SHA256 of the corresponding installed Orca dependency. Checks covered Unicode columns, anchored includes, config isolation, 150 matching lines, 10,000 dense hits retaining 2,000, FEFF preservation, POSIX Explorer identity on a Windows client, NUL-framed Unicode filenames, regex exit 2, and Windows Cargo PATH fallback. A real invalid-UTF8 filename on Linux also verified explicit listing rejection and incomplete text results. This is live binary/helper validation, not a complete desktop installation or paired app end-to-end test. The listed Linux SSH host was disconnected, so no real SSH host result is claimed. Host-path tests and CI do not substitute for release notarization or deployment smoke tests. Existing limits remain: 5 MiB files, 2,000 requested matches, 500-character snippets and 15-second search timeout. Remote Markdown ignore-policy differences and listing partial-result policy are called out in the audit rather than silently changed.

Checklist

  • Final diff reviewed; shared contracts and their callers are kept together
  • Before/after behavior, mechanism and alternatives explained
  • Visual proof attached
  • Final correctness/security/performance review complete
  • Cross-platform, folder-workspace and remote compatibility considered
  • Final test, typecheck and quality results recorded; full packaging left to CI

@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d1437f4e-232f-4811-b60a-9427bd54cdfa
📥 Commits

Reviewing files that changed from the base of the PR and between 2bc589d and 3d4a95b.

📒 Files selected for processing (10)
  • src/main/ipc/markdown-documents-remote-paths.test.ts
  • src/main/ipc/markdown-documents.ts
  • src/renderer/src/components/editor/editor-external-watch-path-index.test.ts
  • src/renderer/src/components/right-sidebar/file-explorer-directory-filename-identity.test.ts
  • src/renderer/src/components/right-sidebar/file-explorer-directory-listing.ts
  • src/renderer/src/components/right-sidebar/file-explorer-paths.test.ts
  • src/renderer/src/components/right-sidebar/file-explorer-paths.ts
  • src/renderer/src/components/right-sidebar/file-explorer-watch-filename-identity.test.ts
  • src/renderer/src/components/right-sidebar/file-explorer-watch-path.ts
  • src/renderer/src/components/right-sidebar/file-explorer-watcher-reconcile.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.


📝 Walkthrough

Walkthrough

Ripgrep filename listings now use NUL-delimited records and incremental UTF-8 decoding. Path handling preserves literal backslashes for non-Windows roots and applies Windows separator rules to Windows roots. Text search adds bounded JSON parsing, Unicode-aware match offsets, root-aware path resolution, and diagnostic-based process outcomes. The renderer now stores and displays search errors. Windows relay ripgrep lookup uses the effective command environment PATH and refreshes cached results when that path changes.

Priority: ⬆️ High

Merge Risk: ⚪ Minimal · up to 3d4a9

No outstanding issue is established; the change is mergeable after normal checks.

Architecture Summary

Architecture risk: 🟡 Medium · up to 3d4a9

The change affects 3 systems.

Changed systems: src, config, pnpm-workspace.yaml

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 69 changed files map to changed impact.
  • observed — config (service) was modified; 1 changed file maps to changed impact.
  • observed — pnpm-workspace.yaml (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in src/main/ipc/filesystem-list-files-name-filter.test.ts: The ripgrep fixture for the cap-count test now separates paths with NUL characters instead of newlines.
  • observed — Modified behavior in src/main/ipc/filesystem-list-files-name-filter.test.ts: The ripgrep fixture for the filtered ignored-pass startup-failure test now uses NUL-separated paths instead of newline-separated paths.
  • observed — Modified behavior in src/main/ipc/filesystem-list-files-name-filter.test.ts: The ripgrep fixture for the filtered ignored-pass failure test now uses NUL-separated paths instead of newline-separated paths.
  • observed — Modified behavior in src/main/ipc/filesystem-list-files-name-filter.test.ts: The ripgrep fixture for the unfiltered ignored-pass failure test now uses NUL-separated paths instead of newline-separated paths.

Reliability and maintainability

  • inferred — Risk-relevant change factors for src: blast_radius_1; blast_radius_2; direct_dependents_1; direct_dependents_2
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.13% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 71 functions across 65 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 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 summarizes the main changes to ripgrep result completeness, filename handling, and search errors.
Description check ✅ Passed The description covers the required sections, explains the user-facing changes and rationale, provides visual proof, and records testing and platform coverage. It marks the linked issue as not applica…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

I read the full 53-file diff, ran the new and changed suites (all green), and had two specialists independently verify the two novel algorithms. No blocking or actionable defects found.

  • Config isolation — --no-config added to buildRgArgs, buildRgArgsForQuickOpen, and listMarkdownDocuments, so a user's RIPGREP_CONFIG_PATH no longer silently changes results; repo ignore files still apply.
  • NUL framing — every rg --files builder now emits --null and every consumer splits on \0, so filenames with embedded newlines/CR stay intact. normalizeQuickOpenRgLine no longer strips a trailing \r.
  • Strict filename decoding — new RipgrepFilenameDecoder (fatal TextDecoder) rejects invalid UTF-8 and, when WSL translation is required, literal-backslash names, marking results incomplete rather than fabricating replacement-character paths.
  • Root-relative search target — buildRgArgs(query, '.', opts) with cwd: rootPath across main/runtime/relay, so anchored globs such as src/** match; new resolveSearchResultPath resolves rg's cwd-relative output.
  • UTF-16 columns — new ripgrep-line-decoding / ripgrep-match-offsets map rg byte offsets to editor columns with a monotonic reader. A specialist brute-forced all 3-byte prefixes (0 mismatches) and 4-byte F0–F4 prefixes plus randomized fuzzing against Buffer.toString('utf8') — exact parity, including malformed runs.
  • Dense matches — the silent 100-per-file cap is removed; parseDenseRipgrepMatchJson uses @streamparser/json to retain the remaining global budget from records exceeding the structural-token limit. Verified against @streamparser/[email protected]'s keepStack:false live-stack semantics: the budget is exact and no undercount-without-truncated path exists.
  • Failure diagnostics — RipgrepSearchDiagnostics makes searches that error with no matches (e.g. invalid regex) reject instead of resolving as a false-empty result; permission errors with matches stay incomplete-but-present.
  • Renderer + Windows relay PATH — the error surfaces in SearchResultsPane, stale rejections are ignored by latestSearchIdRef, and the Windows relay now resolves rg from buildRelayCommandEnv()'s effective PATH with a bounded-miss cache and drive-rooted entries only.

I did not flag the one narrow compatibility consideration (--no-config is not in older ripgrep) because the relay prefers the bundled rg 15.0.0 and only a PATH-fallback host with an ancient rg would regress.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker force-pushed the nwparker/ripgrep-search-correctness branch from cc4fea1 to 2bc589d Compare October 4, 2026 07:07
@nwparker
nwparker requested a review from brennanb2025 as a code owner October 4, 2026 07:07

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

This run incrementally re-reviewed the delta since the prior pullfrog review (8da6986 → cc4fea1), a follow-up commit that closes the two round-one adversarial findings. I read the raw incremental diff and the full PR diff for context, and verified the load-bearing claims against the installed dependency and the changed callers.

  • Preserves U+FEFF inside dense-record strings — a new pnpm patch on @streamparser/[email protected] adds ignoreBOM: true to both buffered decoders. The tokenizer encodes string input to bytes, so the decoder is on the path; a BOM inside path.text/lines.text now survives instead of being stripped (which had shifted dense-match columns). A document-leading BOM is still handled by the tokenizer's own BOM state, so the patch is scoped to in-string BOMs.
  • Distinguishes literal POSIX backslashes — normalizeRelativePath now takes a root and only folds \ when the root is Windows-like; splitPathSegments, isDotfileRelativePath, buildIgnoredSet, and the name-filter projection thread worktreePath through, so Explorer filtering no longer merges a\b.txt with a/b.txt on POSIX.
  • Consistent synthetic row paths — name-filter projection builds relativePath with / unconditionally, matching the non-filtered listing's normalization on Windows.
  • Regression coverage — new tests cover BOMs at string-buffer boundaries (the dependency directly and through the dense parser), a real-rg dense-line BOM column case, and POSIX/Windows filename-identity projection cases. Each can fail against the pre-fix code.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

This run re-reviewed the delta after the branch rebase (cc4fea1 → 2bc589d). The only content change is the third commit registering the search-failure localization entry.

  • Registered the fileSearch.failed string — src/renderer/src/i18n/locales/en.json gains "fileSearch": { "failed": "Search failed. Try again." }, matching the translate('fileSearch.failed', 'Search failed. Try again.') call added in useFileSearchRunner.ts. This is the translator-source entry for the already-reviewed inline fallback, so the English fallback path is unchanged and non-English catalogs can now translate it. The rebase re-attributed this same hunk from the first commit to the third, so the net tree is otherwise identical to the previously approved revision.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

This run incrementally re-reviewed the delta since the prior pullfrog review (2bc589d → 3d4a95b), the fourth commit that carries host filename identity through the document and watcher consumers. I read the raw incremental range-diff and the relevant full-diff hunks, then read each touched source file to trace the identity plumbing end to end. No specialist was needed — the change is mechanical threading of an existing rootPath parameter.

  • Preserves literal POSIX backslashes in renderer path helpers — normalizeRelativePath(path, rootPath?) and joinPath (src/renderer/src/lib/path.ts) now fold \ only when isWindowsAbsolutePathLike(rootPath), so a POSIX filename like a\b.txt stays distinct from the directory path a/b.txt instead of being merged.
  • Threads worktreePath through the identity-sensitive consumers — splitPathSegments, isDotfileRelativePath, buildIgnoredSet, getRevealAncestorDirs, the name-filter projection, and useFileExplorerVisibleRowProjection all receive the root now, so node relativePath, ignored-set keys, and dotfile checks agree byte for byte on POSIX.
  • Fixes watcher and directory-listing identity — normalizeExplorerAbsolutePath only strips trailing / on POSIX; parentDirForWatchPath gained a POSIX lastIndexOf('/') branch; getExternalFileChangeRelativePath passes the root; clearStalePendingReveal relies on isPathInsideOrEqual's normalization; and fileExplorerEntriesToTreeNodes uses getRelativePathInsideRoot(path, worktreePath), which also fixes first-character truncation when the root ends in a separator.
  • Hardens Markdown document classification/decoding — markdownDocumentFromRelativePath uses posix.extname after remote-separator normalization while isMarkdownDocumentName keeps platform extname; rootRelativePath is root-aware; and listMarkdownDocuments now rejects invalid UTF-8 and WSL literal-backslash names via RipgrepFilenameDecoder.
  • Regression coverage — new cases cover Windows-client remote paths, local literal-backslash names, invalid/incomplete UTF-8 listing rejection, abandoned-scalar timeout preservation, and Explorer directory/filter/watcher identity. These assert exact values and would fail against the pre-fix code.

The sibling call sites that still normalize without a root (buildStatusMap, buildFolderStatusMap, source-control-tree.ts) are untouched and remain out of scope, matching the PR's stated boundary for presentation/Git path helpers.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 58bd15f into main Oct 4, 2026
95 of 96 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