Agents View: directory grouping collapses git worktrees under canonical repo path
Summary
When grouping Agents View by directory (Ctrl+S), background sessions running in different git worktrees of the same repository are all collapsed under a single directory header — the canonical repo path — making it impossible to visually distinguish which session is running in which worktree.
Repro
- Set up a repo with multiple worktrees, e.g.:
~/my-project(main clone)~/my-project-worktree1~/my-project-worktree2
- Start a background session in each worktree (e.g.
claude --bg "..."from each directory). - Open
claude agentsand pressCtrl+Sto group by directory.
Expected: One directory group per worktree path.
Actual: A single group header ~/my-project containing all sessions from all three worktrees. The actual working directory is only visible via Space (peek) or Enter (attach).
Example (real output, paths anonymized):
~/my-project
✻ session-a ... 13m
✻ session-b running from worktree 3 9m
✻ session-c ... 7m
✻ session-d ... 1m
✻ session-e ... 38s
All five sessions were started from different worktrees but collapse under one header.
Motivation
Git worktrees are a first-class workflow for users running multiple parallel streams of work on the same repo (isolated branches, isolated dev environments, isolated docker projects/ports). Collapsing them in Agents View defeats a major reason for using worktrees in the first place — you lose the at-a-glance map of "which stream of work is this session part of?"
This matters more as users dispatch more background sessions: with 5+ sessions in flight, peeking each one to find its CWD is real friction.
Suggested behavior
Treat each worktree path as its own directory group when grouping by directory. Two options for the header label:
- Full path:
~/my-project-worktree1(most informative, longer) - Repo + worktree suffix:
my-project (worktree1)(compact, requires detecting worktree relationship viagit worktree list)
A Ctrl+S-style toggle between "collapse worktrees" and "separate worktrees" would also work if there's a use case for the current behavior.
Related
- #58597 — Agents View: configurable git worktree behavior for Agent Workers (adjacent: about creating worktrees during edits, not displaying existing ones)
- #28248 — Permission scoping shows main worktree path instead of current worktree path (same root cause: worktree-aware path resolution missing in UI)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗