Fix agent provenance and add store activity for unconscious agents

- Remove bogus "agent:" prefix from provenance - just use agent name
- Add history field to UnconsciousSnapshot
- Update snapshots() to fetch store activity via recent_by_provenance
- Fix TUI to display store activity for both agent types

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-11 21:57:24 -04:00
parent d2dbdedc8f
commit e9e7458013
5 changed files with 66 additions and 32 deletions

View file

@ -62,6 +62,8 @@ pub struct UnconsciousSnapshot {
pub last_run_secs_ago: Option<f64>,
pub agent: Option<std::sync::Arc<crate::agent::Agent>>,
pub last_stats: Option<RunStats>,
/// Recent store activity for this agent: (key, timestamp), newest first.
pub history: Vec<(String, i64)>,
}
pub struct Unconscious {
@ -138,15 +140,20 @@ impl Unconscious {
save_enabled_config(&map);
}
pub fn snapshots(&self) -> Vec<UnconsciousSnapshot> {
self.agents.iter().map(|a| UnconsciousSnapshot {
name: a.name.clone(),
running: a.is_running(),
enabled: a.enabled,
runs: a.runs,
last_run_secs_ago: a.last_run.map(|t| t.elapsed().as_secs_f64()),
agent: a.agent.clone(),
last_stats: a.last_stats.clone(),
pub fn snapshots(&self, store: Option<&crate::store::Store>) -> Vec<UnconsciousSnapshot> {
self.agents.iter().map(|a| {
let history = store.map(|st| st.recent_by_provenance(&a.name, 30))
.unwrap_or_default();
UnconsciousSnapshot {
name: a.name.clone(),
running: a.is_running(),
enabled: a.enabled,
runs: a.runs,
last_run_secs_ago: a.last_run.map(|t| t.elapsed().as_secs_f64()),
agent: a.agent.clone(),
last_stats: a.last_stats.clone(),
history,
}
}).collect()
}
@ -285,7 +292,7 @@ impl Unconscious {
).await;
{
let mut st = agent.state.lock().await;
st.provenance = format!("unconscious:{}", auto.name);
st.provenance = auto.name.clone();
st.priority = Some(10);
}