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
A double-progression range reads as the range in the plan: "2 × 10–15", not "2 × 15"
Duarte Santos380efc21c9d0
diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.jsindex 219eb16d4..38b8975c5 100644--- a/frontend/src/lib/history.js+++ b/frontend/src/lib/history.js@@ -143,6 +143,21 @@ export function defaultConfig(id, mode) {if (m === 'time') return { sets: 3, sec: 45, weight: 0, mode: 'time', ...bw }return { sets: 3, reps: 10, weight: 0, mode: 'reps', ...bw }}+// A double-progression range is stored as its top (`reps`) and its bottom (`repsMin`), and+// reads as the range it is: "8–12". Printing the top alone made "Reps from 10, up to 15" read+// as "2 × 15" in the plan and then open at 10. `fmt` formats each bound (a per-side split).+const hasRange = cfg => cfg.repsMin > 0 && cfg.repsMin < cfg.reps+const repsOf = (cfg, fmt = v => String(v)) => (hasRange(cfg) ? `${fmt(cfg.repsMin)}–${fmt(cfg.reps)}` : fmt(cfg.reps))++/** "2 × 10", "3 × 8–12", "2 × 0:45": what a plan asks for per set, without its load. */+export function setsRepsOf(cfg) {+ const mode = modeOf(cfg)+ const n = cfg.sets || 1+ if (mode === 'cardio') return `${n} × ${cfg.min || 20} min`+ if (mode === 'time') return `${n} × ${fmtSec(cfg.sec || 45)}`+ return `${n} × ${repsOf(cfg)}`+}+// One-line summary of a planned exercise ("3 × 10 · 60 kg"), shared by the routine editor// and the plan export so a mode is described the same way everywhere.export function exLine(cfg, unit) {@@ -151,10 +166,10 @@ export function exLine(cfg, unit) {// Added weight reads as added: "+10 kg" on a dip belt, "60 kg" on a barbell.const load = cfg.weight ? ' · ' + (isBw(cfg) ? '+' : '') + fmtNum(cfg.weight) + ' ' + unit : ''if (mode === 'cardio') return `${n} × ${cfg.min || 20} min @ ${fmtNum(cfg.speed || 8)} km/h`- if (mode === 'time') return `${n} × ${fmtSec(cfg.sec || 45)}${load}`+ if (mode === 'time') return `${setsRepsOf(cfg)}${load}`// This is the line with room for it, so the split is spelled out: "3 × 16 · 8/side".- const split = isPerSide(cfg) ? ' · ' + t('{0}/side', fmtNum(sideReps(cfg.reps))) : ''- return `${n} × ${cfg.reps}${load}${split}`+ const split = isPerSide(cfg) ? ' · ' + t('{0}/side', repsOf(cfg, v => fmtNum(sideReps(v)))) : ''+ return `${setsRepsOf(cfg)}${load}${split}`}// Drop superset ids that no longer have an adjacent partner (after unlink/reorder/remove).diff --git a/frontend/src/lib/history.test.js b/frontend/src/lib/history.test.jsindex b01921196..4177355be 100644--- a/frontend/src/lib/history.test.js+++ b/frontend/src/lib/history.test.js@@ -1,5 +1,5 @@import { describe, it, expect } from 'vitest'-import { nextTrainingDay, modeOf, isTimed, fmtSec, setLabel, defaultConfig, buildSets, freestyleConfig, exLine, workoutVolume, bestWeightFor, bestWeightForEntry, effortOf, stepEffort, capEffort, isBw, isPerSide, sideReps, repStep, cascadeWeight, insertWarmupRow, removeRowAt, workSetsDone, setsDone, setsDoneActive, setUnits, doneUnits, setUnitsTotal, pairAdjacent, unpairSuperset, supersetUnits, applyIntensifierPlan, pinnedNoteFor, exNoteFor, effectiveRoutineIds, effectiveRoutines, effectiveRoutineId, effectiveRoutine, lastEntryFor, entryExcluded, entryRoutineId } from './history.js'+import { nextTrainingDay, modeOf, isTimed, fmtSec, setLabel, defaultConfig, buildSets, freestyleConfig, exLine, workoutVolume, bestWeightFor, bestWeightForEntry, effortOf, stepEffort, capEffort, isBw, isPerSide, sideReps, repStep, cascadeWeight, insertWarmupRow, removeRowAt, workSetsDone, setsDone, setsDoneActive, setUnits, doneUnits, setUnitsTotal, pairAdjacent, unpairSuperset, supersetUnits, applyIntensifierPlan, pinnedNoteFor, exNoteFor, effectiveRoutineIds, effectiveRoutines, effectiveRoutineId, effectiveRoutine, lastEntryFor, entryExcluded, entryRoutineId, setsRepsOf } from './history.js'import { makeSideSet, setSideField, toggleSide } from './workout-model.js'import { EXDB } from './exercises.js'@@ -333,6 +333,18 @@ describe('exLine', () => {expect(exLine({ id: LIFT, sets: 2, sec: 90, weight: 20, mode: 'time' }, 'kg')).toBe('2 × 1:30 · 20 kg')expect(exLine({ id: CARDIO, sets: 1, min: 20, speed: 8 }, 'kg')).toBe('1 × 20 min @ 8 km/h')})+ it('reads a double-progression range as the range, not as its top', () => {+ // "Reps from 10, up to 15" used to read "2 × 15" in the plan and then open at 10.+ expect(exLine({ id: LIFT, sets: 2, reps: 15, repsMin: 10, weight: 40 }, 'kg')).toBe('2 × 10–15 · 40 kg')+ expect(exLine({ id: LIFT, sets: 3, reps: 16, repsMin: 12, side: true }, 'kg')).toBe('3 × 12–16 · 6–8/side')+ // A bottom at or above the top is not a range.+ expect(exLine({ id: LIFT, sets: 2, reps: 10, repsMin: 10 }, 'kg')).toBe('2 × 10')+ })+ it('gives the sets and reps alone for the workout card', () => {+ expect(setsRepsOf({ id: LIFT, sets: 2, reps: 10, weight: 60 })).toBe('2 × 10')+ expect(setsRepsOf({ id: LIFT, sets: 3, reps: 12, repsMin: 8, weight: 40 })).toBe('3 × 8–12')+ expect(setsRepsOf({ id: LIFT, sets: 2, sec: 45, mode: 'time' })).toBe('2 × 0:45')+ })})const emptyS = { workouts: [], exWeights: {} }diff --git a/mcp/src/labels.js b/mcp/src/labels.jsindex f65e1625a..abb813918 100644--- a/mcp/src/labels.js+++ b/mcp/src/labels.js@@ -20,7 +20,10 @@ export function exLine(cfg, unit) {const load = cfg.weight ? ' · ' + fmtNum(cfg.weight) + ' ' + unit : ''if (mode === 'cardio') return `${n} × ${cfg.min || 20} min @ ${fmtNum(cfg.speed || 8)} km/h`if (mode === 'time') return `${n} × ${fmtSec(cfg.sec || 45)}${load}`- return `${n} × ${cfg.reps}${load}`+ // A double-progression range is stored as its top (`reps`) and bottom (`repsMin`); it reads+ // as the range, the way the app's routine editor shows it ("3 × 8–12").+ const reps = cfg.repsMin > 0 && cfg.repsMin < cfg.reps ? `${cfg.repsMin}–${cfg.reps}` : `${cfg.reps}`+ return `${n} × ${reps}${load}`}export function muscleName(slug) {diff --git a/mcp/test/tools.test.js b/mcp/test/tools.test.jsindex e7aecc9dd..7a2cdc874 100644--- a/mcp/test/tools.test.js+++ b/mcp/test/tools.test.js@@ -129,6 +129,12 @@ describe('get_routine', () => {expect(r.exercises[0]).toMatchObject({ reps: 8, reps_min: 8, reps_max: 12 })})+ test('summarises a double-progression range as the range, not as its top', () => {+ Object.assign(S.routines[0].ex[0], { mode: 'reps', sets: 3, reps: 12, repsMin: 8, weight: 40 })+ const r = call('get_routine', { routine_id: S.routines[0].id })+ expect(r.exercises[0].summary).toBe('3 × 8–12 · 40 kg')+ })+test('reports an exercise\'s own rest, and leaves it out when it inherits the timer', () => {S.routines[0].ex[0].restSec = 180delete S.routines[0].ex[1]?.restSec