diff --git a/codex-rs/tui/src/chatwidget/slash_dispatch.rs b/codex-rs/tui/src/chatwidget/slash_dispatch.rs index 34adea23e2..63fbd0e3f6 100644 --- a/codex-rs/tui/src/chatwidget/slash_dispatch.rs +++ b/codex-rs/tui/src/chatwidget/slash_dispatch.rs @@ -46,6 +46,7 @@ impl ChatWidget { /// rule as normal text. pub(super) fn handle_slash_command_dispatch(&mut self, cmd: SlashCommand) { let clear_review_draft = cmd == SlashCommand::Review + && (!self.active_side_conversation || cmd.available_in_side_conversation()) && !self.slash_command_blocked_by_active_task(SlashCommand::Review); self.dispatch_command(cmd); if clear_review_draft { diff --git a/codex-rs/tui/src/chatwidget/tests/mcp_startup.rs b/codex-rs/tui/src/chatwidget/tests/mcp_startup.rs index b20918ee90..0d486efc78 100644 --- a/codex-rs/tui/src/chatwidget/tests/mcp_startup.rs +++ b/codex-rs/tui/src/chatwidget/tests/mcp_startup.rs @@ -322,6 +322,26 @@ async fn compact_task_blocks_review_when_mcp_startup_arrives() { assert_eq!(chat.bottom_pane.composer_text(), "/review"); } +#[tokio::test] +async fn side_conversation_rejection_preserves_review_draft_during_mcp_startup() { + let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await; + notify_mcp_status(&mut chat, "alpha", McpServerStartupState::Starting); + chat.set_side_conversation_active(/*active*/ true); + + chat.bottom_pane + .set_composer_text("/review".to_string(), Vec::new(), Vec::new()); + chat.handle_key_event(KeyEvent::new(KeyCode::Esc, KeyModifiers::NONE)); + chat.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE)); + chat.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE)); + + let error = drain_insert_history(&mut rx) + .into_iter() + .map(|lines| lines_to_single_string(&lines)) + .collect::(); + assert!(error.contains("'/review' is unavailable in side conversations.")); + assert_eq!(chat.bottom_pane.composer_text(), "/review"); +} + #[tokio::test] async fn mcp_startup_dedupes_same_round_duplicate_failure_warning() { let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;