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 <noreply@anthropic.com>
This commit is contained in:
caoqianming 2026-03-26 08:44:46 +08:00
parent 8c1b7b636d
commit dd0e782450
1 changed files with 6 additions and 1 deletions

View File

@ -94,7 +94,12 @@ async fn unit_task(state: AppState, store: Arc<ControlRuntimeStore>, 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;
}