Skip to content

fix(hooks): an empty command list no longer leaves a bare heading - #3641

Merged
max-sixty merged 1 commit into
mainfrom
hook-preview-shared-context
Jul 29, 2026
Merged

fix(hooks): an empty command list no longer leaves a bare heading#3641
max-sixty merged 1 commit into
mainfrom
hook-preview-shared-context

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

wt hook show decided whether a section had printed anything from whether the config held an entry for each hook type, not from whether any command was rendered. A hook type declared with an empty command list has an entry but no commands, so the section printed its heading and then stopped:

$ cat .config/wt.toml
post-switch = []

$ wt hook show
PROJECT HOOKS @ /path/.config/wt.toml

Both sections carried it, since the loop and the (none configured) fallback were duplicated in render_user_hooks and render_project_hooks. render_hook_commands now reports whether it wrote any rows, and the loop plus fallback live once in render_hook_section, which both callers delegate to. The flag means "something was printed", which is what the (none configured) line claims.

The execution path was already correct: an empty list announces nothing, and the JSON output omits it. Verified against the built binary across four cases (project-only empty, user-only empty, an empty list alongside a real hook, and a filter naming the empty type), and pinned by test_hook_show_empty_command_lists, which covers both the user and project halves. Reverting the flag to its old meaning fails the test on both.

Also corrects a docstring in the same file that still described the preview's pre-#3638 behavior ("shows a vars.* template raw"), the same drift #3639 fixed for wt config alias dry-run.

This was written by Claude Code on behalf of max

`wt hook show` decided whether a section had printed anything from whether
the config held an entry for each hook type, not from whether any command
was rendered. A hook type declared with an empty command list has an entry
but no commands, so the section printed its heading and then stopped:

    $ cat .config/wt.toml
    post-switch = []

    $ wt hook show
    PROJECT HOOKS @ /path/.config/wt.toml

Both sections carried it, since the loop and the `(none configured)`
fallback were duplicated in `render_user_hooks` and `render_project_hooks`.
`render_hook_commands` now reports whether it wrote any rows, and the loop
plus fallback live once in `render_hook_section`, which both callers
delegate to. The flag means "something was printed", which is what the
`(none configured)` line claims.

The execution path was already correct: an empty list announces nothing,
and the JSON output omits it.

Also corrects a docstring in the same file that still described the
preview's pre-#3638 behavior ("shows a `vars.*` template raw").

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@max-sixty
max-sixty merged commit 0e74548 into main Jul 29, 2026
39 checks passed
@max-sixty
max-sixty deleted the hook-preview-shared-context branch July 29, 2026 01:13
max-sixty added a commit that referenced this pull request Jul 29, 2026
Two commits landed on `main` while #3640's CI ran, so they ship in
0.70.0 but weren't in its changelog. The release's drift check caught
them before the tag.

- **#3641** — a user-facing fix: `wt hook show` printed a section
heading and nothing else for a hook type declared with an empty command
list. Added as its own Fixed entry.
- **#3639** — help-text only, no behavior change, correcting `wt config
alias dry-run`'s description of the `vars.*` preview. Folded into the
existing hook-previews bullet, since it's the same feature's
documentation catching up rather than a separate change.

No version change; `v0.70.0` is tagged after this lands so the tag
covers both.

> _This was written by Claude Code on behalf of Maximilian_
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