Worktree project badge always shows main worktree's name (e.g. "core") for linked worktrees

Status Open
Reported on v2.1.204
Maintainer reply None cached
Activity 0 comments · opened Jul 21, 2026

Description

When using git worktree to check out multiple worktrees of the same repo, the
project/repo badge in the session list/header shows the main worktree's
directory name for every worktree — not the worktree actually open.

Repro

git worktree list
/path/to/core       (main worktree)
/path/to/pr         (linked worktree)
/path/to/scripting  (linked worktree)

Opening a session in pr or scripting still shows a "core" badge.

Root cause (verified locally)

$ cd core && git rev-parse --show-toplevel --git-common-dir
core
.git
$ cd pr && git rev-parse --show-toplevel --git-common-dir
pr
/path/to/core/.git

For linked worktrees, --git-common-dir always resolves back into the main
worktree's .git. The badge appears to derive the "repo name" from the common
dir's parent rather than from --show-toplevel, so it always resolves to the
main worktree's directory name regardless of which worktree is actually open.

Note: this isn't a data problem — ~/.claude.json's per-project entries are
correctly keyed by full worktree path, and session cwd metadata is accurate.
It's purely the badge-rendering logic picking the wrong git path.

Expected

Badge should reflect the current worktree (--show-toplevel), not the shared
common git dir.

Environment

  • claude version: 2.1.204
  • macOS Darwin 25.5.0

View original on GitHub ↗