worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

wt remove implicitly switches but does not call the post-switch hook

Open mjakl opened this issue 8 months ago • 1 comments

I've taken over the idea of updating the tmux window name when switching the worktrees, this works fine in most cases, but wt remove does not seem to work in this case.

Repro:

wt switch --create test
wt remove test

post-switch is not executed when coming back to our initial worktree/branch.

Observed in Worktrunk 0.29

mjakl avatar Mar 11 '26 20:03 mjakl

Thanks for reporting this! I was able to reproduce the issue and identified the root cause: when removing the current worktree, spawn_hooks_after_remove creates a new Repository at the primary worktree but load_project_config() looks for .config/wt.toml using the process cwd (the removed worktree), so no project hooks are found.

I've opened #1452 with a fix. A maintainer will review it shortly.

worktrunk-bot avatar Mar 11 '26 21:03 worktrunk-bot