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
An ab wheel, a stability ball or a bosu logged at 0 kg climbs reps again
Duarte Santos132c88f5ecb9
diff --git a/frontend/src/lib/exercises.js b/frontend/src/lib/exercises.jsindex d2ecc221c..7c7c67e12 100644--- a/frontend/src/lib/exercises.js+++ b/frontend/src/lib/exercises.js@@ -149,6 +149,15 @@ const BODYWEIGHT_EQ = new Set(['body weight', 'band', 'resistance band'])export const isBodyweightEq = idOrEx =>BODYWEIGHT_EQ.has((typeof idOrEx === 'string' ? EXIDX[idOrEx] : idOrEx)?.eq)+// Equipment that is a load in its own right: a bar, a bell, a stack, a sled, a weight. A set on+// one of these logged at 0 kg is a number nobody typed in. The rest of the catalogue that is not+// bodyweight — an ab wheel, a stability ball, a bosu, a rope, a roller, the "assisted" straps —+// often has no load to enter at all, so 0 there is the honest number and progression moves the+// reps instead (lib/progression.js).+const LOADED_EQ = new Set(['barbell', 'ez barbell', 'olympic barbell', 'trap bar', 'dumbbell', 'kettlebell', 'cable', 'leverage machine', 'smith machine', 'sled machine', 'weighted'])+export const isLoadedEq = idOrEx =>+ LOADED_EQ.has((typeof idOrEx === 'string' ? EXIDX[idOrEx] : idOrEx)?.eq)+/* Assistance machines run the other way round: the stack carries part of your body weight, so* a smaller number is the harder set and the record (issue #232). Getting the set wrong is* worse than not having the feature — inverting a normal lift would hide real progress — so thediff --git a/frontend/src/lib/progression.js b/frontend/src/lib/progression.jsindex c50df3626..fd3365066 100644--- a/frontend/src/lib/progression.js+++ b/frontend/src/lib/progression.js@@ -17,7 +17,7 @@// So a session that fell apart can never advance the load as though it had succeeded.import { modeOf, repStep, rerampWarmups, isBw, isPerSide, entryExcluded, entryRoutineId } from './history.js'-import { EXIDX, isAssisted } from './exercises.js'+import { EXIDX, isAssisted, isLoadedEq } from './exercises.js'import { isWarmupRow, isSideSet, syncSideAggregate, makeSideSet } from './workout-model.js'import { normalizeRepRange } from './rep-range.js'@@ -222,6 +222,11 @@ export function plannedOf(cfg) {if (c.weight != null) out.weight = c.weightreturn out}+// Work with no load to enter climbs in reps, then sets, when it is logged at 0: a bodyweight+// exercise, or one whose equipment is not a load of its own — an ab wheel, a stability ball, a+// bosu (isLoadedEq). Only a loaded implement logged at 0 is a weight nobody typed in.+const climbsReps = cfg => isBw(cfg) || !isLoadedEq(cfg.id)+const PLAN_KEYS = ['sets', 'reps', 'repsMin', 'sec']const samePlan = (a, b) => PLAN_KEYS.every(k => (a[k] ?? null) === (b[k] ?? null))/** Did the routine's sets or reps change since the session that stamped `planned`? */@@ -397,7 +402,7 @@ export function nextPrescription(S, cfg, routine) {if (last.planned ? planChanged(last.planned, cfg) : borrowed) {const why = borrowed ? ['First time in this routine — starting from its own target.'] : ['Plan changed — starting from your new target.']if (mode === 'time') return { policy, kind: 'hold', sec: cfg.sec || last.goal || undefined, why }- if (last.weight <= 0 && isBw(cfg)) return { policy, kind: 'hold', weight: 0, reps: cfg.reps || undefined, why }+ if (last.weight <= 0 && climbsReps(cfg)) return { policy, kind: 'hold', weight: 0, reps: cfg.reps || undefined, why }// A loaded lift logged at 0 had no weight typed in (see below): the plan's, if it has one.const held = last.weight > 0 ? { weight: last.weight } : cfg.weight > 0 ? { weight: cfg.weight } : {}if (policy === 'double') {@@ -426,10 +431,10 @@ export function nextPrescription(S, cfg, routine) {const w = last.weight// Bodyweight work carries no external load, so there is nothing to add or take away —// "deload your push-ups to 2.5 kg" is not advice. Progress in reps instead. This runs ahead- // of the individual policies because it is true for all of them. The trigger is a bodyweight- // exercise logged without added weight: a dip done with a belt has a load to progress and- // belongs on the normal policies.- if (w <= 0 && isBw(cfg)) {+ // of the individual policies because it is true for all of them. The trigger is work with no+ // load to enter logged without one (climbsReps): a dip done with a belt has a load to progress+ // and belongs on the normal policies.+ if (w <= 0 && climbsReps(cfg)) {const goal = last.goal || cfg.reps || 0// The set count this has reached: the plan's, or more once the ceiling below added sets.// Read off the last session's target, or the added set lasted one session and the next@@ -457,6 +462,7 @@ export function nextPrescription(S, cfg, routine) {// A loaded lift logged at 0 had its weight never typed in — a quick-added exercise starts at// 0 kg. Climbing its reps as though it were a push-up turned a 2 × 10 bench into 2 × 11, 12…// There is nothing to progress from, so it asks for the weight: the plan's, when it has one.+ // Only a bar, a bell, a stack or a sled gets here; an ab wheel at 0 climbed reps above.if (w <= 0) return { policy, kind: 'hold', ...(cfg.weight > 0 ? { weight: cfg.weight } : {}), why: ['No weight logged last time — enter what you lift and progression takes it from there.'] }// Epley deloads apply only to externally loaded rep work. Keep the prescribed target from thediff --git a/frontend/src/lib/progression.test.js b/frontend/src/lib/progression.test.jsindex 0a931f3bb..90beebe19 100644--- a/frontend/src/lib/progression.test.js+++ b/frontend/src/lib/progression.test.js@@ -28,6 +28,10 @@ const hist = (id, rows, target) => ({}))})+// The same history with the plan each session was built from stamped on its entries, the way+// a session started since #275 saves them.+const stamped = (st, planned) => ({ ...st, workouts: st.workouts.map(w => ({ ...w, entries: w.entries.map(e => ({ ...e, planned })) })) })+describe('readSession', () => {const T = { sets: 3, reps: 5 }it('counts a session where every set made its reps as a hit', () => {@@ -347,10 +351,11 @@ describe('bodyweight exercises', () => {// A quick-added exercise starts at 0 kg, and a bench press ticked off without typing a weight// is logged at 0. That is a missing number, not a push-up: it must not climb reps.describe('a loaded lift logged at 0 kg', () => {- const zero = hist(LIFT, [[0, 10, 10, 10]], { sets: 3, reps: 10 })+ const BENCH = '0025' // barbell bench press+ const zero = hist(BENCH, [[0, 10, 10, 10]], { sets: 3, reps: 10 })it('holds and asks for the weight instead of climbing reps', () => {- const p = nextPrescription(zero, { id: LIFT, sets: 3, reps: 10, weight: 0, prog: 'linear' })+ const p = nextPrescription(zero, { id: BENCH, sets: 3, reps: 10, weight: 0, prog: 'linear' })expect(p.kind).toBe('hold')expect(p.reps).toBeUndefined()expect(p.weight).toBeUndefined()@@ -358,8 +363,20 @@ describe('a loaded lift logged at 0 kg', () => {})it('falls back to the plan\'s weight when the routine has one', () => {- expect(nextPrescription(zero, { id: LIFT, sets: 3, reps: 10, weight: 60, prog: 'double' })).toMatchObject({ kind: 'hold', weight: 60 })- })+ expect(nextPrescription(zero, { id: BENCH, sets: 3, reps: 10, weight: 60, prog: 'double' })).toMatchObject({ kind: 'hold', weight: 60 })+ })++ // Only a bar, a bell, a stack or a sled has a load nobody typed in. An ab wheel, a stability+ // ball, a bosu or the straps of an assisted knee raise are logged at 0 because there is no+ // load to enter, and they climb reps the way a push-up does — they always have.+ const noLoad = { '0857': 'wheel rollerout', '0271': 'crunch on a stability ball', '0653': 'push-up on a bosu ball', '0011': 'assisted hanging knee raise' }+ for (const [id, name] of Object.entries(noLoad)) {+ it(`climbs reps on a ${name}, which has nothing to load`, () => {+ const cfg = { id, sets: 3, reps: 10, weight: 0 }+ const twice = stamped(hist(id, [[0, 10, 10, 10], [0, 10, 10, 10]], { sets: 3, reps: 10 }), plannedOf(cfg))+ expect(nextPrescription(twice, cfg)).toMatchObject({ kind: 'up', weight: 0, reps: 11 })+ })+ }})describe('Greyskull LP', () => {@@ -734,8 +751,9 @@ describe('an edited plan restarts progression (#275)', () => {})it('opens a loaded lift logged at 0 kg at the plan\'s weight when the plan changed', () => {- const S = { unit: 'kg', workouts: [logged(LIFT, { sets: 2, reps: 15, weight: 0 }, { sets: 2, reps: 15, weight: 0 }, 0, [15, 15])] }- expect(nextPrescription(S, { id: LIFT, sets: 2, reps: 10, weight: 50, prog: 'linear' }, R)).toMatchObject({ kind: 'hold', weight: 50, reps: 10 })+ const BENCH = '0025' // barbell bench press: a load nobody typed in, not a bodyweight set+ const S = { unit: 'kg', workouts: [logged(BENCH, { sets: 2, reps: 15, weight: 0 }, { sets: 2, reps: 15, weight: 0 }, 0, [15, 15])] }+ expect(nextPrescription(S, { id: BENCH, sets: 2, reps: 10, weight: 50, prog: 'linear' }, R)).toMatchObject({ kind: 'hold', weight: 50, reps: 10 })})it('continues another routine\'s progression when its plan is the same one (a copied routine)', () => {diff --git a/frontend/src/lib/session-start.plan.test.js b/frontend/src/lib/session-start.plan.test.jsindex 9b113a26b..7e5867873 100644--- a/frontend/src/lib/session-start.plan.test.js+++ b/frontend/src/lib/session-start.plan.test.js@@ -217,6 +217,16 @@ describe('bodyweight progression and a lift logged without a weight', () => {expect(shape).toEqual(['2x10', '2x11', '3x10', '3x11', '4x10'])})+ it('climbs reps on an ab wheel logged at 0 kg — it has no load to enter', () => {+ const WHEEL = '0857' // wheel rollerout — wheel roller equipment+ const st = state([{ id: 'A', name: 'A', ex: [{ id: WHEEL, sets: 3, reps: 10, weight: 0 }] }])+ train(st, ['A'])+ train(st, ['A'])+ const [e] = start(st, ['A'])+ expect(e.plan.kind).toBe('up')+ expect(reps(e)).toEqual([12, 12, 12])+ })+it('does not climb reps on a loaded lift whose rows were logged at 0 kg', () => {const st = state([{ id: 'A', name: 'A', ex: [{ id: BENCH, sets: 2, reps: 10, weight: 0 }] }])train(st, ['A'])