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
mrbatch: preview_session baut die Session ueber session-start.js (Progression aus, Deload-Routinen, Warm-up-Schritt), meldet auch Zeit/Cardio-Overrides; Rest-Toast auch nach verstecktem Ablauf
Duarte Santos6e9f5e7b9cc8
diff --git a/frontend/src/store/useUI.js b/frontend/src/store/useUI.jsindex e93ea94a1..884178958 100644--- a/frontend/src/store/useUI.js+++ b/frontend/src/store/useUI.js@@ -111,8 +111,12 @@ export const useUI = create((set, get) => ({if (left <= 0) {if (seenLive) {beep(snd, 880, 0.15); beep(snd, 880, 0.15, 0.25); beep(snd, 1320, 0.4, 0.5)- vibrate([200, 100, 200]); get().flashTimer(); get().toast(t('Rest over — next set!'))+ vibrate([200, 100, 200]); get().flashTimer()}+ // The toast stays even when the rest ran out while the app was hidden: a guest, or anyone+ // without push permission, gets no notification, and a countdown that silently vanishes+ // on reopen reads like a bug. Only the loud parts (beep, vibration, flash) are gated.+ get().toast(t('Rest over — next set!'))maybeRestNotification(); get().stopRest(); return}if (left <= 3) beep(snd, 660, 0.1)diff --git a/mcp/README.md b/mcp/README.mdindex f710feece..18532ad38 100644--- a/mcp/README.md+++ b/mcp/README.md@@ -120,7 +120,7 @@ dependencies landed in `frontend/`, no public exports changed.cd mcp && npm test```-54 cases seeding state from `frontend/src/lib/demoSeed.js` (the same deterministic fixture+58 cases seeding state from `frontend/src/lib/demoSeed.js` (the same deterministic fixturethe public demo runs on). Pins JSON shape and the user-facing edge cases: rest-day override,missing routine, zero-workout history, no synced state, superset links, three 1RM formulas."Today" is pinned via `vi.useFakeTimers({ now: ..., toFake: ['Date'] })` so date-dependentdiff --git a/mcp/src/tools.js b/mcp/src/tools.jsindex 4b5932416..453ff24c4 100644--- a/mcp/src/tools.js+++ b/mcp/src/tools.js@@ -7,8 +7,7 @@ import {fmt, setLabel, exLine, muscleName, policyName, friendlyDuration, ratio, muscleOrder} from './labels.js'import {- modeOf, workoutVolume, setsDone, effectiveRoutine, effectiveRoutineId,- buildSets, applyIntensifierPlan, lastEntryFor+ modeOf, workoutVolume, setsDone, effectiveRoutine, effectiveRoutineId, lastEntryFor} from '../../frontend/src/lib/history.js'import { exOr } from '../../frontend/src/lib/exercises.js'import { isWarmupRow } from '../../frontend/src/lib/workout-model.js'@@ -16,7 +15,8 @@ import {estimate1RM, best1RM, e1rmSeries, DEFAULT_FORMULA, REP_CAP} from '../../frontend/src/lib/onerm.js'import { loadOfWorkouts, rankOf, levelsOf } from '../../frontend/src/lib/muscles.js'-import { policyFor, nextPrescription, applyPrescription } from '../../frontend/src/lib/progression.js'+import { policyFor } from '../../frontend/src/lib/progression.js'+import { buildSessionEntries } from '../../frontend/src/lib/session-start.js'/* ---------- helpers ---------- */@@ -419,7 +419,10 @@ export const muscleBalance = {// whatever the progression policy decided. Reporting the winner is the whole point of this// tool — "the plan says 60" is not an answer to "what will the app show me".function sourceOf(S, cfg, plan, field) {- const decided = plan && plan.kind !== 'off' && plan.kind !== 'first' && plan[field] != null+ // Progression off (or a deload routine): the session is built from the routine's own target,+ // exactly as session-start.js does with useTarget — history and the confirmed weight are ignored.+ if (!plan || plan.kind === 'off') return 'routine_plan'+ const decided = plan.kind !== 'first' && plan[field] != nullif (decided) return 'progression'if (field === 'weight') {const conf = (S.exWeights || {})[cfg.id]@@ -460,16 +463,20 @@ export const previewSession = {}const unit = S.unit || 'kg'+ // The same builder the app starts a session with (sheets.jsx beginWorkout → session-start.js):+ // prescription, step, progression-off targets, deload routines and warm-up ramps all come from+ // there, so the preview cannot drift from what the screen shows.+ const built = buildSessionEntries(S, r).entriesconst exercises = (r.ex || []).map((cfg, i) => {const ex = exerciseOf(cfg.id, S)const mode = modeOf({ ...cfg, id: cfg.id })- const plan = nextPrescription(S, cfg, r)- // Mirrors beginWorkout() exactly (sheets.jsx): build, apply the prescription, then stamp- // the intensifier. Anything less and the preview stops matching the real session.- const rows = applyIntensifierPlan(applyPrescription(buildSets(S, cfg), plan), cfg)+ const plan = built[i].plan+ const rows = built[i].setsconst work = rows.filter(s => !isWarmupRow(s))const openW = work.length ? (work[0].w || 0) : 0const openR = work.length ? (work[0].r || 0) : 0+ const openSec = work.length ? (work[0].sec || 0) : 0+ const openMin = work.length ? (work[0].min || 0) : 0const wSrc = sourceOf(S, cfg, plan, 'weight')const rSrc = sourceOf(S, cfg, plan, 'reps')return {@@ -514,11 +521,15 @@ export const previewSession = {// rep target moved, and saying which one moved saves the caller diffing it themselves.changed: [...(mode === 'reps' && cfg.weight != null && openW !== cfg.weight ? ['weight'] : []),- ...(mode === 'reps' && (cfg.reps || 0) > 0 && openR !== cfg.reps ? ['reps'] : [])+ ...(mode === 'reps' && (cfg.reps || 0) > 0 && openR !== cfg.reps ? ['reps'] : []),+ ...(mode === 'time' && (cfg.sec || 0) > 0 && openSec !== cfg.sec ? ['sec'] : []),+ ...(mode === 'cardio' && (cfg.min || 0) > 0 && openMin !== cfg.min ? ['min'] : [])],differs_from_plan:(mode === 'reps' && cfg.weight != null && openW !== cfg.weight) ||- (mode === 'reps' && (cfg.reps || 0) > 0 && openR !== cfg.reps)+ (mode === 'reps' && (cfg.reps || 0) > 0 && openR !== cfg.reps) ||+ (mode === 'time' && (cfg.sec || 0) > 0 && openSec !== cfg.sec) ||+ (mode === 'cardio' && (cfg.min || 0) > 0 && openMin !== cfg.min)}})@@ -540,6 +551,10 @@ export const previewSession = {opening_weight: e.opening_sets.filter(s => s.phase === 'work')[0]?.w ?? null,planned_reps: e.planned.reps,opening_reps: e.opening_sets.filter(s => s.phase === 'work')[0]?.r ?? null,+ planned_sec: e.planned.sec,+ opening_sec: e.opening_sets.filter(s => s.phase === 'work')[0]?.sec ?? null,+ planned_min: e.planned.min,+ opening_min: e.opening_sets.filter(s => s.phase === 'work')[0]?.min ?? null,changed: e.changed,reason: e.prescription.why || e.weight_source_text}))diff --git a/mcp/test/tools.test.js b/mcp/test/tools.test.jsindex 2320b6c62..b6674a4b5 100644--- a/mcp/test/tools.test.js+++ b/mcp/test/tools.test.js@@ -686,8 +686,10 @@ describe('preview_session', () => {// One routine, one exercise, scheduled for the pinned "today". Nothing from the demo seed,// so the arithmetic below is checkable by hand.- function only(cfg, { prog = 'off', workouts = [], exWeights = {} } = {}) {- S.routines = [{ id: 'r-preview', name: 'Preview', emoji: 'barbell', prog, ex: [cfg] }]+ // Linear by default: with progression off the app opens the routine's own numbers (see the+ // two tests at the end), so history-vs-plan precedence is only observable under a policy.+ function only(cfg, { prog = 'linear', workouts = [], exWeights = {}, routine = {} } = {}) {+ S.routines = [{ id: 'r-preview', name: 'Preview', emoji: 'barbell', prog, ex: [cfg], ...routine }]S.week = { [WD]: 'r-preview' }S.dayPlan = {}S.workouts = workouts@@ -792,6 +794,55 @@ describe('preview_session', () => {expect(r.exercises).toEqual([])})+ test('with progression off the routine\'s own numbers open, whatever history says (matches session-start.js)', () => {+ only({ id: '0025', sets: 3, reps: 8, weight: 50 }, {+ prog: 'off',+ exWeights: { '0025': { w: 72.5, d: '2026-07-20' } },+ workouts: [{+ id: 'w1', d: '2026-07-20', routineId: 'r-preview', name: 'Preview',+ entries: [{ id: '0025', target: { id: '0025', sets: 3, reps: 5, weight: 60 }, sets: [{ w: 60, r: 5, done: true }] }]+ }]+ })+ const out = call('preview_session')+ const e = out.exercises[0]+ expect(e.prescription.kind).toBe('off')+ expect(e.opening_sets.map(s => [s.w, s.r])).toEqual([[50, 8], [50, 8], [50, 8]])+ expect(e.weight_source).toBe('routine_plan')+ expect(e.reps_source).toBe('routine_plan')+ expect(e.differs_from_plan).toBe(false)+ expect(out.overridden_count).toBe(0)+ })++ test('a deload routine (excludeFromProgression) opens its own numbers even under a policy', () => {+ only({ id: '0025', sets: 3, reps: 5, weight: 50 }, {+ prog: 'linear', routine: { excludeFromProgression: true },+ workouts: [{+ id: 'w1', d: '2026-07-20', routineId: 'r-preview', name: 'Preview',+ entries: [{ id: '0025', target: { id: '0025', sets: 3, reps: 5, weight: 60 }, sets: [{ w: 60, r: 5, done: true }, { w: 60, r: 5, done: true }, { w: 60, r: 5, done: true }] }]+ }]+ })+ const e = call('preview_session').exercises[0]+ expect(e.prescription.kind).toBe('off')+ expect(e.opening_sets.every(s => s.w === 50 && s.r === 5)).toBe(true)+ expect(e.weight_source).toBe('routine_plan')+ })++ test('a timed exercise that progressed is listed as overridden too', () => {+ only({ id: '0025', mode: 'time', sets: 3, sec: 30, inc: 10 }, {+ prog: 'time',+ workouts: [{+ id: 'w1', d: '2026-07-20', routineId: 'r-preview', name: 'Preview',+ entries: [{ id: '0025', target: { id: '0025', mode: 'time', sets: 3, sec: 30 }, sets: [{ sec: 45, done: true }, { sec: 45, done: true }, { sec: 45, done: true }] }]+ }]+ })+ const out = call('preview_session')+ const e = out.exercises[0]+ expect(e.prescription.kind).toBe('up')+ expect(e.changed).toEqual(['sec'])+ expect(e.differs_from_plan).toBe(true)+ expect(out.overridden[0].opening_sec).toBeGreaterThan(30)+ })+test('an unknown routine_id is an error, not an empty session', () => {only({ id: '0025', sets: 3, reps: 8, weight: 50 })expect(() => call('preview_session', { routine_id: 'nope' })).toThrow(/no routine with id/)