[BUG] Desktop diff panel silently shows the base repo when a WorktreeCreate-hook worktree is not auto-trusted

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

Environment

  • Claude Desktop 1.21459.3 (Windows 11), Claude Code 2.1.209
  • Repo-committed WorktreeCreate/WorktreeRemove hooks in .claude/settings.json that delegate worktree creation to worktrunk, printing a path outside the base repo (e.g. D:\work\worktrees\<repo>.<branch>)

Bug

Since Desktop stopped auto-trusting worktrees created by a WorktreeCreate hook that lives in a committable settings tier, the session diff panel silently shows the diff of the base repository instead of the session's worktree. Every agent edit shows as "no changes to show", with no indication anything is wrong.

At worktree creation, Desktop logs:

[WorktreeHooks] WorktreeCreate hook created worktree at D:\work\worktrees\<repo>.<branch>
Skipped auto-trust for hook-based worktree at D:\work\worktrees\<repo>.<branch> — hook came from a repo-committed settings tier
Skipped per-machine config overlay for hook-based worktree "<branch>" — hook came from a repo-committed settings tier

The session itself runs in the worktree correctly. But because the worktree path is untrusted, getGitInfo/getGitDiff return null for it, and the diff panel falls back to the original project directory. When the panel is opened, the log shows:

LocalSessions.getGitDiff: cwd=D:\work\<base-repo>, base=main, head=<tree>, patches=false → 0 files (0 with patch)

cwd is the base repo, not the worktree the session is running in.

Repro / verification

  1. Repo with a WorktreeCreate hook in .claude/settings.json that creates a worktree outside <repo>/.claude/worktrees and prints its path.
  2. Start a Desktop agent session (worktree is created and the session runs in it).
  3. Have the agent edit a file in the worktree → diff panel says "no changes to show".
  4. Edit a file in the base repo working tree → that edit appears in the session's diff panel, confirming the panel is diffing the wrong directory.

Expected

Either of:

  • Auto-trust hook-created worktrees when the base repo is already trusted — the hook only ran because the user accepted the base repo's trust dialog, so refusing to trust the resulting worktree protects little while breaking the diff view; or
  • If the worktree stays untrusted, the diff panel should say so (or show nothing) instead of silently diffing the base repository — the silent wrong-directory fallback made this very hard to debug.

Workaround

Our hook now mirrors Desktop's own auto-trust write before printing the path: set projects[<worktreePath>].hasTrustDialogAccepted = true in ~/.claude.json (under both the realpath and literal path). This restores the diff view, but it depends on Desktop internals.

Related papercut

When a WorktreeRemove hook fails partway, the worktree directory can be left with its .git file already deleted — a non-git husk directory that later sessions can resume into (WorktreeRemove hook did not remove worktree, left at: <path>). A failed hook removal should leave the worktree intact or remove it fully.

View original on GitHub ↗