From 6631447acc1fba9f13c0432943d301f43a07c17e Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 5 Sep 2026 15:48:11 +0000 Subject: [PATCH] Have the refresh button check for a new build too The version poller already diffs /api/version against the manifest captured at boot -- hot-swapping changed CSS, reloading for changed JS/HTML once playback allows -- but only on its own 60s tick or when the tab regains visibility. Pressing refresh now runs that same check in the background, so a tab left open across a deploy picks the new build up when the user asks for fresh content rather than up to a minute later. App.version.checkNow() exposes it; with no baseline (the endpoint was down at boot) it just adopts the current manifest, since there is nothing to compare against yet. Verified against the running app: appending to style.css and pressing refresh swapped the tag to style.css?v= with the page still alive, and appending to a .js file reloaded the page. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01QBDkEXP4htyXTCZUwMLphd --- frontend/js/ui.js | 7 +++++++ frontend/js/version.js | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/frontend/js/ui.js b/frontend/js/ui.js index 5474ef6..f27c5a9 100644 --- a/frontend/js/ui.js +++ b/frontend/js/ui.js @@ -461,6 +461,13 @@ App.ui = App.ui || {}; if (reloadChannelBtn) { reloadChannelBtn.onclick = () => { + // Refresh means "give me the current everything": the videos + // below, and the app itself. The version check runs in the + // background and only acts if the deployed assets actually + // differ from what this tab is running. + if (App.version && typeof App.version.checkNow === 'function') { + App.version.checkNow(); + } App.videos.resetAndReload(); }; } diff --git a/frontend/js/version.js b/frontend/js/version.js index c121704..d2fda1a 100644 --- a/frontend/js/version.js +++ b/frontend/js/version.js @@ -114,6 +114,21 @@ App.version = App.version || {}; } } + // Same check the poller runs, on demand: the top-bar refresh button asks for + // it so a tab left open across a deploy picks the new build up right then, + // rather than up to POLL_INTERVAL_MS later. Changed CSS hot-swaps; changed + // JS/HTML reloads as soon as that won't interrupt playback. + App.version.checkNow = function() { + if (!baseline) { + // start() never got a manifest (endpoint down, or it hasn't run + // yet). Adopt whatever the server reports now so there's something + // to diff against next time -- there's no baseline to compare this + // one against, so nothing can be concluded from it today. + return fetchVersion().then((latest) => { baseline = latest; }).catch(() => {}); + } + return check(); + }; + App.version.start = async function() { try { baseline = await fetchVersion();