mirror of
https://github.com/openai/codex.git
synced 2026-11-26 23:40:43 +00:00
Windows Terminal supports 24-bit color but `supports-color` often reports only ANSI-16 because `COLORTERM` is not set. Introduce `diff_color_level_for_terminal`, a pure mapping from detected color level to intended diff palette, that promotes to truecolor when Windows Terminal is detected. Detection uses two independent signals — `TerminalName::WindowsTerminal` (from `terminal_info()`) and raw `WT_SESSION` presence — so the promotion fires even if one detection path changes. When `WT_SESSION` is present, promotion is unconditional (including `Unknown` level); without it, only ANSI-16 is promoted for named WindowsTerminal sessions. Setting `FORCE_COLOR` suppresses both paths to preserve explicit user intent. All env reads stay in the thin `diff_color_level()` wrapper; the core function is pure for testability. Six unit tests cover every branch.