the runtime your coding agents live on
Rust agentagent-orchestrationaiai-agentsclaude-codeclicodexcoding-agentsdeveloper-toolsdevtoolsmultiplexerrustterminalterminal-multiplexerterminal-uitmuxtuiworkspace-manager
fix: run prefix bindings for plain text from kitty terminals (#5277)
Can Celikf53f92dd40d5
diff --git a/src/client/shell/input.rs b/src/client/shell/input.rsindex e3a801cf8..ee92d5909 100644--- a/src/client/shell/input.rs+++ b/src/client/shell/input.rs@@ -112,8 +112,15 @@ impl ClientShellState {/// so any plain text is a commit (kitty sends those as text too). A legacy/// host sends both as plain text; non-ASCII text has no key in the/// keyboard model, so only that is treated as a commit there.+ /// Only text bound for the focused pane is a commit. In prefix, navigate+ /// and other Herdr-owned input, plain text is still a key that may run a+ /// binding (#5255).fn host_text_commit(&self, key: &crate::input::TerminalKey) -> Option<String> {- if !self.host_reports_all_keys || key.kind != KeyEventKind::Press {+ if !self.host_reports_all_keys+ || key.kind != KeyEventKind::Press+ || self.mode != ClientShellMode::Terminal+ || self.overlay.is_some()+ {return None;}let plain_text = keydiff --git a/src/client/shell/tests/input.rs b/src/client/shell/tests/input.rsindex 1b15bf6f0..8b817d0ae 100644--- a/src/client/shell/tests/input.rs+++ b/src/client/shell/tests/input.rs@@ -958,3 +958,96 @@ fn every_configured_prefix_enters_prefix_mode() {assert_eq!(state.mode, ClientShellMode::Terminal);}}++fn pane_text_commits(outcome: &ClientShellInput) -> Vec<String> {+ outcome+ .requests+ .iter()+ .filter_map(|request| match request {+ ClientMessage::ClientShellPaneInput { events, .. } => Some(events),+ _ => None,+ })+ .flatten()+ .filter_map(|event| match event {+ ClientPaneInputEvent::TextCommit(text) => Some(text.clone()),+ _ => None,+ })+ .collect()+}++/// A Kitty host that Herdr switched to report-all for prefix or navigate+/// mode. Plain text can still arrive: Tern ignores report-all, IMEs commit+/// text, and Ghostty `text:` binds type their bytes (#5255).+fn report_all_kitty_host_state(snapshot: crate::protocol::ClientShellSnapshot) -> ClientShellState {+ let mut state = ClientShellState::new(ClientShellConfig::from_config(&Config::default()));+ state.set_host_reports_key_releases(true);+ state.set_host_reports_all_keys(true);+ state.set_snapshot(Box::new(snapshot));+ state.set_pane_surface(surface());+ state+}++#[test]+fn plain_text_after_the_prefix_runs_the_prefix_binding_on_a_report_all_host() {+ // Prefix as a key report, then a plain `q` (Tern, IME commit).+ let mut state = report_all_kitty_host_state(snapshot());+ let _ = state.handle_input_bytes(b"\x1b[98;5u");+ assert_eq!(state.mode, ClientShellMode::Prefix);+ let detach = state.handle_input_bytes(b"q");+ assert!(detach.detach, "plain q after a reported prefix must detach");+ assert!(pane_text_commits(&detach).is_empty());++ // Raw prefix byte and the key in one write (Ghostty `text:` bind).+ let mut state = report_all_kitty_host_state(snapshot());+ let detach = state.handle_input_bytes(b"\x02q");+ assert!(detach.detach, "one-write ^B q must detach");+ assert!(pane_text_commits(&detach).is_empty());+}++#[test]+fn plain_text_in_navigate_mode_runs_the_navigate_binding_on_a_report_all_host() {+ let mut snapshot = snapshot();+ let mut second = snapshot.workspaces[0].clone();+ second.workspace_id = "ws_2".into();+ second.number = 2;+ second.label = "second".into();+ second.focused = false;+ snapshot.workspaces.push(second);+ let mut state = report_all_kitty_host_state(snapshot);++ let _ = state.handle_input_bytes(b"\x1b[98;5u");+ let _ = state.handle_input_bytes(b"\x1b[119u");+ assert_eq!(state.mode, ClientShellMode::Navigate);+ let jump = state.handle_input_bytes(b"2");+ assert!(+ jump.actions.iter().any(|action| matches!(+ action,+ ClientShellAction::Endpoint { request, .. }+ if matches!(+ &request.method,+ crate::api::schema::Method::WorkspaceFocus(target)+ if target.workspace_id == "ws_2"+ )+ )),+ "plain 2 in navigate mode must focus workspace 2"+ );+}++#[test]+fn committed_text_still_reaches_a_report_all_pane_as_text() {+ // The #5017 behavior #5255 must keep: in a pane that asked for every key,+ // IME and compose commits arrive as text, not invented key reports.+ let mut state = report_all_kitty_host_state(snapshot());+ assert_eq!(state.mode, ClientShellMode::Terminal);+ let cjk = state.handle_input_bytes("\u{4f60}\u{597d}".as_bytes());+ assert_eq!(pane_text_commits(&cjk).concat(), "\u{4f60}\u{597d}");+ let ascii = state.handle_input_bytes(b"n");+ assert_eq!(pane_text_commits(&ascii), ["n"]);++ // And after leaving prefix mode the pane gets text commits again.+ let _ = state.handle_input_bytes(b"\x1b[98;5u");+ let _ = state.handle_input_bytes(b"\x1b");+ assert_eq!(state.mode, ClientShellMode::Terminal);+ let after = state.handle_input_bytes("\u{3042}".as_bytes());+ assert_eq!(pane_text_commits(&after).concat(), "\u{3042}");+}diff --git a/src/client/shell/tests/text_editing.rs b/src/client/shell/tests/text_editing.rsindex 118a606ea..f3db057ec 100644--- a/src/client/shell/tests/text_editing.rs+++ b/src/client/shell/tests/text_editing.rs@@ -393,3 +393,22 @@ fn every_field_renders_long_unicode_across_resize_without_mutation() {}}}++#[test]+fn plain_and_ime_text_fill_every_field_on_a_report_all_host() {+ // #5255: a report-all pane under a Kitty host still lets plain bytes and+ // IME commits type into Herdr's own fields.+ for field in 0..10 {+ let mut state = shell(field);+ state.set_host_reports_key_releases(true);+ state.set_host_reports_all_keys(true);+ *editor(&mut state) = TextEditor::default();+ let result = state.handle_input_bytes("x\u{4f60}\u{597d}".as_bytes());+ assert!(result.requests.is_empty(), "field {field}");+ assert_eq!(+ editor(&mut state).as_str(),+ "x\u{4f60}\u{597d}",+ "field {field}"+ );+ }+}