tui: cancel paused turns with ctrl-x

This commit is contained in:
2026-06-23 22:37:40 +09:00
parent 5954021cc5
commit 90b1a1fccb
5 changed files with 207 additions and 9 deletions
+26 -2
View File
@@ -938,11 +938,11 @@ fn handle_key(app: &mut App, key: KeyEvent) -> Option<Method> {
}
KeyCode::Char('c') if ctrl => Some(handle_pause_or_quit(app)),
KeyCode::Char('x') if ctrl => Some(match app.pod_status {
PodStatus::Running => {
PodStatus::Running | PodStatus::Paused => {
app.clear_queued_inputs();
Some(Method::Cancel)
}
PodStatus::Paused | PodStatus::Idle => Some(Method::Shutdown),
PodStatus::Idle => Some(Method::Shutdown),
}),
KeyCode::Char('d') if ctrl => {
app.quit = true;
@@ -1518,6 +1518,30 @@ mod tests {
assert_eq!(app.queued_input_count(), 0);
}
#[test]
fn ctrl_x_cancels_paused_turn_without_shutdown() {
let mut app = App::new("agent".to_string());
app.set_pod_status(PodStatus::Paused);
let cancel = handle_key(
&mut app,
KeyEvent::new(KeyCode::Char('x'), KeyModifiers::CONTROL),
);
assert!(matches!(cancel, Some(Method::Cancel)));
}
#[test]
fn ctrl_x_shutdown_while_idle_is_unchanged() {
let mut app = App::new("agent".to_string());
app.set_pod_status(PodStatus::Idle);
let shutdown = handle_key(
&mut app,
KeyEvent::new(KeyCode::Char('x'), KeyModifiers::CONTROL),
);
assert!(matches!(shutdown, Some(Method::Shutdown)));
}
#[test]
fn word_navigation_keys_edit_composer() {
let mut app = App::new("agent".to_string());
+1 -1
View File
@@ -1446,7 +1446,7 @@ fn draw_status(frame: &mut Frame, app: &App, area: Rect) {
.add_modifier(Modifier::BOLD),
));
spans.push(Span::styled(
" — Enter to resume, type to start new turn",
" — Enter to resume, Ctrl-X to cancel, type to start new turn",
Style::default().fg(Color::DarkGray),
));
} else {