Files
token-circles/frontend/index.html
T
KomediruzeckiandGitHub beb328c309 fix(updates): one-reload deploy transitions with a truthful version label (#353)
An open prod tab crossing the v5.6.0/v5.6.1 releases reloaded several
times in a row, hit the 'Update needed' panel, and afterwards showed
v5.6.0 while 5.6.1 code was demonstrably running. Full audit, sequence
map, and manual verification steps: docs/deploy-update-pipeline.md.

- Service worker: stop precaching index.html and drop navigateFallback;
  navigations are NetworkFirst (finance-manager-pages-v1, 4s offline
  fallback), so a reload can never be re-served a stale shell by the old
  worker - the root cause of the reload loop. The js/css runtime cache
  lives 7 days instead of 5 minutes so offline boots actually work
  (online stays network-first either way).
- Every auto-reload path refreshes the SW first: bootRecovery's new
  activateUpdatedServiceWorker() triggers registration.update() and
  waits (bounded) for the skipWaiting/clientsClaim takeover, then
  reloads once.
- Reloads are hard-bounded: one per server sha plus a rolling cap of 3
  per 10 minutes in appVersion; the index.html watchdog moves from
  once-per-SESSION to a 2-minute cooldown, so the second release of the
  day auto-recovers instead of stranding the user on the panel.
- Version truth: APP_VERSION uses git describe --tags without
  --abbrev=0, so a non-tag prod build stamps 5.6.0-2-gxxxxxxx instead of
  impersonating the previous release (the observed lying label). The
  displayed version (login footer, Settings About, crash modal) comes
  from a reconciled displayVersion() signal - when version.json reports
  the same sha under a different string, the network string wins - and
  Settings shows the pending version while an update is armed.
- The per-release SW unregister inline script (keyed on package.json, a
  third version source) becomes a one-time SW_CLEANUP_EPOCH migration
  that re-registers after the unregisters settle.
- 25 new unit tests for the decision logic (appVersion.test.ts,
  bootRecovery.test.ts); vitest gains the build-identity defines.
2026-07-17 15:16:28 +02:00

237 lines
9.7 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<meta name="theme-color" content="#0a0e1c" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<link rel="apple-touch-icon" href="/icon-192.png" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<!-- Pre-paint theme stamp (external, not inline: the self-hosted Express
deployment enforces script-src 'self', which blocks inline scripts). -->
<script src="/theme-init.js"></script>
<title>Token Circles — Personal Finance</title>
<meta
name="description"
content="Token Circles is an open-source, local-first personal finance app — budgets, analytics, calculators, and investments, right in your browser. Your data stays yours."
/>
<link rel="canonical" href="https://tokencircles.com/" />
<!-- Open Graph / Twitter -->
<meta property="og:type" content="website" />
<meta property="og:site_name" content="Token Circles" />
<meta property="og:title" content="Token Circles — Personal Finance" />
<meta
property="og:description"
content="Open-source, local-first personal finance — budgets, analytics, calculators, and investments, right in your browser. Your data stays yours."
/>
<meta property="og:url" content="https://tokencircles.com/" />
<meta property="og:image" content="https://tokencircles.com/og-image.jpg" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="og:image:alt" content="Token Circles — personal finance in clear orbit" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Token Circles — Personal Finance" />
<meta
name="twitter:description"
content="Open-source, local-first personal finance — budgets, analytics, calculators, and investments, right in your browser."
/>
<meta name="twitter:image" content="https://tokencircles.com/og-image.jpg" />
<!-- Fonts are self-hosted (see src/styles/index.css) — no cross-origin Google Fonts,
so nothing here trips CSP and headings render offline. -->
<!-- Boot watchdog: the LAST-RESORT recovery for a bad deploy. When a hashed chunk from a
stale index.html is gone, the entry module fails to load and the app never mounts —
so the in-app crash screen (which lives *inside* that bundle) can't help. This inline
script runs with zero dependencies: if an app asset errors before boot, or the app
hasn't signaled boot in time, it clears the service worker + caches and reloads once
per cooldown window (a plain reload won't fix a stale SW), then falls back to a
manual recovery panel. -->
<script>
;(function () {
var booted = function () {
return window.__APP_BOOTED__ === true
}
var recovering = false
function isAppAsset(el) {
if (!el || !el.tagName) return false
var tag = el.tagName.toUpperCase()
if (tag !== 'SCRIPT' && tag !== 'LINK') return false
return /\/assets\//.test(el.src || el.href || '')
}
function clearCachesAndSW() {
var tasks = []
try {
if ('serviceWorker' in navigator) {
tasks.push(
navigator.serviceWorker
.getRegistrations()
.then(function (rs) {
return Promise.all(
rs.map(function (r) {
return r.unregister()
})
)
})
.catch(function () {})
)
}
if (window.caches && caches.keys) {
tasks.push(
caches
.keys()
.then(function (ks) {
return Promise.all(
ks.map(function (k) {
return caches.delete(k)
})
)
})
.catch(function () {})
)
}
} catch (e) {}
return Promise.all(tasks).catch(function () {})
}
function showPanel() {
if (document.getElementById('tc-recovery')) return
var wrap = document.createElement('div')
wrap.id = 'tc-recovery'
wrap.setAttribute(
'style',
'position:fixed;inset:0;z-index:2147483647;display:flex;align-items:center;' +
'justify-content:center;background:#0a0e1c;color:#f1f5f9;font-family:Inter,' +
'system-ui,-apple-system,sans-serif;padding:24px;text-align:center'
)
var box = document.createElement('div')
box.setAttribute('style', 'max-width:420px')
var h = document.createElement('h1')
h.textContent = 'Update needed'
h.setAttribute('style', 'font-size:1.4rem;font-weight:600;margin:0 0 10px')
var p = document.createElement('p')
p.textContent =
'A new version was released and this page could not finish loading. ' +
'Reload to get the latest, or reset the app cache if that does not help.'
p.setAttribute('style', 'color:#94a3b8;line-height:1.6;margin:0 0 20px')
var reload = document.createElement('button')
reload.textContent = 'Reload'
reload.setAttribute(
'style',
'display:block;width:100%;margin:0 0 10px;padding:12px;border:none;border-radius:8px;' +
'background:#3b82f6;color:#fff;font-size:1rem;font-weight:600;cursor:pointer'
)
reload.addEventListener('click', function () {
location.reload()
})
var reset = document.createElement('button')
reset.textContent = 'Reset app cache & reload'
reset.setAttribute(
'style',
'display:block;width:100%;padding:12px;border:1px solid #334155;border-radius:8px;' +
'background:transparent;color:#f1f5f9;font-size:1rem;cursor:pointer'
)
reset.addEventListener('click', function () {
reset.textContent = 'Resetting…'
clearCachesAndSW().then(function () {
location.reload()
})
})
box.appendChild(h)
box.appendChild(p)
box.appendChild(reload)
box.appendChild(reset)
wrap.appendChild(box)
;(document.body || document.documentElement).appendChild(wrap)
}
function recover() {
if (recovering || booted()) return
recovering = true
// One auto-recovery per cooldown window, not per session: back-to-back releases can
// legitimately need this twice in one long-lived tab (each deploy gets one clean
// clear+reload), while a genuinely broken build still can't loop — repeats inside
// the window hand off to the user panel. The legacy value '1' parses as an ancient
// timestamp, so pre-cooldown sessions are allowed to recover again.
var RECOVER_COOLDOWN_MS = 2 * 60 * 1000
var recentlyTried = false
try {
var last = Number(sessionStorage.getItem('tc-recovered') || 0)
recentlyTried = last > 0 && Date.now() - last < RECOVER_COOLDOWN_MS
} catch (e) {}
if (recentlyTried) {
showPanel()
return
}
try {
sessionStorage.setItem('tc-recovered', String(Date.now()))
} catch (e) {}
clearCachesAndSW().then(function () {
location.reload()
})
}
// Precise signal: an app asset (entry bundle, a chunk, or the stylesheet) failed to
// load before the app booted. Capture phase catches resource errors that don't bubble.
window.addEventListener(
'error',
function (e) {
if (!booted() && isAppAsset(e.target)) recover()
},
true
)
// Backstop: nothing errored loudly, but the app never mounted anything in time.
setTimeout(function () {
var root = document.getElementById('root')
if (
!booted() &&
root &&
root.childElementCount === 0 &&
document.visibilityState !== 'hidden'
) {
recover()
}
}, 12000)
})()
</script>
</head>
<body>
<noscript>
<div
style="
max-width: 640px;
margin: 16vh auto;
padding: 0 24px;
font-family:
Inter,
system-ui,
-apple-system,
sans-serif;
color: #f1f5f9;
text-align: center;
"
>
<h1 style="font-size: 1.6rem; font-weight: 600; margin: 0 0 12px">Token Circles</h1>
<p style="color: #94a3b8; line-height: 1.7; margin: 0 0 16px">
Token Circles is an open-source, local-first personal finance app — budgets, analytics,
calculators, and investments, right in your browser, with your data staying on your
device. The app needs JavaScript to run.
</p>
<p style="margin: 0">
<a href="https://about.tokencircles.com" style="color: #60a5fa; text-decoration: none"
>Learn more at about.tokencircles.com &rarr;</a
>
</p>
</div>
</noscript>
<div id="root"></div>
<script src="/src/index.tsx" type="module"></script>
</body>
</html>