fix(tui): make main green — unreachable composer hint, half-applied no-color mode - #53
Conversation
`main` is red: `an_empty_composer_shows_a_hint_with_the_caret_after_the_prompt`
fails on the assertion that every span on the line is `Color::Gray`.
The assertion is right and the code was wrong. The hint sat behind
`if lines.is_empty()`, but the wrap loop above it cannot leave `lines`
empty: `"".split('\n')` yields one empty segment, and `chunk` returns
`vec![""]` for it, so an empty buffer still pushes a line. That line is a
styled prompt followed by `Span::raw("")` — and a raw span has no
foreground, which is what the new assertion caught.
So the hint had been dead code since it was written, and an empty
composer showed a bare prompt instead of "send a message, /help for
commands". The contrast pass that added the assertion did not break this;
it exposed it.
Fixed by handling the empty buffer before the wrap loop instead of as a
fallback after it, and deleting the unreachable branch.
The existing test passed on the broken render for all three of its other
assertions — one line, caret at (2, 0), no DIM modifier — because a bare
prompt satisfies every one of them. A test named "shows a hint" that
never checks the hint text is how this survived, so this adds one that
names the text.
The second failure keeping `main` red: `disabling_color_preserves_text_and_non_color_attributes` fails asserting the span kept its BOLD. The bold was never on the span. `Line::styled` puts the style on the *line* and gives its spans the default style, so the test's fg and bg assertions were passing vacuously against a span that had no color to begin with, and the modifier assertion failed because it was looking in the wrong place. Fixing where the test looks exposed the real defect underneath it: `remove_colors` cleared spans only. Rendering patches a line's style underneath each span's, so a color set at line level is a color the terminal still paints — "colors off" was a half-measure, which matters here because it is an accessibility mode rather than a preference. It now clears both levels, and a second test covers the line-level case the first one cannot reach. Modifiers stay untouched at both levels: bold and underline are how emphasis survives once color cannot carry it. Verified locally by temporarily swapping acton-ai's `fips` feature for `tls-ring`, which sidesteps this machine's AWS-LC-FIPS self-test abort and lets the suite actually run: 1294 passed, 0 failed across the workspace. That swap is a local diagnostic and is not part of this commit.
|
Second commit added: Same shape as the first. Full suite now verified locally, not just by CI: temporarily swapping acton-ai's |
mainis currently red. This fixes it.The failure
an_empty_composer_shows_a_hint_with_the_caret_after_the_promptfails on the assertion added by the contrast pass (499fe55):The assertion is right; the code was wrong
The hint sat behind
if lines.is_empty(), but the wrap loop above it cannot leavelinesempty:"".split('\n')yields one (empty) segmentchunk("", width)hitswidth("") <= widthand returnsvec![""]— one empty rowSpan::raw("")Span::rawcarries no foreground, which is exactly what the new assertion caught.So the hint has been dead code since it was written: an empty composer showed a bare
›instead of› send a message, /help for commands. The contrast pass didn't break this — it exposed a user-visible bug that had been shipping.Fixed by handling the empty buffer before the wrap loop and deleting the unreachable branch.
Why it hid for so long
The test's other three assertions — one line, caret at
(2, 0), noDIM— are all satisfied by a bare prompt. A test named "shows a hint" that never checks the hint text will pass on a render with no hint in it. This adds one that names the text.Verified:
cargo clippy --locked --workspace --all-targets -- -D warningsclean. The test itself runs in CI —garrison-agent's test binary aborts on this machine's known AWS-LC-FIPS self-test.