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
Per side on timed holds, rebased on v1.3.9 with the progression fix
Suroh Susejd75468069ea1
diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.jsindex 4bcf90565..15af7547f 100644--- a/frontend/src/lib/history.js+++ b/frontend/src/lib/history.js@@ -190,7 +190,9 @@ export function exLine(cfg, unit, speedUnit) {// 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 @ ${fmtSpeed(cfg.speed || 8, speedUnit)}`- if (mode === 'time') return `${setsRepsOf(cfg)}${load}`+ // A timed hold has no rep count to spell a split out of ("8/side" below) — "per side" says it+ // happens twice, once each side (buildWorkSets), rather than trying to divide a duration.+ if (mode === 'time') return `${setsRepsOf(cfg)}${load}${isPerSide(cfg) ? ' · ' + t('per side') : ''}`// 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', repsOf(cfg, v => fmtNum(sideReps(v)))) : ''return `${setsRepsOf(cfg)}${load}${split}`@@ -483,12 +485,20 @@ function buildWorkSets(S, cfg, options = {}) {return sets}if (mode === 'time') {- for (let i = 0; i < n; i++) {+ // A timed hold has no rep count to split in half, so "per side" here means the whole hold+ // happens once per side rather than once total: the planned sets double (2 sets of 30s+ // becomes 2 left + 2 right, each still 30s) instead of the duration being divided. Plain+ // rows tagged with `side`, not the L/R sub-row pair reps uses (isSideSet) — there is only+ // one duration to log per row, not two independent values to track side by side.+ const count = isPerSide(cfg) ? n * 2 : n+ for (let i = 0; i < count; i++) {// Only carry a previous value over when it came from a timed set — switching an// exercise from reps to time must not seed the duration from a rep count.const prev = prevAt(i)const carried = prev && prev.sec > 0 ? prev : null- sets.push({ sec: carried ? carried.sec : (cfg.sec || 45), w: carried ? (carried.w || 0) : (cfg.weight || 0), done: false })+ const row = { sec: carried ? carried.sec : (cfg.sec || 45), w: carried ? (carried.w || 0) : (cfg.weight || 0), done: false }+ if (isPerSide(cfg)) row.side = i % 2 === 0 ? 'L' : 'R'+ sets.push(row)}return sets}diff --git a/frontend/src/lib/history.test.js b/frontend/src/lib/history.test.jsindex a483ff617..fc918562a 100644--- a/frontend/src/lib/history.test.js+++ b/frontend/src/lib/history.test.js@@ -347,9 +347,12 @@ describe('sideReps', () => {})})-describe('exLine — per side never reaches a timed hold', () => {- it('ignores a stale side flag on a hold, which has no reps to split', () => {- expect(exLine({ id: LIFT, sets: 3, sec: 45, mode: 'time', side: true }, 'kg')).toBe('3 × 0:45')+describe('exLine — per side on a timed hold', () => {+ it('reads "per side" rather than splitting a duration in half', () => {+ expect(exLine({ id: LIFT, sets: 3, sec: 45, mode: 'time', side: true }, 'kg')).toBe('3 × 0:45 · per side')+ })+ it('leaves a plain hold untouched', () => {+ expect(exLine({ id: LIFT, sets: 3, sec: 45, mode: 'time' }, 'kg')).toBe('3 × 0:45')})})@@ -528,6 +531,22 @@ describe('buildSets', () => {.toEqual([{ sec: 60, w: 20, done: false }, { sec: 60, w: 20, done: false }])})+ it('doubles a per-side timed hold — once on each side, full duration both times', () => {+ expect(buildSets(emptyS, { id: LIFT, mode: 'time', sets: 2, sec: 30, weight: 0, side: true }))+ .toEqual([+ { sec: 30, w: 0, done: false, side: 'L' }, { sec: 30, w: 0, done: false, side: 'R' },+ { sec: 30, w: 0, done: false, side: 'L' }, { sec: 30, w: 0, done: false, side: 'R' },+ ])+ })++ it('carries a per-side timed hold forward by row, L and R each keeping their own history', () => {+ const S = { exWeights: {}, workouts: [{ d: '2026-01-01', entries: [{ id: LIFT, target: { mode: 'time', side: true }, sets: [+ { sec: 40, w: 5, done: true, side: 'L' }, { sec: 35, w: 5, done: true, side: 'R' },+ ] }] }] }+ expect(buildSets(S, { id: LIFT, mode: 'time', sets: 1, sec: 30, weight: 0, side: true }))+ .toEqual([{ sec: 40, w: 5, done: false, side: 'L' }, { sec: 35, w: 5, done: false, side: 'R' }])+ })+it('builds cardio sets unchanged', () => {expect(buildSets(emptyS, { id: CARDIO, sets: 1, min: 25, speed: 9 })).toEqual([{ min: 25, speed: 9, done: false }])diff --git a/frontend/src/lib/progression.js b/frontend/src/lib/progression.jsindex 571495a0e..deeab2bf6 100644--- a/frontend/src/lib/progression.js+++ b/frontend/src/lib/progression.js@@ -262,7 +262,12 @@ export function readSession(entry, fallback) {// Warm-up rows are prep, not the session: one filtered read beats guarding every consumer// below (an undone warm-up otherwise poisons `ok` forever and its reps drag `low`/`count`).const logged = ((entry && entry.sets) || []).filter(s => !isWarmupRow(s))- const planned = target.sets || logged.length+ // A timed per-side hold doubles its row count (buildWorkSets: one set on the plan becomes an+ // L row and an R row) — `target.sets` is still the plan's pre-doubling number, so it has to+ // double here too, or `sets` below stops after the first side's rows and the other side's+ // holds never reach `ok`/`held`/`best`.+ const plannedRows = target.sets || logged.length+ const planned = mode === 'time' && isPerSide(target) ? plannedRows * 2 : plannedRowsconst enough = logged.length >= planned// Only the sets the plan asked for decide what happens next (issue #233). A set added on top// is extra work, and it used to be read as part of the prescription: one heavier bonus setdiff --git a/frontend/src/lib/progression.test.js b/frontend/src/lib/progression.test.jsindex 8b985c165..9b9c3f1a9 100644--- a/frontend/src/lib/progression.test.js+++ b/frontend/src/lib/progression.test.js@@ -67,6 +67,26 @@ describe('readSession', () => {expect(s.best).toBe(50)expect(readSession({ id: LIFT, target: { sets: 2, sec: 45, mode: 'time' }, sets: [{ sec: 45, done: true }, { sec: 30, done: true }] }).ok).toBe(false)})++ it('reads all of a per-side timed hold\'s doubled rows, not just the first pair', () => {+ const T = { sets: 2, sec: 30, mode: 'time', side: true }+ // 2 planned sets, per side, is 4 real rows (buildSets) — every one of them has to be read,+ // or a miss on the second pair goes unnoticed and progression bumps the hold anyway.+ const allHeld = readSession({ id: LIFT, target: T, sets: [+ { sec: 30, done: true, side: 'L' }, { sec: 30, done: true, side: 'R' },+ { sec: 30, done: true, side: 'L' }, { sec: 30, done: true, side: 'R' },+ ] })+ expect(allHeld.ok).toBe(true)+ const secondPairShort = readSession({ id: LIFT, target: T, sets: [+ { sec: 30, done: true, side: 'L' }, { sec: 30, done: true, side: 'R' },+ { sec: 15, done: true, side: 'L' }, { sec: 30, done: true, side: 'R' },+ ] })+ expect(secondPairShort.ok).toBe(false)+ // Fewer logged rows than the doubled count is short, same as any other mode.+ expect(readSession({ id: LIFT, target: T, sets: [+ { sec: 30, done: true, side: 'L' }, { sec: 30, done: true, side: 'R' },+ ] }).ok).toBe(false)+ })})describe('stallCount', () => {diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsxindex 71020da59..506d31d00 100644--- a/frontend/src/sheets.jsx+++ b/frontend/src/sheets.jsx@@ -1408,9 +1408,10 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, i}// Written only when it differs from what the dataset already says, so a barbell config// stays exactly the shape it was before these flags existed.- // `bodyweight` is true of a hold as much as of a set of reps; `side` is not — it counts- // reps, and a timed hold has none. Switching an exercise to Time therefore drops it- // rather than carrying a flag nothing downstream can read.+ // `bodyweight` is true of a hold as much as of a set of reps. `side` used to be dropped on+ // switching to Time too — a timed hold has no rep count to split — but "per side" does not+ // have to mean splitting: for a hold it means doing the whole thing once per side, so the+ // flag now survives the switch and buildWorkSets doubles the planned sets instead.const flags = {}if (bw !== isBodyweightEq(ex.id)) flags.bodyweight = bw// Free text, e.g. a pyramid's per-set loading ("bar only, +1 plate/side each set") — the@@ -1428,7 +1429,7 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, iconst restSec = Math.max(0, Math.round(c.restSec) || 0)const withRest = restSec ? { restSec } : {}if (cardio) onSave({ sets, min: Math.max(1, Math.round(c.min) || 20), speed: Math.max(0, c.speed || 8), ...withNote, ...withRest })- else if (mode === 'time') onSave({ sets, mode: 'time', sec: Math.max(1, Math.round(c.sec) || 45), weight: Math.max(0, c.weight || 0), ...flags, ...prog, ...withNote, ...withWarmups, ...withRest })+ else if (mode === 'time') onSave({ sets, mode: 'time', sec: Math.max(1, Math.round(c.sec) || 45), weight: Math.max(0, c.weight || 0), ...flags, ...(perSide ? { side: true } : {}), ...prog, ...withNote, ...withWarmups, ...withRest })else {// 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.@@ -1529,11 +1530,17 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, isubtitle={bw ? (mode === 'time' ? t('No weight to enter — just time the hold.') : t('No weight to enter — just log the reps.')) : t('Ask for a weight on every set.')}><Switch checked={bw} onChange={v => setC(x => ({ ...x, bodyweight: v, weight: v ? 0 : x.weight }))} /></Row>- {mode === 'reps' && <Row icon="shuffle" iconTint="var(--blue)" title={t('Reps per side')}- subtitle={perSide ? t('You still log the total: {0} is {1} per side.', c.reps || 0, fmtNum(sideReps(c.reps))) : t('For lunges, single-arm rows and the like.')}>- {/* Turning it on rounds the target up to an even number, since half of an odd- total is a rep one side does not get. */}+ {mode !== 'cardio' && <Row icon="shuffle" iconTint="var(--blue)" title={t('Per side')}+ subtitle={mode === 'time'+ ? (perSide+ ? t('{0} sets become {1}: one on each side, {2}s held every time.', c.sets || 0, (c.sets || 0) * 2, c.sec || 0)+ : t('For a side plank, single-arm hold and the like — trains each side on its own.'))+ : (perSide ? t('You still log the total: {0} is {1} per side.', c.reps || 0, fmtNum(sideReps(c.reps))) : t('For lunges, single-arm rows and the like.'))}>+ {/* Reps: turning it on rounds the target up to an even number, since half of an odd total+ is a rep one side does not get. Time: nothing to round — a hold's whole duration+ happens twice, so only the flag changes (buildWorkSets doubles the planned sets). */}<Switch checked={perSide} onChange={v => setC(x => {+ if (mode === 'time') return { ...x, side: v || undefined }const next = { ...x, side: v || undefined, reps: v ? Math.ceil((x.reps || 0) / 2) * 2 : x.reps }return policyFor({ ...next, id: ex.id }, routine, 'reps') === 'double'? { ...next, ...normalizeRepRange(next.reps, next.repsMin, v ? 2 : 1) }diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsxindex 39340a4ed..1685edf99 100644--- a/frontend/src/views/Workout.jsx+++ b/frontend/src/views/Workout.jsx@@ -363,10 +363,20 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSi})// The set number is the set's own menu: drop / burst / remove — three things that used to// sit as chips and an X on every single row.+ // A timed per-side exercise plans in L/R pairs (buildWorkSets, addSet below), so the two+ // halves of a pair read as one set number — "Set 1 — Left" then "Set 1 — Right" — rather than+ // counting every row and making the second half look like an extra set.+ const setNumOf = (s, i) => {+ const warm = isWarmupRow(s)+ const phaseNum = entry.sets.slice(0, i + 1).filter(x => isWarmupRow(x) === warm).length+ return s.side ? Math.ceil(phaseNum / 2) : phaseNum+ }+ const sideTagOf = s => s.side === 'L' ? t('Left') : s.side === 'R' ? t('Right') : nullconst openSetMenu = (s, i) => {const warm = isWarmupRow(s)+ const sideTag = sideTagOf(s)menuSheet({- title: (warm ? t('Warm-up') : t('Set {0}', entry.sets.slice(0, i + 1).filter(x => isWarmupRow(x) === warm).length)),+ title: warm ? t('Warm-up') : sideTag ? t('Set {0} — {1}', setNumOf(s, i), sideTag) : t('Set {0}', setNumOf(s, i)),subtitle: setLabel(entry.id, s, entry.target, speedUnit),items: [!warm && mode === 'reps' && !isRestPauseSet(s) && { icon: 'arrowDown', label: t('Drop set'), sub: t('+ Drop'), onClick: () => addDropRow(i) },@@ -523,10 +533,11 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSi{!dense && <><div className="row" style={{ gap: 6, flexWrap: 'wrap', marginBottom: 8 }}>{cardio && <span className="tag acc"><Icon name="figureRun" />{t('Cardio')}</span>}- {/* A unilateral exercise is logged per side directly (the L/R rows below), so the old- "{n} per side" chip — which halved the combined total for display — is gone: the split- is no longer derived, it is what you enter. The tag only flags that this is per-side. */}- {!cardio && !timed && isPerSide(cfg) && <span className="tag acc nocap"><Icon name="shuffle" />{t('Per side')}</span>}+ {/* A unilateral exercise is logged per side directly (the L/R rows below for reps, a+ "Left"/"Right" tag on each doubled row for a timed hold), so the old "{n} per side"+ chip — which halved the combined total for display — is gone: the split is no longer+ derived, it is what you enter. The tag only flags that this is per-side. */}+ {!cardio && isPerSide(cfg) && <span className="tag acc nocap"><Icon name="shuffle" />{t('Per side')}</span>}{(ex.tg || ex.bp) && <span className="tag">{t(MUSCLE_NAME[ex.tg] || ex.tg || ex.bp)}</span>}{ex.eq && <span className="tag">{t(ex.eq)}</span>}{best > 0 && <span className="tag nocap">{t('Best:')} {fmtNum(best)} {S.unit}</span>}@@ -577,7 +588,8 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSi</div>) : (<div ref={el => onSetRowRef?.(i, el)} className={'setrow' + (s.done ? ' done' : '') + (col3 ? ' eff3' : '') + (timed ? ' timed' : '')}>- <button type="button" className="n" aria-label={t('Set {0}', phaseNum)} title={t('More')} onClick={() => openSetMenu(s, i)}>{phaseNum}</button>+ <button type="button" className="n" aria-label={sideTagOf(s) ? t('Set {0} — {1}', setNumOf(s, i), sideTagOf(s)) : t('Set {0}', setNumOf(s, i))} title={t('More')} onClick={() => openSetMenu(s, i)}>{setNumOf(s, i)}</button>+ {sideTagOf(s) && <span className="tag acc nocap">{sideTagOf(s)}</span>}{cell(s, i, col1, 'w')}{col2 && cell(s, i, col2, 'r')}{col3 && effortCell(s, i, col3)}@@ -781,7 +793,14 @@ function ActiveWorkout() {const l = e.sets[e.sets.length - 1]const m = modeOf({ ...(e.target || {}), id: e.id })if (m === 'cardio') e.sets.push({ min: l ? l.min : (e.target.min || 20), speed: l ? l.speed : (e.target.speed || 8), done: false })- else if (m === 'time') e.sets.push({ sec: l ? l.sec : (e.target.sec || 45), w: l ? (l.w || 0) : (e.target.weight || 0), done: false })+ else if (m === 'time') {+ const sec = l ? l.sec : (e.target.sec || 45)+ const w = l ? (l.w || 0) : (e.target.weight || 0)+ // A timed per-side exercise is planned in pairs (buildWorkSets), so one more "set" is one+ // more hold on each side, not a lone row an L/R count would fall out of sync with.+ if (isPerSide({ ...(e.target || {}), id: e.id })) e.sets.push({ sec, w, done: false, side: 'L' }, { sec, w, done: false, side: 'R' })+ else e.sets.push({ sec, w, done: false })+ }else {const row = { w: l ? l.w : 0, r: l ? l.r : e.target.reps, done: false }// A unilateral exercise keeps adding per-side rows (issue #60): seed each side from the