From 0f2d0db3c7138b4d9d6dce0efed6de33c6ab4ceb Mon Sep 17 00:00:00 2001 From: codex Date: Wed, 11 Nov 2026 14:15:04 +0300 Subject: [PATCH] fix: keep guide accessible when browser storage is blocked --- app/static/guide.js | 32 ++++++++++++++++++++++------ app/templates/guide_walkthrough.html | 4 ++-- app/version.py | 6 +++--- pyproject.toml | 2 +- tests/browser_users.py | 9 ++++++++ tests/test_api.py | 2 +- tests/test_council.py | 2 +- tests/test_users.py | 2 +- 8 files changed, 44 insertions(+), 15 deletions(-) diff --git a/app/static/guide.js b/app/static/guide.js index 1c77ed1..a560db7 100644 --- a/app/static/guide.js +++ b/app/static/guide.js @@ -70,6 +70,7 @@ const main = document.querySelector('#main-content'); const trigger = document.querySelector('[data-guide-open]'); + const fallback = document.querySelector('[data-guide-fallback]'); const heading = guide.querySelector('#guide-title'); const progress = guide.querySelector('[data-guide-progress]'); const intro = guide.querySelector('[data-guide-intro]'); @@ -152,7 +153,10 @@ } function goTo(number, path = steps[number].path || '/admin/account') { - sessionStorage.setItem(storageKey, steps[number].id); + if (!saveStep(steps[number].id)) { + location.assign(trigger.href); + return; + } if (path !== location.pathname) { location.assign(path); return; @@ -164,11 +168,20 @@ function hide(remember = true) { clearTips(); guide.hidden = true; - if (remember) sessionStorage.setItem(storageKey, 'closed'); - else sessionStorage.removeItem(storageKey); + saveStep(remember ? 'closed' : null); trigger?.focus(); } + function saveStep(step) { + try { + if (step === null) sessionStorage.removeItem(storageKey); + else sessionStorage.setItem(storageKey, step); + return true; + } catch { + return false; + } + } + async function finish() { if (saving) return; if (guide.dataset.guidePending !== 'true') { @@ -219,13 +232,20 @@ finish(); }); function restore(allowAutoStart) { - const active = sessionStorage.getItem(storageKey); + let active; + try { + active = sessionStorage.getItem(storageKey); + } catch { + return; + } const requested = steps.findIndex(step => step.id === active); + const autoStart = allowAutoStart && requested < 0 && active !== 'closed' && guide.dataset.guidePending === 'true'; + if (autoStart && !saveStep(steps[0].id)) return; + if (fallback) fallback.hidden = true; if (requested >= 0) { index = requested; showStep(!allowAutoStart || index > 0); - } else if (allowAutoStart && active !== 'closed' && guide.dataset.guidePending === 'true') { - sessionStorage.setItem(storageKey, steps[0].id); + } else if (autoStart) { showStep(false); } else { clearTips(); diff --git a/app/templates/guide_walkthrough.html b/app/templates/guide_walkthrough.html index 6af8763..e5f41eb 100644 --- a/app/templates/guide_walkthrough.html +++ b/app/templates/guide_walkthrough.html @@ -16,10 +16,10 @@ {% if request.state.guide_pending|default(false) %} -