TUI dark-theme diff foregrounds have low contrast on tinted backgrounds
What version of Codex CLI is running?
codex-cli 0.144.4; also reproduced against main at 365d70203da18c2a6f6848df3778e390e794ef17.
What subscription do you have?
ChatGPT authentication; the exact tier does not appear relevant to this local TUI renderer issue.
Which model were you using?
gpt-5.6-sol, but the issue is in local diff rendering and is model-independent.
What platform is your computer?
Darwin 24.5.0 arm64 arm
What terminal emulator and version are you using?
Reproduced in both Apple Terminal 455.1 and iTerm2 3.6.11 on dark terminal profiles. iTerm2 reported TERM=xterm-256color and COLORTERM=truecolor.
What issue are you seeing?
In the TUI's built-in diff cards, foregrounds on dark-theme insert/delete backgrounds can have very low contrast:
- plain insert/delete content uses green/red foregrounds over dark green/red backgrounds;
- syntax-highlighted delete content additionally receives
Modifier::DIM, producing dim gray or muted syntax colors over the dark red background; - the gutter is also dimmed.
The result can be difficult to distinguish even though the terminal correctly supports 256 colors and truecolor. The same terminals render ordinary git diff --color=always foreground colors correctly.
The root cause is in codex-rs/tui/src/diff_render.rs: dark rich-color content uses red/green foregrounds, syntax-highlighted deletions are always dimmed, and dark gutters use style_gutter_dim().
This is distinct from #13012 (overly bright backgrounds, fixed by #13037) and #33422 (tmux rendering the fills as solid yellow).
What steps can reproduce the bug?
- Use a dark terminal profile with 256-color or truecolor support.
- Start Codex CLI 0.144.4.
- Ask Codex to modify a syntax-highlighted source file with both additions and deletions.
- Inspect the built-in
Edited ...diff card, especially deleted syntax-highlighted lines.
What is the expected behavior?
Keep the dark red/green background cues, but render the gutter, sign, and content with a high-contrast foreground. For dark truecolor and ANSI-256 diff lines, white foreground text is substantially more readable. Light themes and ANSI-16 foreground-only behavior should remain unchanged.
Additional information
I prepared and tested a focused implementation against current main:
https://github.com/chouchunming/codex/commit/bf0c12406bd669874542ebcce33da743084e9575
The proposed change:
- uses white foregrounds only for dark truecolor/ANSI-256 insert and delete lines;
- removes
DIMfrom syntax-highlighted deletions in those dark rich-color modes; - clears per-token syntax backgrounds so the line-level diff background remains visible;
- preserves light-theme and ANSI-16 behavior;
- adds coverage for plain and syntax-highlighted insert/delete lines in truecolor and ANSI-256 modes.
Validation completed:
just fmtjust fmt-checkjust fix -p codex-tuicargo test --offline --locked -p codex-tui --lib diff_render::tests::— 52 passed, 0 failed
Per the contribution policy, I am opening the issue first and requesting confirmation of the approach before opening a PR.