From 10e6bbd7a96e11766e9fa2ee4d0e5f8c54cbbcac Mon Sep 17 00:00:00 2001 From: Alexander Embiricos Date: Tue, 7 Oct 2025 19:02:34 -0700 Subject: [PATCH] fix: tui launch latency by disabling osc probe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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-rs/tui/src/terminal_palette.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/codex-rs/tui/src/terminal_palette.rs b/codex-rs/tui/src/terminal_palette.rs index c35b2cfff4..ac5f6e4b35 100644 --- a/codex-rs/tui/src/terminal_palette.rs +++ b/codex-rs/tui/src/terminal_palette.rs @@ -34,6 +34,8 @@ mod imp { use std::sync::Mutex; use std::sync::OnceLock; + const TERMINAL_QUERIES_ENABLED: bool = false; + struct Cache { attempted: bool, value: Option, @@ -70,6 +72,9 @@ mod imp { } pub(super) fn terminal_palette() -> Option<[(u8, u8, u8); 256]> { + if !TERMINAL_QUERIES_ENABLED { + return None; + } static CACHE: OnceLock> = OnceLock::new(); *CACHE.get_or_init(|| match query_terminal_palette() { Ok(Some(palette)) => Some(palette), @@ -78,12 +83,18 @@ mod imp { } pub(super) fn default_colors() -> Option { + if !TERMINAL_QUERIES_ENABLED { + return None; + } let cache = default_colors_cache(); let mut cache = cache.lock().ok()?; cache.get_or_init_with(|| query_default_colors().unwrap_or_default()) } pub(super) fn requery_default_colors() { + if !TERMINAL_QUERIES_ENABLED { + return; + } if let Ok(mut cache) = default_colors_cache().lock() { cache.refresh_with(|| query_default_colors().unwrap_or_default()); }