[BUG] PR shortcut indicator shows ghost branch from deleted worktree, persists across full restart (Windows)

Resolved 💬 3 comments Opened Apr 25, 2026 by Nasty-Fury Closed Apr 28, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report
  • [x] I am using the latest version of Claude Code (2.1.81)

What's Wrong?

Summary
After a Claude Code-managed git worktree is deleted (via the system's worktree teardown — confirmed by the SessionStart:resume hook message "The git worktree at <path> was deleted. This session now operates on the origin repository at <origin>"), the TUI's PR shortcut indicator continues to show the deleted worktree's branch name as if it were the current branch:

master ← claude/practical-austin   +1 -0   [Create PR]

The branch does not exist anywhere on disk.

Environment

  • Claude Code version: 2.1.81
  • OS: Windows 11
  • Shell: PowerShell 5.1 (also reproduced via Git Bash for git ops)
  • Repo: standard single-worktree git repo, branch master

Reproduction

  1. A previous Claude Code agent dispatch created an isolated worktree (claude/<adjective-name> branch + .claude/worktrees/<name>/ directory).
  2. The worktree got torn down externally (directory removed, branch deleted, no .git/worktrees/ metadata leftover).
  3. On next claude --resume, the hook fires:

> The git worktree at D:\Proyectos\BuildCalc Pro\.claude\worktrees\practical-austin was deleted. This session now operates on the origin repository at D:\Proyectos\BuildCalc Pro.

  1. Despite operating on origin (verified by pwd, git branch --show-current, both reporting master), the TUI PR shortcut indicator renders master ← claude/practical-austin +1 -0 [Create PR].
  2. Survives Ctrl+C + relaunch and full process kill + relaunch from origin path.

Expected behavior
After worktree teardown, the PR shortcut indicator should either:

  • Re-detect git state from on-disk .git/HEAD and show the actual current branch (master), or
  • Hide entirely if no comparison branch is detectable.

Actual behavior
The indicator persists indefinitely with the now-non-existent branch. Clicking "Create PR" would presumably attempt to operate on a branch that doesn't exist (not tested to avoid pollution).

Verification that the branch is gone

  • git symbolic-ref HEADrefs/heads/master
  • cat .git/HEADref: refs/heads/master
  • git show-ref | grep practical-austin → empty
  • ls .git/refs/heads/claude/ → only other adjective-name branches, no practical-austin
  • .git/worktrees/ directory does not exist (no orphan worktree metadata)
  • .git/packed-refs does not contain it
  • git reflog --all | grep practical-austin → empty
  • Worktree directory .claude/worktrees/practical-austin/ has been deleted
  • Removed the stale ~/.claude.json project entry for the worktree path → no effect on the indicator
  • grep -rln "practical-austin" ~/.claude/ returns only backups/.claude.json.backup.* and historical session JSONLs (no live config files)

Diagnostic hypothesis
The active session sub-directory contains only the tool-results/ hook output (no session metadata yet). The historical worktree session JSONL at ~/.claude/projects/D--Proyectos-BuildCalc-Pro--claude-worktrees-<name>/<session-id>.jsonl still has "gitBranch":"claude/<name>" baked into every entry. Plausible cause: TUI reads cached gitBranch from a session-metadata index (e.g., sessions-index.json referenced in #25032) rather than from live git symbolic-ref HEAD.

Workaround tried
None confirmed. Starting a brand-new session (no --resume/-c) is likely the only escape hatch but loses conversation context.

Related

  • #25032 (sessions-index.json staleness)
  • #48270 (claude --resume picks stale branch — different angle, same area)
  • #26725 (stale worktrees never cleaned up)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗