Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
demo seed: measurements draw from their own PRNG, not the training stream
Robert Geica9fa60d0b87be
diff --git a/frontend/src/lib/demoSeed.js b/frontend/src/lib/demoSeed.jsindex 18fbf390f..17719d85d 100644--- a/frontend/src/lib/demoSeed.js+++ b/frontend/src/lib/demoSeed.js@@ -62,6 +62,12 @@ const monday = date => { const d = new Date(date); d.setDate(d.getDate() - ((d.g// per-set effort ratings on most (not all) of it.export function buildDemoState() {const rnd = rng(20260723)+ // Measurements draw from their own stream. They are logged on a different cadence than the+ // training they sit next to, so taking them from `rnd` would slide every later draw along —+ // the weigh-in jitter, the missed-session roll, the rep drop-offs, the session start times —+ // and silently rewrite the demo history that mcp/test/tools.test.js pins exact values against.+ // Anything added here later wants its own generator too, not a share of this one.+ const mrnd = rng(20260724)const [push, pull, legs] = starterRoutines()const byWeekday = { 1: push, 3: pull, 5: legs }@@ -92,20 +98,20 @@ export function buildDemoState() {if (day.getDay() === 0 && weekIdx % 2 === 0) {const e = emptyMeasurement(iso)e.t = at(day, 8, 10)- e.neck = Math.round((39.8 - p * 0.8 + (rnd() - 0.5) * 0.2) * 10) / 10- e.shoulders = Math.round((119.5 + p * 1.6 + (rnd() - 0.5) * 0.4) * 10) / 10- e.chest = Math.round((103 - p * 1.4 + (rnd() - 0.5) * 0.3) * 10) / 10- e.waist = Math.round((89 - p * 7.2 + (rnd() - 0.5) * 0.5) * 10) / 10- e.hips = Math.round((101 - p * 3.1 + (rnd() - 0.5) * 0.3) * 10) / 10- e.upperArmLeft = Math.round((35.2 + p * 0.9 + (rnd() - 0.5) * 0.2) * 10) / 10- e.upperArmRight = Math.round((35.5 + p * 0.9 + (rnd() - 0.5) * 0.2) * 10) / 10+ e.neck = Math.round((39.8 - p * 0.8 + (mrnd() - 0.5) * 0.2) * 10) / 10+ e.shoulders = Math.round((119.5 + p * 1.6 + (mrnd() - 0.5) * 0.4) * 10) / 10+ e.chest = Math.round((103 - p * 1.4 + (mrnd() - 0.5) * 0.3) * 10) / 10+ e.waist = Math.round((89 - p * 7.2 + (mrnd() - 0.5) * 0.5) * 10) / 10+ e.hips = Math.round((101 - p * 3.1 + (mrnd() - 0.5) * 0.3) * 10) / 10+ e.upperArmLeft = Math.round((35.2 + p * 0.9 + (mrnd() - 0.5) * 0.2) * 10) / 10+ e.upperArmRight = Math.round((35.5 + p * 0.9 + (mrnd() - 0.5) * 0.2) * 10) / 10e.forearmLeft = Math.round((28.6 + p * 0.4) * 10) / 10e.forearmRight = Math.round((28.9 + p * 0.4) * 10) / 10e.thighLeft = Math.round((58.1 + p * 0.5) * 10) / 10e.thighRight = Math.round((58.5 + p * 0.5) * 10) / 10e.calfLeft = Math.round((38.2 + p * 0.3) * 10) / 10e.calfRight = Math.round((38.5 + p * 0.3) * 10) / 10- e.bodyFat = Math.round((20.4 - p * 3.8 + (rnd() - 0.5) * 0.3) * 10) / 10+ e.bodyFat = Math.round((20.4 - p * 3.8 + (mrnd() - 0.5) * 0.3) * 10) / 10measurements.push(e)}diff --git a/frontend/src/lib/demoSeed.test.js b/frontend/src/lib/demoSeed.test.jsindex 03315c30f..900c14eea 100644--- a/frontend/src/lib/demoSeed.test.js+++ b/frontend/src/lib/demoSeed.test.js@@ -1,7 +1,7 @@// The demo build is the only openGym most people ever see, so its seeded history has to// exercise the stats it is there to show off — including the effort card, which renders as// dashes on a history that is rated too thinly or not at all.-import { describe, it, expect } from 'vitest'+import { describe, it, expect, vi, beforeAll, afterAll } from 'vitest'import { buildDemoState } from './demoSeed.js'import {effortSummary, effortWeeks, effortHistogram, hasEffort, displayScale, avgRir,@@ -107,3 +107,50 @@ describe('demo seed — effort', () => {expect(flat(b)).toBe(flat(S))})})++// The demo history is a published fixture: mcp/test/tools.test.js pins exact values against it,+// and every existing viewer's demo profile is these numbers. Anything drawn from a generator the+// training loop shares slides the whole sequence along and rewrites that history — which is how+// the measurement block first broke the mcp suite. So the training stream gets pinned here too,+// on the frontend side of the boundary, where the seed actually lives.+describe('demo seed — the training stream is a fixture', () => {+ const TODAY = '2026-07-27' // Monday, matching the mcp suite's pinned clock+ // Not copied off a run: 18412.5 is the sum of w×r over the twenty completed sets of the newest+ // session, and 78.3 is BW_TO, the end of the body-weight trend. Same two values mcp asserts.+ const NEWEST = { d: '2026-07-24', name: 'Leg Day', vol: 18412.5 }+ const LATEST_BW = { d: TODAY, w: 78.3 }+ let D = null++ beforeAll(() => {+ vi.useFakeTimers({ now: new Date(TODAY + 'T12:00:00Z'), toFake: ['Date'] })+ D = buildDemoState()+ })+ afterAll(() => vi.useRealTimers())++ it('ends the body-weight trend where the goal delta is derived from', () => {+ expect(D.bodyweight.at(-1)).toMatchObject(LATEST_BW)+ })++ it('closes on the session the mcp suite reads as newest', () => {+ const w = D.workouts.at(-1)+ expect({ d: w.d, name: w.name, vol: w.vol }).toEqual(NEWEST)+ const sets = w.entries.flatMap(e => e.sets)+ expect(sets.length).toBe(20)+ expect(sets.every(s => s.done)).toBe(true)+ // …and the volume really is the sum of w×r over them, not a number that drifted into place.+ expect(sets.reduce((n, s) => n + s.w * s.r, 0)).toBe(NEWEST.vol)+ })++ it('logs measurements without touching that stream', () => {+ // Measurements land on their own cadence, so a shared generator would show up as a shifted+ // history rather than as anything wrong with the measurements themselves.+ expect(D.measurements.length).toBeGreaterThanOrEqual(5)+ const dates = D.measurements.map(m => m.d)+ expect(new Set(dates).size).toBe(dates.length)+ expect(dates).toEqual([...dates].sort())+ // The waist trend is the one the demo exists to show moving; it should actually move.+ const waist = D.measurements.map(m => m.waist)+ expect(waist.every(v => v > 60 && v < 130)).toBe(true)+ expect(waist.at(0) - waist.at(-1)).toBeGreaterThan(3)+ })+})