Repository navigation
fix(tui): colour per thread, one quiet failure row, signal handlers, empty panels, box-title rules - #1391
Merged
Conversation
…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
enabled auto-merge (squash)
October 27, 2026 09:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Verification
Run locally on the branch tip (
6f86f2033) with the pinned rustc/clippy 1.99.1 toolchain andulimit -n 8192:cargo fmt --all -- --check-> cleancargo clippy -p future-tui --all-targets -- -D warnings-> cleancargo test -p future-tui --lib-> 1443 passed, 0 failedcargo test -p future-tui --test i18n_guard-> 8 passedcargo test -p future-tui --test signal_shutdown-> 6 passedmake check-docs-> 358 docs OK, provider matrix 13 rowsNotes
The branch is
origin/mainplus these five commits only; no unrelated work is bundled in.