Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/worktrunk/hooks/hooks.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"hooks": [
{
"type": "command",
"command": "bash -c 'p=$(jq -er .worktree_path) || exit 1; cd \"${CLAUDE_PROJECT_DIR:-.}\" || exit 1; [ -e \"$p\" ] || exit 0; bash \"$CLAUDE_PLUGIN_ROOT/hooks/wt.sh\" remove --foreground \"$p\"'"
"command": "bash -c 'p=$(jq -er .worktree_path) || exit 1; [ -e \"$p\" ] || exit 0; bash \"$CLAUDE_PLUGIN_ROOT/hooks/wt.sh\" -C \"$p\" remove --foreground \"$p\"'"
}
]
}
Expand Down
17 changes: 17 additions & 0 deletions tests/integration_tests/config_show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3882,6 +3882,23 @@ fn test_plugin_layout_is_consolidated() {
hooks.json:\n{hooks}"
);

// The WorktreeRemove hook must resolve against the worktree path Claude
// Code hands it, not the session's project dir. The `claude agents` view
// spans every repo with a background session and is often launched from a
// parent directory that merely contains them, so `CLAUDE_PROJECT_DIR` names
// the wrong repo or none at all, `wt remove <path>` dies with `fatal: not a
// git repository`, and the session row is left undeletable (#3754, after
// the #3489 anchor proved insufficient). `-C "$p"` is layout-independent: a
// linked worktree carries a `.git` file pointing at its owning repository.
assert!(
worktree_remove_cmd.contains("-C \"$p\"")
&& !worktree_remove_cmd.contains("CLAUDE_PROJECT_DIR"),
"WorktreeRemove hook must resolve via -C \"$p\" (the worktree path Claude Code \
handed it), never CLAUDE_PROJECT_DIR — the agents view is multi-repo, so no \
single project dir is correct for every session (#3754). \
command:\n{worktree_remove_cmd}"
);

// The WorktreeCreate hook pipes `wt … --format=json | jq -er .path`. Without
// `set -o pipefail` the pipeline's exit status is jq's, and `jq -er .path`
// on the empty stdout of a failed `wt` exits 0 on jq 1.6 — so a `wt` failure
Expand Down
Loading