From dd0e782450718a0bb7dd8ac00d3f3eeb3f42e17e Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 26 Mar 2026 08:44:46 +0800 Subject: [PATCH] fix(engine): push WS immediately on notify wake-up When auto_enabled or fault_locked changes externally, the engine task wakes via notify but previously only pushed WS on the next state transition (potentially seconds later). Now push the fresh runtime immediately in the notify.notified() arm so the frontend reflects the change without delay. Co-Authored-By: Claude Sonnet 4.6 --- src/control/engine.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/control/engine.rs b/src/control/engine.rs index 4a77193..e547915 100644 --- a/src/control/engine.rs +++ b/src/control/engine.rs @@ -94,7 +94,12 @@ async fn unit_task(state: AppState, store: Arc, unit_id: Uu if !runtime.auto_enabled || runtime.fault_locked || runtime.comm_locked { tokio::select! { _ = fault_tick.tick() => {} - _ = notify.notified() => {} + _ = notify.notified() => { + // Push fresh runtime immediately so the frontend reflects the change + // (e.g. auto_enabled toggled) without waiting for the next state transition. + let runtime = store.get_or_init(unit_id).await; + push_ws(&state, &runtime).await; + } } continue; }