ActiveTools wrapper: replace SharedActiveTools Arc<Mutex<Vec>>

New ActiveTools struct with proper methods: push, remove, abort_all,
take_finished, take_foreground, iter, len. Lives directly on AgentState,
no separate Arc<Mutex> needed.

TUI reads active tools through agent.state.try_lock(). Turn loop uses
helpers instead of manual index iteration.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-08 16:45:56 -04:00
parent 9c9618d034
commit 31a41fa042
5 changed files with 23 additions and 26 deletions

View file

@ -21,7 +21,6 @@ mod vision;
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
use std::time::Instant;
fn default_timeout() -> u64 { 120 }
@ -108,6 +107,12 @@ impl ActiveTools {
self.0.iter()
}
pub fn abort_all(&mut self) {
for entry in self.0.drain(..) {
entry.handle.abort();
}
}
pub fn len(&self) -> usize { self.0.len() }
pub fn is_empty(&self) -> bool { self.0.is_empty() }
}