single control flow for both Esc and Ctrl+C (#2691)

Esc and Ctrl+C while a task is running should do the same thing. There
were some cases where pressing Esc would leave a "stuck" widget in the
history; this fixes that and cleans up the logic so there's just one
path for interrupting the task. Also clean up some subtly mishandled key
events (e.g. Ctrl+D would quit the app while an approval modal was
showing if the textarea was empty).

---------

Co-authored-by: Ahmed Ibrahim <aibrahim@openai.com>
This commit is contained in:
Jeremy Rose
2025-08-25 20:15:38 -07:00
committed by GitHub
parent d63e44ae29
commit e5283b6126
6 changed files with 141 additions and 74 deletions

View File

@@ -175,6 +175,26 @@ impl WidgetRef for &ExecCell {
}
}
impl ExecCell {
/// Convert an active exec cell into a failed, completed exec cell.
/// Replaces the spinner with a red ✗ and sets a zero/elapsed duration.
pub(crate) fn into_failed(mut self) -> ExecCell {
let elapsed = self
.start_time
.map(|st| st.elapsed())
.unwrap_or_else(|| Duration::from_millis(0));
self.start_time = None;
self.duration = Some(elapsed);
self.output = Some(CommandOutput {
exit_code: 1,
stdout: String::new(),
stderr: String::new(),
formatted_output: String::new(),
});
self
}
}
#[derive(Debug)]
struct CompletedMcpToolCallWithImageOutput {
_image: DynamicImage,