Skip to content

Fix stale listings when search query changes - #22173

Merged
AmethystLiang merged 2 commits into
mainfrom
fix-file-search-2
Sep 22, 2026
Merged

AmethystLiang merged 2 commits into
mainfrom
fix-file-search-2

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​119 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​116
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​36 $\color{#cf222e}{\Huge{\mathbf{−}}}$​42 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6

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 requestKey that matches the request that produced it. The UI only displays a listing if its requestKey matches 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 resolvedQuery field 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

  • Added test: "never renders the previous listing once the remote query changes" — verifies stale files don't appear during remote searches
  • Added test: "keeps the local listing across query changes without restarting it" — verifies local listings don't re-fetch unnecessarily
  • Added tests in use-file-explorer-name-filter: verify settled vs. unsettled listing projection

Checklist

  • This PR is small and focused
  • Before/after explained (UI no longer flashes stale results when query changes)
  • Self-reviewed for correctness
  • Tests added for the fix

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

coderabbitai Bot commented Sep 22, 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

The 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 834af

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)

Check name Status Explanation Resolution
Description check ⚠️ Warning 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,… 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,…
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 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: preventing stale file listings when the search query changes.
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.
Full details: Description check

Explanation

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.

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

@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: 45320378-ae01-42b1-883a-08ebf0f9376b

📥 Commits

Reviewing files that changed from the base of the PR and between 8568d77 and 834af91.

📒 Files selected for processing (4)
  • 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/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; 9 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.

✅ No new issues found.

Reviewed changes

  • Render-time listing invalidation — useRuntimeFileListForWorktree now keeps a single { requestKey, files, truncated } listing and only exposes it when listing.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-time setFiles([]) cleared only after paint.
  • Local listings key without the query — requestKey includes remoteQuery only when usesRuntimePathSearch, 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 — useFileExplorerNameFilter drops the resolvedQuery === nameFilterQuery.trim() branch and returns loading ? 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.

Pullfrog  | View workflow run | Using 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".
@AmethystLiang
AmethystLiang merged commit b57facc into main Sep 22, 2026
30 of 31 checks passed
nplez1 added a commit to nplez1/orca that referenced this pull request Sep 22, 2026
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.
GhostFlying pushed a commit to GhostFlying/orca that referenced this pull request Sep 22, 2026
* 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".
nplez1 added a commit to nplez1/orca that referenced this pull request Sep 25, 2026
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.
nplez1 added a commit to nplez1/orca that referenced this pull request Sep 27, 2026
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.
nplez1 added a commit to nplez1/orca that referenced this pull request Sep 29, 2026
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.
nplez1 added a commit to nplez1/orca that referenced this pull request Oct 1, 2026
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.
nplez1 added a commit to nplez1/orca that referenced this pull request Oct 6, 2026
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.
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