You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Auto set light/dark theme variants based on OS preference #12840
After update to 105 I see this, is that the intended default? I'm on Windows Terminal with dark mode.
It seems that the /theme options all change text colour, but because the background colours are close to medium lightness, neither light nor dark text gives particularly good contrast. Changing to the GitHub theme makes diffs just readable, but it's a real squint-fest, and other text becomes unreadable.
This makes 105 unusable for me, unless there's some option for "make it like it used to be"?
Then Codex correctly recognises my terminal as truecolor and I get the default dark green/red and can read diffs.
For fellow Terminal users, this can be set as a regular environment variable, or in the settings JSON, as a property of a particular profile in Terminal:
The underlying issue is that the supports-color crate used to detect color seems to just check environment variables, maybe some other heuristics, not the actual capability. E.g. if I run node then process.stdout.getColorDepth() it returns returns 24 for my terminal, which should be treated as truecolor.
These background colours are blinding me, please can we do something to get those more natural colours we had in 0.104 or someway of easily configuring these background colours in the diff (including none as an option). I would of much preferred if 0.104 was the default theme after upgrading to 0.105. Completely onboard with everything david has mentioned above.
update:
david's fix with base16-256 theme is ok (i can see again!)
I think a quick fix in Codex would be logic like: "if a terminal can't do true color, don't use background colors".
Then a more refined step would be to better detect truecolor-able terminals.
@etraut-openai the most pressing thing for me, which is related, is to fix the text background issue when switching between light/dark on the OS level, since right now when doing so the text is unreadable at all.
The prompt background (and diffs/syntax theme) doesn't update on OS theme change because the terminal bg is queried once via OSC 11 and cached, re-query only happens on FocusGained.
I'd like to add mode 2031 support so terminals that implement it (Ghostty, Kitty, WezTerm, foot, etc.) notify Codex on theme change, triggering requery_default_colors() + redraw. All three color subsystems already key off is_light(default_bg()), so this should just work. Terminals without mode 2031 fall back to the existing FocusGained behavior.
Would this be welcome?
Reacted by Gilles Duboscq, Hiero dos Santos de Paula, Ben and Chris Souers
The terminal already has colors. Why another layer of theme on top of theme? Your Ghostty, Alacritty, etc., almost surely already has a light/dark theme. Just use that. (That's why I wrote https://github.com/mavam/pi-terminal-theme for Pi.)
Tennis includes a termbg.zig module to detect the terminal background color so it can choose the correct theme (dark or light). Detection is complicated, and I'm calling it out here because I don't think anyone has implemented this in Zig yet.
By the way it seems there's a OSC 11 sequence, on which tennis is based, that is used to query the terminal background (and OSC 10 for the foreground).
Root cause and a working implementation, since external PRs are not accepted here.
Why it stays stale today. The TUI probes OSC 10/11 once in terminal_probe::startup and never again. Event::FocusGained in tui/event_stream.rs deliberately keeps the startup-cached palette. So after a macOS auto light/dark switch nothing re-reads the background, and highlight::adaptive_default_theme_selection keeps the mocha/latte pick from launch.
The signal exists. Terminals that implement DEC private mode 2031 (Ghostty, Contour, kitty, foot, WezTerm) send CSI ? 997 ; 1 n (dark) / CSI ? 997 ; 2 n (light) the moment the scheme changes, if the app enabled it with CSI ? 2031 h. Claude Code already uses this. The Codex crossterm fork currently parses that report as an unknown private CSI and discards it, so Codex cannot see it.
codex: main...arzafran:codex:theme-2031 (commit arzafran/codex@901c4d4cf7) (branch theme-2031, 3 files, +107). Enables mode 2031 in set_modes, disables it on restore. On the event: broker.pause_events(), re-run the existing bounded terminal_probe::default_colors (100 ms cap), set_default_colors_from_startup_probe, re-resolve the adaptive theme unless tui.theme is set, resume_events(), TuiEvent::Draw. Same pause-probe-resume shape as the suspend-key path and probe_default_colors_after_protected_startup on Windows. A failed probe keeps the cached palette rather than clearing it (the TUI: one failed color requery permanently disables OSC 10/11 re-detection (poisoned cache in requery_default_colors) #37298 pattern).
Cost: keys typed inside the 100 ms probe window at the instant of the flip are dropped, same as the Windows post-startup probe. Unix only, since Windows Terminal declined mode 2031.
Activity
etraut-openai commentedon Feb 26, 2026
You're using the CLI, right? Terminal programs generally have their own light/dark settings and color themes that are independent of the OS's.
galah92 commentedon Feb 26, 2026
CLI, yes. And in bat for example I can do:
Also many programs like neovim, ghostty, support that and auto switching when I toggle that option at the OS level.
Edit: This might be helpful.
davidgilbertson commentedon Feb 26, 2026
After update to 105 I see this, is that the intended default? I'm on Windows Terminal with dark mode.
It seems that the
/themeoptions all change text colour, but because the background colours are close to medium lightness, neither light nor dark text gives particularly good contrast. Changing to the GitHub theme makes diffs just readable, but it's a real squint-fest, and other text becomes unreadable.This makes 105 unusable for me, unless there's some option for "make it like it used to be"?
davidgilbertson commentedon Feb 26, 2026
If I do this:
Then Codex correctly recognises my terminal as truecolor and I get the default dark green/red and can read diffs.
For fellow Terminal users, this can be set as a regular environment variable, or in the settings JSON, as a property of a particular profile in Terminal:
The underlying issue is that the
supports-colorcrate used to detect color seems to just check environment variables, maybe some other heuristics, not the actual capability. E.g. if I runnodethenprocess.stdout.getColorDepth()it returns returns 24 for my terminal, which should be treated as truecolor.laffo16 commentedon Feb 26, 2026
These background colours are blinding me, please can we do something to get those more natural colours we had in 0.104 or someway of easily configuring these background colours in the diff (including none as an option). I would of much preferred if 0.104 was the default theme after upgrading to 0.105. Completely onboard with everything david has mentioned above.
update:
david's fix with base16-256 theme is ok (i can see again!)
davidgilbertson commentedon Feb 26, 2026
I think a quick fix in Codex would be logic like: "if a terminal can't do true color, don't use background colors".
Then a more refined step would be to better detect truecolor-able terminals.
fix(tui): promote windows terminal diff ansi16 to truecolor (openai#1…
galah92 commentedon Feb 27, 2026
@etraut-openai not sure why this issue was closed with a fix PR - the original request was to support light/dark variants based on OS preference.
etraut-openai commentedon Feb 27, 2026
Sorry, Github automatically closed it because it was referenced in the PR commit notes. Reopening.
[pull] main from openai:main (#16)
[pull] main from openai:main (#16) (#17)
acgxv commentedon Feb 28, 2026
And I set it to auto. The theme will be changed automatically. Codex must support this.
Allow to set different themes for different system themes.
galah92 commentedon Mar 4, 2026
@etraut-openai the most pressing thing for me, which is related, is to fix the text background issue when switching between light/dark on the OS level, since right now when doing so the text is unreadable at all.
The prompt background (and diffs/syntax theme) doesn't update on OS theme change because the terminal bg is queried once via OSC 11 and cached, re-query only happens on
FocusGained.I'd like to add mode 2031 support so terminals that implement it (Ghostty, Kitty, WezTerm, foot, etc.) notify Codex on theme change, triggering
requery_default_colors()+ redraw. All three color subsystems already key offis_light(default_bg()), so this should just work. Terminals without mode 2031 fall back to the existingFocusGainedbehavior.Would this be welcome?
galah92 commentedon May 18, 2026
@etraut-openai any chance to push this forward?
Currently we have:
I would be appreciated if we can support:
mavam commentedon May 31, 2026
Even better: just give us
theme = "terminal".The terminal already has colors. Why another layer of theme on top of theme? Your Ghostty, Alacritty, etc., almost surely already has a light/dark theme. Just use that. (That's why I wrote https://github.com/mavam/pi-terminal-theme for Pi.)
fix(tui): promote windows terminal diff ansi16 to truecolor (#13016)
bric3 commentedon Jun 10, 2026
Also note that currently with the default settings, when the theme changes, e.g. from dark to light the prompt stays with the previous color. E.g.
iTerm2

IntelliJ IDEA

This is so annoying that one has to restart and resume the session. Pretty disruptive.
bric3 commentedon Jun 10, 2026
Also FYI, it seems that
tennisfound a way to reliably detect the term background:https://github.com/gurgeous/tennis/blob/498c1c6762f0d78297dc25bb5c13a195083238a6/src/termbg.zig
By the way it seems there's a
OSC 11sequence, on which tennis is based, that is used to query the terminal background (and OSC 10 for the foreground).bric3 commentedon Jun 10, 2026
Oh actually it seems that codex is already doing that #16335 (comment)
Which means codex should just refresh the values.
fix(tui): promote windows terminal diff ansi16 to truecolor (openai#1…
fix(tui): promote windows terminal diff ansi16 to truecolor (#13016)
arzafran commentedon Sep 18, 2026
Root cause and a working implementation, since external PRs are not accepted here.
Why it stays stale today. The TUI probes OSC 10/11 once in
terminal_probe::startupand never again.Event::FocusGainedintui/event_stream.rsdeliberately keeps the startup-cached palette. So after a macOS auto light/dark switch nothing re-reads the background, andhighlight::adaptive_default_theme_selectionkeeps the mocha/latte pick from launch.The signal exists. Terminals that implement DEC private mode 2031 (Ghostty, Contour, kitty, foot, WezTerm) send
CSI ? 997 ; 1 n(dark) /CSI ? 997 ; 2 n(light) the moment the scheme changes, if the app enabled it withCSI ? 2031 h. Claude Code already uses this. The Codex crossterm fork currently parses that report as an unknown private CSI and discards it, so Codex cannot see it.Implementation (built,
cargo clippy -p codex-tui --all-targets -- -D warningsclean):Event::ColorSchemeChanged(ColorScheme::{Dark, Light})from the?997;N nreport, with a parser test.theme-2031, 3 files, +107). Enables mode 2031 inset_modes, disables it on restore. On the event:broker.pause_events(), re-run the existing boundedterminal_probe::default_colors(100 ms cap),set_default_colors_from_startup_probe, re-resolve the adaptive theme unlesstui.themeis set,resume_events(),TuiEvent::Draw. Same pause-probe-resume shape as the suspend-key path andprobe_default_colors_after_protected_startupon Windows. A failed probe keeps the cached palette rather than clearing it (the TUI: one failed color requery permanently disables OSC 10/11 re-detection (poisoned cache in requery_default_colors) #37298 pattern).Cost: keys typed inside the 100 ms probe window at the instant of the flip are dropped, same as the Windows post-startup probe. Unix only, since Windows Terminal declined mode 2031.
Happy to adjust if a different shape fits better.