Auto set light/dark theme variants based on OS preference
Open 💬 15 comments Opened Feb 26, 2026 by galah92
💡 Likely answer: A maintainer (etraut-openai, contributor)
responded on this thread — see the highlighted reply below.
What variant of Codex are you using?
v0.105.0
What feature would you like to see?
In continuation to #1618, I would like the Codex CLI to auto detect the MacOS preference (light/dark) and apply the relevant theme accordingly.
Additional information
_No response_
15 Comments
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.
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.
After update to 105 I see this, is that the intended default? I'm on Windows Terminal with dark mode.
<img width="1401" height="1289" alt="Image" src="https://github.com/user-attachments/assets/01fc63cd-8006-4540-9077-70e2a8e94cba" />
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.<img width="1038" height="907" alt="Image" src="https://github.com/user-attachments/assets/d277cdaa-4fb7-43ea-a065-dd2f6a430e1a" />
This makes 105 unusable for me, unless there's some option for "make it like it used to be"?
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.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!)
<img width="1109" height="243" alt="Image" src="https://github.com/user-attachments/assets/3e9f83f6-da6d-44ca-b48b-486f7f3bc864" />
<img width="1133" height="217" alt="Image" src="https://github.com/user-attachments/assets/8982c208-2e02-4107-b5f4-348d7e17d5e2" />
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 not sure why this issue was closed with a fix PR - the original request was to support light/dark variants based on OS preference.
Sorry, Github automatically closed it because it was referenced in the PR commit notes. Reopening.
<img width="682" height="548" alt="Image" src="https://github.com/user-attachments/assets/5785c815-b92d-4278-9a34-89f0a317d734" />
<img width="699" height="513" alt="Image" src="https://github.com/user-attachments/assets/efa21cbd-cfd3-4e3b-8b0a-8a165ca51743" />
---
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.
@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?
@etraut-openai any chance to push this forward?
Currently we have:
I would be appreciated if we can support:
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.)
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
<img width="1492" height="366" alt="codex in iTerm2 after going back from dark to light" src="https://github.com/user-attachments/assets/1e101729-e9d1-41cf-87c0-167ef2f34a72" />
IntelliJ IDEA
<img width="1492" height="366" alt="codex in IntelliJ IDEA after going back from dark to light" src="https://github.com/user-attachments/assets/fca5c225-7bc3-4dd8-adfc-d7ef6884bea1" />
This is so annoying that one has to restart and resume the session. Pretty disruptive.
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).Oh actually it seems that codex is already doing that https://github.com/openai/codex/issues/16335#issuecomment-4178952724
Which means codex should just refresh the values.