fix: drain crossterm characters in zellij in kitty contexts to prevent DA1 responses from entering prompt

This commit is contained in:
2026-08-18 15:30:07 -06:00
parent dffaf6b9db
commit b12829db39
3 changed files with 29 additions and 11 deletions
@@ -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"
}
}
}
+13 -9
View File
@@ -1,6 +1,6 @@
use crate::client::{ClientConfig, Model, ModelType, list_models}; use crate::client::{ClientConfig, Model, ModelType, list_models};
use crate::render::{MarkdownRender, RenderOptions}; 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 super::paths;
use anyhow::{Context, Result, anyhow, bail}; use anyhow::{Context, Result, anyhow, bail};
@@ -616,14 +616,18 @@ impl AppConfig {
if self.highlight && self.theme.is_none() { if self.highlight && self.theme.is_none() {
if let Some(v) = super::read_env_value::<String>(&get_env_name("theme")) { if let Some(v) = super::read_env_value::<String>(&get_env_name("theme")) {
self.theme = v; self.theme = v;
} else if *IS_STDOUT_TERMINAL } else if *IS_STDOUT_TERMINAL {
&& let Ok(color_scheme) = color_scheme(QueryOptions::default()) if let Ok(color_scheme) = color_scheme(QueryOptions::default()) {
{ let theme = match color_scheme {
let theme = match color_scheme { ColorScheme::Dark => "dark",
ColorScheme::Dark => "dark", ColorScheme::Light => "light",
ColorScheme::Light => "light", };
}; self.theme = Some(theme.into());
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::<String>(&get_env_name("left_prompt")) { if let Some(v) = super::read_env_value::<String>(&get_env_name("left_prompt")) {
+6 -2
View File
@@ -19,8 +19,8 @@ use crate::config::{AssetCategory, paths};
use crate::function::supervisor::{GuardrailAction, check_pending_agents_guardrail}; use crate::function::supervisor::{GuardrailAction, check_pending_agents_guardrail};
use crate::render::render_error; use crate::render::render_error;
use crate::utils::{ use crate::utils::{
AbortSignal, SHELL, abortable_run_with_spinner, create_abort_signal, dimmed_text, run_command, AbortSignal, SHELL, abortable_run_with_spinner, create_abort_signal, dimmed_text,
set_text, temp_file, drain_stale_tty_input, run_command, set_text, temp_file,
}; };
use crate::sandbox::SANDBOX_ENV_FLAG; 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 { loop {
if self.abort_signal.aborted_ctrld() { if self.abort_signal.aborted_ctrld() {
break; break;