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,14 +547,18 @@ impl Session {
for p in &procs {
self.process_tracker.kill(p.pid).await;
}
if let Some(handle) = self.turn_handle.take() {
handle.abort();
self.turn_in_progress = false;
self.dmn = dmn::State::Resting {
since: Instant::now(),
};
self.update_status();
let _ = self.ui_tx.send(UiMessage::Activity(String::new()));
// 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() {
handle.abort();
self.turn_in_progress = false;
self.dmn = dmn::State::Resting {
since: Instant::now(),
};
self.update_status();
let _ = self.ui_tx.send(UiMessage::Activity(String::new()));
}
}
self.pending_input = None;
let killed = procs.len();