A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.
Rust agentagent-orchestrationaiai-agentsclaude-codecodexcoding-agentlinuxmacosmultiplayermultiplexerrustterminalterminal-emulatorterminal-multiplexertmuxtuiweztermwindows
fix(input): honor restored Kitty keyboard negotiation
RoversX7faf5f340584
diff --git a/term/src/terminalstate/performer.rs b/term/src/terminalstate/performer.rsindex aa53a9fe..ad807496 100644--- a/term/src/terminalstate/performer.rs+++ b/term/src/terminalstate/performer.rs@@ -60,6 +60,16 @@ impl<'a> Drop for Performer<'a> {}impl<'a> Performer<'a> {+ fn kitty_keyboard_enabled(&self) -> bool {+ // Restored terminals may have negotiated Kitty with another owner.+ // Let that session update its flags until it pops the saved state.+ self.config.enable_kitty_keyboard()+ || matches!(+ self.screen().keyboard_stack.last(),+ Some(KeyboardEncoding::Kitty(_))+ )+ }+pub fn new(state: &'a mut TerminalState) -> Self {Self {state,@@ -677,7 +687,7 @@ impl<'a> Performer<'a> {.replace(ParagraphDirectionHint::RightToLeft);}CSI::Keyboard(Keyboard::SetKittyState { flags, mode }) => {- if self.config.enable_kitty_keyboard() {+ if self.kitty_keyboard_enabled() {let current_flags = match self.screen().keyboard_stack.last() {Some(KeyboardEncoding::Kitty(flags)) => *flags,_ => KittyKeyboardFlags::NONE,@@ -694,7 +704,7 @@ impl<'a> Performer<'a> {}}CSI::Keyboard(Keyboard::PushKittyState { flags, mode }) => {- if self.config.enable_kitty_keyboard() {+ if self.kitty_keyboard_enabled() {let current_flags = match self.screen().keyboard_stack.last() {Some(KeyboardEncoding::Kitty(flags)) => *flags,_ => KittyKeyboardFlags::NONE,@@ -717,7 +727,7 @@ impl<'a> Performer<'a> {}}CSI::Keyboard(Keyboard::QueryKittySupport) => {- if self.config.enable_kitty_keyboard() {+ if self.kitty_keyboard_enabled() {let flags = match self.screen().keyboard_stack.last() {Some(KeyboardEncoding::Kitty(flags)) => *flags,_ => KittyKeyboardFlags::NONE,diff --git a/wezterm-gui/src/termwindow/keyevent.rs b/wezterm-gui/src/termwindow/keyevent.rsindex 8c1d6d16..02d690f2 100644--- a/wezterm-gui/src/termwindow/keyevent.rs+++ b/wezterm-gui/src/termwindow/keyevent.rs@@ -11,6 +11,14 @@ use std::sync::Arc;use std::time::{Duration, Instant};use termwiz::input::KeyboardEncoding;+fn encode_negotiated_kitty_input(encoding: KeyboardEncoding, key: &KeyEvent) -> Option<String> {+ if let KeyboardEncoding::Kitty(flags) = encoding {+ Some(key.encode_kitty(flags))+ } else {+ None+ }+}+#[derive(Debug, Clone)]pub struct KeyTableStateEntry {name: String,@@ -214,6 +222,30 @@ mod content_view_key_routing_tests {false));}++ #[test]+ fn an_imported_keyboard_protocol_is_used_without_new_negotiation() {+ use super::*;+ let key = KeyEvent {+ key: KeyCode::Char('a'),+ modifiers: Modifiers::CTRL,+ leds: KeyboardLedStatus::default(),+ repeat_count: 1,+ key_is_down: true,+ raw: None,+ #[cfg(windows)]+ win32_uni_char: None,+ };+ let flags = termwiz::escape::csi::KittyKeyboardFlags::from_bits_truncate(3);+ assert_eq!(+ encode_negotiated_kitty_input(KeyboardEncoding::Kitty(flags), &key),+ Some("\x1b[97;5u".into())+ );+ assert_eq!(+ encode_negotiated_kitty_input(KeyboardEncoding::Xterm, &key),+ None+ );+ }}impl super::TermWindow {@@ -434,14 +466,10 @@ impl super::TermWindow {}fn encode_kitty_input(&self, pane: &Arc<dyn Pane>, key: &KeyEvent) -> Option<String> {- if !self.config.enable_kitty_keyboard {- return None;- }- if let KeyboardEncoding::Kitty(flags) = pane.get_keyboard_encoding() {- Some(key.encode_kitty(flags))- } else {- None- }+ // The owner gates negotiation with enable_kitty_keyboard. A program+ // imported from another terminal has already negotiated its protocol;+ // the frontend must honor that state until the program resets it.+ encode_negotiated_kitty_input(pane.get_keyboard_encoding(), key)}fn lookup_key(