fix(vcs): prefer fresh refs over cached on branch-list reload#2986
fix(vcs): prefer fresh refs over cached on branch-list reload#2986denniskasper wants to merge 1 commit into
Conversation
When the ref list reloads with `preserveLoadedRefs`, the merge applied the previously-cached refs last, so they overwrote the fresh server entries for overlapping branch names. A stale `current: true` (the branch checked out before an external switch) then survived, leaving two refs both badged "current" in the picker. Pass the fresh refs last so server truth wins while still retaining previously paginated entries. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
ApprovabilityVerdict: Approved This is a straightforward bug fix that swaps argument order in You can customize Macroscope's approvability policy. Learn more. |
What Changed
In the client ref cache, the
preserveLoadedRefsmerge passed the previously-cached refs last, somergeRefslet them overwrite the fresh server entries for overlapping branch names. Reordered the arguments so fresh server refs win, while still retaining previously-paginated entries that aren't in the smaller fresh result.Why
A stale
current: trueflag (the branch you had checked out before an externalgit switch) survived the reload, so the branch picker showed two refs both badged "current". Git only ever has one current branch, so this is purely a client merge defect. With the fix, server truth always wins for a given branch name.Checklist
Note
Low Risk
Single merge-argument reorder in client ref caching; no server, auth, or persistence changes.
Overview
Fixes a client-side ref cache merge bug when reloading the branch list with
preserveLoadedRefs(e.g. background refresh after pagination).Previously, cached refs were passed last into
mergeRefs, so they overwrote fresh server data for the same branch name. A stalecurrent: trueon the old HEAD could survive an externalgit switch, so the branch picker showed two refs both marked current.The merge order is flipped so server refs win on name collisions, while still keeping extra paginated entries from cache that are not in the smaller fresh response.
Reviewed by Cursor Bugbot for commit 482f6a2. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix stale
currentflags in branch list by preferring fresh refs over cached on reloadWhen
preserveLoadedRefsis true and the cached ref list is larger than the fresh result,mergeRefsin vcsRefState.ts was called with cached refs taking priority over fresh ones. This caused stalecurrent: trueflags and duplicate 'current' badges for overlapping branch names. The merge argument order is swapped so fresh server refs always win for name collisions.Macroscope summarized 482f6a2.