Repository navigation
fix(explorer): make filename search find all workspace files - #21423
Conversation
📝 WalkthroughWalkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to Filename searches can fail for local workspaces and briefly show files from a previous workspace; these are bounded UI correctness issues. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Keep the path result synchronized with nameFilterQuery. · use-file-explorer-name-filter.ts:51-61
src/renderer/src/components/right-sidebar/use-file-explorer-name-filter.ts:51-61
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winKeep the path result synchronized with
nameFilterQuery.useFileExplorerNameFiltercombines the current query withnameFilterFiles.files. After a non-empty search completes, a query change can render the new query with the previous paths beforeuseRuntimeFileListForWorktreeclears them in its effect.FileExplorerpasses this source to the name-filter projection, which applies the new query to those paths. This can briefly render previous-result rows and omit matches from the new result. WithholdrelativePathsunless its result query matches the current query, or synchronize the query and result state.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: e0405000-3972-438e-941f-0f9451403164
📒 Files selected for processing (2)
src/renderer/src/components/right-sidebar/use-file-explorer-name-filter.test.tssrc/renderer/src/components/right-sidebar/use-file-explorer-name-filter.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.
There was a problem hiding this comment.
Important
The runtime path search this delegates to is a fuzzy, 32-result-ranked search, while the Explorer projection still demands every whitespace token as a contiguous substring. On SSH / paired-runtime workspaces this can show fewer matches — or "No files match this filter" — exactly where the previous full-listing path found them.
Reviewed changes
- Forward the name-filter query into the runtime path search —
useFileExplorerNameFilternow passesquery: nameFilterQuerytouseRuntimeFileListForWorktree, so SSH/paired-runtime workspaces callsearchRuntimeFilePathsinstead of filtering a capped full listing. - Forwarding regression test —
use-file-explorer-name-filter.test.tsmocks the hook and asserts the query reachesuseRuntimeFileListForWorktreeand is surfaced onnameFilterSource.
ℹ️ Local workspaces still use the capped inventory
usesRuntimePathSearch in quick-open-file-list.ts:188-189 requires a runtime environment or connection, so a {kind:'local'} workspace still takes the listRuntimeFiles branch and ignores query entirely. The PR body says the change "works for local, SSH, and paired runtime workspaces," but local behavior is unchanged: a local repo with more than QUICK_OPEN_LISTING_MAX_RESULTS (20 001) paths still filters only that capped page. Worth confirming which kind of workspace the reported bug was on — if it was local, this does not fix it.
Technical details
# Local path is unchanged
## Affected sites
- `src/renderer/src/components/quick-open-file-list.ts:188-190` — `usesRuntimePathSearch` is false for `{kind:'local'}` owners (`file-explorer-operation-owner.ts:106-110` returns `activeRuntimeEnvironmentId: null`, no `connectionId`), so the new `query` is not part of `requestKey` and `listRuntimeFiles` still runs with `maxResults: QUICK_OPEN_LISTING_MAX_RESULTS`.
- `src/renderer/src/components/quick-open-file-list.react.test.tsx:569-599` — existing test already pins that local listings do not restart on query change.
## Required outcome
- Either confirm the reported workspace was remote (and correct the PR body), or add a local search path so local workspaces are not limited to the capped listing.ℹ️ Nitpicks
- Query-size gates disagree: the Explorer rejects only above 2 KB (
FILE_EXPLORER_NAME_FILTER_QUERY_MAX_BYTES), but the remote search rejects above 256 code units (QUICK_OPEN_REMOTE_QUERY_MAX_CODE_UNITS). A 257–2048-char query passes the Explorer'snameFilterQueryTooLargecheck yet produces an empty remote result and the "No files match this filter" state. - The new test mocks
useRuntimeFileListForWorktree, so it only proves the argument is forwarded. A test that runs the real hook pluscreateNameFilteredFileExplorerProjectionfor a remote worktree would exercise the matching mismatch below.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| enabled: hasNameFilter && !nameFilterQueryTooLarge, | ||
| worktreeId: activeWorktreeId | ||
| worktreeId: activeWorktreeId, | ||
| query: nameFilterQuery |
There was a problem hiding this comment.
Passing the raw query here routes SSH/paired-runtime workspaces through searchRuntimeFilePaths, whose QuickOpenPathRanker is a fuzzy subsequence matcher capped at 32 results. The Explorer projection still requires every whitespace token to be a contiguous substring, so fuzzy-only matches are dropped and genuine matches can rank below the 32-result page — yielding fewer or zero rows where the old full listing matched.
Multi-word queries are hit hardest: the whole trimmed query (internal spaces included) goes to the fuzzy matcher, which needs a literal space in the path, so "app delegate" can match nothing while the projection would have matched src/delegate/app.ts. The 32-result page's truncated flag is never read by the Explorer, so the shortfall is silent.
Technical details
# Fuzzy runtime search vs. contiguous-substring projection
## Affected sites
- `src/renderer/src/components/right-sidebar/use-file-explorer-name-filter.ts:46-50` — passes `query: nameFilterQuery` unconditionally.
- `src/renderer/src/components/quick-open-file-list.ts:188-260` — `remoteQuery = query.trim()` (internal spaces retained); `searchRuntimeFilePaths(..., { limit: 32 })`.
- `src/shared/quick-open-path-search.ts:109-157` — `normalizeQuickOpenQuery` only trims/case-folds; `fuzzyMatchIndexedFile` matches every query char as a subsequence.
- `src/renderer/src/components/right-sidebar/file-explorer-name-filter-projection.ts:99-106,191` — `tokens.every((token) => haystack.includes(token))`, contiguous substrings, all tokens required.
- `src/renderer/src/components/right-sidebar/use-file-explorer-name-filter.ts:51-72` — `nameFilterSource` reads only `files`, `loading`, `operationOwner`; `nameFilterFiles.truncated` is unused, and `FileExplorerFilesTreePane.tsx` never renders it.
## Required outcome
- A remote filename query must not show "No files match this filter" when matching paths exist, and must not silently drop matches beyond the first ranked page.
## Suggested approach (optional)
- Skip the token re-filter in `createNameFilteredFileExplorerProjection` when `relativePaths` came from a runtime query search (keep the dotfile / git-ignored / tree-building work), or align the runtime search semantics with the Explorer's contiguous-token matching.
- Parameterize the limit for the Explorer call and surface `truncated` in the pane so a partial page is visible.There was a problem hiding this comment.
Important
The local-workspace path this commit adds does not actually search: the main-process fs:listFiles handler drops searchQuery for the no-connectionId branch, so a plain local workspace still filters the first capped inventory page. The new local test mocks the IPC boundary, so it cannot catch this.
Reviewed changes
- Local workspaces routed through the runtime path search —
usesRuntimePathSearchis nowquery !== undefined && operationRouteAvailable, and the non-environment branch ofsearchRuntimeFilePathsno longer requires aconnectionId, so{kind:'local'}owners call the path search instead oflistRuntimeFiles. - Result limit raised to
QUICK_OPEN_LISTING_MAX_RESULTS— SSH/local searches request up to 20 001 paths; environment (paired-runtime) searches are clamped back to 32 by the wire schema. resolvedQueryadded to keep results synchronized with the query — the Explorer withholdsrelativePathsuntil the hook reports results for the exact trimmed query, closing the stale-rows window.- Tests updated — the hook test now asserts query routing, and a new runtime-client test asserts the local query reaches
window.api.fs.listFiles.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| const target = getActiveRuntimeTarget(context.settings) | ||
| if (target.kind !== 'environment') { | ||
| if (!context.connectionId || !context.worktreePath) { | ||
| if (!context.worktreePath) { |
There was a problem hiding this comment.
This change lets {kind:'local'} workspaces reach searchRuntimeFilePaths, but the query still never searches the filesystem: the main-process fs:listFiles handler's no-connectionId branch calls listQuickOpenFiles(rootPath, store, excludePaths, signal, maxResults) and drops searchQuery, returning the first capped page in traversal order. Local Explorer search therefore behaves exactly as before (client-side filtering over the 20 001-path page), and the reported bug is only fixed for SSH/paired-runtime. The added test mocks window.api.fs.listFiles, so it cannot catch this.
Technical details
# Local `fs:listFiles` drops searchQuery
## Affected sites
- `src/main/ipc/filesystem/filesystem-search-handlers.ts:224-230` — no-`connectionId` branch calls `listQuickOpenFiles(rootPath, store, excludePaths, signal, maxResults)`; `args.searchQuery` is only read on the SSH branch (198-222).
- `src/main/ipc/filesystem-list-files.ts:32-39` — `listQuickOpenFiles` has no query parameter; it returns `Array.from(files).slice(0, maxResults)` in rg traversal order (line 316).
- `src/renderer/src/runtime/runtime-file-search-client.ts:92-105` — local branch assumes the host filtered by `searchQuery`, then slices to `limit`.
- `src/renderer/src/runtime/runtime-file-client-search-listing.test.ts:208-233` — mocks `window.api.fs.listFiles`, so it passes regardless of handler behavior; `src/main/ipc/filesystem.test.ts:545-606` covers only the SSH branch.
## Required outcome
- A local filename query must search the filesystem, not filter a capped traversal page, matching the SSH behavior this PR relies on.
## Suggested approach (optional)
- In the no-`connectionId` branch, when `args.searchQuery` is present, reuse `searchQuickOpenFilePaths(rootPath, store, { query, limit: maxResults, excludePaths, signal })` (`src/main/ipc/filesystem-search-file-paths.ts`) and return its `paths`.
- Add a main-process test for the local branch asserting the query is honored.| } | ||
| const worktreeSelector = toRuntimeWorktreeSelector(context.worktreeId) | ||
| const limit = args.limit ?? 32 | ||
| const limit = Math.min(args.limit ?? 32, 32) |
There was a problem hiding this comment.
This clamps every environment (paired-runtime) path search to 32, so the limit: QUICK_OPEN_LISTING_MAX_RESULTS the Explorer now passes is silently reduced for those targets — only SSH/local get the larger page. The clamp matches FilePathSearch.limit's max(32), so it is required to avoid a schema rejection, but paired-runtime Explorer results remain a 32-item fuzzy page and truncated is never surfaced, so incomplete results stay silent.
Technical details
# Paired-runtime Explorer search is still capped at 32
## Affected sites
- `src/renderer/src/runtime/runtime-file-search-client.ts:111` — `Math.min(args.limit ?? 32, 32)`.
- `src/shared/rpc-contract/files-params.ts:12` — `FilePathSearch.limit` is `z.number().int().positive().max(32).default(16)`; sending `QUICK_OPEN_LISTING_MAX_RESULTS` would be rejected.
- `src/renderer/src/components/quick-open-file-list.ts:261` — requests `limit: QUICK_OPEN_LISTING_MAX_RESULTS`.
- `src/renderer/src/components/right-sidebar/use-file-explorer-name-filter.ts:51-67` — `nameFilterSource` never reads `truncated`.
## Required outcome
- Either document that paired-runtime Explorer search is a 32-item page, or raise the wire cap (capability-negotiated) so the Explorer can request a full page on paired runtimes.
## Open questions for the human (optional)
- Is paired-runtime completeness in scope for this PR, or only SSH/local?There was a problem hiding this comment.
Caution
This delta restores the connectionId requirement in searchRuntimeFilePaths but leaves usesRuntimePathSearch broadened, so local workspaces now route into a search that returns empty. This breaks the pre-existing does not restart local listings when only the query changes test and regresses the local Explorer filename filter to "no matches".
Reviewed changes
Since the last pullfrog review, the author narrowed the change to SSH/paired-runtime only:
- Local search path reverted —
searchRuntimeFilePathsagain requires aconnectionIdfor non-environment targets, and the Explorer's request limit dropped fromQUICK_OPEN_LISTING_MAX_RESULTSback to32. - Tests reverted — the local-search assertion was removed from
runtime-file-client-search-listing.test.ts, andquick-open-file-list.react.test.tsxwas restored to its pre-PR expectations. resolvedQuerysynchronization retained — the stale-rows fix from the previous commit stays.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Fence results by target identity. · quick-open-file-list.ts:286
src/renderer/src/components/quick-open-file-list.ts:286
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winFence results by target identity.
When
worktreePathoroperationOwnerKeychanges with the same non-empty query,requestKeychanges, butuseRuntimeFileListForWorktreeclearsfilesinuseEffect. The render before that effect retains the previousfiles, matchingresolvedQuery, andloading === false.useFileExplorerNameFiltercan therefore expose paths from the previous target. Store the target identity with the result, or gate the projection against the current request identity.
🟡 Minor · Preserve the query for local file-list results. · quick-open-file-list.ts:191-192
src/renderer/src/components/quick-open-file-list.ts:191-192
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winPreserve the query for local file-list results. The local owner route has
activeRuntimeEnvironmentId: nulland noconnectionId, so this state is reachable. It callslistRuntimeFiles, then storesresolvedQueryasundefined.useFileExplorerNameFiltertherefore rejects the full listing because it does not match the trimmed query, so local filename filtering returns no results. Keep query changes out ofrequestKey, but record the query identity for the full-list fallback.setResolvedQuery(usesRuntimePathSearch ? remoteQuery : query?.trim())
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 61e1e7bd-ddae-401d-adb7-e35740928395
📒 Files selected for processing (1)
src/renderer/src/components/quick-open-file-list.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.

ELI5
Before, Explorer downloaded a limited list of files and searched only that list. If the file was outside the list, it looked like it did not exist. Now the runtime searches for the typed filename directly, so matching files can be found even in a large workspace.
What Changed
The Explorer name filter passes its query into the existing runtime path-search API. The result is still projected into the same tree UI, so matching folders and files behave as before while large workspaces no longer depend on the first capped inventory. Added a regression test that verifies the filename query is forwarded.
Why
This reuses the runtime search path already used by Quick Open and works for local, SSH, and paired runtime workspaces. It avoids increasing the full-workspace listing cap or maintaining a second search implementation.
Linked Issue
Visual Proof
Before (unfiltered Explorer):
After (filename filter returns matching paths):
Testing
pnpm test src/renderer/src/components/right-sidebar/use-file-explorer-name-filter.test.ts src/renderer/src/components/quick-open-file-list.react.test.tsxpnpm test src/renderer/src/components/right-sidebar/useFileExplorerVisibleRowProjection.test.tspnpm tc:webpnpm exec oxlint ...pnpm run check:code-quality:changedRendered the Explorer through Electron/CDP in background mode on macOS; verified the Names mode and filename filter UI.
I manually tested these changes locally
Automated tests added/updated
Review