Skip to content

fix(explorer): find files by name in large local workspaces - #22369

Merged
nwparker merged 5 commits into
mainfrom
nwparker/notion-file
Sep 23, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/notion-file

Conversation

@nwparker

@nwparker nwparker commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​517 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​516
Prod 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​245 $\color{#cf222e}{\Huge{\mathbf{−}}}$​131 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​114

ELI5

In a large local project, the Explorer's "Names" filter only searched the first 20,001 files it had listed. A file past that point looked like it did not exist, even though Contents search could find it. Now, when a local project is that large, the filter asks the computer to scan every file for the name instead.

What Changed

  • Before: A local workspace's name filter loaded a listing capped at 20,001 files and filtered it in the window. Files outside the listing never matched: AppDelegate.swift showed "No files match this filter". The earlier fix (fix(explorer): make filename search find all workspace files #21423) only covered SSH and remote-host workspaces, so this still reproduced on 1.4.207.
  • After, normal-size repos (no change): one listing, then instant filtering in the window.
  • After, repos whose listing hits the 20,001 cap:
    • The Explorer re-lists on the host with the filter applied during the scan, so the cap counts matching files instead of scanned files.
    • It uses the Explorer's own rule (every space-separated word must appear in the path, ignoring case), so results are the same as the window-side filter.
    • Typing is debounced by 120 ms before each host scan.
  • Mechanism:
    • The matching rule moved to src/shared/file-name-filter-tokens.ts, used by both the renderer and the main process.
    • fs:listFiles accepts an optional local-only nameFilter. listQuickOpenFiles applies it before its cap in the ripgrep path.
    • Without ripgrep, the git fallback lists every file and then filters.
    • If a host scan fails (for example a timeout, or a non-git folder over the directory-walk budget), the Explorer quietly falls back to filtering the capped listing, which is the old behavior. It doesn't retry the scan for that workspace until the filter is reopened.
    • A timeout in the ignored-files scan keeps the matches already found.
  • Unchanged: Quick Open (Cmd+P), SSH, and paired-host listings.

Why

The first version of this PR reused Quick Open's fuzzy top-32 host search. Review found it broke multi-word queries (for example "app delegate"), limited visible results to 32 with no notice, and could let gitignored files crowd out real matches. Filtering during the scan with the Explorer's exact rule avoids all three.

Doing this only when the listing is capped keeps the instant, no-scan-per-keystroke behavior for the common case.

Alternatives considered:

  • Raising the cap: it only moves the limit.
  • Bundling ripgrep: it's a bigger packaging change and is better handled separately.

Linked Issue

Fixes Slack report: https://stablygroup.slack.com/archives/C0BSSHPEL66/p1789581486749449 (follow-up to #21423)

Visual Proof

N/A: no visual change. The same Explorer UI now shows matches it used to miss in large repos. Verified with real scans (see Testing).

Testing

  • Real-filesystem check (temporary, not committed) on a 25,001-file git repo with zz/Notion Web Clipper/AppDelegate.swift:

    • Without ripgrep, the old capped listing did not contain the file, which reproduces the bug.
    • The filtered listing found it with ripgrep (38 ms) and without it (58 ms).
  • New tests:

    • The ripgrep cap counts matches only.
    • The real git fallback filters the whole listing.
    • A walk-budget overflow keeps the capped prefix.
    • The handler applies the word rule.
    • The client sends nameFilter to local listings only, not SSH.
    • The hook re-lists only when the local listing is capped.
  • pnpm tc, oxlint, oxfmt, check:code-quality:changed, and the main/ipc, runtime, right-sidebar, quick-open, and shared suites (16,897 tests) pass on macOS.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Cross-platform: the filter reuses the existing local listing (ripgrep / git / directory walk), which already handles WSL and Windows paths.
  • SSH, mobile, and paired hosts: unchanged. nameFilter is never sent with a connectionId, and older hosts ignore unknown fields.
  • Performance: host scans happen only for repos at the listing cap, once per settled query. Scans are keyed on the normalized filter words, so changing only case or spacing doesn't rescan.
  • Known limits:
    • In huge repos the filtered tree shows loading for the length of one scan per settled query (debounced 120 ms). Measured at about 40 ms on a 25k-file repo.
    • Without ripgrep, if a query matches more than 20,001 files, the kept ones are alphabetical rather than tracked-first.
    • The host bounds nameFilter to the same 2 KB limit as the Explorer input.
    • These cases fall back to the old capped behavior: a full rg --files that takes more than 10 s, or a repo without ripgrep whose ignored folders exceed the directory-walk budget. Bundling ripgrep and narrowing the scan inside ripgrep are follow-ups.
    • Matching now lowercases without locale rules (toLowerCase), so the host and the window always agree.

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)
  • 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)

The Explorer name filter only searched remote workspaces directly; local
workspaces still filtered the first 20,001 listed files, so files beyond
that cap never matched in large repos. Local name queries now rank the
whole workspace on the host, and fall back to an uncapped git listing
when ripgrep is not installed.
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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

📝 Walkthrough

Walkthrough

Local filename filtering now uses shared tokenization, matching, and query-size validation. The IPC and preload APIs accept a local-only nameFilter. Filesystem listing applies filters before result limits in ripgrep and fallback paths. Runtime requests forward the filter only for local hosts. The file-list hook re-lists capped local results with a debounced host filter and tracks failed host scans. Related tests cover IPC validation, filesystem fallbacks, runtime transport, and capped-list behavior.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to e5b87

After a host-side filter failure, the Explorer performs another full local listing and briefly shows loading despite already having the capped fallback. Avoid that extra scan before merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

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 34 functions across 21 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: fixing name-based file discovery in large local workspaces.
Description check ✅ Passed The description is complete and focused. It explains the user impact, implementation, rationale, linked report, visual proof status, testing, compatibility considerations, known limits, and checklist …
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

…orer word rule

Replaces the Quick Open fuzzy top-32 routing, which dropped multi-word
matches and capped visible results. The Explorer keeps its instant
renderer-side filter; only when the local listing hits its cap does it
re-list on the host with the same word rule applied before the cap.
@nwparker nwparker changed the title fix(explorer): search local workspaces by file name across every file fix(explorer): find files by name in large local workspaces Sep 23, 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 19be44a5-d361-4feb-a80e-f6a57589e236

📥 Commits

Reviewing files that changed from the base of the PR and between c8db0e1 and f84763b.

📒 Files selected for processing (16)
  • src/main/ipc/filesystem-list-files-handler-name-filter.test.ts
  • src/main/ipc/filesystem-list-files-name-filter.test.ts
  • src/main/ipc/filesystem-list-files-without-ripgrep.ts
  • src/main/ipc/filesystem-list-files.ts
  • src/main/ipc/filesystem/filesystem-search-handlers.ts
  • src/preload/api/filesystem-api.ts
  • src/preload/api/fs-bridge.ts
  • src/renderer/src/components/quick-open-file-list.react.test.tsx
  • src/renderer/src/components/quick-open-file-list.ts
  • src/renderer/src/components/right-sidebar/file-explorer-name-filter-projection.ts
  • src/renderer/src/components/right-sidebar/use-file-explorer-name-filter.test.ts
  • src/renderer/src/components/right-sidebar/use-file-explorer-name-filter.ts
  • src/renderer/src/runtime/runtime-file-client-search-listing.test.ts
  • src/renderer/src/runtime/runtime-file-request-debounce.ts
  • src/renderer/src/runtime/runtime-file-search-client.ts
  • src/shared/file-name-filter-tokens.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

maxResults
)
}
return files.filter(pathFilter).slice(0, maxResults)

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Preserve results when maxResults is undefined.

slice(0, undefined) returns an empty array. A filtered request without maxResults therefore returns no files when ripgrep is unavailable.

Apply slice only when the caller supplies a cap.

Proposed fix
-  return files.filter(pathFilter).slice(0, maxResults)
+  const filteredFiles = files.filter(pathFilter)
+  return maxResults === undefined ? filteredFiles : filteredFiles.slice(0, maxResults)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return files.filter(pathFilter).slice(0, maxResults)
const filteredFiles = files.filter(pathFilter)
return maxResults === undefined ? filteredFiles : filteredFiles.slice(0, maxResults)

- Fall back to the capped listing (and stop re-listing) if the host scan fails
- Keep primary matches when the ignored-file pass fails during a filtered scan
- Key host scans on normalized filter words; reset capped state per filter session
- Bound nameFilter size at the IPC boundary; drop the double readdir walk

@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

Reviewed the current head f84763b (2 commits, 16 files) — the rework of the local name-filter fix after the first version's review. The first version (c8db0e1) reused Quick Open's fuzzy top-32 host search; the current version filters the host scan with the Explorer's own word rule and only when the local listing is capped. The earlier multi-word, 32-result, and gitignored-crowding concerns are addressed.

  • Shared matching rule — src/shared/file-name-filter-tokens.ts now holds splitFileNameFilterTokens / pathMatchesFileNameFilterTokens, used by both the renderer projection and the main process, so the host filters a scan exactly like the window.
  • Host-side filtered listing — fs:listFiles takes a local-only nameFilter; listQuickOpenFiles applies it before its cap in the ripgrep path, and listFilesWithoutRipgrep filters the git/readdir listing (falling back to the capped prefix on a walk-budget overflow).
  • Capped-only re-list — useRuntimeFileListForWorktree does the cheap listing first and only re-lists on the host once the local listing is capped, so small repos keep instant in-window filtering.
  • Debounce extraction — the debounce helper moved to runtime-file-request-debounce.ts; behavior is unchanged, and searchRuntimeFilePaths again requires a connection, so Quick Open, SSH, and paired hosts are untouched.

ℹ️ The no-ripgrep fallback scans the whole workspace per settled query

Without ripgrep, a capped local listing re-lists uncapped, so each settled query runs a full git ls-files and materializes the entire path list before filtering. This is the exact large-repo case the fix targets, and ripgrep is not bundled, so it is worth confirming the memory/time envelope is acceptable rather than silently regressing it.

Technical details
# No-ripgrep fallback is uncapped per settled query

## Affected sites
- `src/main/ipc/filesystem-list-files-without-ripgrep.ts:18` — with a `pathFilter`, calls `listFilesWithGit(..., signal)` with no `maxResults`, so the full git/readdir listing is materialized.
- `src/main/ipc/filesystem-list-files.ts:56-75` — the wrapper only applies `maxSerializedBytes` when the caller passes it; the `fs:listFiles` handler passes `undefined`.
- `src/renderer/src/components/quick-open-file-list.ts:265-268` — the re-list runs once per 120 ms-settled query while the listing is capped.

## Required outcome
- Decide whether the uncapped git scan (full `git ls-files` retained in memory) is acceptable for the target large-repo case, or bound it (e.g. filter while streaming the git listing so retention is `maxResults`-sized).

## Open questions for the human
- Is a million-file repo without ripgrep a scenario worth bounding, or is the transient scan acceptable given the PR body already documents "lists every file and then filters"?

Pullfrog  | View workflow run | Using DeepSeek 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

Re-reviewed the delta since the prior pullfrog review at f84763b — the new commits 3f4cb870 and 1a81a052. Both harden the host name-filter path; I found no new issues.

  • Host-filter failure fallback — quick-open-capped-local-listing.ts records the last capped local listing; when the host-filtered re-list rejects, useRuntimeFileListForWorktree restores that capped listing and sets hostFilterFailed, so the workspace is not re-scanned until the filter is reopened. listFilesWithoutRipgrep now rejects on a walk-budget overflow instead of silently re-listing, so the renderer owns the fallback.
  • Ignored-pass resilience — during a filtered rg scan, an ignored-file pass failure (timeout/kill) keeps the primary matches; unfiltered listings still surface the error.
  • Locale-independent matching — file-name-filter-tokens.ts uses toLowerCase() and now owns FILE_NAME_FILTER_QUERY_MAX_BYTES / isFileNameFilterQueryTooLarge (the projection re-exports them). The hook normalizes the filter to lowercased words, so changing only case or spacing no longer triggers a rescan.
  • IPC guard — fs:listFiles rejects an oversized nameFilter before scanning.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

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

Run ID: 00380b2c-0627-40c8-9610-092756a98b6a

📥 Commits

Reviewing files that changed from the base of the PR and between 1a81a05 and e5b8792.

📒 Files selected for processing (3)
  • src/renderer/src/components/quick-open-capped-local-listing.ts
  • src/renderer/src/components/quick-open-file-list-host-name-filter.react.test.tsx
  • src/renderer/src/components/quick-open-file-list.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

if (!cancelled) {
if (!cancelled && hostNameFilter) {
// Why: a failed host scan falls back to filtering the capped listing, not an error.
setCappedLocalListing((current) => current && { ...current, hostFilterFailed: true })

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.

🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '120,340p' src/renderer/src/components/quick-open-file-list.ts
sed -n '1,260p' src/renderer/src/components/quick-open-file-list-host-name-filter.react.test.tsx
sed -n '1,80p' src/renderer/src/components/quick-open-capped-local-listing.ts

Repository: stablyai/orca

Length of output: 16315


Skip the unfiltered request after a host-filter failure.

When the host-filter request fails, hostFilterFailed clears hostNameFilter and changes requestKey back to listingKey. The capped result remains available, but startsRequest becomes true, so the effect starts another unfiltered listFiles() request and shows loading.

Add a failed-host-filter branch that keeps the capped result and stops the effect before it starts a request.

Suggested fix
   const listingKey = `${worktreePath ?? ''}\n${operationOwnerKey}\n${excludeRequest.key}\n${activeTargetStatus ?? ''}`
+  const hostFilterFailed =
+    cappedLocalListing?.key === listingKey && cappedLocalListing.hostFilterFailed
   // Why: a capped listing can omit matches, so only then pay for a host scan per query.
   const hostNameFilter =
     hostFilterWhenCapped &&
     runtimeEnvironmentId === null &&
     connectionId === undefined &&
     cappedLocalListing?.key === listingKey &&
-    !cappedLocalListing.hostFilterFailed
+    !hostFilterFailed
       ? splitFileNameFilterTokens(query ?? '').join(' ')
       : ''

     if (usesRuntimePathSearch && (remoteQuery.length === 0 || remoteQueryTooLarge)) {
       setListing(NO_LISTING)
       setLoadingRequest({ requestKey, loading: false })
       setListedOperationOwner(operationOwnerRef.current)
       return
     }

+    if (hostFilterWhenCapped && !usesRuntimePathSearch && hostFilterFailed) {
+      setLoadingRequest({ requestKey, loading: false })
+      return
+    }
+
     setLoadingRequest({ requestKey, loading: true })
...
     hostNameFilter,
+    hostFilterFailed,
+    hostFilterWhenCapped,

@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

Re-reviewed the delta since the prior pullfrog review at 1a81a052 — the single new commit e5b8792. It removes a render-time ref write from the host name-filter fallback and splits the host-filter tests into a dedicated file. I found no new issues.

  • Fallback no longer caches the listing — CappedLocalListing is now { key, hostFilterFailed } (the files field is gone) and nextCappedLocalListing takes a truncated boolean, so the hook no longer assigns a ref during render. On a failed host scan it sets hostFilterFailed, which flips hostNameFilter to empty and re-runs the plain capped listing instead of restoring cached files.
  • Host-filter tests split out — the host name-filter cases moved from quick-open-file-list.react.test.tsx (now back to its base state) into a dedicated quick-open-file-list-host-name-filter.react.test.tsx, covering the filtered re-list, the uncapped no-rescan case, and the failure fallback.

I ran the new test file and the sibling quick-open-file-list.react.test.tsx / use-file-explorer-name-filter.test.ts; all pass.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 83dd047 into main Sep 23, 2026
68 of 70 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