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
feat: expose the double progression rep range
Manuelc71cb09515a1
diff --git a/frontend/src/lib/progression.js b/frontend/src/lib/progression.jsindex eb9681824..a1c8ac4c5 100644--- a/frontend/src/lib/progression.js+++ b/frontend/src/lib/progression.js@@ -19,6 +19,7 @@import { modeOf, repStep, rerampWarmups } from './history.js'import { EXIDX } from './exercises.js'import { isWarmupRow } from './workout-model.js'+import { normalizeRepRange } from './rep-range.js'export const POLICIES = ['off', 'linear', 'greyskull', 'double', 'time']@@ -210,8 +211,9 @@ export function nextPrescription(S, cfg, routine) {return { policy, kind: 'up', weight: 0, reps: next, why: ['Bodyweight — every rep last time, so go for {0} this time.', next] }}if (policy === 'double') {- const top = cfg.reps || last.goal || 10- const bottom = Math.min(cfg.repsMin || Math.max(1, top - 2), top)+ const range = normalizeRepRange(cfg.reps || last.goal || 10, cfg.repsMin)+ const top = range.reps+ const bottom = range.repsMinif (last.ok) return { policy, kind: 'up', weight: snap(w + inc, inc), reps: bottom, why: ['Top of the rep range in every set — {0} {1} more, back to {2} reps.', inc, unit, bottom] }if (stalls >= deloadAt) {const dw = deloadTo(w, inc)diff --git a/frontend/src/lib/rep-range.js b/frontend/src/lib/rep-range.jsnew file mode 100644index 000000000..b01aab133--- /dev/null+++ b/frontend/src/lib/rep-range.js@@ -0,0 +1,14 @@+// Normalize the two bounds used by double progression.+// `reps` is the upper bound and `repsMin` is the lower bound in persisted configs.+export function normalizeRepRange(reps, repsMin) {+ const upper = positiveInt(reps, 10)+ const lower = positiveInt(repsMin, Math.max(1, upper - 2))+ return lower >= upper+ ? { reps: lower + 1, repsMin: lower }+ : { reps: upper, repsMin: lower }+}++function positiveInt(value, fallback) {+ const n = Number(value)+ return Number.isFinite(n) && n > 0 ? Math.max(1, Math.round(n)) : fallback+}diff --git a/frontend/src/lib/rep-range.test.js b/frontend/src/lib/rep-range.test.jsnew file mode 100644index 000000000..5446b2113--- /dev/null+++ b/frontend/src/lib/rep-range.test.js@@ -0,0 +1,29 @@+import { describe, expect, it } from 'vitest'+import { normalizeRepRange } from './rep-range.js'++describe('normalizeRepRange', () => {+ it('keeps valid positive integer bounds unchanged', () => {+ expect(normalizeRepRange(12, 8)).toEqual({ reps: 12, repsMin: 8 })+ })++ it('rounds bounds to positive integers', () => {+ expect(normalizeRepRange(12.4, 7.6)).toEqual({ reps: 12, repsMin: 8 })+ expect(normalizeRepRange(0, -2)).toEqual({ reps: 10, repsMin: 8 })+ })++ it('raises the upper bound when the lower bound reaches it', () => {+ expect(normalizeRepRange(8, 8)).toEqual({ reps: 9, repsMin: 8 })+ })++ it('raises the upper bound when the lower bound exceeds it', () => {+ expect(normalizeRepRange(8, 12)).toEqual({ reps: 13, repsMin: 12 })+ })++ it('keeps the lower bound at least one below a lowered upper bound', () => {+ expect(normalizeRepRange(6, 8)).toEqual({ reps: 9, repsMin: 8 })+ })++ it('supplies a usable default lower bound for a small upper bound', () => {+ expect(normalizeRepRange(1, undefined)).toEqual({ reps: 2, repsMin: 1 })+ })+})diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex 8c911556c..d5f48c5e4 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -536,6 +536,7 @@ export default {'Step ({0})': 'Schritt ({0})','Step (seconds)': 'Schritt (Sekunden)','Reps from': 'Wdh. ab',+ 'Reps up to': 'Wdh. bis','No automatic progression': 'Keine automatische Progression','Linear progression': 'Lineare Progression','Greyskull LP': 'Greyskull LP',diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex b1ea117af..3c06f516b 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -518,6 +518,7 @@ export default {'Step ({0})': 'Incremento ({0})','Step (seconds)': 'Incremento (segundos)','Reps from': 'Reps desde',+ 'Reps up to': 'Reps hasta','No automatic progression': 'Sin progresión automática','Linear progression': 'Progresión lineal','Greyskull LP': 'Greyskull LP',diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex 387bf2564..a068fb29c 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -518,6 +518,7 @@ export default {'Step ({0})': 'Palier ({0})','Step (seconds)': 'Palier (secondes)','Reps from': 'Reps à partir de',+ 'Reps up to': 'Reps jusqu’à','No automatic progression': 'Pas de progression automatique','Linear progression': 'Progression linéaire','Greyskull LP': 'Greyskull LP',diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex 09038df9c..6623a6ad8 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -518,6 +518,7 @@ export default {'Step ({0})': 'स्टेप ({0})','Step (seconds)': 'स्टेप (सेकंड)','Reps from': 'रेप्स से',+ 'Reps up to': 'रेप्स तक','No automatic progression': 'कोई स्वचालित प्रोग्रेशन नहीं','Linear progression': 'रैखिक प्रोग्रेशन','Greyskull LP': 'Greyskull LP',diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 1c53c34ac..f860f227f 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -518,6 +518,7 @@ export default {'Step ({0})': 'Incremento ({0})','Step (seconds)': 'Incremento (secondi)','Reps from': 'Rip. da',+ 'Reps up to': 'Rip. fino a','No automatic progression': 'Nessuna progressione automatica','Linear progression': 'Progressione lineare','Greyskull LP': 'Greyskull LP',diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex 170f6d375..e32e462e5 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -518,6 +518,7 @@ export default {'Step ({0})': '증가폭 ({0})','Step (seconds)': '증가폭 (초)','Reps from': '최소 횟수',+ 'Reps up to': '최대 횟수','No automatic progression': '자동 증가 없음','Linear progression': '선형 증가','Greyskull LP': 'Greyskull LP',diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex b914fbc37..3ad8d7bb1 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -518,6 +518,7 @@ export default {'Step ({0})': 'Skok ({0})','Step (seconds)': 'Skok (sekundy)','Reps from': 'Powt. od',+ 'Reps up to': 'Powt. do','No automatic progression': 'Bez automatycznej progresji','Linear progression': 'Progresja liniowa','Greyskull LP': 'Greyskull LP',diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.jsindex 11022ba6b..5ed415f60 100644--- a/frontend/src/locales/pt-BR.js+++ b/frontend/src/locales/pt-BR.js@@ -5,6 +5,7 @@ import pt from './pt.js'export const PT_BR_OVERRIDES = {'Press back again to exit': 'Pressione voltar novamente para sair',+ 'Reps up to': 'Reps até','Delete': 'Excluir','Save': 'Salvar','Log': 'Registrar',diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex d14ccb131..c8562b7df 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -518,6 +518,7 @@ export default {'Step ({0})': 'Incremento ({0})','Step (seconds)': 'Incremento (segundos)','Reps from': 'Reps a partir de',+ 'Reps up to': 'Reps até','No automatic progression': 'Sem progressão automática','Linear progression': 'Progressão linear','Greyskull LP': 'Greyskull LP',diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex 1e260d196..0cf2dfac2 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -518,6 +518,7 @@ export default {'Step ({0})': 'Шаг ({0})','Step (seconds)': 'Шаг (секунды)','Reps from': 'Повт. от',+ 'Reps up to': 'Повт. до','No automatic progression': 'Без автопрогрессии','Linear progression': 'Линейная прогрессия','Greyskull LP': 'Greyskull LP',diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex 79b312557..0f487eb2e 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -518,6 +518,7 @@ export default {'Step ({0})': 'Artış ({0})','Step (seconds)': 'Artış (saniye)','Reps from': 'Tekrar en az',+ 'Reps up to': 'Tekrar en çok','No automatic progression': 'Otomatik ilerleme yok','Linear progression': 'Doğrusal ilerleme','Greyskull LP': 'Greyskull LP',diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex 533434d66..2e8978a90 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -518,6 +518,7 @@ export default {'Step ({0})': '加量({0})','Step (seconds)': '加量(秒)','Reps from': '次数下限',+ 'Reps up to': '次数上限','No automatic progression': '不自动进阶','Linear progression': '线性进阶','Greyskull LP': 'Greyskull LP',diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsxindex 6ca69e07a..5f31e95cc 100644--- a/frontend/src/sheets.jsx+++ b/frontend/src/sheets.jsx@@ -20,6 +20,7 @@ import { parseImport, mergeImport } from './lib/import-csv.js'import { buildPlanBundle, parsePlan, mergePlan, printPlan } from './lib/plan-share.js'import { estimate1RM, best1RM, is1RMRecord, REP_CAP } from './lib/onerm.js'import { nextPrescription, applyPrescription, policyFor, defaultIncrement, POLICIES_FOR, POLICY_NAME, POLICY_DESC, MAX_BW_SETS } from './lib/progression.js'+import { normalizeRepRange } from './lib/rep-range.js'import { MOBILE, shareExport } from './lib/mobile.js'import { buildCompletedWorkout } from './lib/finish-workout.js'import { isWarmupRow } from './lib/workout-model.js'@@ -564,10 +565,17 @@ function ProgressionFields({ ex, mode, c, setC, routine, unit }) {const inherited = policyFor({ id: ex.id }, routine, mode)const active = policyFor({ ...c, id: ex.id }, routine, mode)const inc = c.inc > 0 ? c.inc : (mode === 'time' ? 5 : defaultIncrement(ex.id, unit))+ const range = active === 'double' ? normalizeRepRange(c.reps, c.repsMin) : null+ const setRule = v => setC(x => {+ const next = { ...x, prog: v || undefined }+ return policyFor({ ...next, id: ex.id }, routine, mode) === 'double'+ ? { ...next, ...normalizeRepRange(next.reps, next.repsMin) }+ : next+ })return <><h4 className="sec">{t('Progression')}</h4><div className="sect-b" style={{ marginBottom: 8 }}>- <SelectRow title={t('Rule')} sheetTitle={t('Progression')} value={c.prog || ''} onChange={v => setC(x => ({ ...x, prog: v || undefined }))}+ <SelectRow title={t('Rule')} sheetTitle={t('Progression')} value={c.prog || ''} onChange={setRule}options={[{ value: '', label: t('Follow the routine ({0})', t(POLICY_NAME[inherited])) },...options.map(p => ({ value: p, label: t(POLICY_NAME[p]) }))]} /></div>@@ -575,8 +583,12 @@ function ProgressionFields({ ex, mode, c, setC, routine, unit }) {{active !== 'off' && <div className="row cfgrow" style={{ marginBottom: 18 }}><Stepper label={mode === 'time' ? t('Step (seconds)') : t('Step ({0})', unit)} value={inc}step={mode === 'time' ? 5 : 1.25} decimal={mode !== 'time'} onChange={v => setC(x => ({ ...x, inc: v }))} />- {active === 'double' && <Stepper label={t('Reps from')} value={c.repsMin || Math.max(1, (c.reps || 10) - 2)}- step={1} decimal={false} onChange={v => setC(x => ({ ...x, repsMin: v }))} />}+ {active === 'double' && <>+ <Stepper label={t('Reps from')} value={range.repsMin} step={1} decimal={false}+ onChange={v => setC(x => ({ ...x, ...normalizeRepRange(x.reps, v) }))} />+ <Stepper label={t('Reps up to')} value={range.reps} step={1} decimal={false}+ onChange={v => setC(x => ({ ...x, ...normalizeRepRange(v, x.repsMin) }))} />+ </>}</div>}</>}@@ -584,15 +596,28 @@ function ProgressionFields({ ex, mode, c, setC, routine, unit }) {function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {const st = useStore(s => s.S)const cardio = isCardio(ex.id)- const [c, setC] = useState(existing || initial || defaultConfig(ex.id))+ const seed = existing || initial || defaultConfig(ex.id)+ const [c, setC] = useState(() => {+ const cfg = { ...seed }+ return policyFor({ ...cfg, id: ex.id }, routine, modeOf({ ...cfg, id: ex.id })) === 'double'+ ? { ...cfg, ...normalizeRepRange(cfg.reps, cfg.repsMin) }+ : cfg+ })// Cardio keeps its own duration+speed form; the reps/time choice (issue #16) is offered for// everything else, which is where the gap was — planks, hangs, wall sits, loaded carries.const mode = cardio ? 'cardio' : modeOf({ ...c, id: ex.id })// Both default from the dataset and are then whatever the config says — see isBw.const bw = !cardio && isBw({ ...c, id: ex.id })const perSide = isPerSide(c)+ const activePolicy = policyFor({ ...c, id: ex.id }, routine, mode)+ const double = mode === 'reps' && activePolicy === 'double'// Keep whatever the other mode already had (sets, weight) and fill only what is missing.- const setMode = m => setC(x => ({ ...defaultConfig(ex.id, m), ...x, mode: m }))+ const setMode = m => setC(x => {+ const next = { ...defaultConfig(ex.id, m), ...x, mode: m }+ return m === 'reps' && policyFor({ ...next, id: ex.id }, routine, 'reps') === 'double'+ ? { ...next, ...normalizeRepRange(next.reps, next.repsMin) }+ : next+ })const save = () => {close()const sets = Math.max(1, Math.round(c.sets) || (cardio ? 1 : 3))@@ -623,9 +648,15 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {// A unilateral target is stored even: the split has to divide, and a typed 15 would// otherwise plan seven reps on one side and eight on the other, every session.const typed = Math.max(1, Math.round(c.reps) || 10)- const reps = perSide ? Math.ceil(typed / 2) * 2 : typed+ let reps = perSide ? Math.ceil(typed / 2) * 2 : typed+ let range = null+ if (double) {+ range = normalizeRepRange(reps, c.repsMin)+ if (perSide) range = normalizeRepRange(Math.ceil(range.reps / 2) * 2, range.repsMin)+ reps = range.reps+ }const out = { sets, mode: 'reps', reps, weight: Math.max(0, c.weight || 0), ...flags, ...(perSide ? { side: true } : {}), ...prog, ...withNote, ...withWarmups }- if (policyFor({ ...c, id: ex.id }, routine, 'reps') === 'double') out.repsMin = Math.min(reps, Math.max(1, Math.round(c.repsMin) || Math.max(1, reps - 2)))+ if (double) out.repsMin = range.repsMin// A ceiling below the working reps would tell you to add a set on day one.if (bw && !(out.weight > 0) && c.repsMax > 0) out.repsMax = Math.max(reps, Math.round(c.repsMax))// Every set in this exercise becomes a drop-set/rest-pause (buildSets stamps the rows) —@@ -665,7 +696,7 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {rest-pause work set — so "Sets" has nothing left to mean and only invites a mismatch. */}{c.intensifier?.type !== 'restpause' &&<Stepper label={t('Sets')} value={c.sets} step={1} decimal={false} onChange={v => setC(x => ({ ...x, sets: v }))} />}- <Stepper label={t('Reps')} value={c.reps} step={perSide ? 2 : 1} decimal={false} onChange={v => setC(x => ({ ...x, reps: v }))} />+ {!double && <Stepper label={t('Reps')} value={c.reps} step={perSide ? 2 : 1} decimal={false} onChange={v => setC(x => ({ ...x, reps: v }))} />}{/* On bodyweight work the weight stepper is the click #32 is about, so it is not hereuntil there is a belt to describe — see the added-weight row below. */}{!bw && <Stepper label={t('Weight ({0})', st.unit)} value={c.weight} step={2.5} onChange={v => setC(x => ({ ...x, weight: v }))} />}