Follow subagents into worktrees without mis-attributing their work

Commit

peyton-alt1w ago

Hooks follow the agent's working directory on every event, so a turn or task can start in one worktree and end in another. Make that complete:

  • End hooks find the pre-prompt and pre-task baselines in the worktree the turn started in (SessionState.TurnWorktreePath) or the session's home, consume them there and carry the turn's prompt.txt. A baseline scanned in another tree cannot tell this tree's pre-existing untracked files from new ones, so new-file detection falls back to the transcript instead of claiming them.
  • MutateSessionState stamps PendingContentWorktree whenever a mutation adds files or task records, so the re-home guard no longer pins a session to a home that holds none of its pending work; shadow steps still always do.
  • A turn end that saved no step (a subagent-only turn) re-homes too.
  • Only turn boundaries confirm that the parent session itself moved; task and tool-use events follow for their own capture.

Co-Authored-By: Claude Opus 5.5 (1M context) noreply@anthropic.com Entire-Checkpoint: 01M38P78B7JZDR8G45X00K10C0

Checkpoints

Session Review and Smoke Testing Fixes

CodexGPT-5.6-sol
View session
Checkpoint 1

Track Subagent Work Across Worktrees

Claude CodeOpus 5.5[1m]
View session
Checkpoint 1