Skip to content

fix(hook show): merge per-project user hooks into display - #2844

Merged
max-sixty merged 1 commit into
mainfrom
fix/hook-show-projects-merge
May 21, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/hook-show-projects-merge

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Summary

wt hook show rendered only the global user-hooks section, so hooks defined under [projects."<id>"] in the user config were invisible — even though they actually ran when the hook fired. Both the text path (render_user_hooks) and the JSON path (emit_hook_show_json) now use the same UserConfig::hooks(project_id) accessor that the execution path at hook_commands.rs:249 uses, so display matches what runs.

Reported by @airtonix in #2826 after the project-identifier fix in #2827 landed: per-project user hooks keyed by the right identifier still didn't appear in wt hook show. Verified locally before and after — with the bug, only zellij (global) appears; with the fix, both zellij (global) and mise (per-project) appear, matching the announcement line at execution.

Test plan

  • New test test_hook_show_merges_user_project_hooks — fixture writes a global post-start plus a [projects.'<id>'].post-start, asserts both appear under USER HOOKS in the snapshot. Test fails on main (only global-hook appears), passes with the fix.
  • cargo test --test integration hook_show — 18/18 passing (no regressions in existing snapshots).
  • cargo clippy --all-targets -- -D warnings — clean.
  • cargo fmt --all -- --check — clean.
  • Manual repro in a temp repo: wt hook show lists both the global and per-project user hooks, and the JSON output (--format=json) does the same.

`wt hook show` rendered only the global user-hooks section, so hooks
under `[projects."<id>"]` in the user config were invisible even though
the execution path merges them in. Both the text and JSON renderers now
call the same `UserConfig::hooks(project_id)` accessor that
`handle_hook` uses, so display matches what actually runs.

Reported in #2826.
@max-sixty
max-sixty enabled auto-merge (squash) May 21, 2026 01:28

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix looks right — both display paths (render_user_hooks and emit_hook_show_json) now route through UserConfig::hooks(project_id), matching the run path at src/commands/hook_commands.rs:249. The merge semantics in HooksConfig::merge_with also fold deprecated post_create into pre_start, so the deprecation handling the old &config.hooks + HooksConfig::get chain relied on is preserved.

codecov/patch is failing at 90% (9/10), with the single miss on line 430 ()?;) — the closing line of the reformatted multi-line render_user_hooks(...)?; call. The substantive new lines (function args, let user_hooks = config.hooks(project_id)) are all hit. This looks like a multi-line ? reformat artifact rather than a real coverage gap, but per CLAUDE.md it needs explicit approval before merging.

The new snapshot test covers the text path well. The JSON-path branch (emit_hook_show_json at line 502) is exercised by test_hook_show_json (which passes project_id even with no per-project hooks), but no test asserts that [projects.'<id>'.post-start] actually appears in JSON output — a regression there wouldn't be caught. Optional: extend test_hook_show_json with a per-project user hook and assert it appears with source: "user".

@max-sixty
max-sixty merged commit 2b0077b into main May 21, 2026
34 of 35 checks passed
@max-sixty
max-sixty deleted the fix/hook-show-projects-merge branch May 21, 2026 01:35
max-sixty added a commit that referenced this pull request May 21, 2026
The merge of #2844 ("merge per-project user hooks into display") brought
in a new test whose config uses `[post-start]` — canonical on main, a
deprecated alias on this branch. Switch it to `post-create` (the test
exercises the per-project merge, not deprecation) and regenerate the
snapshot, which now shows both hooks under `post-create`.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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