feat: ctrl-c interrupts ongoing prompt in a session, but lets the user inject more instructions mid-stream
CI / All (ubuntu-latest) (push) Failing after 24s
CI / All (macos-latest) (push) Has been cancelled
CI / All (windows-latest) (push) Has been cancelled

This commit is contained in:
2026-07-30 10:21:19 -06:00
parent 233c212d2a
commit 0324436114
+18 -1
View File
@@ -493,13 +493,30 @@ pub async fn call_chat_completions_streaming(
render_stream(rx, client.app_config(), abort_signal.clone(), silent), render_stream(rx, client.app_config(), abort_signal.clone(), silent),
); );
if handler.abort().aborted() { let aborted_ctrlc = handler.abort().aborted_ctrlc();
let aborted_ctrld = handler.abort().aborted_ctrld();
if aborted_ctrld {
bail!("Aborted."); bail!("Aborted.");
} }
render_ret?; render_ret?;
let (text, tool_calls, thinking) = handler.take(); let (text, tool_calls, thinking) = handler.take();
if aborted_ctrlc {
if text.is_empty() || !ctx.working_mode.is_repl() || ctx.session.is_none() {
bail!("Aborted.");
}
if !silent && *IS_STDOUT_TERMINAL {
println!();
eprintln!("{}", error_text("Response interrupted"));
}
return Ok((text, vec![]));
}
match send_ret { match send_ret {
Ok(_) => { Ok(_) => {
if !silent && !text.is_empty() && !text.ends_with('\n') { if !silent && !text.is_empty() && !text.ends_with('\n') {