You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
picker alt-r removal skips pre-remove and post-remove hooks #1704
Worktree removal via alt-r in the picker (wt switch TUI) skips pre-remove and post-remove hooks entirely.
The code at src/commands/picker/mod.rs:70 explicitly notes:
No output, no hooks, no cd directives — we're inside skim's TUI.
Impact
pre-remove hooks intended as safety checks (e.g., preventing removal of worktrees with uncommitted work) are bypassed
post-remove cleanup hooks (e.g., stopping services, cleaning up ports) never run
Context
Running hooks inside skim's TUI event loop is architecturally constrained — the main thread blocks skim, and hooks may produce output or require user interaction. However:
pre-remove hooks could run before signaling skim to reload (they're blocking by design)
post-remove hooks could be spawned in the background thread alongside the git operations
Suggestion
At minimum, run pre-remove hooks before the removal. If the hook fails, skip the removal and show a brief indicator. For post-remove, spawn in the background thread after execute_removal.
If hooks can't be supported, document this limitation in wt switch --help and the picker legend, not just as an inline code comment.
The picker's background thread now runs pre-remove hooks (silently, with suppressed output) before execute_removal, and spawns post-remove hooks via spawn_background_hooks after. Pre-remove hook failure aborts the removal. Template variables match the normal wt remove flow.
Added run_hooks_silently() for TUI contexts where stderr output would corrupt skim's display — it runs each hook command, checks exit codes, and bails on first failure.
Activity
max-sixty commentedon Mar 24, 2026
@worktrunk-bot fix
fix: run pre-remove and post-remove hooks during picker alt-r removal
worktrunk-bot commentedon Mar 24, 2026
Fix in #1710.
The picker's background thread now runs pre-remove hooks (silently, with suppressed output) before
execute_removal, and spawns post-remove hooks viaspawn_background_hooksafter. Pre-remove hook failure aborts the removal. Template variables match the normalwt removeflow.Added
run_hooks_silently()for TUI contexts where stderr output would corrupt skim's display — it runs each hook command, checks exit codes, and bails on first failure.