Skip to content

refactor(hooks): make HookAnnouncer the single entry point - #2484

Merged
max-sixty merged 2 commits into
mainfrom
hooks-retire-spawn-background
Apr 30, 2026
Merged

max-sixty merged 2 commits into
mainfrom
hooks-retire-spawn-background

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Builds on #2477 and #2482. Drops the Option<&mut HookAnnouncer<'_>> plumbing through commit.rs::commit, step_commands::handle_squash, output/handlers.rs::handle_remove_output (and its four sub-handlers), and the multi-target prune loop in step_commands::step_prune. Each function now takes &mut HookAnnouncer<'_> unconditionally — the if/else around "share with caller's announcer or self-announce" is gone. Standalone callers (wt commit, wt step squash, wt remove, wt step prune, wt switch picker post-remove) construct a local announcer and flush right after; multi-phase callers (wt merge) keep their existing single-announcer-per-command pattern.

run_hooks_background is now a module-private helper of HookAnnouncer::flush (was pub(crate)). hook_commands::run_post_hook also routes through HookAnnouncer, so flush is the only path that reaches the announce/spawn primitive. RemovedWorktreeOutputContext loses its now-redundant show_branch_in_hooks field — callers configure the announcer directly when constructing it.

No behavior change: combined announce lines, log paths, show_branch semantics for batch contexts (prune, multi-target remove), and exit codes are all unchanged. Existing snapshots and the full integration suite (3399 tests) pass; cargo run -- hook pre-merge --yes is green.

This was written by Claude Code on behalf of @max-sixty

Drops the `Option<&mut HookAnnouncer<'_>>` plumbing through
`commit.rs::commit`, `step_commands::handle_squash`,
`output/handlers.rs::handle_remove_output` and its sub-handlers, and the
multi-target prune loop in `step_commands::step_prune`. Each function
now takes `&mut HookAnnouncer<'_>` unconditionally; standalone callers
(`wt commit`, `wt step squash`, `wt remove`, `wt step prune`,
`wt switch` picker post-remove) construct a local announcer and flush
right after, while multi-phase callers (`wt merge`) keep their existing
single-announcer-per-command pattern.

`run_hooks_background` is now a module-private helper of
`HookAnnouncer::flush` (was `pub(crate)`). `hook_commands::run_post_hook`
also routes through `HookAnnouncer` so flush is the only path that
reaches the announce/spawn primitive. `RemovedWorktreeOutputContext`
loses its now-redundant `show_branch_in_hooks` field — callers configure
the announcer directly.

No behavior change: combined announce lines, log paths, `show_branch`
semantics, and exit codes are unchanged. Existing snapshots and the full
integration suite (3399 tests) pass.

Co-Authored-By: Claude <[email protected]>
…ckground

# Conflicts:
#	src/commands/commit.rs
#	src/commands/step_commands.rs
#	src/main.rs
@max-sixty
max-sixty merged commit 7d354c7 into main Apr 30, 2026
27 checks passed
@max-sixty
max-sixty deleted the hooks-retire-spawn-background branch April 30, 2026 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants