Skip to content

fix(vcs): prefer fresh refs over cached on branch-list reload - #2986

Closed
denniskasper wants to merge 1 commit into
pingdotgg:mainfrom
denniskasper:fix/vcs-ref-stale-current-badge
Closed

fix(vcs): prefer fresh refs over cached on branch-list reload#2986
denniskasper wants to merge 1 commit into
pingdotgg:mainfrom
denniskasper:fix/vcs-ref-stale-current-badge

Conversation

@denniskasper

@denniskasper denniskasper commented Jun 7, 2026

Copy link
Copy Markdown

What Changed

In the client ref cache, the preserveLoadedRefs merge passed the previously-cached refs last, so mergeRefs let 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: true flag (the branch you had checked out before an external git 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

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes (N/A — no UI change)
  • I included a video for animation/interaction changes (N/A)

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 listRefs response with a larger paginated cache.

In vcsRefState.ts, the preserveLoadedRefs path now calls mergeRefs(current.refs, result.refs) instead of the reverse. mergeRefs gives the second list priority on name collisions, so server refs (including the single true current branch) 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 current flags in branch list by preferring fresh refs over cached on reload

When preserveLoadedRefs is true and the cached ref list is larger than the fresh result, mergeRefs in vcsRefState.ts was called with cached refs taking priority over fresh ones. This caused stale current: true flags 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.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5cf445f3-929c-4c4b-bfa9-0c716c2384a5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Jun 7, 2026
@denniskasper
denniskasper marked this pull request as draft June 7, 2026 13:44
@denniskasper
denniskasper marked this pull request as ready for review June 7, 2026 13:47
@macroscopeapp

macroscopeapp Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

This is a straightforward bug fix that swaps argument order in mergeRefs to ensure fresh server refs overwrite stale cached ones, preventing duplicate 'current' branch badges. The fix is minimal, well-documented, and has clear intent.

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>
@juliusmarminge
juliusmarminge force-pushed the fix/vcs-ref-stale-current-badge branch from 482f6a2 to 2fc41ec Compare June 16, 2026 17:31
@t3dotgg

t3dotgg commented Aug 27, 2026

Copy link
Copy Markdown
Member

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 main, so there is no remaining change here that we can merge.

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.

@t3dotgg t3dotgg closed this Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants