Input box remain dark after the system theme turn to light
Open 💬 10 comments Opened Apr 22, 2026 by cynicalight
💡 Likely answer: A maintainer (github-actions[bot], contributor)
responded on this thread — see the highlighted reply below.
What version of Codex CLI is running?
0.122.0
What subscription do you have?
plus
Which model were you using?
gpt-5.4
What platform is your computer?
Darwin 25.3.0 arm64 arm
What terminal emulator and version are you using (if applicable)?
Ghostty + Tmux
What issue are you seeing?
After the system switch to light theme in another day morning, the input box of the codex cli is still in dark mode(last night is in dark mode). I have to /exit codex and reopen it again, the input box turns to light theme.
What steps can reproduce the bug?
- Switch to dark mode in mac, and open codex:
<img width="701" height="168" alt="Image" src="https://github.com/user-attachments/assets/20ed7b47-eb3f-41a6-945f-d64ad51405be" />
- then switch to light mode, and you will see the input box stay dark:
<img width="724" height="295" alt="Image" src="https://github.com/user-attachments/assets/c3c46d45-02a9-4cff-888b-c390d3de96a4" />
What is the expected behavior?
_No response_
Additional information
_No response_
10 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Proposed fix
I have a working branch with a narrow fix here:
The change does three things:
requery_default_colors()onFocusGainedtui.themeoverrides untouchedIt also adds a focused unit test for the
FocusGainedevent path.Why this hook
FocusGainedis already where Codex refreshes its view of the terminal palette, so it is the least invasive place to update the adaptive theme as well. This keeps the work off the render hot path and only runs when the terminal returns focus.User impact
tui.themesetting see no behavior changeany updates?
Same here, also with ghostty + tmux.
This one is a real bummer, sometimes quitting and reopening fixes it, but mostly does not, opening a new session also doesn't fix it.
Still reproducible on
codex-cli 0.147.0(macOS arm64), and the cause onmainis now different from the one this issue was filed against.The re-query was removed.
codex-rs/tui/src/tui/event_stream.rs:274now does:So the terminal's default colors are read exactly once, by the startup probe in
codex-rs/tui/src/terminal_probe.rs(100 ms deadline), cached in aOnceLockincodex-rs/tui/src/terminal_palette.rs, and never refreshed for the life of the process. That makes the stale input box permanent in every terminal, not only after an OS appearance switch.Measurement. I ran
codexunder a PTY harness that plays the host terminal and answersOSC 10/11, then counted the queries in the raw output:| what the harness did |
ESC]10;?|ESC]11;?|ESC[?2031h| composer background emitted || --- | --- | --- | --- | --- |
| answer
rgb:2828/2a2a/3636| 1 | 1 | never |ESC[48;2;65;67;78m|| answer
rgb:ffff/ffff/ffff| 1 | 1 | never |ESC[48;2;244;244;244m|| answer 250 ms late | 1 | 1 | never | none |
| answer nothing | 1 | 1 | never | none |
| answer, then send
ESC[OandESC[Iat t+8s | 1 | 1 | never |ESC[48;2;65;67;78m|Codex enables focus reporting (
ESC[?1004h) and the harness writesESC[Ito its input, and no second query appears. The composer background isuser_message_bg_rgbincodex-rs/tui/src/style.rs, blended from the one cached value.Repro without touching OS appearance. Start codex in a terminal whose theme is light, then switch that terminal to a dark theme. The composer keeps the light background while the text is drawn in the new light foreground, so the input line becomes unreadable. My case was Warp: it answers
ESC]11;?with the active theme's background, and I changed themes 20 minutes into a session.Suggested fix that does not reintroduce the blocking probe. Send
ESC[?2031hat startup and update the cached palette when the terminal pushesCSI ?997;1n(dark) orCSI ?997;2n(light). That is push-based, so it costs nothing on the input loop, and it avoids theFocusGainedfreeze reported in #33037. Terminals that do not implement mode 2031 simply keep today's behavior.Note for triage: #37298 proposes fixing
requery_default_colors(), but that function no longer exists onmain.I’ve implemented and tested a reference fix for this:
on
FocusGainedCodex sends non-blocking OSC 10/11 queries. Responses are consumed through the existing CrosstermEventStream, avoiding a competing terminal reader and preserving input typed during the refresh. Once both colors arrive Codex updates the cached palette and redraws the TUI.my reference fix branch:
https://github.com/dandandy/codex/tree/fix/live-terminal-palette-refresh
crossterm dependency PR:
https://github.com/openai-oss-forks/crossterm/pull/1
Validation:
just test -p codex-tui— 3,447 tests passed, including PTY coverage confirming that palette queries occur when focus returns and immediate input is not lost.I’m happy to open a Codex PR if I can get an to invite to contribute
Independent reproduction on
codex-cli 0.147.0(macOS arm64), in a bare PTY with no tmux, no SSH and no terminal emulator in the path. This corroborates @duc-cloudthinker's reading ofevent_stream.rs:274and separates this from the failure modes in #23489 and #37298.The harness answers OSC 10/11 immediately (microseconds, far inside the 100 ms deadline), then changes the terminal's colours and sends a focus transition:
Three things that pins down:
#101060produces a composer plate of#2C2C73, derived from that answer. So the startup probe succeeded and the cache holds a correct value. This is not #37298 (a failed probe overwriting a good value) and not #23489 (a probe that times out). The palette is right and simply never read again.ZQZwritten to the same fd right after theCSI Icomes back echoed by the TUI. So the bytes arrive;FocusGainedis received and deliberately ignored.Repro, no dependencies, works against any build:
One note for whoever picks up @dandandy's branch: restoring the re-query on
FocusGaineddoes not cover terminals whose theme is application-owned rather than OS-owned. Changing the theme in a focused window produces no focus transition at all, so the composer stays stale while the window never loses focus. DECSET 2031 is the mechanism designed for exactly that, and Codex does not set it today (stringson the 0.147.0 binary contains no 2031). Filed separately as #38575.Codex CLI: 0.149.0
Platform: macOS
Behavior:
When macOS automatically switches from light mode to dark mode at night,
an already-running Codex CLI session does not refresh the TUI theme correctly.
The composer/input area becomes a large white/light block, while the typed text
is effectively invisible because of the foreground/background color conflict.
This happens reproducibly every night when macOS automatically changes appearance.
Workaround:
codex resume <session-id>Important:
The underlying Terminal renders correctly after the macOS appearance switch.
Only the already-running Codex TUI is affected.
Expected behavior:
Codex CLI should detect macOS/terminal appearance changes while running and
refresh the TUI palette automatically, without requiring the user to restart
the session.
<img width="1074" height="127" alt="Image" src="https://github.com/user-attachments/assets/f9aa595b-0c08-4737-89b0-28b725ecc987" />
another data point ruling out the terminal side: this repros in programa (libghostty-based terminal). when macos auto-switches between light and dark, the terminal swaps its default bg/fg immediately and emits the mode 2031 color scheme report, so the background under codex follows the new theme right away. codex keeps painting the palette it detected at startup, so after a dark to light flip you get light gray text on a light background, close to unreadable.
claude code running in the same terminal is unaffected because it draws with terminal defaults / ansi indices instead of fixed rgb.
subscribing to mode 2031 (
CSI ? 2031 hand handling the unsolicited DSR report) or re-running theme detection when it arrives would fix live switching without needing a restart.Working automatic reference implementation covering this repro is posted here: https://github.com/openai/codex/issues/38575#issuecomment-5425261944
It includes both live DEC mode 2031 refresh and the stale composer foreground fix. Validated on Ghostty 1.2.3 through tmux 3.6a. No command or config surface.
~ codex & piotr