mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Preserve blocked review drafts
This commit is contained in:
@@ -2904,9 +2904,13 @@ impl ChatComposer {
|
||||
self.record_pending_slash_command_history();
|
||||
return Some(InputResult::None);
|
||||
}
|
||||
let preserve_review_draft = self.is_task_running
|
||||
&& matches!(command, SlashCommandItem::Builtin(SlashCommand::Review));
|
||||
self.stage_slash_command_history(&command);
|
||||
self.draft.textarea.set_text_clearing_elements("");
|
||||
self.draft.is_bash_mode = false;
|
||||
if !preserve_review_draft {
|
||||
self.draft.textarea.set_text_clearing_elements("");
|
||||
self.draft.is_bash_mode = false;
|
||||
}
|
||||
Some(match command {
|
||||
SlashCommandItem::Builtin(cmd) => InputResult::Command(cmd),
|
||||
SlashCommandItem::ServiceTier(command) => InputResult::ServiceTierCommand(command),
|
||||
|
||||
@@ -360,8 +360,12 @@ impl ChatComposer {
|
||||
}
|
||||
|
||||
self.stage_selected_slash_command_history(&sel);
|
||||
self.draft.textarea.set_text_clearing_elements("");
|
||||
self.draft.is_bash_mode = false;
|
||||
let preserve_review_draft = self.is_task_running
|
||||
&& matches!(sel, CommandItem::Builtin(SlashCommand::Review));
|
||||
if !preserve_review_draft {
|
||||
self.draft.textarea.set_text_clearing_elements("");
|
||||
self.draft.is_bash_mode = false;
|
||||
}
|
||||
return (
|
||||
match sel {
|
||||
CommandItem::Builtin(cmd) => InputResult::Command(cmd),
|
||||
|
||||
@@ -45,7 +45,13 @@ impl ChatWidget {
|
||||
/// that staged entry after dispatch so slash-command recall follows the same "submitted input"
|
||||
/// rule as normal text.
|
||||
pub(super) fn handle_slash_command_dispatch(&mut self, cmd: SlashCommand) {
|
||||
let clear_review_draft = cmd == SlashCommand::Review
|
||||
&& !self.slash_command_blocked_by_active_task(SlashCommand::Review);
|
||||
self.dispatch_command(cmd);
|
||||
if clear_review_draft {
|
||||
self.bottom_pane
|
||||
.set_composer_text(String::new(), Vec::new(), Vec::new());
|
||||
}
|
||||
if cmd == SlashCommand::Goal {
|
||||
self.bottom_pane.drain_pending_submission_state();
|
||||
}
|
||||
@@ -158,7 +164,9 @@ impl ChatWidget {
|
||||
cmd.command()
|
||||
);
|
||||
self.add_to_history(history_cell::new_error_event(message));
|
||||
self.bottom_pane.drain_pending_submission_state();
|
||||
if cmd != SlashCommand::Review {
|
||||
self.bottom_pane.drain_pending_submission_state();
|
||||
}
|
||||
self.request_redraw();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -74,8 +74,13 @@ async fn review_command_during_mcp_startup_opens_popup_snapshot() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
notify_mcp_status(&mut chat, "alpha", McpServerStartupState::Starting);
|
||||
|
||||
chat.dispatch_command(SlashCommand::Review);
|
||||
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));
|
||||
|
||||
assert!(chat.bottom_pane.composer_text().is_empty());
|
||||
let popup = render_bottom_popup(&chat, /*width*/ 80);
|
||||
assert_chatwidget_snapshot!("review_command_during_mcp_startup_opens_popup", popup);
|
||||
}
|
||||
@@ -257,17 +262,22 @@ async fn lag_recovery_during_review_does_not_promote_skipped_terminal_round() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn review_command_remains_blocked_during_agent_turn() {
|
||||
async fn bare_review_submission_during_agent_turn_preserves_draft() {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
handle_turn_started(&mut chat, "turn-1");
|
||||
|
||||
chat.dispatch_command(SlashCommand::Review);
|
||||
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::<String>();
|
||||
assert!(error.contains("'/review' is disabled while a task is in progress."));
|
||||
assert_eq!(chat.bottom_pane.composer_text(), "/review");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
Reference in New Issue
Block a user