Skip to content

implement terminal_palette for modern Windows Terminal shells. - #4865

Closed
iceweasel-oai wants to merge 1 commit into
mainfrom
dev/iceweasel/windows-truecolor
Closed

iceweasel-oai wants to merge 1 commit into
mainfrom
dev/iceweasel/windows-truecolor

Conversation

@iceweasel-oai

Copy link
Copy Markdown
Contributor

External (non-OpenAI) Pull Request Requirements

Before opening this Pull Request, please read the dedicated "Contributing" markdown file or your PR may be closed:
https://github.com/openai/codex/blob/main/docs/contributing.md

If your PR conforms to our contribution guidelines, replace this text with a detailed and high quality description of your changes.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

Comment on lines +71 to +90
fn query_terminal_palette() -> io::Result<Option<[(u8, u8, u8); 256]>> {
if !is_windows_terminal() {
return Ok(None);
}

let mut stdout_handle = io::stdout();
if !stdout_handle.is_terminal() {
return Ok(None);
}

let _output_guard = ConsoleOutputGuard::acquire();
for index in 0..256 {
write!(stdout_handle, "\x1b]4;{index};?\x07")?;
}
stdout_handle.flush()?;

let mut reader = match ConsoleInputReader::new() {
Ok(reader) => reader,
Err(_) => return Ok(None),
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Enable VT input before sending OSC queries

Both query_terminal_palette and query_default_colors emit OSC queries (write!(...) and write_all(...)) before constructing ConsoleInputReader. The reader’s constructor is what flips the console’s input mode to ENABLE_VIRTUAL_TERMINAL_INPUT, so the terminal replies will be parsed by the console using the old mode. Any replies that arrive before the mode switch are translated into regular input events and never appear as raw bytes for ReadFile, causing the functions to time out and cache None even under Windows Terminal. Acquire the ConsoleInputReader (and thus enable virtual terminal input) before sending the queries to ensure responses can be read. This issue is repeated in query_default_colors below.

Useful? React with 👍 / 👎.

@github-actions github-actions Bot locked and limited conversation to collaborators Nov 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants