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=<hash> with the page still alive,
and appending to a .js file reloaded the page.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QBDkEXP4htyXTCZUwMLphd
This commit is contained in:
Simon
2026-09-05 15:48:11 +00:00
parent 0f30480af4
commit 6631447acc
2 changed files with 22 additions and 0 deletions

View File

@@ -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();