Self-hosted fitness tracker. Log workouts, track nutrition, and monitor progress. Docker deployment, mobile-friendly.
Fix the app shell: metadata, fonts, demo sign-in, and a transparent header (#152)
Carter6659b75dc7b6
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 262e985..a517e69 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -19,9 +19,16 @@ go run .# API listens on http://localhost:3000```-On first run the backend seeds the exercise database automatically, plus a demo account —-the latter only because `ENV=development`, which is what `DEMO_MODE` defaults to. A-production install seeds no account at all; set `DEMO_MODE=true` if you want one there.+On first run the backend seeds the exercise database automatically. The demo account is+**not** seeded unless you ask for it — its password is published right below, so the+default is off everywhere, development included:++```bash+DEMO_MODE=true go run .+```++That same flag puts the one-tap "Try demo account" button on the login screen, so the+button only ever appears where the account exists.**Demo credentials**```diff --git a/backend/config/config.go b/backend/config/config.goindex 5537158..41f7335 100644--- a/backend/config/config.go+++ b/backend/config/config.go@@ -86,9 +86,17 @@ func Load() {OEDBBaseURL: getEnv("OEDB_BASE_URL", ""),Registration: getEnv("REGISTRATION", RegistrationOpen),- // Contributors following CONTRIBUTING.md get the demo account without setting- // anything; a self-hoster or the Fly demo has to ask for it.- DemoMode: getEnvBool("DEMO_MODE", env == "development"),+ // Opt-in everywhere, including development. This used to default to+ // `env == "development"`, and ENV itself defaults to "development" — so running+ // the binary without setting either seeded [email protected] with a password+ // published in the docs. Every real deployment already names this explicitly+ // (compose sets DEMO_MODE=${DEMO_MODE:-false}, fly.toml sets it true), and the+ // configuration docs already stated the default was false, so this makes the+ // code agree with what was published rather than changing the contract.+ //+ // It also decides the one-tap demo button on the login screen, via demo_mode on+ // /api/v1/info: the button follows the account because it reads the same flag.+ DemoMode: getEnvBool("DEMO_MODE", false),}if C.Env == "production" && C.JWTSecret == "change-me-in-production-min-32-chars!!" {diff --git a/backend/config/config_test.go b/backend/config/config_test.goindex 545e35c..a292065 100644--- a/backend/config/config_test.go+++ b/backend/config/config_test.go@@ -17,7 +17,7 @@ func TestGetEnvBool(t *testing.T) {{"false", true, false},{"FALSE", true, false},{"0", true, false},- // Unset falls back — this is what makes DEMO_MODE default to ENV=development.+ // Unset falls back to whatever the caller passed.{"", true, true},{"", false, false},// Unparseable falls back rather than reading as false: DEMO_MODE=ture should@@ -36,6 +36,33 @@ func TestGetEnvBool(t *testing.T) {}}+// The demo account's password is published in the documentation, so the only safe+// default is off. It used to key off `env == "development"`, and ENV itself defaults to+// "development" — meaning anyone running the binary without setting either variable+// seeded that account on their own instance. This pins the default so it cannot drift+// back: nothing set means no demo account, and therefore no demo button either, since+// both read this one flag.+func TestDemoModeDefaultsOff(t *testing.T) {+ t.Setenv("DEMO_MODE", "")+ t.Setenv("ENV", "")+ Load()+ if C.DemoMode {+ t.Error("DemoMode with nothing set = true, want false")+ }++ t.Setenv("ENV", "development")+ Load()+ if C.DemoMode {+ t.Error("DemoMode under ENV=development = true, want false — development is not consent")+ }++ t.Setenv("DEMO_MODE", "true")+ Load()+ if !C.DemoMode {+ t.Error("DemoMode with DEMO_MODE=true = false, want true")+ }+}+// Load refuses to start on an unknown mode rather than falling back to open, so this// is the check that decides between "locked down" and "wide open with a typo".func TestValidRegistration(t *testing.T) {diff --git a/backend/controllers/server.go b/backend/controllers/server.goindex 82dbfa4..259a957 100644--- a/backend/controllers/server.go+++ b/backend/controllers/server.go@@ -18,6 +18,11 @@ import (// offering a link that 403s on submit. It is politeness, not enforcement — the check in// Register is what actually closes the door — and only the boolean is exposed, never the// mode, so a scanner learns nothing it could not learn by POSTing once.+//+// demo_mode lets the login screen offer a one-tap sign-in rather than asking a stranger to+// type [email protected]. It is the same flag that decides whether seed.DemoUser runs, so the+// button only ever appears where the account exists. Nothing is disclosed: DEMO_MODE is+// opt-in everywhere, and wherever it is on the credentials are already public.func (h *Handler) ServerInfo(c *gin.Context) {open, err := h.registrationOpen()if err != nil {@@ -27,5 +32,6 @@ func (h *Handler) ServerInfo(c *gin.Context) {"name": "lyftr","version": config.C.Version,"registration_open": open,+ "demo_mode": config.C.DemoMode,})}diff --git a/backend/controllers/server_test.go b/backend/controllers/server_test.goindex a28ef0e..23345de 100644--- a/backend/controllers/server_test.go+++ b/backend/controllers/server_test.go@@ -33,6 +33,42 @@ func TestServerInfo(t *testing.T) {}}+// The one-tap demo sign-in is gated on this flag, so the flag is the only thing standing+// between a stranger's convenience and a self-hoster's login screen advertising an account+// that does not exist there. Both directions are asserted: reporting true where DEMO_MODE is+// off would put a button on every self-hosted instance that 401s when pressed.+func TestServerInfoReportsDemoMode(t *testing.T) {+ demoMode := func(t *testing.T) any {+ t.Helper()+ c, w := newContext(0, "GET", "/api/v1/info", nil)+ th.ServerInfo(c)+ data := decodeResponse(t, w)["data"].(map[string]any)+ return data["demo_mode"]+ }++ t.Run("off by default", func(t *testing.T) {+ setupTestDB(t)+ prev := config.C.DemoMode+ t.Cleanup(func() { config.C.DemoMode = prev })++ config.C.DemoMode = false+ if got := demoMode(t); got != false {+ t.Errorf("demo_mode = %v, want false", got)+ }+ })++ t.Run("on where the demo user is seeded", func(t *testing.T) {+ setupTestDB(t)+ prev := config.C.DemoMode+ t.Cleanup(func() { config.C.DemoMode = prev })++ config.C.DemoMode = true+ if got := demoMode(t); got != true {+ t.Errorf("demo_mode = %v, want true", got)+ }+ })+}+// The flag both clients read to decide whether to offer "Create account". Under// first-user it has to flip the moment the owner claims the instance — a static value// per mode would keep advertising an open server that now 403s.diff --git a/backend/main.go b/backend/main.goindex 31a45d3..6ce2769 100644--- a/backend/main.go+++ b/backend/main.go@@ -91,8 +91,15 @@ func main() {config.Load()db.Connect()warnIfUnclaimed()- // The demo account's credentials are published, so it is not something a self-hosted- // instance should get by default — only the public demo and local development ask for+ // The demo account's credentials are published, so nothing gets it without asking:+ // DEMO_MODE is opt-in everywhere, development included. Only the Fly demo (fly.toml)+ // and a contributor who types DEMO_MODE=true turn it on.+ //+ // The else branch is not redundant. Turning the flag off stops the account being+ // created and hides the one-tap button, but it cannot un-create one already in the+ // database — and deleting it here would risk taking real workouts with it, since+ // someone may have trained under that login. So an existing account keeps working and+ // this warns at every startup until the operator removes it or changes its password.if config.C.DemoMode {seed.DemoUser(db.DB)} else {diff --git a/package-lock.json b/package-lock.jsonindex 84bf398..0d7ce63 100644--- a/package-lock.json+++ b/package-lock.json@@ -3267,6 +3267,30 @@"excpretty": "build/cli.js"}},+ "node_modules/@fontsource-variable/jetbrains-mono": {+ "version": "5.3.0",+ "resolved": "https://registry.npmjs.org/@fontsource-variable/jetbrains-mono/-/jetbrains-mono-5.3.0.tgz",+ "integrity": "sha512-F32xpS2NsGYoQi2ADSkKTgpJj7ozajsGgDJ8woTnqjmIB+dxDIqImjl4pXZVEExu8UFZ2ndhmX18EBS/hdz3Lw==",+ "funding": {+ "url": "https://github.com/sponsors/ayuhito"+ }+ },+ "node_modules/@fontsource-variable/outfit": {+ "version": "5.3.0",+ "resolved": "https://registry.npmjs.org/@fontsource-variable/outfit/-/outfit-5.3.0.tgz",+ "integrity": "sha512-fPb5XnYK0k7SbR++HEmm4+ZqDszmLKQ+sPRUr8oQ/KNC0vy6r6hazJFe8iYozv4cqlHbvJ/JECkJWrfDodUMVQ==",+ "funding": {+ "url": "https://github.com/sponsors/ayuhito"+ }+ },+ "node_modules/@fontsource-variable/plus-jakarta-sans": {+ "version": "5.3.0",+ "resolved": "https://registry.npmjs.org/@fontsource-variable/plus-jakarta-sans/-/plus-jakarta-sans-5.3.0.tgz",+ "integrity": "sha512-/l/4r0yyWK9JzAlmA0LiYgGgmJe/Gswt4jTJEzr5QhJfwMbvJZDmYWyW0M4X7yCK69BajMVlV/Lx8g7WDc1+sw==",+ "funding": {+ "url": "https://github.com/sponsors/ayuhito"+ }+ },"node_modules/@humanfs/core": {"version": "0.19.2","resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.2.tgz",@@ -20069,6 +20093,9 @@"name": "lyfter-web","version": "0.0.0","dependencies": {+ "@fontsource-variable/jetbrains-mono": "^5.3.0",+ "@fontsource-variable/outfit": "^5.3.0",+ "@fontsource-variable/plus-jakarta-sans": "^5.3.0","@lyftr/shared": "*","@tanstack/react-virtual": "^3.13.24","axios": "^1.6.2",diff --git a/packages/shared/src/client.ts b/packages/shared/src/client.tsindex b8d254d..06e0cc4 100644--- a/packages/shared/src/client.ts+++ b/packages/shared/src/client.ts@@ -16,6 +16,10 @@ export interface ServerInfo {// Optional: a backend older than the REGISTRATION feature omits it. Read it through// registrationOpen() so "absent" means open rather than closed.registration_open?: boolean+ // Optional, and the opposite polarity to the field above: read through demoMode() so+ // "absent" means no demo account. Guessing wrong here shows a sign-in button that 401s,+ // whereas guessing wrong on registration only hides a link that would have worked.+ demo_mode?: boolean}export interface ClientOptions {diff --git a/packages/shared/src/hooks/useServerInfo.test.ts b/packages/shared/src/hooks/useServerInfo.test.tsindex 82f43cc..554e97f 100644--- a/packages/shared/src/hooks/useServerInfo.test.ts+++ b/packages/shared/src/hooks/useServerInfo.test.ts@@ -1,4 +1,4 @@-import { registrationOpen } from './useServerInfo'+import { registrationOpen, demoMode } from './useServerInfo'// The one rule worth pinning: which values hide the "Create account" affordance.// Getting the absent case backwards would hide signup on every server older than the@@ -22,3 +22,26 @@ describe('registrationOpen', () => {expect(registrationOpen(undefined)).toBe(true)})})++// The mirror image of the rule above, and the polarity is the point: every uncertain case+// resolves to "no demo button". Offering one where no demo account was seeded produces a+// sign-in that 401s, which reads as a broken app rather than a missing feature — so absent,+// unreachable and still-loading all mean no, and only an explicit true means yes.+describe('demoMode', () => {+ it('is on only when the server explicitly says so', () => {+ expect(demoMode({ name: 'lyftr', version: '1.0.0', demo_mode: true })).toBe(true)+ })++ it('is off on an explicit false — a self-hosted instance', () => {+ expect(demoMode({ name: 'lyftr', version: '1.0.0', demo_mode: false })).toBe(false)+ })++ it('is off when the field is absent — a backend older than this feature', () => {+ expect(demoMode({ name: 'lyftr', version: '0.1.0' })).toBe(false)+ })++ it('is off while the probe is still in flight or the server is unreachable', () => {+ expect(demoMode(null)).toBe(false)+ expect(demoMode(undefined)).toBe(false)+ })+})diff --git a/packages/shared/src/hooks/useServerInfo.ts b/packages/shared/src/hooks/useServerInfo.tsindex 9a6e9d1..ed60f14 100644--- a/packages/shared/src/hooks/useServerInfo.ts+++ b/packages/shared/src/hooks/useServerInfo.ts@@ -57,3 +57,12 @@ export function useServerInfoFor(base: string, probe: Probe): ServerInfo | nullexport function registrationOpen(info: ServerInfo | null | undefined): boolean {return info?.registration_open !== false}++// Whether to offer one-tap demo sign-in. Only an explicit true counts — the inverse of+// registrationOpen() above, and deliberately so. A wrongly-shown "Create account" link+// costs a 403 on submit; a wrongly-shown demo button asks someone to sign in as an account+// that was never seeded, which fails and looks like the app is broken. So an old backend,+// an unreachable one, or a still-loading probe all mean no button.+export function demoMode(info: ServerInfo | null | undefined): boolean {+ return info?.demo_mode === true+}diff --git a/site/package-lock.json b/site/package-lock.jsonindex 4c31729..dc0da05 100644--- a/site/package-lock.json+++ b/site/package-lock.json@@ -10,6 +10,9 @@"dependencies": {"@astrojs/starlight": "0.37.0","@astrojs/tailwind": "6.0.2",+ "@fontsource-variable/jetbrains-mono": "^5.3.0",+ "@fontsource-variable/outfit": "^5.3.0",+ "@fontsource-variable/plus-jakarta-sans": "^5.3.0","astro": "5.18.2","sharp": "^0.33.5","tailwindcss": "3.4.17"@@ -737,6 +740,30 @@"@expressive-code/core": "^0.41.7"}},+ "node_modules/@fontsource-variable/jetbrains-mono": {+ "version": "5.3.0",+ "resolved": "https://registry.npmjs.org/@fontsource-variable/jetbrains-mono/-/jetbrains-mono-5.3.0.tgz",+ "integrity": "sha512-F32xpS2NsGYoQi2ADSkKTgpJj7ozajsGgDJ8woTnqjmIB+dxDIqImjl4pXZVEExu8UFZ2ndhmX18EBS/hdz3Lw==",+ "funding": {+ "url": "https://github.com/sponsors/ayuhito"+ }+ },+ "node_modules/@fontsource-variable/outfit": {+ "version": "5.3.0",+ "resolved": "https://registry.npmjs.org/@fontsource-variable/outfit/-/outfit-5.3.0.tgz",+ "integrity": "sha512-fPb5XnYK0k7SbR++HEmm4+ZqDszmLKQ+sPRUr8oQ/KNC0vy6r6hazJFe8iYozv4cqlHbvJ/JECkJWrfDodUMVQ==",+ "funding": {+ "url": "https://github.com/sponsors/ayuhito"+ }+ },+ "node_modules/@fontsource-variable/plus-jakarta-sans": {+ "version": "5.3.0",+ "resolved": "https://registry.npmjs.org/@fontsource-variable/plus-jakarta-sans/-/plus-jakarta-sans-5.3.0.tgz",+ "integrity": "sha512-/l/4r0yyWK9JzAlmA0LiYgGgmJe/Gswt4jTJEzr5QhJfwMbvJZDmYWyW0M4X7yCK69BajMVlV/Lx8g7WDc1+sw==",+ "funding": {+ "url": "https://github.com/sponsors/ayuhito"+ }+ },"node_modules/@img/colour": {"version": "1.1.0","resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz",diff --git a/site/package.json b/site/package.jsonindex f7f11a3..f1ff1e1 100644--- a/site/package.json+++ b/site/package.json@@ -13,6 +13,9 @@"dependencies": {"@astrojs/starlight": "0.37.0","@astrojs/tailwind": "6.0.2",+ "@fontsource-variable/jetbrains-mono": "^5.3.0",+ "@fontsource-variable/outfit": "^5.3.0",+ "@fontsource-variable/plus-jakarta-sans": "^5.3.0","astro": "5.18.2","sharp": "^0.33.5","tailwindcss": "3.4.17"diff --git a/site/src/pages/index.astro b/site/src/pages/index.astroindex c4db60d..d3fcf33 100644--- a/site/src/pages/index.astro+++ b/site/src/pages/index.astro@@ -125,13 +125,6 @@ const jsonLd = {<meta name="twitter:description" content={description} /><meta name="twitter:image" content={ogImage} />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />- <link- href="https://fonts.googleapis.com/css2?family=Outfit:wght@500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap"- rel="stylesheet"- />-<script type="application/ld+json" set:html={JSON.stringify(jsonLd)} /></head>@@ -175,8 +168,12 @@ const jsonLd = {Deploy in one command</a></div>+ {/* The demo's login screen now offers one-tap sign-in, so the credentials are a+ fallback rather than an instruction. Keeping them stated means this line is+ true both before and after the demo redeploys with that button. */}<p class="mt-4 text-sm text-tx-muted">- Demo login <code class="font-mono text-tx-secondary">[email protected]</code> /+ One tap to sign in — no account needed. Or use+ <code class="font-mono text-tx-secondary">[email protected]</code> /<code class="font-mono text-tx-secondary">password123</code> · resets hourly</p></div>diff --git a/site/src/styles/starlight-brand.css b/site/src/styles/starlight-brand.cssindex 4146c52..38dcca2 100644--- a/site/src/styles/starlight-brand.css+++ b/site/src/styles/starlight-brand.css@@ -1,10 +1,15 @@+/* The docs theme named these families but nothing loaded them — the Google Fonts <link>+ only ever existed on the landing page, so every Starlight page fell back to system-ui. */+@import '@fontsource-variable/plus-jakarta-sans';+@import '@fontsource-variable/jetbrains-mono';+/* Brand the Starlight docs theme with Lyftr's electric-cyan accent (#00b8d9). */:root {--sl-color-accent-low: #003d4d;--sl-color-accent: #00b8d9;--sl-color-accent-high: #b0f1fe;- --sl-font: 'Plus Jakarta Sans', system-ui, sans-serif;- --sl-font-mono: 'JetBrains Mono', 'Fira Code', monospace;+ --sl-font: 'Plus Jakarta Sans Variable', 'Plus Jakarta Sans', system-ui, sans-serif;+ --sl-font-mono: 'JetBrains Mono Variable', 'JetBrains Mono', 'Fira Code', monospace;}/* Light mode: use a slightly deeper cyan so it stays legible on white. */diff --git a/site/src/styles/tailwind.css b/site/src/styles/tailwind.cssindex 96f5acf..6a960b1 100644--- a/site/src/styles/tailwind.css+++ b/site/src/styles/tailwind.css@@ -1,3 +1,10 @@+/* Bundled rather than fetched from fonts.googleapis.com: it was a render-blocking+ third-party request on the LCP path, and it handed every visitor's IP to Google.+ Vite dedupes these with the docs theme's copy, so one set of files ships. */+@import '@fontsource-variable/plus-jakarta-sans';+@import '@fontsource-variable/outfit';+@import '@fontsource-variable/jetbrains-mono';+@tailwind base;@tailwind components;@tailwind utilities;diff --git a/site/tailwind.config.mjs b/site/tailwind.config.mjsindex 3f8f442..df79bb7 100644--- a/site/tailwind.config.mjs+++ b/site/tailwind.config.mjs@@ -6,10 +6,12 @@ export default {darkMode: 'class',theme: {extend: {+ // '<name> Variable' is what @fontsource-variable registers; the bare name is kept next+ // in each stack so a locally-installed copy still wins over the system fallback.fontFamily: {- sans: ['Plus Jakarta Sans', 'system-ui', 'sans-serif'],- display: ['Outfit', 'Plus Jakarta Sans', 'sans-serif'],- mono: ['JetBrains Mono', 'Fira Code', 'monospace'],+ sans: ['Plus Jakarta Sans Variable', 'Plus Jakarta Sans', 'system-ui', 'sans-serif'],+ display: ['Outfit Variable', 'Outfit', 'Plus Jakarta Sans Variable', 'sans-serif'],+ mono: ['JetBrains Mono Variable', 'JetBrains Mono', 'Fira Code', 'monospace'],},colors: {surface: {diff --git a/web/e2e/auth.spec.ts b/web/e2e/auth.spec.tsindex 8489527..a0baf6f 100644--- a/web/e2e/auth.spec.ts+++ b/web/e2e/auth.spec.ts@@ -200,3 +200,31 @@ test('a password too long for bcrypt is refused before it can be submitted', asyawait expect(page.getByText(/at most 72 characters/i)).toBeVisible()await expect(page.getByRole('button', { name: /create account/i })).toBeDisabled()})++// The demo button used to be gated on import.meta.env.DEV, which is decided when the bundle+// is built rather than by the server it ends up talking to. It is now gated on the server's+// own demo_mode flag, and both directions matter enough to pin:+//+// absent — a self-hosted instance must never offer a sign-in as an account it never+// seeded. That is the failure with a real victim, and this suite runs against+// DEMO_MODE=off, so the assertion is against a genuine server rather than a mock.+// present — the public demo runs a production build, so the old gate hid the button from+// the one deployment that exists for it. Forced through a route intercept+// because this stack has no demo account to sign into.+test('no demo sign-in button on a server without a demo account', async ({ page }) => {+ await page.goto('/login')+ await expect(page.getByRole('button', { name: /sign in/i })).toBeVisible()+ await expect(page.getByRole('button', { name: /try demo account/i })).toHaveCount(0)+})++test('demo sign-in button appears when the server reports demo mode', async ({ page }) => {+ await page.route('**/api/v1/info', async route => {+ const res = await route.fetch()+ const body = await res.json()+ body.data.demo_mode = true+ await route.fulfill({ response: res, json: body })+ })++ await page.goto('/login')+ await expect(page.getByRole('button', { name: /try demo account/i })).toBeVisible()+})diff --git a/web/index.html b/web/index.htmlindex b7b668f..8599057 100644--- a/web/index.html+++ b/web/index.html@@ -6,10 +6,34 @@<link rel="icon" type="image/png" href="/favicon-transparent.png" /><link rel="apple-touch-icon" href="/favicon-transparent.png" /><meta name="viewport" content="width=device-width, initial-scale=1.0" />- <title>Lyfter - Workout Tracking</title>- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />- <link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Outfit:wght@700;800;900&display=swap" rel="stylesheet" />+ <title>Lyftr — Workout & Nutrition Tracker</title>+ <meta+ name="description"+ content="Log workouts, run guided gym sessions, and track nutrition and bodyweight. Self-hosted, so the data stays yours."+ />+ <!--+ surfaces.dark.base, matching the store's dark-first default — what the browser paints+ before JS runs. applyThemeClass() then REPLACES this element on load and on every+ toggle (see web/src/lib/lyftr.ts): browsers diff the value to decide whether to+ repaint their chrome, and editing this element's content in place is not reliably+ seen as a change.++ Not a prefers-color-scheme pair, which is the usual advice: the theme comes from+ localStorage and defaults to dark whatever the OS says, so a light-mode OS would paint+ a light bar over a dark app.+ -->+ <meta name="theme-color" content="#070d1a" />++ <!--+ Every self-hosted instance ships this file, so a crawler that finds someone's server+ would be indexing their private training log.++ No og:* tags for the same reason: they need an absolute image URL, and the only one+ available at build time is the project's CDN — so sharing a private instance in a chat+ would tell that CDN the instance hostname. Links still preview from the title and+ description above.+ -->+ <meta name="robots" content="noindex, nofollow" /></head><body><div id="root"></div>diff --git a/web/package.json b/web/package.jsonindex 5604fa8..23e1df0 100644--- a/web/package.json+++ b/web/package.json@@ -17,6 +17,9 @@"lint": "eslint . --max-warnings=52"},"dependencies": {+ "@fontsource-variable/jetbrains-mono": "^5.3.0",+ "@fontsource-variable/outfit": "^5.3.0",+ "@fontsource-variable/plus-jakarta-sans": "^5.3.0","@lyftr/shared": "*","@tanstack/react-virtual": "^3.13.24","axios": "^1.6.2",diff --git a/web/src/components/Layout.tsx b/web/src/components/Layout.tsxindex faa25c1..7c7a71b 100644--- a/web/src/components/Layout.tsx+++ b/web/src/components/Layout.tsx@@ -163,7 +163,13 @@ export default function Layout() {return (<div className="min-h-screen flex flex-col bg-surface-base">- <header className="sticky top-0 z-50 border-b border-surface-border bg-surface-base/95 backdrop-blur-sm">+ {/* Opaque, not bg-surface-base/95. That class generated nothing: Tailwind cannot apply+ an opacity modifier to a colour held in a CSS variable as a hex, so it was silently+ dropped and this bar had no background at all — content scrolled under it behind a+ 4px blur. Opaque also gives iOS 26 Safari something to read: it tints its toolbar+ from the background-color of sticky elements at the viewport edges, and a+ transparent one leaves the tint stuck on whatever it sampled at load. */}+ <header className="sticky top-0 z-50 border-b border-surface-border bg-surface-base"><div className="max-w-6xl mx-auto px-5 h-14 flex justify-between items-center"><Link to="/"><Logo size="md" /></Link><UserMenu />@@ -188,7 +194,9 @@ export default function Layout() {{/* Active session pill floats above bottom nav */}<div className="sticky bottom-0 z-50 relative"><ActiveSessionBar />- <nav className="border-t border-surface-border bg-surface-base/95 backdrop-blur-sm">+ {/* Opaque for the same two reasons as the header above — the /95 variant never+ rendered, and Safari tints the bottom toolbar from this element. */}+ <nav className="border-t border-surface-border bg-surface-base"><div className="max-w-6xl mx-auto flex">{NAV.map(({ path, label, icon: Icon }) => {const active = pathname === pathdiff --git a/web/src/index.css b/web/src/index.cssindex abc6e61..c417c7e 100644--- a/web/src/index.css+++ b/web/src/index.css@@ -1,3 +1,10 @@+/* Bundled, not fetched from fonts.googleapis.com — an instance on a LAN with no outbound+ internet could never load the CDN stylesheet and silently fell back to system fonts.+ JetBrains Mono was declared in tailwind.config.ts but never loaded at all. */+@import '@fontsource-variable/plus-jakarta-sans';+@import '@fontsource-variable/outfit';+@import '@fontsource-variable/jetbrains-mono';+@tailwind base;@tailwind components;@tailwind utilities;diff --git a/web/src/lib/lyftr.test.ts b/web/src/lib/lyftr.test.tsindex 5d8daa4..b2a470f 100644--- a/web/src/lib/lyftr.test.ts+++ b/web/src/lib/lyftr.test.ts@@ -1,6 +1,7 @@import { describe, it, expect, beforeEach } from 'vitest'import { hydrateStores, useAuthStore, useServerStore, useSettingsStore, useThemeStore, useWorkoutSession } from './lyftr'import { storage } from './storage'+import { surfaces } from '@lyftr/shared'// main.tsx awaits hydrateStores() before the first render. Everything that depends on// that ordering is invisible from the store code itself, so this pins the contract:@@ -72,6 +73,29 @@ describe('hydrateStores', () => {expect(document.documentElement.classList.contains('dark')).toBe(false)})++ // Browsers diff theme-color to decide whether to repaint their chrome, and editing the+ // existing element's content is not reliably seen as a change — the address bar stayed+ // stale until a reload. So the assertion is not just "the value is right" but "the node+ // was replaced", which is the part that makes the repaint happen. Exactly one must+ // survive, or the browser reads whichever it likes.+ it('replaces the theme-color element so the browser repaints its chrome', async () => {+ const original = document.createElement('meta')+ original.setAttribute('name', 'theme-color')+ original.setAttribute('content', surfaces.dark.base)+ document.head.appendChild(original)++ localStorage.setItem('theme', 'light')+ await hydrateStores()++ const tags = document.head.querySelectorAll('meta[name="theme-color"]')+ expect(tags).toHaveLength(1)+ expect(tags[0].getAttribute('content')).toBe(surfaces.light.base)+ expect(tags[0]).not.toBe(original)+ expect(original.isConnected).toBe(false)++ tags[0].remove()+ })})describe('the localStorage StorageAdapter', () => {diff --git a/web/src/lib/lyftr.ts b/web/src/lib/lyftr.tsindex 0aa17c4..da84ae6 100644--- a/web/src/lib/lyftr.ts+++ b/web/src/lib/lyftr.ts@@ -6,6 +6,7 @@ import {createSettingsStore,createThemeStore,createWorkoutSession,+ surfaces,} from '@lyftr/shared'import { storage } from './storage'@@ -37,11 +38,30 @@ export const useWorkoutSession = createWorkoutSession(storage)// Dark-first on web (mobile is light-first, per product).export const useThemeStore = createThemeStore(storage, 'dark')-// The <html class="dark"> toggle every CSS variable cascades from. Kept out of the-// store because the store is platform-agnostic; called once before the first render-// and again on every change, so the class and the store never disagree.+// Replaces the theme-color tag rather than editing it. Browsers diff this value to decide+// whether to repaint their chrome, and setAttribute('content', …) on the existing element+// is not always seen as a change — which is why the address bar used to lag until a+// reload. Removing the node and inserting a fresh one is unambiguous.+//+// Not a prefers-color-scheme pair: this theme lives in localStorage and defaults to dark+// whatever the OS reports, so an OS query would paint a light bar over a dark app.+const paintThemeColor = (color: string) => {+ document.head.querySelectorAll('meta[name="theme-color"]').forEach(m => m.remove())+ const meta = document.createElement('meta')+ meta.setAttribute('name', 'theme-color')+ meta.setAttribute('content', color)+ document.head.appendChild(meta)+}++// The <html class="dark"> toggle every CSS variable cascades from, plus the browser chrome+// so the two move together. Kept out of the store because the store is platform-agnostic;+// called once before the first render and again on every change, so the class and the store+// never disagree. `color-scheme` (emitted into :root and .dark by the token plugin) already+// handles scrollbars and form controls with no JavaScript; this covers the address bar,+// which CSS cannot reach.export const applyThemeClass = (mode: 'light' | 'dark') => {document.documentElement.classList.toggle('dark', mode === 'dark')+ paintThemeColor(surfaces[mode].base)}// Load everything persisted before the first render. localStorage is synchronous, sodiff --git a/web/src/pages/Login.tsx b/web/src/pages/Login.tsxindex 029d34f..97c9b72 100644--- a/web/src/pages/Login.tsx+++ b/web/src/pages/Login.tsx@@ -4,7 +4,7 @@ import { AlertCircle, Zap, Dumbbell, Apple, TrendingUp, LogIn } from 'lucide-reaimport { useAuthStore } from '../stores/auth'import { apiErrorMessage } from '../services/api'import { useServerInfo } from '../hooks/useServerInfo'-import { formatVersion, registrationOpen } from '@lyftr/shared'+import { formatVersion, registrationOpen, demoMode } from '@lyftr/shared'import Logo from '../components/Logo'import ServerSettings from '../components/ServerSettings'import PasswordField from '../components/ui/PasswordField'@@ -168,10 +168,10 @@ export default function Login() {</button>{/* Divider — only when something follows it that is genuinely an alternative- way in. In a production build the demo button is absent, so on a server- with registration closed there is nothing below but a statement, and an- "or" heading it reads like the start of an option that never arrives. */}- {(import.meta.env.DEV || registrationOpen(serverInfo)) && (+ way in. Where there is no demo account and registration is closed there is+ nothing below but a statement, and an "or" heading it reads like the start+ of an option that never arrives. */}+ {(demoMode(serverInfo) || registrationOpen(serverInfo)) && (<div className="relative flex items-center my-6"><div className="flex-1 h-px bg-surface-border" /><span className="px-3 text-xs text-tx-muted uppercase tracking-wider">or</span>@@ -179,8 +179,11 @@ export default function Login() {</div>)}- {/* Demo button — dev only */}- {import.meta.env.DEV && (+ {/* Gated on the server, not on import.meta.env.DEV, which is decided at build+ time and so was wrong both ways: absent from the public demo (a production+ build) and present against a DEMO_MODE=off server, where it 401s. DemoMode is+ the same flag that seeds the account, so the button follows the account. */}+ {demoMode(serverInfo) && (<buttontype="button"onClick={handleDemoLogin}diff --git a/web/tailwind.config.ts b/web/tailwind.config.tsindex 0cf5ea5..2c69927 100644--- a/web/tailwind.config.ts+++ b/web/tailwind.config.ts@@ -9,10 +9,12 @@ export default {content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],theme: {extend: {+ // '<name> Variable' is what @fontsource-variable registers; the bare name stays next in+ // each stack so a locally-installed copy still beats the system fallback.fontFamily: {- sans: ['Plus Jakarta Sans', 'system-ui', 'sans-serif'],- display: ['Outfit', 'Plus Jakarta Sans', 'sans-serif'],- mono: ['JetBrains Mono', 'Fira Code', 'monospace'],+ sans: ['Plus Jakarta Sans Variable', 'Plus Jakarta Sans', 'system-ui', 'sans-serif'],+ display: ['Outfit Variable', 'Outfit', 'Plus Jakarta Sans Variable', 'sans-serif'],+ mono: ['JetBrains Mono Variable', 'JetBrains Mono', 'Fira Code', 'monospace'],},colors: {// Surface/text tokens stay CSS-variable-backed so one class works in both