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
Composer text becomes unreadable after live terminal theme switch #14105
Switch the terminal to a light theme without restarting Codex.
Return focus to Codex and keep typing.
Actual
Composer input becomes nearly invisible, effectively white/light text on a white/light background.
Expected
Composer text should stay readable after a terminal theme change.
Suspected cause
The composer background is recomputed from terminal colors, but textarea text is rendered with default/inherited cell styling. After a dark -> light theme switch, stale
foreground styling can remain while the background updates, leaving the input white-on-white.
Root cause:terminal_palette.rs captures the terminal's foreground/background colors at startup (or palette construction time). When the terminal theme changes externally (dark -> light), ratatui widgets that use Color::Reset or no explicit color inherit the new terminal defaults correctly. But the composer input widget in public_widgets/composer_input.rs appears to use explicit or cached foreground colors derived from the original palette, creating a stale-color-on-new-background mismatch.
Relevant files:
codex-rs/tui/src/terminal_palette.rs - initial color capture
codex-rs/tui/src/public_widgets/composer_input.rs - text rendering
codex-rs/tui/src/color.rs and codex-rs/tui/src/style.rs - color/style helpers
codex-rs/tui/src/bottom_pane/list_selection_view.rs - theme picker (syntax highlighting themes, separate concern)
The pattern: Any widget that caches a resolved foreground color from the palette at init time will break on theme switch. The fix needs to address the root (palette staleness), not just the symptom (composer text).
Proposed Fix
Simplest approach: In the composer input widget, use Color::Reset for text foreground instead of a cached color value. This delegates color choice to the terminal, which always reflects the current theme. This is the lowest-risk fix and matches how most ratatui apps handle default text colors.
More robust approach: Detect terminal theme changes via OSC 10/11 escape sequences (query terminal fg/bg colors) on each draw cycle or on SIGWINCH. If the resolved colors differ from the cached palette, rebuild the palette. This would fix the issue for all widgets, not just the composer.
The simpler Color::Reset approach is probably right for a first fix - it solves the reported problem with minimal blast radius. Happy to submit a PR if invited.
Working automatic reference implementation covering this repro is posted here: #38575 (comment)
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.
Additional reproduction on Codex CLI 0.154.0 (macOS arm64), observed while switching the terminal palette in Superset 1.27.0. Full RGB and syntax highlighting must remain enabled.
In a controlled real-PTY replay of light → dark → light, the unmodified release issued OSC 11 background queries [1, 0, 0] across the three phases. Its message background stayed at the light-derived RGB (244,244,244) during the dark phase. This reproduces without depending on a host focus transition.
A local experimental Unix patch, based on release commit 6b9826e3aa83b1a5947db50f4332cb9c65f1b340, periodically re-queries OSC 10/11 using the existing bounded probe and invalidates the viewport and rendering caches only when the RGB pair changes. Missing replies retain the last good palette and trigger a longer backoff. The event reader is paused during the query and consumed user input is replayed through the existing parser, including timeout/error paths.
The candidate passed same-process light → dark → light checks for composer, diff preview, and unsaved syntax-theme preview. Message backgrounds changed (244,244,244) → (64,65,60) → (244,244,244). A Unicode bracketed paste interleaved with the OSC response remained intact. Explicit syntax themes and unsaved previews were preserved; automatic theme reconciliation was deferred until the popup closed.
Two implementation pitfalls worth covering in any upstream fix:
OSC probing must preserve interleaved keyboard/paste input, including missing replies.
Restoring the configured syntax theme during a live palette change can silently overwrite an unsaved /theme preview.
All five added Rust regression tests passed. The full TUI suite was not entirely green: 34 failures also reproduced with the patch removed; seven additional failures/timeouts under load passed when rerun in isolation. This is experimental local evidence, not a claim of an upstream-approved solution. DECSET 2031 support would provide event-driven notification in supporting terminals; a fallback still matters for hosts that only answer OSC queries.
Closing as a duplicate of #45163, which tracks the same unreadable composer after a live terminal theme change and explains the current startup-only palette cache. It is still unresolved there; no fix is being claimed.
Activity
mvanhorn commentedon Mar 10, 2026
Analysis & Root Cause
I traced the rendering path through the TUI code.
Root cause:
terminal_palette.rscaptures the terminal's foreground/background colors at startup (or palette construction time). When the terminal theme changes externally (dark -> light), ratatui widgets that useColor::Resetor no explicit color inherit the new terminal defaults correctly. But the composer input widget inpublic_widgets/composer_input.rsappears to use explicit or cached foreground colors derived from the original palette, creating a stale-color-on-new-background mismatch.Relevant files:
codex-rs/tui/src/terminal_palette.rs- initial color capturecodex-rs/tui/src/public_widgets/composer_input.rs- text renderingcodex-rs/tui/src/color.rsandcodex-rs/tui/src/style.rs- color/style helperscodex-rs/tui/src/bottom_pane/list_selection_view.rs- theme picker (syntax highlighting themes, separate concern)The pattern: Any widget that caches a resolved foreground color from the palette at init time will break on theme switch. The fix needs to address the root (palette staleness), not just the symptom (composer text).
Proposed Fix
Simplest approach: In the composer input widget, use
Color::Resetfor text foreground instead of a cached color value. This delegates color choice to the terminal, which always reflects the current theme. This is the lowest-risk fix and matches how most ratatui apps handle default text colors.More robust approach: Detect terminal theme changes via OSC 10/11 escape sequences (query terminal fg/bg colors) on each draw cycle or on SIGWINCH. If the resolved colors differ from the cached palette, rebuild the palette. This would fix the issue for all widgets, not just the composer.
The simpler
Color::Resetapproach is probably right for a first fix - it solves the reported problem with minimal blast radius. Happy to submit a PR if invited.ctbeiser commentedon Aug 13, 2026
I can confirm this is still extant. It's particularly a problem if you have long running tasks and use auto-light mode.
piotrostr commentedon Aug 26, 2026
Working automatic reference implementation covering this repro is posted here: #38575 (comment)
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
lubosxyz commentedon Sep 10, 2026
Additional reproduction on Codex CLI 0.154.0 (macOS arm64), observed while switching the terminal palette in Superset 1.27.0. Full RGB and syntax highlighting must remain enabled.
In a controlled real-PTY replay of light → dark → light, the unmodified release issued OSC 11 background queries
[1, 0, 0]across the three phases. Its message background stayed at the light-derived RGB(244,244,244)during the dark phase. This reproduces without depending on a host focus transition.A local experimental Unix patch, based on release commit
6b9826e3aa83b1a5947db50f4332cb9c65f1b340, periodically re-queries OSC 10/11 using the existing bounded probe and invalidates the viewport and rendering caches only when the RGB pair changes. Missing replies retain the last good palette and trigger a longer backoff. The event reader is paused during the query and consumed user input is replayed through the existing parser, including timeout/error paths.The candidate passed same-process light → dark → light checks for composer, diff preview, and unsaved syntax-theme preview. Message backgrounds changed
(244,244,244)→(64,65,60)→(244,244,244). A Unicode bracketed paste interleaved with the OSC response remained intact. Explicit syntax themes and unsaved previews were preserved; automatic theme reconciliation was deferred until the popup closed.Two implementation pitfalls worth covering in any upstream fix:
/themepreview.All five added Rust regression tests passed. The full TUI suite was not entirely green: 34 failures also reproduced with the patch removed; seven additional failures/timeouts under load passed when rerun in isolation. This is experimental local evidence, not a claim of an upstream-approved solution. DECSET 2031 support would provide event-driven notification in supporting terminals; a fallback still matters for hosts that only answer OSC queries.
⌘ codex & lubosxyz
etraut-openai commentedon Oct 12, 2026
(response from codex)
Closing as a duplicate of #45163, which tracks the same unreadable composer after a live terminal theme change and explains the current startup-only palette cache. It is still unresolved there; no fix is being claimed.