rendering

This commit is contained in:
Kent Overstreet 2026-04-05 23:04:10 -04:00
parent 36d698a3e1
commit 49cd6d6ab6
8 changed files with 178 additions and 157 deletions

View file

@ -72,6 +72,7 @@ impl Agent {
started: std::time::Instant::now(),
expires_at: std::time::Instant::now() + std::time::Duration::from_secs(3600),
});
self.changed.notify_one();
id
}
@ -85,6 +86,7 @@ impl Agent {
started: std::time::Instant::now(),
expires_at: std::time::Instant::now() + ACTIVITY_LINGER,
});
self.changed.notify_one();
}
/// Remove expired activities.
@ -179,6 +181,8 @@ pub struct Agent {
pub agent_cycles: crate::subconscious::subconscious::AgentCycleState,
/// Shared active tools — Agent writes, TUI reads.
pub active_tools: tools::SharedActiveTools,
/// Fires when agent state changes — UI wakes on this instead of polling.
pub changed: Arc<tokio::sync::Notify>,
}
fn render_journal(entries: &[context::JournalEntry]) -> String {
@ -237,6 +241,7 @@ impl Agent {
generation: 0,
agent_cycles,
active_tools,
changed: Arc::new(tokio::sync::Notify::new()),
};
agent.load_startup_journal();
@ -292,6 +297,7 @@ impl Agent {
}
}
self.context.entries.push(entry);
self.changed.notify_one();
}
/// Append streaming text to the last entry (creating a partial
@ -301,6 +307,7 @@ impl Agent {
let msg = entry.message_mut();
if msg.role == Role::Assistant {
msg.append_content(text);
self.changed.notify_one();
return;
}
}
@ -308,6 +315,7 @@ impl Agent {
self.context.entries.push(ConversationEntry::Message(
Message::assistant(text),
));
self.changed.notify_one();
}
pub fn budget(&self) -> ContextBudget {