claude-code - 💡(How to fix) Fix Session branch chip is stale — shows branch from session start, not current HEAD [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52705Fetched 2026-04-24 10:41:53
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×4

The session header chip in Claude Code (Cowork sessions specifically) shows the branch the session was bound to at creation time, and does not refresh when the branch is renamed, deleted, or when HEAD moves to a different branch during the session.

Root Cause

Minor — mostly cosmetic confusion. Git CLI operations (commit / push / merge) work correctly because they ignore the chip. But the UI sows doubt about where work is actually landing, and made me second-guess whether my cleanup had succeeded.

Fix Action

Workaround

Starting a new Claude Code session in the current worktree rebinds the chip correctly.

RAW_BUFFERClick to expand / collapse

Summary

The session header chip in Claude Code (Cowork sessions specifically) shows the branch the session was bound to at creation time, and does not refresh when the branch is renamed, deleted, or when HEAD moves to a different branch during the session.

Environment

  • Claude Code (Cowork session, via Claude Desktop / web UI)
  • Host repo: standard git repo, single or multiple worktrees

Steps to reproduce

  1. Start a Claude Code / Cowork session inside a worktree currently on branch feature-xyz.
  2. During the session, delete feature-xyz locally and on the remote (e.g., after merging it into main and cleaning up).
  3. Check out a different branch — develop, main, etc. — and continue work.
  4. Look at the session header chip (the main ← feature-xyz style chip).

Expected

Chip reflects the current HEAD. For example, after checking out develop following a branch delete, the chip should show develop (or main ← develop if it also tracks a target branch).

Actual

Chip still shows the original feature-xyz branch from session creation time, even though:

  • The branch no longer exists locally (git branch doesn't list it)
  • The branch no longer exists on remote (git ls-remote doesn't list it)
  • Git itself has no trace of it (checked for-each-ref, packed-refs, reflog, .git/info/refs)

Impact

Minor — mostly cosmetic confusion. Git CLI operations (commit / push / merge) work correctly because they ignore the chip. But the UI sows doubt about where work is actually landing, and made me second-guess whether my cleanup had succeeded.

Suggested fix

Poll git symbolic-ref --short HEAD (or git branch --show-current) on a short interval, or subscribe to file-system events on .git/HEAD, and update the chip. Fall back to the short commit SHA when in detached HEAD. VS Code's source-control view does this.

Workaround

Starting a new Claude Code session in the current worktree rebinds the chip correctly.

extent analysis

TL;DR

Update the session header chip by polling git symbolic-ref --short HEAD or subscribing to file-system events on .git/HEAD to reflect the current branch.

Guidance

  • Implement a periodic poll of git symbolic-ref --short HEAD to update the session header chip with the current branch.
  • Alternatively, subscribe to file-system events on .git/HEAD to update the chip when the branch changes.
  • When in a detached HEAD state, fall back to displaying the short commit SHA.
  • Consider using a similar approach to VS Code's source-control view, which already implements this functionality.

Example

git symbolic-ref --short HEAD

This command can be used to get the current branch, which can then be used to update the session header chip.

Notes

The suggested fix may require modifications to the Claude Code application to implement the polling or event subscription mechanism.

Recommendation

Apply workaround: Starting a new Claude Code session in the current worktree rebinds the chip correctly, as this provides a simple and effective solution to the issue, even if it requires manual intervention.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING