UI diff/file view stays pinned to original harness worktree; doesn't follow EnterWorktree branch switch
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
- Start a session that the harness places in a managed worktree (e.g.
.claude/worktrees/<name>). - From within that session, invoke
EnterWorktree(which checks out a new branchworktree-<name>in place / switches the session's working dir+branch). - 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:
- The UI should follow the session's active worktree/branch (or at least surface that they diverged).
EnterWorktreeshould 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)
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗