Shared subconscious state — walked keys are Mind-level, not per-agent

SubconsciousSharedState holds walked keys shared between all
subconscious agents. Enables splitting surface-observe into separate
surface and observe agents that share the same walked state.

Walked is passed to run_forked() at run time instead of living on
AutoAgent. UI shows walked count in the subconscious screen header.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-07 02:13:06 -04:00
parent ef868cb98f
commit f3ba7e7097
4 changed files with 37 additions and 23 deletions

View file

@ -128,6 +128,7 @@ pub struct App {
pub(crate) context_info: Option<ContextInfo>,
pub(crate) shared_context: SharedContextState,
pub(crate) agent_state: Vec<crate::mind::SubconsciousSnapshot>,
pub(crate) subconscious_shared: crate::mind::SubconsciousSharedState,
pub(crate) channel_status: Vec<ChannelStatus>,
pub(crate) idle_info: Option<IdleInfo>,
}
@ -150,6 +151,7 @@ impl App {
should_quit: false, submitted: Vec::new(),
context_info: None, shared_context,
agent_state: Vec::new(),
subconscious_shared: Default::default(),
channel_status: Vec::new(), idle_info: None,
}
}
@ -406,7 +408,9 @@ pub async fn run(
// State sync on every wake
idle_state.decay_ewma();
app.update_idle(&idle_state);
app.agent_state = mind.subconscious_snapshots().await;
let (snaps, shared) = mind.subconscious_snapshots().await;
app.agent_state = snaps;
app.subconscious_shared = shared;
if !startup_done {
if let Ok(mut ag) = agent.try_lock() {
let model = ag.model().to_string();

View file

@ -76,7 +76,9 @@ impl SubconsciousScreen {
let hint = Style::default().fg(Color::DarkGray).add_modifier(Modifier::ITALIC);
lines.push(Line::raw(""));
lines.push(Line::styled("── Subconscious Agents ──", section));
let walked = app.subconscious_shared.walked.len();
lines.push(Line::styled(
format!("── Subconscious Agents ── walked: {}", walked), section));
lines.push(Line::styled(" (↑/↓ select, Enter view log)", hint));
lines.push(Line::raw(""));
@ -121,8 +123,8 @@ impl SubconsciousScreen {
),
Span::styled("", bg.fg(Color::DarkGray)),
Span::styled(
format!("idle last: {} entries: {} walked: {}",
ago, entries, snap.walked_count),
format!("idle last: {} entries: {}",
ago, entries),
bg.fg(Color::DarkGray),
),
]