Fix subconscious screen showing empty names during runs

Keep name and last_run_entries on SubconsciousAgent directly,
not just on the AutoAgent (which gets replaced with a placeholder
during spawned runs). Snapshot reads stable fields.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-07 02:39:16 -04:00
parent 3788695634
commit 48c843234d

View file

@ -297,9 +297,11 @@ pub struct SubconsciousSnapshot {
}
struct SubconsciousAgent {
name: String,
auto: AutoAgent,
last_trigger_bytes: u64,
last_run: Option<Instant>,
last_run_entries: Vec<ConversationEntry>,
handle: Option<tokio::task::JoinHandle<(AutoAgent, Result<String, String>)>>,
}
@ -326,7 +328,11 @@ impl SubconsciousAgent {
def.temperature.unwrap_or(0.6), def.priority,
);
Some(Self { auto, last_trigger_bytes: 0, last_run: None, handle: None })
Some(Self {
name: name.to_string(),
auto, last_trigger_bytes: 0, last_run: None,
last_run_entries: Vec::new(), handle: None,
})
}
fn is_running(&self) -> bool {
@ -341,12 +347,12 @@ impl SubconsciousAgent {
fn snapshot(&self) -> SubconsciousSnapshot {
SubconsciousSnapshot {
name: self.auto.name.clone(),
name: self.name.clone(),
running: self.is_running(),
current_phase: self.auto.current_phase.clone(),
turn: self.auto.turn,
last_run_secs_ago: self.last_run.map(|t| t.elapsed().as_secs_f64()),
last_run_entries: self.auto.last_run_entries.clone(),
last_run_entries: self.last_run_entries.clone(),
}
}
}
@ -387,11 +393,12 @@ impl Subconscious {
let (auto_back, result) = handle.await.unwrap_or_else(
|e| (AutoAgent::new(String::new(), vec![], vec![], 0.0, 0),
Err(format!("task panicked: {}", e))));
self.agents[idx].last_run_entries = auto_back.last_run_entries.clone();
self.agents[idx].auto = auto_back;
match result {
Ok(_) => {
let name = self.agents[idx].auto.name.clone();
let name = self.agents[idx].name.clone();
let outputs = std::mem::take(&mut self.agents[idx].auto.outputs);
if let Some(walked_str) = outputs.get("walked") {