Skip to content

fix(tui): colour per thread, one quiet failure row, signal handlers, empty panels, box-title rules - #1391

Merged
huichen merged 5 commits into
mainfrom
pr/huichen
Oct 27, 2026
Merged

huichen merged 5 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

What

Five follow-up fixes for the TUI, most of them prompted by red CI on the previous PR: theme colours are now resolved per thread instead of from process environment variables, a failed tool call renders as one quiet row instead of a red block, the POSIX signal handlers are installed in every profile, a panel with nothing to list still fills its own rectangle, and a box title's rule is drawn after the title instead of being padded away.

Commits

  • fix(tui): decide colour styling per thread, not by the process environment
  • fix(tui): a failed call is one quiet row, not a red block
  • fix(tui): install the signal handlers in every profile
  • fix(tui): a panel with nothing to list still fills its rectangle
  • fix(tui): draw the rule after a box title instead of padding it away

Verification

Run locally on the branch tip (6f86f2033) with the pinned rustc/clippy 1.99.1 toolchain and ulimit -n 8192:

  • cargo fmt --all -- --check -> clean
  • cargo clippy -p future-tui --all-targets -- -D warnings -> clean
  • cargo test -p future-tui --lib -> 1443 passed, 0 failed
  • cargo test -p future-tui --test i18n_guard -> 8 passed
  • cargo test -p future-tui --test signal_shutdown -> 6 passed
  • make check-docs -> 358 docs OK, provider matrix 13 rows

Notes

The branch is origin/main plus these five commits only; no unrelated work is bundled in.

…nment

`theme::tests::no_color_applies_to_composed_styles_and_reverse_video` set
`NO_COLOR` in the *process* environment, and every styling helper reads that
variable. `cargo test` runs a binary's tests in parallel threads of one process,
so for as long as the guard lived, a neighbouring test's `fg()` returned bare
text: CI run 40475346830 failed `fg_wraps_with_256_color_and_reset` with
`left: "hi"` while the same tree passed standalone. Any of this crate's ~90
colour assertions was exposed, not just that one.

The styling helpers now resolve the policy through one function that reads the
environment, and let a test inject a value for **its own thread** instead. The
existing assertion keeps its exact expectations (`style`/`reverse_raw` go plain)
while forcing the policy; a new test checks the production read still answers to
the real `NO_COLOR`, which holds whichever way the ambient environment has it.
No lock is needed: a thread-local override cannot reach a peer.

Evidence: with the old guard plus a 4 s sleep in its window, `theme::tests` failed
four colour assertions deterministically (3/3 runs, `raw_variants_omit_reset`,
`style_composes_without_double_reset`, `wrapped_styles_emit_exact_sequences`,
`raw_styles_omit_trailing_reset`); `NO_COLOR=1` alone reproduces CI's message for
`fg_wraps_with_256_color_and_reset` verbatim. With the fix, the same 4 s window
inside the injected policy leaves all 32 `theme::tests` green (3/3).
A call that came back an error was the one entry a collapsed transcript
still printed in full: a red band across the screen and its whole body in
error red. A `cargo test` halted mid-run therefore turned its own
diagnostics into the loudest thing on screen and pushed the reply that
mattered off it.

Every call is now one row, whichever way it ended — the neutral band, a
dim `✗`, and the body behind `/tool-output` like any other output. With
the bodies open, a failed call's text is painted in the body colour, never
the error one.

- chat_area: `render_tool_message` stops special-casing `Error`; the
  collapsed preview and `rows`'s `expanded`/`error` parameters go with it,
  so a body is only ever drawn at the expanded cap.
- tests: the failed-call cases pin the one-row shape, the `✗`, the neutral
  band, the absence of the red one, and the body one toggle away.
- docs: the `/tool-output` row says a failure is collapsed too.

`tool_error_bg` stays in the palette — a theme's fields are a contract, and
the picker previews them — but this row no longer paints it, and the test
holds that line.
`sigaction` was called from inside `debug_assert_eq!`, so a release build
installed nothing: SIGWINCH never reached the process and a resized window
kept painting the geometry it started with (measured on the installed
release `future`: 2.36 s later it repainted all 38 rows of the old size,
while the debug build answered in 5 ms at the new 26). The termination
signals were lost the same way, so SIGTERM/SIGHUP left the terminal in raw
mode on the alternate screen.

The calls are now plain statements whose error is propagated, with a
rollback in `enable_raw` for the pipe and termios it had already set up.
The install test reads the dispositions back from the kernel, which is what
`cargo test --release -p future-tui` needs to catch this class of bug — it
fails against the debug_assert form and passes against this one.
The 改动 and 储藏 tabs of a clean checkout, a failed git read, and `/diff` on a
clean working tree all returned their box after the four rows they had drawn, so
the conversation underneath showed through the rest of the panel's rectangle —
`No stashes` sat above rows of the chat.

Both surfaces now close their box the way the full lists already did: pad the
panel to the frame's height, then the bottom rule. `/diff`'s empty branch also
lost its `indent`, so it painted at column 0 while every other branch centred
the same box.
`box_top` measured the label after `fit` had padded it to `inner - 1`
columns, so `used` was always the full room, `rest` was always zero, and
every titled box drew `╭─ title` and then blanks up to the corner. The
composer only showed it once #1355 started passing it a title
(`输入 · enter 发送 · ctrl+j 换行`): the top rule of the input box read as
gone, and the panel and preview boxes had carried the same blank rule
since the workbench landed.

Clip the label to its room instead of fitting it to the room, so the
`saturating_sub` leaves the remaining columns for `─`. A title that does
not fit is still clipped with an ellipsis and the corner stays on the
row. The regression test asserts the rule itself, not just the width.
@huichen huichen changed the title fix(tui): colour per thread, one quiet failure row, signal handlers, empty panels fix(tui): colour per thread, one quiet failure row, signal handlers, empty panels, box-title rules Oct 27, 2026
@huichen
huichen enabled auto-merge (squash) October 27, 2026 09:27
@huichen
huichen merged commit 9e94740 into main Oct 27, 2026
10 checks passed
@huichen
huichen deleted the pr/huichen branch October 27, 2026 10:16
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.

1 participant