From b12829db390ed8c2e183c21b644001bd8890530d Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Tue, 18 Aug 2026 15:30:07 -0600 Subject: [PATCH] fix: drain crossterm characters in zellij in kitty contexts to prevent DA1 responses from entering prompt --- .../ses_026efaf26ffe448NpJ40MEYYDx.json | 10 +++++++++ src/config/app_config.rs | 22 +++++++++++-------- src/repl/mod.rs | 8 +++++-- 3 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 .omo/run-continuation/ses_026efaf26ffe448NpJ40MEYYDx.json diff --git a/.omo/run-continuation/ses_026efaf26ffe448NpJ40MEYYDx.json b/.omo/run-continuation/ses_026efaf26ffe448NpJ40MEYYDx.json new file mode 100644 index 0000000..9839d4a --- /dev/null +++ b/.omo/run-continuation/ses_026efaf26ffe448NpJ40MEYYDx.json @@ -0,0 +1,10 @@ +{ + "sessionID": "ses_026efaf26ffe448NpJ40MEYYDx", + "updatedAt": "2026-08-18T01:47:32.627Z", + "sources": { + "background-task": { + "state": "idle", + "updatedAt": "2026-08-18T01:47:32.627Z" + } + } +} \ No newline at end of file diff --git a/src/config/app_config.rs b/src/config/app_config.rs index c3f671e..be85041 100644 --- a/src/config/app_config.rs +++ b/src/config/app_config.rs @@ -1,6 +1,6 @@ use crate::client::{ClientConfig, Model, ModelType, list_models}; use crate::render::{MarkdownRender, RenderOptions}; -use crate::utils::{IS_STDOUT_TERMINAL, NO_COLOR, decode_bin, get_env_name}; +use crate::utils::{IS_STDOUT_TERMINAL, NO_COLOR, decode_bin, drain_stale_tty_input, get_env_name}; use super::paths; use anyhow::{Context, Result, anyhow, bail}; @@ -616,14 +616,18 @@ impl AppConfig { if self.highlight && self.theme.is_none() { if let Some(v) = super::read_env_value::(&get_env_name("theme")) { self.theme = v; - } else if *IS_STDOUT_TERMINAL - && let Ok(color_scheme) = color_scheme(QueryOptions::default()) - { - let theme = match color_scheme { - ColorScheme::Dark => "dark", - ColorScheme::Light => "light", - }; - self.theme = Some(theme.into()); + } else if *IS_STDOUT_TERMINAL { + if let Ok(color_scheme) = color_scheme(QueryOptions::default()) { + let theme = match color_scheme { + ColorScheme::Dark => "dark", + ColorScheme::Light => "light", + }; + self.theme = Some(theme.into()); + } + // The OSC/DA1 reply can arrive after colorsaurus stops reading + // (observed under zellij-in-kitty). Drain any late reply bytes so + // they are neither echoed nor read as line-editor input. + drain_stale_tty_input(); } } if let Some(v) = super::read_env_value::(&get_env_name("left_prompt")) { diff --git a/src/repl/mod.rs b/src/repl/mod.rs index 13d2c50..47e95c0 100644 --- a/src/repl/mod.rs +++ b/src/repl/mod.rs @@ -19,8 +19,8 @@ use crate::config::{AssetCategory, paths}; use crate::function::supervisor::{GuardrailAction, check_pending_agents_guardrail}; use crate::render::render_error; use crate::utils::{ - AbortSignal, SHELL, abortable_run_with_spinner, create_abort_signal, dimmed_text, run_command, - set_text, temp_file, + AbortSignal, SHELL, abortable_run_with_spinner, create_abort_signal, dimmed_text, + drain_stale_tty_input, run_command, set_text, temp_file, }; use crate::sandbox::SANDBOX_ENV_FLAG; @@ -411,6 +411,10 @@ Type ".help" for additional help. } } + // Discard any stray terminal-query reply bytes (e.g. late colorsaurus + // OSC 11 / DA1 responses) so they don't get injected into the prompt. + drain_stale_tty_input(); + loop { if self.abort_signal.aborted_ctrld() { break;