mind: remove Arc from MindState

MindState is now std::sync::Mutex<MindState> owned by Mind, not
Arc-wrapped. Background scoring completion signals through a
BgEvent channel instead of locking shared directly. Retry sends
a Turn command instead of pushing to shared input.

No Arc on Mind (scoped tasks), no Arc on MindState (owned by Mind).
Only Arc<Mutex<Agent>> remains — needed for background turn spawns.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2026-04-05 05:01:45 -04:00
parent 5eaba3c951
commit 7dc515b985
2 changed files with 28 additions and 16 deletions

View file

@ -86,7 +86,7 @@ fn send_help(ui_tx: &ui_channel::UiSender) {
async fn cmd_retry(
agent: &Arc<Mutex<Agent>>,
shared_mind: &crate::mind::SharedMindState,
mind_tx: &tokio::sync::mpsc::UnboundedSender<MindCommand>,
ui_tx: &ui_channel::UiSender,
) {
let mut agent_guard = agent.lock().await;
@ -104,7 +104,8 @@ async fn cmd_retry(
Some(text) => {
let preview_len = text.len().min(60);
let _ = ui_tx.send(UiMessage::Info(format!("(retrying: {}...)", &text[..preview_len])));
shared_mind.lock().unwrap().input.push(text);
// Send as a Turn command — Mind will process it
let _ = mind_tx.send(MindCommand::Turn(text, crate::user::ui_channel::StreamTarget::Conversation));
}
None => {
let _ = ui_tx.send(UiMessage::Info("(nothing to retry)".into()));
@ -411,12 +412,12 @@ pub async fn run(
"/score" => { let _ = mind_tx.send(MindCommand::Score); }
"/retry" => {
let agent = agent.clone();
let sm = shared_mind.clone();
let mind_tx = mind_tx.clone();
let ui_tx = ui_tx.clone();
let mut tw = turn_watch.clone();
tokio::spawn(async move {
let _ = tw.wait_for(|&active| !active).await;
cmd_retry(&agent, &sm, &ui_tx).await;
cmd_retry(&agent, &mind_tx, &ui_tx).await;
});
}
cmd if cmd.starts_with("/model ") => {