Repository navigation
fix(help): drop the stray trailing space from the --help aliases list - #2689
Conversation
codecov/patch failing — new if-block body uncovered (lines 237-238)
worktrunk-bot
left a comment
There was a problem hiding this comment.
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_sectionoutput run throughwrap_styled_textat widths 80/40/20/12/6 — the last line ends with\x1b[0min 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:
-
Drop the new
ifblock. 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. -
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.
`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]>
fb19677 to
9f12155
Compare
render_aliases_help_section(the compactAliases:block inwt --help/wt step --help, added in #2688) padded its joined alias-name list with a trailing space, with a comment claimingwrap_styled_textdrops a reset that ends a line so the last name's color would otherwise bleed onto the "Runwt config alias show…" line below.That premise is wrong:
wrap-ansikeeps a line-final\x1b[0m, so the terminal output never bled. The trailing space only mattered against the snapshot harness's\x1b[0m\n→\nfilter, 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::Resetin that function stays — it's what keeps the,separators uncolored, matching how clap closes eachCommands: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 lockedwrap-ansi 0.1.0).Thanks to the auto-reviewer for catching that the originally-proposed
wrap_styled_textfix was dead code (codecov showed the new branch never executed).