Repository navigation
implement terminal_palette for modern Windows Terminal shells. - #4865
iceweasel-oai wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 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
| 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), | ||
| }; |
There was a problem hiding this comment.
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 👍 / 👎.
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.