Skip to content

fix(search): ignore completed results from an older submit - #5

Closed
lawrence-millard wants to merge 1 commit into
mainfrom
cursor/fix-search-stale-results-6515
Closed

lawrence-millard wants to merge 1 commit into
mainfrom
cursor/fix-search-stale-results-6515

Conversation

@lawrence-millard

Copy link
Copy Markdown
Owner

Problem

SearchViewModel.submit started an unowned Task for each query. SearchService.search cancels the previous InnerTube task, but if request A already completed before B started, fetchResults(A) still assigned results / phase after B’s UI update.

Repro at the call level: submit “hello”, then immediately submit “hello world”. A can finish parse and write sections for “hello” after “hello world” is the submitted query.

Fix

  • Track resultsTask and cancel it in cancelTasks() (new submit and idle clear).
  • After await, apply results or failure only if submittedQuery == query and the task was not cancelled.

How to verify

  1. Submit a slow/broad query, then immediately submit a different query.
  2. The list must show only the last submitted query’s sections (or its error), never the first query after the second has been submitted.

Device search not run here. No Last.fm/Discord RPC.

Open in Web Open in Cursor 

submit() spawned an untracked Task per query. A slower first
InnerTube response could apply after a second submit, replacing
the newer results. Cancel the previous results task and apply
only when submittedQuery still matches.

Co-authored-by: Lawrence <lawrence-millard@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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.

@lawrence-millard

Copy link
Copy Markdown
Owner Author

Closed: Lawrence said no auto-PRs.

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.

2 participants