Fix grain/level vanishing after reconnect at an active step
sudStepIndex was reset to null in updateSudForecast whenever isNewSchedule=true (i.e. on every fresh page load). If the Step message arrived before Json in the global-state replay, or in a separate message, the schedule would be rebuilt but the index would be null, leaving grain mass as 0 with no subsequent Step to restore it. Step messages are the authoritative source for the current index, so the reset is removed. The Step handler always overwrites it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JLR2133M2PyjiYq584i2G7
This commit is contained in:
+14
-2
@@ -504,7 +504,11 @@ function updateSudForecast(doc) {
|
||||
sudEmpty = sudSchedule.length === 0;
|
||||
if (isNewSchedule) {
|
||||
sudStepDescr = null;
|
||||
sudStepIndex = null;
|
||||
// sudStepIndex is NOT reset here: Step messages are the authoritative
|
||||
// source. If a Step already arrived before this Json (e.g. from the
|
||||
// global-state replay), resetting would leave the schedule built but
|
||||
// the index null, causing grain/level to vanish until the next step
|
||||
// change. The Step handler always overwrites it anyway.
|
||||
sudStepType = null;
|
||||
sudHoldRemaining = 0;
|
||||
forecastStepStarts = {};
|
||||
@@ -624,7 +628,15 @@ function onTempCtrlChanged(msg) {
|
||||
}
|
||||
|
||||
function onSudChanged(msg) {
|
||||
for (const key of Object.keys(msg)) {
|
||||
// Json must be processed before Step: both can arrive in the same
|
||||
// global-state replay message, but Step was inserted into global_state
|
||||
// first (at brew start), so it precedes Json in server key order.
|
||||
// Processing Step first would set sudStepIndex before the schedule
|
||||
// exists, then Json would reset it to null (isNewSchedule=true on
|
||||
// first/reloaded connect) with no subsequent Step to restore it.
|
||||
const keys = ['Json', ...Object.keys(msg).filter(k => k !== 'Json')];
|
||||
for (const key of keys) {
|
||||
if (!(key in msg)) continue;
|
||||
if (key === 'Json') {
|
||||
// A standalone reply to a just-sent {Save: true} (see
|
||||
// btn-sud-save's handler below) - not a schedule update to
|
||||
|
||||
Reference in New Issue
Block a user