Skip to content

fix(tui): guard Windows raw ANSI output - #23723

Closed
fcoury-oai wants to merge 1 commit into
mainfrom
codex/windows-vt-output-hardening
Closed

fcoury-oai wants to merge 1 commit into
mainfrom
codex/windows-vt-output-hardening

Conversation

@fcoury-oai

@fcoury-oai fcoury-oai commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Why

Several Windows reports show Codex TUI control sequences being rendered as visible text instead of being interpreted by the terminal. The affected startup shapes are still not fully pinned down: #23512 narrows one report to repo-conditioned startup, while #23031 and #23628 show the same raw-control-byte symptom in other startup contexts.

The boundary we can harden now is smaller and concrete. When Windows stdout is an inspectable console handle and VT processing is still disabled, raw ANSI-only TUI extras should not emit OSC, synchronized-update, alternate-screen, or inline-history control bytes into the user-visible terminal buffer.

What Changed

  • Added shared Windows stdout VT inspection and enable/verify helpers in codex-terminal-detection.
  • Added a single TUI raw-ANSI capability gate in tui/src/raw_ansi.rs.
  • Verify the Windows stdout VT state before optional startup mode writes, and skip raw ANSI-only title, synchronized-update, alternate-screen, and inline-history paths when inspectable stdout cannot be brought to a VT-enabled state.
  • Preserve existing behavior for stdout handles that cannot be inspected as Windows console handles, so PTY-style paths do not get treated as broken just because console-mode visibility is unavailable.
  • Extend the existing codex doctor terminal details with Windows stdout console-mode visibility and VT-processing state without mutating terminal mode during the doctor run.

When Codex has to degrade, the TUI keeps running on the safer paths and keeps transcript state in the app. The terminal scrollback/history insertion extras are the part that get skipped while Windows stdout VT output is not trustworthy.

How to Test

  1. On Windows Terminal, run codex doctor --json.
  2. Confirm the existing terminal.env details include Windows stdout console-mode visibility plus Windows stdout VT-processing state.
  3. Start Codex from a Git repo and confirm the startup card and composer render normally without literal control-byte text such as ESC]0, ESC[?2026h, or scroll-region escape output.
  4. Start Codex from a directory outside a Git repo and confirm the normal startup path still renders normally.
  5. For the disabled-VT path, use a local harness that forces inspectable Windows stdout VT processing off, then confirm Codex skips raw ANSI-only extras instead of printing title, synchronized-update, or inline-history control bytes. This PR intentionally does not add a production flag for that forced-failure path.

Targeted tests:

  • cargo test -p codex-tui raw_ansi
  • cargo test -p codex-cli terminal_check_reports
  • cargo test -p codex-terminal-detection

@fcoury-oai fcoury-oai changed the title fix(tui): harden Windows VT output fix(tui): guard Windows raw ANSI output May 20, 2026
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 14 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions Bot closed this Jun 4, 2026
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