feat(boardwalk): expose the admin build id and show a reload banner when a new build is deployed (quick-261028-rqb)

- boardwalk.BuildID hashes the dist tree plus the binary's build info once
  per handler; X-Summer-Build on every response, {prefix}/build.json and the
  summer-admin-build meta carry it
- the SPA reads the booted build, re-checks on focus, visibility and every
  5 minutes, and shows UpdateBanner on a different build
This commit is contained in:
Jakub Zych
2026-10-28 21:19:36 +01:00
parent 4957e5ce25
commit 291b18fb1e
12 changed files with 404 additions and 5 deletions

View File

@@ -1,8 +1,12 @@
// Runtime configuration read once from the served index.html. The Go server
// (boardwalk) writes the configured backend.uri into the summer-admin-base
// meta; the SPA derives its router base and API base from it (D-02, D-03).
// It also writes the build id into the summer-admin-build meta, the build the
// tab booted with (buildUpdate.ts compares it with build.json).
export const DEFAULT_BASE = '/backend'
const TOKEN = '__SUMMER_ADMIN_BASE__'
const BUILD_TOKEN = '__SUMMER_ADMIN_BUILD__'
const BUILD_SHAPE = /^[0-9a-f]{6,64}$/
export function readBase(doc: Document = document): string {
const content = doc.querySelector<HTMLMetaElement>('meta[name="summer-admin-base"]')?.content.trim() ?? ''
@@ -13,6 +17,18 @@ export function readBase(doc: Document = document): string {
return trimmed === '' ? DEFAULT_BASE : trimmed
}
/**
* The build id from the summer-admin-build meta, or "" when the meta is
* missing, empty, the unreplaced token (the dev server) or not lowercase hex.
*/
export function readBuild(doc: Document = document): string {
const content = doc.querySelector<HTMLMetaElement>('meta[name="summer-admin-build"]')?.content.trim() ?? ''
if (content === BUILD_TOKEN || !BUILD_SHAPE.test(content)) {
return ''
}
return content
}
const base = readBase()
export const runtime = {
@@ -20,4 +36,6 @@ export const runtime = {
base,
/** Admin API root, the mount path plus /api/v1. */
api: `${base}/api/v1`,
/** The build id this tab booted with; "" turns the version check off. */
build: readBuild(),
} as const