From 4b478b593fe4133b169d9648cb6cdcd0ce610cd8 Mon Sep 17 00:00:00 2001 From: Felipe Coury Date: Wed, 22 Apr 2026 13:28:29 -0300 Subject: [PATCH] fix(tui): resolve keymap rebase fallout --- codex-rs/tui/src/app/event_dispatch.rs | 3 +- codex-rs/tui/src/app/tests.rs | 6 ++++ codex-rs/tui/src/bottom_pane/chat_composer.rs | 33 +++++++++---------- ...__tests__footer_mode_shortcut_overlay.snap | 2 +- ...shortcuts_collaboration_modes_enabled.snap | 3 +- ...tests__footer_shortcuts_shift_and_esc.snap | 2 +- codex-rs/tui/src/chatwidget/slash_dispatch.rs | 2 ++ 7 files changed, 29 insertions(+), 22 deletions(-) diff --git a/codex-rs/tui/src/app/event_dispatch.rs b/codex-rs/tui/src/app/event_dispatch.rs index 843c6c04a9..b9d3754df2 100644 --- a/codex-rs/tui/src/app/event_dispatch.rs +++ b/codex-rs/tui/src/app/event_dispatch.rs @@ -1667,7 +1667,8 @@ impl App { key, intent, } => { - self.apply_keymap_capture(context, action, key, intent).await; + self.apply_keymap_capture(context, action, key, intent) + .await; } AppEvent::KeymapCleared { context, action } => { self.apply_keymap_clear(context, action).await; diff --git a/codex-rs/tui/src/app/tests.rs b/codex-rs/tui/src/app/tests.rs index 34b5a58abe..a14030c7eb 100644 --- a/codex-rs/tui/src/app/tests.rs +++ b/codex-rs/tui/src/app/tests.rs @@ -3630,6 +3630,8 @@ async fn make_test_app() -> App { let file_search = FileSearchManager::new(config.cwd.to_path_buf(), app_event_tx.clone()); let model = crate::legacy_core::test_support::get_model_offline(config.model.as_deref()); let session_telemetry = test_session_telemetry(&config, model.as_str()); + let keymap = RuntimeKeymap::from_config(&config.tui_keymap) + .expect("test config should always produce a valid runtime keymap"); App { model_catalog: chat_widget.model_catalog(), @@ -3643,6 +3645,7 @@ async fn make_test_app() -> App { runtime_approval_policy_override: None, runtime_sandbox_policy_override: None, file_search, + keymap, transcript_cells: Vec::new(), overlay: None, deferred_history_lines: Vec::new(), @@ -3686,6 +3689,8 @@ async fn make_test_app_with_channels() -> ( let file_search = FileSearchManager::new(config.cwd.to_path_buf(), app_event_tx.clone()); let model = crate::legacy_core::test_support::get_model_offline(config.model.as_deref()); let session_telemetry = test_session_telemetry(&config, model.as_str()); + let keymap = RuntimeKeymap::from_config(&config.tui_keymap) + .expect("test config should always produce a valid runtime keymap"); ( App { @@ -3700,6 +3705,7 @@ async fn make_test_app_with_channels() -> ( runtime_approval_policy_override: None, runtime_sandbox_policy_override: None, file_search, + keymap, transcript_cells: Vec::new(), overlay: None, deferred_history_lines: Vec::new(), diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rs index 7d99e67122..e66381e920 100644 --- a/codex-rs/tui/src/bottom_pane/chat_composer.rs +++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs @@ -4094,24 +4094,23 @@ impl ChatComposer { show_queue_hint, ) }; - let right_line = if let Some(label) = - self.side_conversation_context_label.as_ref() - { - Some(side_conversation_context_line(label)) - } else if let Some(line) = self.shell_mode_footer_line() { - Some(line) - } else if status_line_active { - let full = self.mode_indicator_line(show_cycle_hint); - let compact = self.mode_indicator_line(/*show_cycle_hint*/ false); - let full_width = full.as_ref().map(|l| l.width() as u16).unwrap_or(0); - if can_show_left_with_context(hint_rect, left_width, full_width) { - full + let right_line = + if let Some(label) = self.side_conversation_context_label.as_ref() { + Some(side_conversation_context_line(label)) + } else if let Some(line) = self.shell_mode_footer_line() { + Some(line) + } else if status_line_active { + let full = self.mode_indicator_line(show_cycle_hint); + let compact = self.mode_indicator_line(/*show_cycle_hint*/ false); + let full_width = full.as_ref().map(|l| l.width() as u16).unwrap_or(0); + if can_show_left_with_context(hint_rect, left_width, full_width) { + full + } else { + compact + } } else { - compact - } - } else { - Some(self.right_footer_line_with_context()) - }; + Some(self.right_footer_line_with_context()) + }; let right_width = right_line.as_ref().map(|l| l.width() as u16).unwrap_or(0); if status_line_active && let Some(max_left) = max_left_width_for_right(hint_rect, right_width) diff --git a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__footer_mode_shortcut_overlay.snap b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__footer_mode_shortcut_overlay.snap index 6ab0483570..0186176b15 100644 --- a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__footer_mode_shortcut_overlay.snap +++ b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__footer_mode_shortcut_overlay.snap @@ -16,6 +16,6 @@ expression: terminal.backend() " ctrl + g to edit in external editor esc again to edit previous message " " ctrl + r search history ctrl + c to exit " " ⌥ + , reasoning down ⌥ + . reasoning up " -" ctrl + t to view transcript " +" ctrl + t to view transcript " " " " [tui.keymap] customize shortcuts in ~/.codex/config.toml " diff --git a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__footer__tests__footer_shortcuts_collaboration_modes_enabled.snap b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__footer__tests__footer_shortcuts_collaboration_modes_enabled.snap index 3deaf79f3d..a29f3c635d 100644 --- a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__footer__tests__footer_shortcuts_collaboration_modes_enabled.snap +++ b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__footer__tests__footer_shortcuts_collaboration_modes_enabled.snap @@ -8,7 +8,6 @@ expression: terminal.backend() " ctrl + g to edit in external editor esc esc to edit previous message " " ctrl + r search history ctrl + c to exit " " ⌥ + , reasoning down ⌥ + . reasoning up " -" shift + tab to change mode " -" ctrl + t to view transcript " +" shift + tab to change mode ctrl + t to view transcript " " " " [tui.keymap] customize shortcuts in ~/.codex/config.toml " diff --git a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__footer__tests__footer_shortcuts_shift_and_esc.snap b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__footer__tests__footer_shortcuts_shift_and_esc.snap index 35583087f6..13783abced 100644 --- a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__footer__tests__footer_shortcuts_shift_and_esc.snap +++ b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__footer__tests__footer_shortcuts_shift_and_esc.snap @@ -8,6 +8,6 @@ expression: terminal.backend() " ctrl + g to edit in external editor esc again to edit previous message " " ctrl + r search history ctrl + c to exit " " ⌥ + , reasoning down ⌥ + . reasoning up " -" ctrl + t to view transcript " +" ctrl + t to view transcript " " " " [tui.keymap] customize shortcuts in ~/.codex/config.toml " diff --git a/codex-rs/tui/src/chatwidget/slash_dispatch.rs b/codex-rs/tui/src/chatwidget/slash_dispatch.rs index 490d9f5d1e..7bdbdfc376 100644 --- a/codex-rs/tui/src/chatwidget/slash_dispatch.rs +++ b/codex-rs/tui/src/chatwidget/slash_dispatch.rs @@ -736,6 +736,7 @@ impl ChatWidget { | SlashCommand::Rollout | SlashCommand::Copy | SlashCommand::Diff + | SlashCommand::Vim | SlashCommand::Rename | SlashCommand::TestApproval => QueueDrain::Continue, SlashCommand::Feedback @@ -768,6 +769,7 @@ impl ChatWidget { | SlashCommand::Skills | SlashCommand::Title | SlashCommand::Statusline + | SlashCommand::Keymap | SlashCommand::Theme => QueueDrain::Stop, } }