add branch search with server-side filtering#3084
Conversation
This reverts commit 072523d.
Console (appwrite/console)Project ID: Tip MCP server integration brings LLM superpowers to Claude Desktop and Cursor IDE |
Greptile SummaryThis PR introduces a new
Confidence Score: 4/5Safe to merge after fixing the out-of-order search response race condition in BranchSelector. The new BranchSelector component has a race condition in searchBranches: a slow earlier request can resolve after a faster later one and overwrite searchResults with stale data. The 300 ms debounce reduces but does not eliminate this window — on slow or variable-latency connections it is reproducible and shows users incorrect branch lists. src/lib/components/git/branchSelector.svelte — specifically the searchBranches async function lacks response-ordering guards. Important Files Changed
Reviews (5): Last reviewed commit: "fix portal class mismatch causing dropdo..." | Re-trigger Greptile |
| async function searchBranches(query: string) { | ||
| if (!query) { | ||
| searchResults = []; | ||
| searching = false; | ||
| return; | ||
| } | ||
| searching = true; | ||
| try { | ||
| const { branches: results } = await sdk | ||
| .forProject(page.params.region, page.params.project) | ||
| .vcs.listRepositoryBranches({ | ||
| installationId, | ||
| providerRepositoryId: repositoryId, | ||
| search: query, | ||
| queries: [Query.limit(100)] | ||
| }); | ||
| searchResults = results.map((b) => b.name); | ||
| } finally { | ||
| searching = false; | ||
| } | ||
| } |
There was a problem hiding this comment.
Stale search results from out-of-order responses
The 300 ms debounce reduces but does not eliminate the race: if request A (for "mai") is still in flight when request B (for "main") starts and finishes first, A's finally block will overwrite searchResults with the wrong data after B has already completed. searching is false at that point, so the UI silently shows stale results for the old query while searchQuery displays the newer value.
Fix by tracking a sequence counter and discarding responses that arrive out of order — increment before each call, capture the value, and skip the assignment if the counter has advanced by the time the response arrives.

What does this PR do?
(Provide a description of what this PR does.)
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)
Related PRs and Issues
(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)
Have you read the Contributing Guidelines on issues?
(Write your answer here.)