Skip to content

Name the template owner in the -v variables block - #3495

Merged
max-sixty merged 1 commit into
mainfrom
template-var-labels
Jul 17, 2026
Merged

Name the template owner in the -v variables block#3495
max-sixty merged 1 commit into
mainfrom
template-var-labels

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

The question

When wt shows a template variables: block under -v, does it say which template the variables belong to? Mostly no — and in one case it genuinely can't be worked out from the header.

What was there

Four sites print a variables listing, and none named its owner in the header:

Site Header How you'd tell what it's for
foreground hook (command_executor.rs) template variables: the hook_type row at the bottom of the table, or the Running … line below it
background hook (hooks.rs) template variables: same — but see below
alias (alias.rs) template variables: only the Running alias greet line below it
wt step eval (eval.rs) Available template variables unambiguous (one template, named on the command line)

The adjacent blocks in the same -v lane already label themselves — ○ eval source, ○ user:noop result — so the variables table was the odd one out in its own family.

Background hooks turned that from inconvenient into ambiguous. wt -v remove <branch> prints one table per hook type back to back, then a single combined Running post-remove: cleanup (user); post-switch: notify (user) line — two identical headers over two ~20-row tables that differ only in their rows.

The change

Prefix each header with the hook type, alias name, or eval.

- ○ template variables:                 ○ post-remove template variables:
- ○ template variables:                 ○ post-switch template variables:

wt step eval -v now reads as one labeled family:

○ eval template variables:
  branch = feature/auth-oauth2
○ eval source
  {{ branch }}
○ eval result
  feature/auth-oauth2

eval's header was reworded from Available template variables for the same shape; it was never ambiguous, but it's the fourth member of the family and now matches the source / result headers directly beneath it.

Display-only — no logic changed. Snapshots and the generated step.md pages regenerated; cargo run -- hook pre-merge --yes green (4461 tests).

This was written by Claude Code on behalf of Maximilian Roos

🤖 Generated with Claude Code

The `-v` variables table printed a bare `template variables:` header, so
nothing in it said which template the variables were for. The adjacent
blocks in the same lane already label themselves (`○ eval source`,
`○ user:noop result`), and the table only carried its owner incidentally —
in the `hook_type` row at the bottom of a ~20-row listing, or in the
`Running ...` line below it.

Background hooks made that ambiguous rather than just inconvenient:
`wt -v remove` prints one table per hook type back to back, then a single
combined `Running post-remove: cleanup; post-switch: notify` line, leaving
two identical headers above two tables that differ only in their rows.

Prefix each header with the hook type, alias name, or `eval`, matching the
sibling `source` / `result` headers. `wt step eval -v` now reads:

    ○ eval template variables:
    ○ eval source
    ○ eval result

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@max-sixty
max-sixty marked this pull request as ready for review July 17, 2026 04:27
@max-sixty
max-sixty merged commit 85c9241 into main Jul 17, 2026
40 checks passed
@max-sixty
max-sixty deleted the template-var-labels branch July 17, 2026 04:37
max-sixty added a commit that referenced this pull request Jul 22, 2026
`wt step eval -v` was the last of the four `-v` template-variable
listings to hand-roll its own formatting. The hook (foreground +
background) and alias sites all render through `format_hook_variables` /
`format_alias_variables`; eval instead sorted keys alphabetically,
padded, and joined them by hand. #3495 labelled all four block *headers*
with their owner, which made eval's differently-formatted *body* stand
out.

This adds a sibling `format_base_variables` for the bare `base_vars`
scope (no hook operation/infrastructure vars, no alias `args`) and
routes eval through it, so all four listings are one family.

Consequences for the eval listing, now matching the other three:

- curated help-table order instead of alphabetical
- deprecated aliases (`main_worktree`, `repo_root`, `worktree`,
`main_worktree_path`) dropped, as the other sites already omit them
- absent optional vars show `(unset)` (e.g. `owner` with no PR context)
- variable names render plain, not bold

Behavior-only change to the `-v` diagnostic lane; the `eval_verbose` /
`eval_format_json_verbose` snapshots capture the new output.

> _This was written by Claude Code on behalf of max_

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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