diff options
| author | Dillon Mulroy <dillon.mulroy@gmail.com> | 2026-06-15 11:23:24 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-15 18:23:24 +0300 |
| commit | 16b69b6faa3f6de4ff8ae404442be95887370918 (patch) | |
| tree | 33dc8e62fef1daf29265dfc956e8bc0ca30c73d0 /src/app/api_helpers.rs | |
| parent | 9805e23a1225f74bb955b703c9457fdcff1bc952 (diff) | |
fix: support key-combo syntax for API send keys (#613)
Co-authored-by: Can Celik <ogulcancelik@gmail.com>
Diffstat (limited to 'src/app/api_helpers.rs')
| -rw-r--r-- | src/app/api_helpers.rs | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/src/app/api_helpers.rs b/src/app/api_helpers.rs index 1ebb30ef..c07a431d 100644 --- a/src/app/api_helpers.rs +++ b/src/app/api_helpers.rs @@ -9,24 +9,16 @@ pub(super) fn tab_attention_priority(state: crate::detect::AgentState, seen: boo } fn parse_api_key(key: &str) -> Option<crossterm::event::KeyEvent> { - use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; + let normalized = normalize_api_key_alias(key.trim()); + let (code, modifiers) = crate::config::parse_key_combo(normalized)?; + Some(crossterm::event::KeyEvent::new(code, modifiers)) +} - let normalized = key.trim(); - match normalized { - "Enter" | "enter" => Some(KeyEvent::new(KeyCode::Enter, KeyModifiers::empty())), - "Tab" | "tab" => Some(KeyEvent::new(KeyCode::Tab, KeyModifiers::empty())), - "Esc" | "esc" => Some(KeyEvent::new(KeyCode::Esc, KeyModifiers::empty())), - "Backspace" | "backspace" => Some(KeyEvent::new(KeyCode::Backspace, KeyModifiers::empty())), - "Up" | "up" => Some(KeyEvent::new(KeyCode::Up, KeyModifiers::empty())), - "Down" | "down" => Some(KeyEvent::new(KeyCode::Down, KeyModifiers::empty())), - "Left" | "left" => Some(KeyEvent::new(KeyCode::Left, KeyModifiers::empty())), - "Right" | "right" => Some(KeyEvent::new(KeyCode::Right, KeyModifiers::empty())), - "C-c" | "c-c" | "ctrl+c" => Some(KeyEvent::new(KeyCode::Char('c'), KeyModifiers::CONTROL)), - _ if normalized.len() == 1 => normalized - .chars() - .next() - .map(|ch| KeyEvent::new(KeyCode::Char(ch), KeyModifiers::empty())), - _ => None, +fn normalize_api_key_alias(key: &str) -> &str { + match key { + "C-c" | "c-c" => "ctrl+c", + "+" => "plus", + _ => key, } } |
