fix(tui): map AnsiValue indices through the ratatui bridge#274
Merged
Conversation
#271's color downgrade path converts Color::Rgb to Color::AnsiValue(n) when EmitMode is Ansi256 (Apple Terminal, screen-256color, tmux-256color, NO_COLOR override). theme_to_ratatui in tui.rs only handled truecolor and the 16 named ANSI variants; the AnsiValue variant fell through the wildcard arm to Color::Reset. Result: on the very terminals #271 was meant to fix, every themed color the TUI consumes (status lines, REPL prompt, accent / muted / success / error / warning) was silently reset to terminal default. Map AnsiValue(n) -> ratatui::style::Color::Indexed(n). ratatui emits that as SGR 38;5;n, matching the 256-color path the downgrade targets at the crossterm side.
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.
Summary
#271 added a 256-color downgrade path for Apple Terminal / screen-256color / tmux-256color via `color_emit::adapt`, which converts `Color::Rgb` to `Color::AnsiValue(n)` when the active `EmitMode` is `Ansi256`. The TUI bridge in `crates/cli/src/ui/tui.rs::theme_to_ratatui` did not handle the `AnsiValue` variant, so it fell through the wildcard arm to `Color::Reset`.
Result: on the very terminals #271 was meant to fix, every themed color the TUI consumes (status lines, REPL prompt, accent / muted / success / error / warning) was silently reset to terminal default. Visible regression on first-class targets.
Fix
Map `crossterm::style::Color::AnsiValue(n)` → `ratatui::style::Color::Indexed(n)`. ratatui emits that as SGR `38;5;n`, the same 256-color escape the downgrade path is targeting at the crossterm side.
Four-line patch.
Test plan