fix(app): the game placement reads the card again and stage retries start over with each new wish
- the game stage reads the card again: other programs as at the last normal placement made with no game running, and a reserve of at least what grew since (the game and programs opened after that reading); with a game already running at the start (game detection now looks once before the LLM starts) it counts what the card holds now and leaves only the room for other programs, so it no longer pauses for counting the game twice - the retry count starts over whenever another stage is wanted, also when the game ends with the normal stage already running, so the next game tries again - the wait before the next try counts from when the failed switch and its way back are over - the worker client keeps, sends and readies a connection under one lock (llm, then state), so an LLM state set while a worker connects is not lost - a game watch dropped by a start that fails part way stops its thread Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -370,7 +370,9 @@ impl WorkerClient {
|
||||
if let Some(n) = notice {
|
||||
m["notice"] = json!(n);
|
||||
}
|
||||
*self.inner.llm.lock().unwrap() = Some(m.clone());
|
||||
// Kept and sent under one lock, so a connection being set up sends this or a later state.
|
||||
let mut llm = self.inner.llm.lock().unwrap();
|
||||
*llm = Some(m.clone());
|
||||
self.send_json(m);
|
||||
id
|
||||
}
|
||||
@@ -378,7 +380,8 @@ impl WorkerClient {
|
||||
/// Tell the brain the LLM is `ready` (answer what waited) or `paused` (answer nothing).
|
||||
pub fn llm_state(&self, state: &str) -> bool {
|
||||
let m = json!({"type": "llm", "state": state});
|
||||
*self.inner.llm.lock().unwrap() = Some(m.clone());
|
||||
let mut llm = self.inner.llm.lock().unwrap();
|
||||
*llm = Some(m.clone());
|
||||
self.send_json(m)
|
||||
}
|
||||
|
||||
@@ -516,18 +519,20 @@ async fn connect_once(inner: &Arc<Inner>) -> bool {
|
||||
|
||||
let (tx, mut rx) = mpsc::unbounded_channel::<Message>();
|
||||
{
|
||||
// Locks in the order llm, then state (as `llm_state` takes them): the latest LLM state goes
|
||||
// first, and the connection is ready for sending before an LLM state set meanwhile is sent.
|
||||
let llm = inner.llm.lock().unwrap();
|
||||
let mut st = inner.state.lock().unwrap();
|
||||
if st.closed {
|
||||
return true;
|
||||
}
|
||||
// The LLM state the brain should have, before anything else it is asked.
|
||||
if let Some(m) = inner.llm.lock().unwrap().clone() {
|
||||
if let Some(m) = llm.clone() {
|
||||
let _ = tx.send(Message::text(m.to_string()));
|
||||
}
|
||||
st.conn = Some(tx);
|
||||
inner.ready.send_replace(Some(hello_ok.clone()));
|
||||
}
|
||||
debug_log!("worker", "voice worker ready stt={} tts={}", hello_ok.stt_ready, hello_ok.tts_ready);
|
||||
inner.ready.send_replace(Some(hello_ok.clone()));
|
||||
let _ = inner.events.send(WorkerEvent::Ready(hello_ok));
|
||||
|
||||
loop {
|
||||
|
||||
Reference in New Issue
Block a user