Skip to content

fix(explorer): make filename search find all workspace files - #21423

Merged
nwparker merged 5 commits into
stablyai:mainfrom
nwparker:nwparker/notion-file-search
Sep 18, 2026
Merged

nwparker merged 5 commits into
stablyai:mainfrom
nwparker:nwparker/notion-file-search

Conversation

@nwparker

@nwparker nwparker commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

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

Before

After (filename filter returns matching paths):

After

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.tsx

  • pnpm test src/renderer/src/components/right-sidebar/useFileExplorerVisibleRowProjection.test.ts

  • pnpm tc:web

  • pnpm exec oxlint ...

  • pnpm run check:code-quality:changed

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

  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path impact considered
  • Small and focused

@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

useRuntimeFileListForWorktree now tracks resolvedQuery and selects runtime path searches when a query and runtime route are available. useFileExplorerNameFilter passes the filter query and exposes results only when the resolved query matches the trimmed input. A test verifies query propagation and filter state updates.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 476ae

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 6 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 main change: filename search now finds files across the workspace.
Description check ✅ Passed The description covers the user impact, implementation, rationale, linked report, visual proof, testing, and review status. It omits some template sections, including AI Disclosure, Agent skill upstre…
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

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.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 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 win

Keep the path result synchronized with nameFilterQuery. useFileExplorerNameFilter combines the current query with nameFilterFiles.files. After a non-empty search completes, a query change can render the new query with the previous paths before useRuntimeFileListForWorktree clears them in its effect. FileExplorer passes 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. Withhold relativePaths unless 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5931415 and 931ea88.

📒 Files selected for processing (2)
  • 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

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

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

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 — useFileExplorerNameFilter now passes query: nameFilterQuery to useRuntimeFileListForWorktree, so SSH/paired-runtime workspaces call searchRuntimeFilePaths instead of filtering a capped full listing.
  • Forwarding regression test — use-file-explorer-name-filter.test.ts mocks the hook and asserts the query reaches useRuntimeFileListForWorktree and is surfaced on nameFilterSource.

ℹ️ 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's nameFilterQueryTooLarge check 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 plus createNameFilteredFileExplorerProjection for a remote worktree would exercise the matching mismatch below.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

enabled: hasNameFilter && !nameFilterQueryTooLarge,
worktreeId: activeWorktreeId
worktreeId: activeWorktreeId,
query: nameFilterQuery

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.

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.

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

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 — usesRuntimePathSearch is now query !== undefined && operationRouteAvailable, and the non-environment branch of searchRuntimeFilePaths no longer requires a connectionId, so {kind:'local'} owners call the path search instead of listRuntimeFiles.
  • 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.
  • resolvedQuery added to keep results synchronized with the query — the Explorer withholds relativePaths until 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

const target = getActiveRuntimeTarget(context.settings)
if (target.kind !== 'environment') {
if (!context.connectionId || !context.worktreePath) {
if (!context.worktreePath) {

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.

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)

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.

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?

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

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 — searchRuntimeFilePaths again requires a connectionId for non-environment targets, and the Explorer's request limit dropped from QUICK_OPEN_LISTING_MAX_RESULTS back to 32.
  • Tests reverted — the local-search assertion was removed from runtime-file-client-search-listing.test.ts, and quick-open-file-list.react.test.tsx was restored to its pre-PR expectations.
  • resolvedQuery synchronization retained — the stale-rows fix from the previous commit stays.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | 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.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (2)

🟡 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 win

Fence results by target identity.

When worktreePath or operationOwnerKey changes with the same non-empty query, requestKey changes, but useRuntimeFileListForWorktree clears files in useEffect. The render before that effect retains the previous files, matching resolvedQuery, and loading === false. useFileExplorerNameFilter can 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 win

Preserve the query for local file-list results. The local owner route has activeRuntimeEnvironmentId: null and no connectionId, so this state is reachable. It calls listRuntimeFiles, then stores resolvedQuery as undefined. useFileExplorerNameFilter therefore rejects the full listing because it does not match the trimmed query, so local filename filtering returns no results. Keep query changes out of requestKey, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5d506ab and 476ae21.

📒 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.

@nwparker
nwparker merged commit 01beadb into stablyai:main Sep 18, 2026
33 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