fix(merge): gate commit-append separately so declining it keeps hooks#2802
Merged
Conversation
`wt merge` bundled the project commit-append into the hook-approval batch and shadowed `verify = false` on any decline. When hooks were already approved (filtered out of the prompt), declining the lone commit-append prompt skipped every pre-merge/post-merge hook for that run. Resolve the append through the shared `approve_commit_template_append` gate instead — the same path `wt step commit`/`squash` use — so its decline drops only the append and never touches hook approval. Also: - Canonicalize the "Commands declined, …" messages: merge, removal, prune, and switch now say "… without hooks", matching the existing squash/commit wording (the operation continues; only project hooks are skipped). `wt hook` / `wt config approvals add` stay bare — they end on decline rather than continuing an operation. - Document the decline behavior in the hook Security section: declining skips every project command for that operation, including already-approved ones; saved approvals are unaffected. - Correct HookGate / PreApprovedGuidance doc comments that still described the old bundled-prompt flow. Adds a regression test (test_merge_decline_append_keeps_approved_hooks) and renames the bundling test to describe the corrected two-prompt flow. Co-Authored-By: Claude <noreply@anthropic.com>
worktrunk-bot
approved these changes
May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
wt mergebundled the project commit-append into the hook-approval batch and shadowedverify = falseon any decline. When the project hooks were already approved (and thus filtered out of the prompt), declining the lone commit-append prompt skipped every pre-merge/post-merge hook for that run — even though the user only meant to skip the append. This was flagged as a follow-up during review of #2774.The append is now resolved through the shared
approve_commit_template_appendgate — the same pathwt step commit/wt step squashalready use — so its decline drops only the append and never touches hook approval. Hooks are approved on their own; only a hook decline skips hooks.Trade-off: when both project hooks and the append are unapproved on a fresh repo, the user now sees two prompts instead of one bundled prompt. This matches the standalone commit/squash flow and is the canonical behavior; the old single-prompt bundling was what introduced the conflation. Already-approved appends still don't re-prompt.
Also in this PR
merge,removal,prune, andswitchnow printCommands declined, … without hooks, matching the wordingstep squash/step commitalready used.wt hookandwt config approvals addstay bare (they end on decline rather than continuing an operation).HookGate/PreApprovedGuidancecomments no longer describe the removed bundled-prompt flow.Testing
test_merge_decline_append_keeps_approved_hooks: with the hook pre-approved, declining the append still runs the pre-commit hook and the merge succeeds (fails on the old code, passes now).test_merge_bundles_append_into_hook_approvalrenamed totest_merge_prompts_hooks_and_append_separately, updated for the two-prompt flow.