mind: move CycleAutonomy to event_loop, simplify MindCommand

CycleAutonomy just flips DMN state — handled directly in event_loop
by locking shared MindState. MindCommand::Hotkey replaced with
MindCommand::Interrupt — the only command that needs Mind's async
context (abort handles, kill processes).

Remove dmn_interval() wrapper — inline self.dmn.interval().

MindCommand is now: Turn, Compact, Score, Interrupt, NewSession, None.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2026-04-05 03:41:47 -04:00
parent 402bae4178
commit 2d6a17e773
2 changed files with 10 additions and 15 deletions

View file

@ -66,8 +66,8 @@ pub enum MindCommand {
Compact,
/// Run memory scoring
Score,
/// Hotkey action
Hotkey(crate::user::HotkeyAction),
/// Abort current turn, kill processes
Interrupt,
/// Reset session
NewSession,
/// Nothing to do
@ -91,11 +91,7 @@ impl MindState {
}
}
pub fn dmn_interval(&self) -> Duration {
self.dmn.interval()
}
/// Consume pending input, return a Turn action if ready.
/// Consume pending input, return a Turn command if ready.
pub fn take_pending_input(&mut self) -> MindCommand {
if self.turn_active || self.input.is_empty() {
return MindCommand::None;
@ -252,7 +248,7 @@ impl Mind {
self.start_memory_scoring();
}
}
MindCommand::Hotkey(crate::user::HotkeyAction::Interrupt) => {
MindCommand::Interrupt => {
self.shared.lock().unwrap().interrupt();
let ag = self.agent.lock().await;
let mut tools = ag.active_tools.lock().unwrap();
@ -262,10 +258,6 @@ impl Mind {
self.shared.lock().unwrap().turn_active = false;
let _ = self.turn_watch.send(false);
}
MindCommand::Hotkey(crate::user::HotkeyAction::CycleAutonomy) => {
self.shared.lock().unwrap().cycle_autonomy();
}
MindCommand::Hotkey(_) => {}
MindCommand::NewSession => {
self.shared.lock().unwrap().dmn_sleep();
let new_log = log::ConversationLog::new(
@ -351,7 +343,7 @@ impl Mind {
mut turn_rx: mpsc::Receiver<(Result<TurnResult>, StreamTarget)>,
) {
loop {
let timeout = self.shared.lock().unwrap().dmn_interval();
let timeout = self.shared.lock().unwrap().dmn.interval();
let turn_active = self.shared.lock().unwrap().turn_active;
let mut cmds = Vec::new();