shared active tools: Agent writes, TUI reads directly

Move active tool tracking from TUI message-passing to shared
Arc<RwLock> state. Agent pushes on dispatch, removes on
apply_tool_result. TUI reads during render. Background tasks
show as active until drained at next turn start.

Co-Developed-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
ProofOfConcept 2026-04-03 22:57:46 -04:00
parent d25033b9f4
commit 474b66c834
6 changed files with 62 additions and 49 deletions

View file

@ -22,6 +22,22 @@ pub fn shared_context_state() -> SharedContextState {
Arc::new(RwLock::new(Vec::new()))
}
/// Active tool info for TUI display.
#[derive(Debug, Clone)]
pub struct ActiveTool {
pub id: String,
pub name: String,
pub detail: String,
pub started: std::time::Instant,
}
/// Shared active tools — agent writes, TUI reads.
pub type SharedActiveTools = Arc<RwLock<Vec<ActiveTool>>>;
pub fn shared_active_tools() -> SharedActiveTools {
Arc::new(RwLock::new(Vec::new()))
}
/// Which pane streaming text should go to.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum StreamTarget {