the runtime your coding agents live on
Rust agentagent-orchestrationaiai-agentsclaude-codeclicodexcoding-agentsdeveloper-toolsdevtoolsmultiplexerrustterminalterminal-multiplexerterminal-uitmuxtuiworkspace-manager
fix: accept unicode keybindings
Ogulcan Celik29fd06747b31
diff --git a/docs/next/CHANGELOG.md b/docs/next/CHANGELOG.mdindex 760453ea2..7c9a005cb 100644--- a/docs/next/CHANGELOG.md+++ b/docs/next/CHANGELOG.md@@ -10,6 +10,7 @@- Added named-session reattach and stop command hints so detach and update guidance point back to the active session. (#199, thanks @Golden-Pigeon)### Fixed+- Keybinding parsing now accepts non-ASCII printable keys such as `ö`, `é`, and `ğ`, including UTF-8 Alt chords. (#247)- Kimi Code CLI sessions now use structural terminal detection for approval prompts and live thinking/tool status, improving working and blocked state reporting in the Agents panel. (#215)- Antigravity CLI (`agy`) sessions are now detected, and their terminal UI now reports working and blocked states in the Agents panel. (#207)- Cursor Agent sessions launched as `cursor-agent` are now detected, and their terminal UI now reports working and blocked states in the Agents panel. (#225)diff --git a/src/config/keybinds.rs b/src/config/keybinds.rsindex edd64c90a..014bab7ac 100644--- a/src/config/keybinds.rs+++ b/src/config/keybinds.rs@@ -820,6 +820,7 @@ pub(super) fn parse_key_combo(s: &str) -> Option<KeyCombo> {}let key_str = key_str?;+ let single_char = single_key_char(key_str);let lower = key_str.to_lowercase();let code = match lower.as_str() {"space" | " " => KeyCode::Char(' '),@@ -848,8 +849,8 @@ pub(super) fn parse_key_combo(s: &str) -> Option<KeyCombo> {"ampersand" => KeyCode::Char('&'),"backtick" => KeyCode::Char('`'),"plus" => KeyCode::Char('+'),- s if s.len() == 1 => {- let ch = key_str.chars().next().unwrap();+ _ if single_char.is_some() => {+ let ch = single_char?;if ch.is_ascii_uppercase() {modifiers |= KeyModifiers::SHIFT;KeyCode::Char(ch.to_ascii_lowercase())@@ -864,6 +865,16 @@ pub(super) fn parse_key_combo(s: &str) -> Option<KeyCombo> {Some(normalize_key_combo((code, modifiers)))}+fn single_key_char(s: &str) -> Option<char> {+ let mut chars = s.chars();+ let ch = chars.next()?;+ if chars.next().is_none() {+ Some(ch)+ } else {+ None+ }+}+fn parse_key_combo_with_diagnostic(s: &str,field: &str,@@ -1004,6 +1015,34 @@ mod tests {);}+ #[test]+ fn parse_unicode_char_combo() {+ assert_eq!(+ parse_key_combo("ö"),+ Some((KeyCode::Char('ö'), KeyModifiers::empty()))+ );+ assert_eq!(+ parse_key_combo("alt+é"),+ Some((KeyCode::Char('é'), KeyModifiers::ALT))+ );+ }++ #[test]+ fn unicode_prefix_config_is_valid() {+ let config: Config = toml::from_str(+ r#"+[keys]+prefix = "ö"+"#,+ )+ .unwrap();+ assert_eq!(+ config.prefix_key(),+ (KeyCode::Char('ö'), KeyModifiers::empty())+ );+ assert!(config.collect_diagnostics().is_empty());+ }+#[test]fn parse_shift_tab_as_backtab() {assert_eq!(diff --git a/src/raw_input.rs b/src/raw_input.rsindex fa496b955..d75c6c49a 100644--- a/src/raw_input.rs+++ b/src/raw_input.rs@@ -231,6 +231,11 @@ pub(crate) fn flush_incomplete_input_bytes(buffer: &mut Vec<u8>) -> Option<Vec<ureturn None;}+ if buffer.first() == Some(&ESC) && starts_with_incomplete_utf8_char(&buffer[1..]) {+ tracing::trace!(bytes = ?buffer, "waiting for escaped UTF-8 continuation bytes");+ return None;+ }+tracing::debug!(bytes = ?buffer, "dropping incomplete raw input buffer after timeout");buffer.clear();None@@ -388,7 +393,12 @@ fn complete_escape_sequence_len(buffer: &[u8]) -> Option<usize> {return (buffer.len() >= 3).then_some(3);}- Some(2)+ let escaped_char_width = utf8_char_width(buffer[1])?;+ if buffer.len() < 1 + escaped_char_width {+ return None;+ }+ std::str::from_utf8(&buffer[1..1 + escaped_char_width]).ok()?;+ Some(1 + escaped_char_width)}fn find_osc_terminator(buffer: &[u8]) -> Option<usize> {@@ -1045,6 +1055,41 @@ mod tests {assert!(buffer.is_empty());}+ #[test]+ fn alt_utf8_char_drains_as_one_event_before_following_input() {+ let events = parse_raw_input_bytes_sync("\x1béx".as_bytes());+ assert_eq!(events.len(), 2);+ assert_raw_key(+ events.into_iter().next().unwrap(),+ KeyCode::Char('é'),+ KeyModifiers::ALT,+ );+ }++ #[test]+ fn chunked_alt_utf8_waits_for_continuation_byte_after_escape() {+ let (tx, mut rx) = mpsc::channel(8);+ let mut buffer = Vec::new();+ let bytes = "\x1bé".as_bytes();++ drain_chunk(&mut buffer, &tx, &bytes[..2]);+ assert_eq!(buffer, bytes[..2]);+ assert!(collect_events(&mut rx).is_empty());+ flush_incomplete_buffer(&mut buffer, &tx);+ assert_eq!(buffer, bytes[..2]);+ assert!(collect_events(&mut rx).is_empty());++ drain_chunk(&mut buffer, &tx, &bytes[2..]);+ assert!(buffer.is_empty());+ let events = collect_events(&mut rx);+ assert_eq!(events.len(), 1);+ assert_raw_key(+ events.into_iter().next().unwrap(),+ KeyCode::Char('é'),+ KeyModifiers::ALT,+ );+ }+#[test]fn chunked_utf8_waits_for_continuation_byte() {let (tx, mut rx) = mpsc::channel(8);