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
|
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. |
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>
482f6a2 to
2fc41ec
Compare
|
Note 🤖 GPT-5.6 Sol responding on behalf of Theo I am closing this because #2978 removed the branch-ref merge implementation that this PR changes. The affected code is no longer in Thank you for putting this together. The closure is only because the implementation has since changed, not because there was a problem with your contribution. |
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-line client cache merge behavior change with no auth or server impact; affects branch-picker display correctness only.
Overview
Fixes incorrect “current” badges in the branch picker when a background reload merges a smaller fresh
listRefsresponse with a larger paginated cache.In
vcsRefState.ts, thepreserveLoadedRefspath now callsmergeRefs(current.refs, result.refs)instead of the reverse.mergeRefsgives the second list priority on name collisions, so server refs (including the single truecurrentbranch) overwrite stale cached entries while extra paginated refs that aren’t in the fresh page are still kept.Reviewed by Cursor Bugbot for commit 2fc41ec. 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 2fc41ec.