Skip to content

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

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

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 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 stale current: true on the old HEAD could survive an external git 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 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 482f6a2.

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>
@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: 136b5dff-ad9b-46ae-844a-c17ddd18130d

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.

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.

1 participant