mirror of
https://github.com/openai/codex.git
synced 2026-09-05 15:18:41 +00:00
fix(tui): interrupt pending turns before quitting
This commit is contained in:
@@ -480,9 +480,10 @@ impl ChatWidget {
|
||||
self.bottom_pane.show_quit_shortcut_hint(key);
|
||||
}
|
||||
|
||||
// Review mode counts as cancellable work so Ctrl+C interrupts instead of quitting.
|
||||
// A submitted turn waiting for TurnStarted is cancellable too; otherwise an immediate Ctrl+C
|
||||
// is misclassified as an idle quit.
|
||||
fn is_cancellable_work_active(&self) -> bool {
|
||||
self.bottom_pane.is_task_running() || self.review.is_review_mode
|
||||
self.is_user_turn_pending_or_running() || self.review.is_review_mode
|
||||
}
|
||||
|
||||
fn pause_active_goal_for_interrupt(&self) {
|
||||
|
||||
@@ -991,6 +991,23 @@ async fn patch_activity_prevents_cancelled_turn_prompt_restore() {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn ctrl_c_interrupts_turn_pending_start_instead_of_quitting() {
|
||||
let (mut chat, mut rx, mut op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.thread_id = Some(ThreadId::new());
|
||||
chat.submit_user_message(UserMessage::from("commit"));
|
||||
assert_matches!(next_submit_op(&mut op_rx), Op::UserTurn { .. });
|
||||
assert!(chat.input_queue.user_turn_pending_start);
|
||||
assert!(!chat.bottom_pane.is_task_running());
|
||||
|
||||
chat.handle_key_event(KeyEvent::new(KeyCode::Char('c'), KeyModifiers::CONTROL));
|
||||
|
||||
next_interrupt_op(&mut op_rx);
|
||||
while let Ok(event) = rx.try_recv() {
|
||||
assert!(!matches!(event, AppEvent::Exit(_)));
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn pending_steer_esc_does_not_steal_vim_insert_escape() {
|
||||
let (mut chat, _rx, mut op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
|
||||
Reference in New Issue
Block a user