codex - 💡(How to fix) Fix Adaptive TUI theme does not refresh after system light/dark changes in running session [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#19153Fetched 2026-04-24 05:59:46
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×3closed ×1commented ×1

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.

Root Cause

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.

Fix Action

Fix / Workaround

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.

RAW_BUFFERClick to expand / collapse

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:

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() on FocusGained
  • leave explicit user-configured tui.theme overrides 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.theme setting 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.

extent analysis

TL;DR

To fix the issue where Codex doesn't update its adaptive syntax theme after a system appearance switch, apply the proposed fix from the provided branch, which recalculates the theme on focus regain.

Guidance

  • Review the proposed fix in the auto-theme-on-focus branch and consider applying it to your codebase.
  • Verify that the fix works by switching the system appearance while Codex is running and checking if the syntax theme updates correctly.
  • Test the fix with both automatic light/dark theme selection and explicit tui.theme overrides to ensure no regressions.
  • Consider adding more unit tests to cover different scenarios and ensure the fix is robust.

Example

No code snippet is provided as the issue already includes a link to the proposed fix.

Notes

The proposed fix seems to be a targeted solution that updates the adaptive theme on focus regain, which is a reasonable approach given the existing codebase. However, it's essential to review and test the fix thoroughly to ensure it works as expected and doesn't introduce any regressions.

Recommendation

Apply the workaround by merging the proposed fix from the auto-theme-on-focus branch, as it seems to be a well-thought-out solution that addresses the issue without introducing significant changes.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING