mind: keep supervisor alive on Mind struct

The channel daemon supervisor was created in init() and immediately
dropped. Keep it on Mind so it can restart crashed daemons.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2026-04-05 04:32:11 -04:00
parent 57b0f94b54
commit d5a706147a

View file

@ -177,6 +177,7 @@ pub struct Mind {
turn_tx: mpsc::Sender<(Result<TurnResult>, StreamTarget)>,
turn_handle: Option<tokio::task::JoinHandle<()>>,
turn_watch: tokio::sync::watch::Sender<bool>,
_supervisor: crate::thalamus::supervisor::Supervisor,
}
impl Mind {
@ -206,7 +207,12 @@ impl Mind {
let shared = shared_mind_state(config.app.dmn.max_turns);
let (turn_watch, _) = tokio::sync::watch::channel(false);
Self { agent, shared, config, ui_tx, turn_tx, turn_handle: None, turn_watch }
let mut sup = crate::thalamus::supervisor::Supervisor::new();
sup.load_config();
sup.ensure_running();
Self { agent, shared, config, ui_tx, turn_tx, turn_handle: None, turn_watch, _supervisor: sup }
}
/// Initialize — restore log, start daemons and background agents.
@ -216,11 +222,6 @@ impl Mind {
ag.restore_from_log();
drop(ag);
// Start channel daemons
let mut sup = crate::thalamus::supervisor::Supervisor::new();
sup.load_config();
sup.ensure_running();
// Start observation socket
if !self.config.no_agents {
let socket_path = self.config.session_dir.join("agent.sock");