mind: clean startup split between Mind and event_loop

Mind::init() now handles channel daemons, observation socket, and
scoring startup. event_loop::run() creates its own idle state and
channel polling — UI concerns owned by the UI.

Startup run() is now: create agent, create Mind, init, spawn Mind,
run event_loop. Seven parameters on event_loop::run() instead of
twelve.

Remove observe_input_rx from event loop (being replaced by channel).

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2026-04-05 04:17:04 -04:00
parent 9d597b5eff
commit 91033fe754
2 changed files with 33 additions and 49 deletions

View file

@ -185,12 +185,20 @@ pub async fn run(
mind_tx: tokio::sync::mpsc::UnboundedSender<MindCommand>,
ui_tx: ui_channel::UiSender,
mut ui_rx: ui_channel::UiReceiver,
mut observe_input_rx: tokio::sync::mpsc::UnboundedReceiver<String>,
channel_tx: tokio::sync::mpsc::Sender<Vec<(String, bool, u32)>>,
mut channel_rx: tokio::sync::mpsc::Receiver<Vec<(String, bool, u32)>>,
notify_rx: std::sync::mpsc::Receiver<crate::thalamus::channels::ChannelNotification>,
mut idle_state: crate::thalamus::idle::State,
) -> Result<()> {
// UI-owned state
let mut idle_state = crate::thalamus::idle::State::new();
idle_state.load();
let (channel_tx, mut channel_rx) = tokio::sync::mpsc::channel::<Vec<(String, bool, u32)>>(4);
{
let tx = channel_tx.clone();
tokio::spawn(async move {
let result = crate::thalamus::channels::fetch_all_channels().await;
let _ = tx.send(result).await;
});
}
let notify_rx = crate::thalamus::channels::subscribe_all();
let mut terminal = tui::init_terminal()?;
let mut reader = EventStream::new();
@ -251,10 +259,6 @@ pub async fn run(
}
}
Some(line) = observe_input_rx.recv() => {
app.submitted.push(line);
dirty = true;
}
_ = render_interval.tick() => {
idle_state.decay_ewma();