claude-code - 💡(How to fix) Fix Agents View: directory grouping collapses git worktrees under canonical repo path [1 comments, 2 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#58723Fetched 2026-05-14 03:41:08
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Assignees
Timeline (top)
labeled ×4assigned ×1commented ×1

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.

Root Cause

  • #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)

Fix Action

Fix / Workaround

This matters more as users dispatch more background sessions: with 5+ sessions in flight, peeking each one to find its CWD is real friction.

Code Example

~/my-project
 ✻ session-a              ...                                   13m
 ✻ session-b              running from worktree 3                9m
 ✻ session-c              ...                                    7m
 ✻ session-d              ...                                    1m
 ✻ session-e              ...                                   38s
RAW_BUFFERClick to expand / collapse

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

  1. Set up a repo with multiple worktrees, e.g.:
    • ~/my-project (main clone)
    • ~/my-project-worktree1
    • ~/my-project-worktree2
  2. Start a background session in each worktree (e.g. claude --bg "..." from each directory).
  3. Open claude agents and press Ctrl+S to 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 via git 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)

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