From 961ed31901b00e60241e54c0b2f1646048473043 Mon Sep 17 00:00:00 2001 From: jif-oai Date: Fri, 10 Oct 2025 15:35:28 +0100 Subject: [PATCH] feat: make shortcut works even with capslock (#5049) Shortcut where not working in caps-lock. Fixing this --- codex-rs/core/tests/suite/shell_serialization.rs | 2 +- codex-rs/tui/src/chatwidget.rs | 12 ++++++------ codex-rs/tui/src/chatwidget/tests.rs | 12 ++++++++++++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/codex-rs/core/tests/suite/shell_serialization.rs b/codex-rs/core/tests/suite/shell_serialization.rs index 67fc2786..fd9c26d8 100644 --- a/codex-rs/core/tests/suite/shell_serialization.rs +++ b/codex-rs/core/tests/suite/shell_serialization.rs @@ -213,7 +213,7 @@ async fn shell_output_reserializes_truncated_content() -> Result<()> { let call_id = "shell-truncated"; let args = json!({ "command": ["/bin/sh", "-c", "seq 1 400"], - "timeout_ms": 1_000, + "timeout_ms": 5_000, }); let responses = vec![ sse(vec![ diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index aeaf239f..787e0980 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -1034,20 +1034,20 @@ impl ChatWidget { pub(crate) fn handle_key_event(&mut self, key_event: KeyEvent) { match key_event { KeyEvent { - code: KeyCode::Char('c'), - modifiers: crossterm::event::KeyModifiers::CONTROL, + code: KeyCode::Char(c), + modifiers, kind: KeyEventKind::Press, .. - } => { + } if modifiers.contains(KeyModifiers::CONTROL) && c.eq_ignore_ascii_case(&'c') => { self.on_ctrl_c(); return; } KeyEvent { - code: KeyCode::Char('v'), - modifiers: KeyModifiers::CONTROL, + code: KeyCode::Char(c), + modifiers, kind: KeyEventKind::Press, .. - } => { + } if modifiers.contains(KeyModifiers::CONTROL) && c.eq_ignore_ascii_case(&'v') => { if let Ok((path, info)) = paste_image_to_temp_png() { self.attach_image(path, info.width, info.height, info.encoded_format.label()); } diff --git a/codex-rs/tui/src/chatwidget/tests.rs b/codex-rs/tui/src/chatwidget/tests.rs index d4cf4c7b..3bfdf243 100644 --- a/codex-rs/tui/src/chatwidget/tests.rs +++ b/codex-rs/tui/src/chatwidget/tests.rs @@ -676,6 +676,18 @@ fn streaming_final_answer_keeps_task_running_state() { assert!(chat.bottom_pane.ctrl_c_quit_hint_visible()); } +#[test] +fn ctrl_c_shutdown_ignores_caps_lock() { + let (mut chat, _rx, mut op_rx) = make_chatwidget_manual(); + + chat.handle_key_event(KeyEvent::new(KeyCode::Char('C'), KeyModifiers::CONTROL)); + + match op_rx.try_recv() { + Ok(Op::Shutdown) => {} + other => panic!("expected Op::Shutdown, got {other:?}"), + } +} + #[test] fn exec_history_cell_shows_working_then_completed() { let (mut chat, mut rx, _op_rx) = make_chatwidget_manual();