Move Subconscious + SubconsciousAgent into dmn.rs

Subconscious owns agents and shared walked state. trigger() and
collect_results() take the conscious agent Arc as a parameter.
Mind holds Subconscious behind a tokio Mutex and calls into it
from the event loop.

Drops ~170 lines from mind/mod.rs.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-07 02:31:52 -04:00
parent b7ff205841
commit 6191f30aec
4 changed files with 247 additions and 291 deletions

View file

@ -128,7 +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) walked_count: usize,
pub(crate) channel_status: Vec<ChannelStatus>,
pub(crate) idle_info: Option<IdleInfo>,
}
@ -151,7 +151,7 @@ impl App {
should_quit: false, submitted: Vec::new(),
context_info: None, shared_context,
agent_state: Vec::new(),
subconscious_shared: Default::default(),
walked_count: 0,
channel_status: Vec::new(), idle_info: None,
}
}
@ -408,9 +408,8 @@ pub async fn run(
// State sync on every wake
idle_state.decay_ewma();
app.update_idle(&idle_state);
let (snaps, shared) = mind.subconscious_snapshots().await;
app.agent_state = snaps;
app.subconscious_shared = shared;
app.agent_state = mind.subconscious_snapshots().await;
app.walked_count = mind.subconscious_walked().await.len();
if !startup_done {
if let Ok(mut ag) = agent.try_lock() {
let model = ag.model().to_string();

View file

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