Skip to content

Conversation

ae-openai
Copy link
Collaborator

  • Codex CLI startup slowed to ~1.5 s in Terminal and Ghostty.
  • This was because because Tui::new requested the terminal’s 256-color palette via OSC 4. Trace logging showed the constructor waiting for 1.5s at query_terminal_palette before timing out, since many modern GPU terminals ignore OSC 4/10/11.
  • This is a minimal change that disables those probes, but keeps it easy to bring the back for specific terminals that support it like iTerm or xterm, or with different more performant approach.

- Codex CLI startup slowed to ~1.5 s in Terminal and Ghostty.
- This was because because Tui::new requested the terminal’s
  256-color palette via OSC 4. Trace logging showed the constructor
  waiting for 1.5s at query_terminal_palette before timing out,
  since many modern GPU terminals ignore OSC 4/10/11.
- This is a minimal change that disables those probes, but keeps it
  easy to bring the back for specific terminals that support it
  like iTerm or xterm, or with different more performant approach.
use std::sync::Mutex;
use std::sync::OnceLock;

const TERMINAL_QUERIES_ENABLED: bool = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If query_terminal_palette() is really the issue, then I would rather exit early there.

Rather than categorically disable, we could call:

fn detect_terminal() -> String {

and if that value isn't a "known fast" terminal (like iTerm), then we return Err?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe check if the value from detect_terminal() starts with "iTerm.app" for now?

It's nice not to have unreachable code sitting around.

@bolinfest
Copy link
Collaborator

See #4913 for an example of my proposed changes.

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.

2 participants