Adaptive TUI theme does not refresh after system light/dark changes in running session
Summary
Codex already re-queries terminal default colors on focus regain, but the adaptive syntax theme is not recalculated afterward. As a result, users relying on automatic light/dark theme selection can switch system appearance while Codex is running and still keep the old syntax theme until the session is restarted.
Proposed fix
I have a working branch with a narrow fix here:
- Branch: https://github.com/rushrs/codex/tree/rushrs/auto-theme-on-focus
- Commit: https://github.com/rushrs/codex/commit/95f9e52cd
The change does three things:
- add a helper to reselect the adaptive runtime theme from the current terminal palette
- call it after
requery_default_colors()onFocusGained - leave explicit user-configured
tui.themeoverrides untouched
It also adds a focused unit test for the FocusGained event path.
Why this hook
FocusGained is 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
- terminals that update their reported default colors after a system appearance switch can cause Codex to follow the new appearance without restarting
- users with an explicit
tui.themesetting see no behavior change
Notes
I attempted to open a PR directly from my fork, but openai/codex currently reports pull_request_creation_policy: collaborators_only, so I am filing this issue with the patch link instead.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗