claude-code - 💡(How to fix) Fix UI diff/file view stays pinned to original harness worktree; doesn't follow EnterWorktree branch switch

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…

The session UI (file tree / diff / changes view) is permanently pinned to the harness-assigned worktree state it had at session start. When the session subsequently moves to a different worktree or branch — e.g. via the EnterWorktree tool — the UI does not follow. All work the agent does on the new branch becomes invisible to the user, even though the files physically exist and commits are made. This is a major pain: the user cannot see what the agent produced.

Error Message

  1. EnterWorktree should hard-error (not silently create a parallel branch) when the session is already inside a harness-managed worktree.

Root Cause

The session UI (file tree / diff / changes view) is permanently pinned to the harness-assigned worktree state it had at session start. When the session subsequently moves to a different worktree or branch — e.g. via the EnterWorktree tool — the UI does not follow. All work the agent does on the new branch becomes invisible to the user, even though the files physically exist and commits are made. This is a major pain: the user cannot see what the agent produced.

RAW_BUFFERClick to expand / collapse

Summary

The session UI (file tree / diff / changes view) is permanently pinned to the harness-assigned worktree state it had at session start. When the session subsequently moves to a different worktree or branch — e.g. via the EnterWorktree tool — the UI does not follow. All work the agent does on the new branch becomes invisible to the user, even though the files physically exist and commits are made. This is a major pain: the user cannot see what the agent produced.

Repro

  1. Start a session that the harness places in a managed worktree (e.g. .claude/worktrees/<name>).
  2. From within that session, invoke EnterWorktree (which checks out a new branch worktree-<name> in place / switches the session's working dir+branch).
  3. Have the agent create/commit files on the new branch.

Expected

The UI updates to reflect the session's current worktree/branch, showing the new files and diff.

Actual

The UI stays stuck on the original harness worktree view. The new branch's changes (committed and uncommitted) are not shown — the work appears to vanish from the user's perspective, despite being present on disk and in git.

Notes / contributing factor

EnterWorktree's own docs say it must not be called when already in a worktree session. But the agent isn't reliably told it is already in a harness worktree at session start (git status surfaced branch: main while the working dir was already the worktree), so it's easy to call EnterWorktree and silently desync the UI. Two improvements:

  1. The UI should follow the session's active worktree/branch (or at least surface that they diverged).
  2. EnterWorktree should hard-error (not silently create a parallel branch) when the session is already inside a harness-managed worktree.

Environment

  • Claude Code: 2.1.152
  • OS: macOS (Darwin 25.5.0)

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