From 3d3ca6475d0a38bb96afd225b49340430fd487f8 Mon Sep 17 00:00:00 2001 From: David Wiesen Date: Mon, 6 Oct 2025 16:10:47 -0700 Subject: [PATCH] assume true color for any Windows Terminal session. --- codex-rs/tui/src/style.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/codex-rs/tui/src/style.rs b/codex-rs/tui/src/style.rs index a26ff923a2..5746576b2b 100644 --- a/codex-rs/tui/src/style.rs +++ b/codex-rs/tui/src/style.rs @@ -24,10 +24,18 @@ pub fn user_message_bg(terminal_bg: (u8, u8, u8)) -> Color { (255, 255, 255) }; let bottom = terminal_bg; - let Some(color_level) = supports_color::on_cached(supports_color::Stream::Stdout) else { + let Some(mut color_level) = supports_color::on_cached(supports_color::Stream::Stdout) else { return Color::default(); }; + #[cfg(windows)] + // Windows Terminal has been the default shell application for Windows since October 2022 + // and has supported truecolor even longer. However it usually does not set COLORTERM to indicate that. + // so this is a pretty safe heuristic. + if std::env::var_os("WT_SESSION").is_some() { + color_level.has_16m = true; + } + let target = blend(top, bottom, 0.1); if color_level.has_16m { // In truecolor terminals we can use the exact RGB value.