From e06bd8435de932b166a46dcea5ad7974ee4b0468 Mon Sep 17 00:00:00 2001 From: timmy Date: Sat, 22 Aug 2026 12:04:23 +0000 Subject: [PATCH] fix: restore timed break after unchanged fresh context (Closes #1262) --- frontend/dashboard.js | 22 ++++++++++++---------- tests/test_today_break.py | 14 ++++++++++++++ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/frontend/dashboard.js b/frontend/dashboard.js index a1b92ba..852c504 100644 --- a/frontend/dashboard.js +++ b/frontend/dashboard.js @@ -5450,6 +5450,18 @@ }); } } + if (snapshot.context) { + const contextIdentityFresh = !snapshot.context.error && !contextFreshness?.stale && + !contextFreshness?.degraded && !contextFreshness?.revalidating; + activeFlushLogin = contextIdentityFresh ? String(snapshot.context.user?.login || '').trim() : ''; + if (activeFlushLogin) { + confirmedOwnerLogin = activeFlushLogin; + timerView.restore(todaySync.flush()); + restoreReleaseReceipt(); + updateDeliveryReceiptControls(); + interruptionPrompt.restore(); + } + } if (snapshot.context && workChanged) { setOfflineWorkMode(false); const retainedPlanningLogin = !snapshot.context.error ? @@ -5463,16 +5475,6 @@ laterSync.migrate(laterWork.read()); laterSync.flush(); } - const contextIdentityFresh = !snapshot.context.error && !contextFreshness?.stale && - !contextFreshness?.degraded && !contextFreshness?.revalidating; - activeFlushLogin = contextIdentityFresh ? String(snapshot.context.user?.login || '').trim() : ''; - if (activeFlushLogin) { - confirmedOwnerLogin = activeFlushLogin; - timerView.restore(todaySync.flush()); - restoreReleaseReceipt(); - updateDeliveryReceiptControls(); - interruptionPrompt.restore(); - } snapshot.context.notifications = lastNotifications; renderContextSnapshot(snapshot.context); if (contextFreshness?.stale) markMyWorkStale(); diff --git a/tests/test_today_break.py b/tests/test_today_break.py index ec465c6..f705b1a 100644 --- a/tests/test_today_break.py +++ b/tests/test_today_break.py @@ -267,6 +267,20 @@ restoring.then(result => {{ assert "timerView.restore(todaySync.flush());" in dashboard +def test_fresh_unchanged_context_restores_the_confirmed_break_owner(): + dashboard = (ROOT / "frontend" / "dashboard.js").read_text() + snapshot_handler = dashboard.split("async function renderLiveSnapshot", 1)[1] + identity_restore, changed_render = snapshot_handler.split( + "if (snapshot.context && workChanged)", 1 + ) + assert "activeFlushLogin = contextIdentityFresh ?" in identity_restore + assert "confirmedOwnerLogin = activeFlushLogin;" in identity_restore + assert "timerView.restore(todaySync.flush());" in identity_restore + assert "activeFlushLogin = contextIdentityFresh ?" not in changed_render.split( + "if (eventsChanged", 1 + )[0] + + def test_timed_break_is_packaged_as_an_accessible_mobile_flow(): html = (ROOT / "frontend" / "index.html").read_text() css = (ROOT / "frontend" / "dashboard.css").read_text()