Skip to content

fix(help): drop the stray trailing space from the --help aliases list - #2689

Merged
max-sixty merged 2 commits into
mainfrom
wrap-trailing-reset
May 11, 2026
Merged

max-sixty merged 2 commits into
mainfrom
wrap-trailing-reset

Conversation

@max-sixty

@max-sixty max-sixty commented May 11, 2026 •

Copy link
Copy Markdown
Owner

render_aliases_help_section (the compact Aliases: block in wt --help / wt step --help, added in #2688) padded its joined alias-name list with a trailing space, with a comment claiming wrap_styled_text drops a reset that ends a line so the last name's color would otherwise bleed onto the "Run wt config alias show …" line below.

That premise is wrong: wrap-ansi keeps a line-final \x1b[0m, so the terminal output never bled. The trailing space only mattered against the snapshot harness's \x1b[0m\n → \n filter, which would otherwise strip the reset from the snapshot and make the diff look like a bleed even though the binary is fine. So this drops the space (a stray trailing space on that help line) and updates the two affected snapshots accordingly — the binary still emits the line-final reset; only the snapshot representation changes.

The per-name anstyle::Reset in that function stays — it's what keeps the , separators uncolored, matching how clap closes each Commands: entry.

Also corrects the matching stale claim in wrap_styled_text's doc comment ("we move these to line ends" → the code strips leading resets and leaves line-final resets in place — verified directly against the locked wrap-ansi 0.1.0).

Thanks to the auto-reviewer for catching that the originally-proposed wrap_styled_text fix was dead code (codecov showed the new branch never executed).

worktrunk-bot
worktrunk-bot previously approved these changes May 11, 2026
@worktrunk-bot
worktrunk-bot dismissed their stale review May 11, 2026 07:22

codecov/patch failing — new if-block body uncovered (lines 237-238)

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

codecov/patch is failing on the new if body in wrap_styled_text — cobertura.xml from code-coverage shows lines 237–238 (the body) with 0 hits while the four conditions on lines 233–236 are hit 3354/894/894/844 times respectively. The 844 evaluations of the final condition all returned false: every last line already ended with \x1b[0m.

I traced this against the locked wrap-ansi 0.1.0 outside the test suite to see whether the new code can fire at all:

  • wrap_styled_text("\x1b[36mname\x1b[0m", 80) — wrap-ansi returns the input unchanged; last line already ends with \x1b[0m.
  • The wrapping test case wrap_styled_text("\x1b[36maaaa bbbb cccc dddd\x1b[0m", 12) — wrap-ansi emits "\x1b[36maaaa bbbb \x1b[39m\n\x1b[36mcccc dddd\x1b[0m"; the last line still ends with \x1b[0m.
  • The full render_aliases_help_section output run through wrap_styled_text at widths 80/40/20/12/6 — the last line ends with \x1b[0m in every case.

So the new conditional and its body don't fire in any pattern I could find. The premise from #2688 ("wrap_styled_text drops a reset that ends a line") seems to have been incorrect — wrap-ansi keeps line-final resets, and the trailing-space workaround was load-bearing only against the snapshot filter (\x1b\[0m\n → \n), not against an actual terminal bleed.

The snapshot diffs are consistent with that read: with the trailing space removed, the snapshot filter now applies and strips \x1b[0m\n, leaving [22m at the line end in the snapshot while the binary still emits the reset.

Two paths forward:

  1. Drop the new if block. If wrap-ansi already preserves the trailing reset, removing the trailing-space hack alone is enough — the snapshot delta you've already taken is the whole fix. The PR shrinks to: doc-comment touchup + remove trailing-space hack + snapshot updates.

  2. Keep it, but cover it. Add a test that constructs an input where wrap-ansi does drop the trailing reset. If no such input exists for this wrap-ansi version, that's evidence the code is dead.

I'm leaning toward (1) — the diff currently claims to fix a wrapper bug, but the verifiable behavior change is removing the workaround. Happy to be wrong if you have a repro where wrap-ansi drops the trailing reset. Dismissing my approval until this is resolved.

max-sixty and others added 2 commits May 11, 2026 00:26
`render_aliases_help_section` padded the joined alias-name list with a
trailing space, with a comment claiming `wrap_styled_text` drops a reset
that ends a line so the last name's color would otherwise bleed onto the
"Run `wt config alias show` …" line. That premise is wrong: `wrap-ansi`
keeps a line-final `\x1b[0m`, so the terminal output never bled — the
trailing space only mattered against the snapshot filter (`\x1b[0m\n` → `\n`),
which would otherwise strip the reset from the snapshot and make it *look*
like a bleed. Drop the space; the per-name `anstyle::Reset` stays since it
keeps the `, ` separators uncolored.

Also corrected the matching stale claim in `wrap_styled_text`'s doc comment
("we move these to line ends" → the code strips leading resets and leaves
line-final resets in place).

Snapshot updates only lose the trailing space.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@max-sixty max-sixty changed the title fix(styling): keep a line-final ANSI reset through wrap_styled_text fix(help): drop the stray trailing space from the --help aliases list May 11, 2026
@max-sixty
max-sixty force-pushed the wrap-trailing-reset branch from fb19677 to 9f12155 Compare May 11, 2026 07:31
@max-sixty
max-sixty merged commit 547092a into main May 11, 2026
33 checks passed
@max-sixty
max-sixty deleted the wrap-trailing-reset branch May 11, 2026 07:45
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