fix stale process count after interrupt

Don't abort the tokio task when killing processes — let SIGTERM'd
processes exit normally so run_bash sees the exit and unregisters
them from the tracker. Only abort the turn when no processes are
running (e.g. interrupting a streaming response).

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-02 17:35:17 -04:00
parent ef7dd59b7e
commit a360607fad

View file

@ -547,6 +547,9 @@ impl Session {
for p in &procs { for p in &procs {
self.process_tracker.kill(p.pid).await; self.process_tracker.kill(p.pid).await;
} }
// Only abort the turn if no processes are running — let SIGTERM'd
// processes exit normally so run_bash can unregister them.
if procs.is_empty() {
if let Some(handle) = self.turn_handle.take() { if let Some(handle) = self.turn_handle.take() {
handle.abort(); handle.abort();
self.turn_in_progress = false; self.turn_in_progress = false;
@ -556,6 +559,7 @@ impl Session {
self.update_status(); self.update_status();
let _ = self.ui_tx.send(UiMessage::Activity(String::new())); let _ = self.ui_tx.send(UiMessage::Activity(String::new()));
} }
}
self.pending_input = None; self.pending_input = None;
let killed = procs.len(); let killed = procs.len();
if killed > 0 || self.turn_in_progress { if killed > 0 || self.turn_in_progress {