Skip to content

picker alt-r removal skips pre-remove and post-remove hooks #1704

Closed

Description

@worktrunk-bot

Bug

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:

  1. pre-remove hooks could run before signaling skim to reload (they're blocking by design)
  2. 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.

Activity

  1. added
    bug
    on Mar 24, 2026
  2. max-sixty commented on Mar 24, 2026

    @max-sixty
    Owner
  3. added a commit that references this issue on Mar 24, 2026
    0f04db3
  4. worktrunk-bot commented on Mar 24, 2026

    @worktrunk-bot
    CollaboratorAuthor

    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 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions