From 853f80d8627f9ca8386ecc318b2f5dd31a1e5d4a Mon Sep 17 00:00:00 2001 From: Sean Halpin Date: Thu, 8 Oct 2026 11:35:53 -0400 Subject: [PATCH 1/3] fix(ui): show transition hint only during belt sequences (ROADMAP 3.18) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Submitting any form called setTransitioning() with the page's hint id, so presets and steppers flashed "Getting the belt moving…" and shifted the layout, and Start/Pause/Resume/End flashed the wrong text. disableButtonsOnSubmit() now only disables and dims the buttons, and the hint follows the SSE belt_transitioning flag alone. Also stop SSE ticks from re-enabling the buttons while a submit is in flight: a page-level submitting flag keeps them disabled until the page navigates away, and is cleared on a back/forward-cache restore. Co-Authored-By: Claude --- templates/active_session.html | 2 +- templates/base.html | 26 +++++++++++++++++++++----- templates/paused_session.html | 2 +- templates/start_session.html | 2 +- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/templates/active_session.html b/templates/active_session.html index 5dfd4aa..6b0a3ef 100644 --- a/templates/active_session.html +++ b/templates/active_session.html @@ -74,7 +74,7 @@

Active Session

// buttons need to stay disabled/dim until belt_transitioning clears, not // just during the on-submit window. var actionButtons = document.querySelectorAll('button[type="submit"]'); - disableButtonsOnSubmit('transitioning-hint', actionButtons); + disableButtonsOnSubmit(actionButtons); // Native only: needs a secure context (localhost/HTTPS), so a phone on LAN HTTP skips it. if ('wakeLock' in navigator) { diff --git a/templates/base.html b/templates/base.html index efb2503..83963da 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1543,23 +1543,39 @@

-- Active/Paused/Start's own page headings are // Toggles a " belt..." hint and disables/dims the buttons that // shouldn't be double-tapped while a belt sequence is in flight. Shared // by active/paused/start, which each pass their own hint id and button set. + // Once a form has submitted, buttons stay disabled regardless of `on`, so + // an SSE tick landing mid-request can't re-enable them. + var submitting = false; function setTransitioning(hintId, buttons, on) { var hint = document.getElementById(hintId); if (hint) hint.style.display = on ? '' : 'none'; + var disable = on || submitting; buttons.forEach(function(b) { - b.disabled = on; - b.style.opacity = on ? '0.5' : ''; + b.disabled = disable; + b.style.opacity = disable ? '0.5' : ''; }); } // Wires every form on the page to disable/dim `buttons` the instant any // of them is submitted -- the SSE-driven belt_transitioning update that // setTransitioning() above also responds to can lag behind by a full - // network round-trip, leaving a window for a double-tap otherwise. - function disableButtonsOnSubmit(hintId, buttons) { + // network round-trip, leaving a window for a double-tap otherwise. The + // hint is left to belt_transitioning alone: most submits (presets, + // steppers) start no belt sequence, and each page's hint text only fits + // the sequence that led to that page. + // `submitting` never clears in normal use since every submit navigates + // away; a back/forward-cache restore brings the page back with it set. + function disableButtonsOnSubmit(buttons) { + window.addEventListener('pageshow', function(e) { + if (e.persisted) { + submitting = false; + setTransitioning(null, buttons, false); + } + }); document.querySelectorAll('form').forEach(function(form) { form.addEventListener('submit', function() { - setTransitioning(hintId, buttons, true); + submitting = true; + setTransitioning(null, buttons, true); }); }); } diff --git a/templates/paused_session.html b/templates/paused_session.html index 8f884ac..cbc4aa1 100644 --- a/templates/paused_session.html +++ b/templates/paused_session.html @@ -47,7 +47,7 @@

Session Paused