Skip to content

Refresh composer colours when the terminal switches appearance - #1

Merged
rodchristiansen merged 1 commit into
mainfrom
fix/live-terminal-palette
Oct 31, 2026
Merged

rodchristiansen merged 1 commit into
mainfrom
fix/live-terminal-palette

Conversation

@rodchristiansen

@rodchristiansen rodchristiansen commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

A running Codex session keeps its startup foreground/background palette after a terminal light/dark change. The composer and submitted prompts can therefore retain a light fill after the terminal switches to light text, making the input unreadable. The focus handler intentionally avoids the old synchronous probe because it could block input and discard keys.

Refresh the palette through the existing input owner instead:

  • Use an opt-in crossterm stream that exposes OSC 10/11 replies and DECSET 2031 notifications alongside keyboard and paste events.
  • Subscribe to theme notifications while Codex owns the terminal; refresh on notifications, focus regain, and return from a terminal handoff.
  • Coalesce outstanding queries under a 250 ms deadline and publish only a complete valid foreground/background pair. Missing, malformed, and late replies keep the last good palette and allow later retries.
  • Invalidate rendered-content caches and request a draw when the palette changes, preserving the selected syntax theme and draft input.
  • Disable theme reporting during suspend, external-editor handoff, and terminal restoration.

Dependency: rodchristiansen/crossterm#1. Both Cargo and Bazel lockfiles pin that fork revision. Related upstream reports: openai#54159 and openai#38575.

Validation:

  • cargo check -p codex-tui --tests --locked passed from codex-rs with the pinned Rust 1.95 compiler, without compiler workarounds.
  • 31 focused tests passed in an isolated harness importing the affected Codex event, palette, style, and syntax-highlight source modules. Unrelated host surfaces were stubbed in that harness.
  • Production event/palette/style modules passed a PTY test for both light/dark directions without focus changes, fragmented and reordered replies, immediate typing, bracketed paste containing literal report bytes, timeouts, malformed replies, and recovery on retry. Composer fill changed to RGB 30/30/30 and 244/244/244; typing during an unanswered query took approximately 0.1 ms in the harness.
  • crossterm: 146 tests passed on the default Unix backend and 144 on use-dev-tty, with 7 ignored per run. Final runs used serial execution after an intermittent concurrent failure in the existing colour-formatting tests.
  • Bazel module-lock regeneration and verification, Rust formatting checks, and whitespace checks passed.
  • An optimized macOS arm64 CLI package and both matching helper executables were built and installed locally. The packaged CLI passed an application-level PTY test: the composer changed light → dark → light without focus changes, and draft typing survived an unanswered refresh. Executable signatures and the selected command paths were verified. Source builds report 0.0.0; the installation records commit ec16e6a.
  • The full Codex test suite and interactive cmux verification were not run.

Scope: Unix terminal palette refresh. Already emitted native terminal scrollback is not repainted; the composer and rendered owned-screen content use the updated palette. This PR stays in the fork because upstream's contribution guide does not accept external code PRs. No screenshot or session content is included.

Risk: high — depends on a new public terminal-input API and touches terminal ownership. Leave open for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant