Repository navigation
Description
What happens
In a Claude Code background session (Claude Code 2.1.310), a Workflow tool run started one agent with isolation: "worktree". Over a couple of hours that agent edited files in its own worktree with Edit and Write and committed them. Afterwards, /wt-diff in the same session didn't list the agent's worktree. The pane showed only the session's own worktree, which by then had no changes left. The work became visible only after the commit was cherry-picked into the session's own worktree.
Expected
The module's header says it notes "each directory Edit, Write or NotebookEdit wrote a file in, and each one a Bash call ran in or changed a file in, subagents' calls included", so the workflow agent's worktree should be listed.
What I checked
I ran a headless session (claude -p --plugin-dir) with a small probe plugin whose tool.call hook logs each call and appends to a $.state value, and whose turn.complete hook logs that value. The session ran one Workflow agent and one Agent-tool subagent, each with isolation: "worktree", in a scratch repository. Each agent wrote a file with Write and ran pwd with Bash.
tool.callfired for both agents' Write and Bash calls. Each carried the agent'sagentId,$.session.cwd()returned the agent's worktree, andfile_pathpointed inside it.- The values those hooks appended to
$.statewere all present when the main loop'sturn.completeread them.
So in that setup every input the module depends on arrives, and I haven't reproduced the miss outside the original session. That session differed in four ways:
- It was a daemon-backed background session, not
claude -p. - It loaded the installed marketplace copy of the plugin (5b3bf92), not
--plugin-dir. - It ran for several hours, with a compaction before the workflow started.
- The plugin's install record was updated twice during the session, to the same version.
Two things that would help pin it down
- The
tool.callhook ends in.catch(($, e, next) => next(e)), so any throw inside it drops the noted directories without a trace. Where the throw comes after the hook's ownawait next(e), it also callsnexta second time. Logging the error there would make the next occurrence diagnosable. tests/diff.test.tsxhas no case where atool.callcarries anagentId, so the subagent and workflow-agent path isn't covered.
Seen on worktrunk 5b3bf92.
This was written by Claude Code on behalf of max-sixty
Activity
worktrunk-bot commentedon Nov 2, 2026
I can't reproduce the missing worktree from the available evidence. The hook records Edit/Write paths for calls with an
agentId; your headless probe observed those calls and shared state working in that setting, but it does not establish what happened in the daemon-backed session. I don't have a Claude Code runtime here to verify a change to that path, so I'm leaving the issue open rather than proposing an untested fix.Could you run the same probe in a daemon-backed background session with the installed plugin, and share one missed Write's
agentId,file_path, and whether its directory survived into the probe'sturn.completestate? That would establish whether the difference is in event delivery/state sharing or inside/wt-diff. The module's catch currently discards its error, so an error trace from that handler during a recurrence would further narrow the latter case.Yash2031v commentedon Nov 4, 2026
I have reproduced the issue and implemented a fix for the error handling along with the missing test cases. I am raising a PR for this.
fix: let /wt-diff tool.call throws reach the hook engine; test the su…
max-sixty commentedon Nov 21, 2026
closing for now: couldn't reproduce, and since #4689 a throw in the hook gets logged as
hook skipped: threw …. will reopen with that line if it recurs.