From 9b33ce34091154c0ce8e6fe8c458ab0c59c37fad Mon Sep 17 00:00:00 2001 From: Jeremy Rose <172423086+nornagon-openai@users.noreply.github.com> Date: Tue, 28 Oct 2025 09:42:57 -0700 Subject: [PATCH] tui: wait longer for color query results (#5004) this bumps the timeout when reading the responses to OSC 10/11 so that we're less likely to pass the deadline halfway through reading the response. --- codex-rs/tui/src/terminal_palette.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/codex-rs/tui/src/terminal_palette.rs b/codex-rs/tui/src/terminal_palette.rs index 05d842d5..f223f3a9 100644 --- a/codex-rs/tui/src/terminal_palette.rs +++ b/codex-rs/tui/src/terminal_palette.rs @@ -96,6 +96,10 @@ mod imp { pub(super) fn requery_default_colors() { if let Ok(mut cache) = default_colors_cache().lock() { + // Don't try to refresh if the cache is already attempted and failed. + if cache.attempted && cache.value.is_none() { + return; + } cache.refresh_with(|| query_default_colors().unwrap_or_default()); } } @@ -114,8 +118,6 @@ mod imp { if !stdout_handle.is_terminal() { return Ok(None); } - stdout_handle.write_all(b"\x1b]10;?\x07\x1b]11;?\x07")?; - stdout_handle.flush()?; let mut tty = match OpenOptions::new().read(true).open("/dev/tty") { Ok(file) => file, @@ -130,7 +132,10 @@ mod imp { } } - let deadline = Instant::now() + Duration::from_millis(200); + stdout_handle.write_all(b"\x1b]10;?\x07\x1b]11;?\x07")?; + stdout_handle.flush()?; + + let mut deadline = Instant::now() + Duration::from_millis(200); let mut buffer = Vec::new(); let mut fg = None; let mut bg = None; @@ -140,6 +145,7 @@ mod imp { match tty.read(&mut chunk) { Ok(0) => break, Ok(n) => { + deadline = Instant::now() + Duration::from_millis(200); buffer.extend_from_slice(&chunk[..n]); if fg.is_none() { fg = parse_osc_color(&buffer, 10);