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

@ -17,7 +17,8 @@ impl App {
/// Draw the main (F1) screen — four-pane layout with status bar.
pub(crate) fn draw_main(&mut self, frame: &mut Frame, size: Rect) {
// Main layout: content area + active tools overlay + status bar
let tool_lines = self.active_tools.len() as u16;
let active_tools = self.active_tools.read().unwrap();
let tool_lines = active_tools.len() as u16;
let main_chunks = Layout::default()
.direction(Direction::Vertical)
.constraints([
@ -107,9 +108,9 @@ impl App {
frame.render_widget(&self.textarea, input_chunks[1]);
// Draw active tools overlay
if !self.active_tools.is_empty() {
if !active_tools.is_empty() {
let tool_style = Style::default().fg(Color::Yellow).add_modifier(Modifier::DIM);
let tool_text: Vec<Line> = self.active_tools.iter().map(|t| {
let tool_text: Vec<Line> = active_tools.iter().map(|t| {
let elapsed = t.started.elapsed().as_secs();
let line = if t.detail.is_empty() {
format!(" [{}] ({}s)", t.name, elapsed)