Repository navigation
Fix stale listings when search query changes - #22173
Conversation
Bundle files and truncated state with the request key that produced them. Only display a listing when its request key matches the current query, preventing previous results from leaking through before the new request completes.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughThe runtime file-list hook now stores results as request-keyed listings instead of separate files, truncation, and resolved-query state. It exposes a listing only when its key matches the current request and clears listings for invalid or failed requests. The file explorer name filter now uses the listing files when loading is complete and returns null while loading. Tests cover remote query changes, local listing retention, and filter projection states. Priority: ➖ Normal Merge Risk: 🔵 Low · up to Changing a remote search query can briefly show “no results” before the new search begins. Key the pending state to the current request before merging if this transient UI state is unacceptable. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the problem, solution, rationale, and testing, but it omits required template content. It has no Linked Issue, no Visual Proof or N/A explanation, no AI Disclosure, no Review, no Agent skill upstream boundary section, and no Notes. It also does not confirm the required validation commands or platform and remote-environment coverage. Resolution Add all required template sections. Include a linked issue after “Fixes #”, attach before-and-after visual proof or write “N/A” with a reason, complete AI Disclosure, Review, Agent skill upstream boundary, and Notes. Confirm manual testing, platform and remote-environment coverage, and the status of pnpm lint, pnpm typecheck, pnpm test, and pnpm build.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 45320378-ae01-42b1-883a-08ebf0f9376b
📒 Files selected for processing (4)
src/renderer/src/components/quick-open-file-list.react.test.tsxsrc/renderer/src/components/quick-open-file-list.tssrc/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; 9 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Render-time listing invalidation —
useRuntimeFileListForWorktreenow keeps a single{ requestKey, files, truncated }listing and only exposes it whenlisting.requestKey === requestKey(quick-open-file-list.ts:213). A remote query change therefore drops the previous listing during the render before the next request starts, closing the stale flash that the old effect-timesetFiles([])cleared only after paint. - Local listings key without the query —
requestKeyincludesremoteQueryonly whenusesRuntimePathSearch, so local listings survive query changes and stay filtered client-side. The effect no longer restarts the full scan on a query change. - Name-filter projection simplified —
useFileExplorerNameFilterdrops theresolvedQuery === nameFilterQuery.trim()branch and returnsloading ? null : files, delegating "do these files answer the current query" to the hook's key. - Tests — new remote stale-listing test, local-listing-retention test, and two projection tests.
I verified the new never renders the previous listing once the remote query changes test actually pins the fix: reverting currentListing to plain listing makes it fail. Both focused suites pass, typecheck:web is clean, and the changed-code quality gate reports 0 findings.
On the loading-gap concern raised elsewhere: when a settled remote query changes, currentListing is NO_LISTING while loading is still false for one frame, so the projection sees relativePaths: [] instead of null. I confirmed the base version produced the same [] through its query-mismatch branch, so this is pre-existing rather than a regression — the PR trades a stale-results flash for an empty one. Worth knowing that a naive "derive loading from key mismatch" fix would hang on the cleared/too-large-query branches.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
When a query changes, there's a gap between the render and the effect that starts the new request. During this gap, the listing becomes empty (because it's scoped to the request key), but the loading indicator was stale. To fix this, track loading per request and also report true if this render is about to start a new request — so the empty listing correctly appears as "loading" rather than "no results".
Three files the 2026-09-22 rebase onto upstream `6ae5ef2d00` merged without a conflict marker, whose fixtures still describe the pre-sync shape: - `use-file-explorer-name-filter.test.ts` set `resolvedQuery` on a mocked listing. Upstream's stablyai#22173 (stale listings) deleted that field from `RuntimeFileListState` and moved the fencing into the hook, so the field no longer exists. Dropped it; the projection behaviour it stood for is unchanged. - `use-visible-worktrees.test.tsx` built a `filterState` for an upstream test added in stablyai#22098 without `hiddenWorkspaceStatusIds`, which our #23 made required. The other three literals in the file already carry it. - `AiVaultPanel.legacy-filter.test.tsx` enabled the vault search as `enabled`, the legacy name, in two tests upstream added. Our `3141d7578a` narrowed this mock's type to `contentEnabled`, which is the field the panel writes and the resolver reads first. Both tests still passed at runtime through the legacy fallback in `resolveAiVaultSearchSettings`, which is why only `pnpm tc` saw this. No production behaviour moves. `pnpm tc` is clean.
* fix(renderer): prevent stale listings when query changes Bundle files and truncated state with the request key that produced them. Only display a listing when its request key matches the current query, preventing previous results from leaking through before the new request completes. * fix(renderer): associate loading state with request key When a query changes, there's a gap between the render and the effect that starts the new request. During this gap, the listing becomes empty (because it's scoped to the request key), but the loading indicator was stale. To fix this, track loading per request and also report true if this render is about to start a new request — so the empty listing correctly appears as "loading" rather than "no results".
Three files the 2026-09-22 rebase onto upstream `6ae5ef2d00` merged without a conflict marker, whose fixtures still describe the pre-sync shape: - `use-file-explorer-name-filter.test.ts` set `resolvedQuery` on a mocked listing. Upstream's stablyai#22173 (stale listings) deleted that field from `RuntimeFileListState` and moved the fencing into the hook, so the field no longer exists. Dropped it; the projection behaviour it stood for is unchanged. - `use-visible-worktrees.test.tsx` built a `filterState` for an upstream test added in stablyai#22098 without `hiddenWorkspaceStatusIds`, which our #23 made required. The other three literals in the file already carry it. - `AiVaultPanel.legacy-filter.test.tsx` enabled the vault search as `enabled`, the legacy name, in two tests upstream added. Our `3141d7578a` narrowed this mock's type to `contentEnabled`, which is the field the panel writes and the resolver reads first. Both tests still passed at runtime through the legacy fallback in `resolveAiVaultSearchSettings`, which is why only `pnpm tc` saw this. No production behaviour moves. `pnpm tc` is clean.
Three files the 2026-09-22 rebase onto upstream `6ae5ef2d00` merged without a conflict marker, whose fixtures still describe the pre-sync shape: - `use-file-explorer-name-filter.test.ts` set `resolvedQuery` on a mocked listing. Upstream's stablyai#22173 (stale listings) deleted that field from `RuntimeFileListState` and moved the fencing into the hook, so the field no longer exists. Dropped it; the projection behaviour it stood for is unchanged. - `use-visible-worktrees.test.tsx` built a `filterState` for an upstream test added in stablyai#22098 without `hiddenWorkspaceStatusIds`, which our #23 made required. The other three literals in the file already carry it. - `AiVaultPanel.legacy-filter.test.tsx` enabled the vault search as `enabled`, the legacy name, in two tests upstream added. Our `3141d7578a` narrowed this mock's type to `contentEnabled`, which is the field the panel writes and the resolver reads first. Both tests still passed at runtime through the legacy fallback in `resolveAiVaultSearchSettings`, which is why only `pnpm tc` saw this. No production behaviour moves. `pnpm tc` is clean.
Three files the 2026-09-22 rebase onto upstream `6ae5ef2d00` merged without a conflict marker, whose fixtures still describe the pre-sync shape: - `use-file-explorer-name-filter.test.ts` set `resolvedQuery` on a mocked listing. Upstream's stablyai#22173 (stale listings) deleted that field from `RuntimeFileListState` and moved the fencing into the hook, so the field no longer exists. Dropped it; the projection behaviour it stood for is unchanged. - `use-visible-worktrees.test.tsx` built a `filterState` for an upstream test added in stablyai#22098 without `hiddenWorkspaceStatusIds`, which our #23 made required. The other three literals in the file already carry it. - `AiVaultPanel.legacy-filter.test.tsx` enabled the vault search as `enabled`, the legacy name, in two tests upstream added. Our `3141d7578a` narrowed this mock's type to `contentEnabled`, which is the field the panel writes and the resolver reads first. Both tests still passed at runtime through the legacy fallback in `resolveAiVaultSearchSettings`, which is why only `pnpm tc` saw this. No production behaviour moves. `pnpm tc` is clean.
Three files the 2026-09-22 rebase onto upstream `6ae5ef2d00` merged without a conflict marker, whose fixtures still describe the pre-sync shape: - `use-file-explorer-name-filter.test.ts` set `resolvedQuery` on a mocked listing. Upstream's stablyai#22173 (stale listings) deleted that field from `RuntimeFileListState` and moved the fencing into the hook, so the field no longer exists. Dropped it; the projection behaviour it stood for is unchanged. - `use-visible-worktrees.test.tsx` built a `filterState` for an upstream test added in stablyai#22098 without `hiddenWorkspaceStatusIds`, which our #23 made required. The other three literals in the file already carry it. - `AiVaultPanel.legacy-filter.test.tsx` enabled the vault search as `enabled`, the legacy name, in two tests upstream added. Our `3141d7578a` narrowed this mock's type to `contentEnabled`, which is the field the panel writes and the resolver reads first. Both tests still passed at runtime through the legacy fallback in `resolveAiVaultSearchSettings`, which is why only `pnpm tc` saw this. No production behaviour moves. `pnpm tc` is clean.
Three files the 2026-09-22 rebase onto upstream `6ae5ef2d00` merged without a conflict marker, whose fixtures still describe the pre-sync shape: - `use-file-explorer-name-filter.test.ts` set `resolvedQuery` on a mocked listing. Upstream's stablyai#22173 (stale listings) deleted that field from `RuntimeFileListState` and moved the fencing into the hook, so the field no longer exists. Dropped it; the projection behaviour it stood for is unchanged. - `use-visible-worktrees.test.tsx` built a `filterState` for an upstream test added in stablyai#22098 without `hiddenWorkspaceStatusIds`, which our #23 made required. The other three literals in the file already carry it. - `AiVaultPanel.legacy-filter.test.tsx` enabled the vault search as `enabled`, the legacy name, in two tests upstream added. Our `3141d7578a` narrowed this mock's type to `contentEnabled`, which is the field the panel writes and the resolver reads first. Both tests still passed at runtime through the legacy fallback in `resolveAiVaultSearchSettings`, which is why only `pnpm tc` saw this. No production behaviour moves. `pnpm tc` is clean.

Problem
When users change a file search query (in Quick Open or File Explorer), the old results briefly appear before the new results load. This race condition occurs because the UI was still showing files from the previous request while waiting for the new one to complete.
Solution
Instead of checking which query produced the current results, each file listing now carries a
requestKeythat matches the request that produced it. The UI only displays a listing if itsrequestKeymatches the current request — otherwise it shows empty. This prevents stale results from appearing between a query change and the new results arriving.Why
The old approach used a
resolvedQueryfield to track which query the files answered, requiring complex comparison logic. This was fragile and didn't guarantee stale listings never showed. The request-key approach is simpler and guarantees correctness: if the key doesn't match, the listing is discarded.Testing
use-file-explorer-name-filter: verify settled vs. unsettled listing projectionChecklist