From 271c609c14fb4ce8a6f44addc5c0387f4d441933 Mon Sep 17 00:00:00 2001 From: Erich Blume Date: Thu, 4 Jun 2026 17:16:15 -0700 Subject: [PATCH] feat(heph-pwa): re-fetch the current view when the app regains focus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The PWA shares the daemon's store with the TUI/desktop popover but only re-fetched on a view switch or action — so a task marked done elsewhere left a stale list on screen. Reload the current view on visibilitychange→visible (switch back to the phone, unlock, tab re-show), skipping it mid-modal/search. Co-Authored-By: Claude Opus 4.8 (1M context) --- heph-pwa/src/app.js | 17 +++++++++++++++++ heph-pwa/sw.js | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/heph-pwa/src/app.js b/heph-pwa/src/app.js index 6acc2a9..f06ba06 100644 --- a/heph-pwa/src/app.js +++ b/heph-pwa/src/app.js @@ -785,6 +785,23 @@ function buildShell() { async function init() { buildShell(); document.addEventListener("keydown", onKeydown); + + // The PWA shares the daemon's store with the TUI / desktop popover, but only + // re-fetches on a view switch or an action. So another surface marking a task + // done leaves a stale list on screen until then. Re-fetch the current view + // whenever the app regains focus (switching back to the phone, unlock, tab + // re-show) — but not while a modal or search is mid-interaction. + document.addEventListener("visibilitychange", () => { + if ( + document.visibilityState === "visible" && + state.client.configured && + !modalOpen() && + !state.search + ) { + reload(); + } + }); + render(); reload(); diff --git a/heph-pwa/sw.js b/heph-pwa/sw.js index 3ecb45d..571d1e6 100644 --- a/heph-pwa/sw.js +++ b/heph-pwa/sw.js @@ -1,7 +1,7 @@ // Service worker: cache the app shell so heph launches offline. Data is never // cached — every /rpc call must hit the live hub (and POSTs aren't cacheable // anyway). Bump CACHE when shell assets change to evict the old set. -const CACHE = "heph-pwa-v2"; +const CACHE = "heph-pwa-v3"; const SHELL = [ "./", "./index.html",