From 68afd41be364acd03520837bdf456ba13efd45e4 Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Mon, 1 Jun 2026 10:42:00 +0900 Subject: fix(frontend): ClaudeReset — global snapshot sequencer fixes cross-hour race MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the per-hour inFlightSeq with a single shared SnapshotSequencer used by both loadFromServer() and postToggle() (Gemini #2, High; nit #4). The bug: applySnapshot replaces the *whole* schedule object. The old per-hour counter could not stop request A for hour 9 (knows only about hour 9) from clobbering request B for hour 10 (knows about both) when B returned first and A straggled in — hour 10 would visually vanish. Same race existed between the initial-mount loadFromServer and a quick user toggle: whichever lost the race won the UI. Fix: every request to /models/wake-schedule (GET and POST) bumps a single monotonic seq. On response, sequencer.accept(seq) returns false if any newer request has already won; we drop the snapshot. Also drops the inFlightSeq mechanism entirely — it was redundant with pendingHours for user clicks AND insufficient for the cross-hour and initial-load races, so two mechanisms became one. --- .../frontend/src/lib/components/ClaudeReset.svelte | 29 ++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/packages/frontend/src/lib/components/ClaudeReset.svelte b/packages/frontend/src/lib/components/ClaudeReset.svelte index 14ffa9e..1bd0f55 100644 --- a/packages/frontend/src/lib/components/ClaudeReset.svelte +++ b/packages/frontend/src/lib/components/ClaudeReset.svelte @@ -1,5 +1,6 @@