From 00b4f543a38f14ec0a4707eebe112552440d98b3 Mon Sep 17 00:00:00 2001 From: Duarte Santos Date: Sat, 1 Aug 2026 16:48:57 +0200 Subject: [PATCH] Per side stays on reps work, where reps exist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Switching a per-side exercise to Time carried `side` onto the hold: the config sheet hides the toggle in that mode but still saved the flag, and the workout badge then halved a rep count a timed set does not have, reading "0 per side". Dropped at all three points it could get through — the config sheet no longer writes it outside reps mode, the badge no longer renders outside it, and the plan serialiser refuses it on a hold so an older file cannot bring it back. --- frontend/src/lib/history.test.js | 6 ++++++ frontend/src/lib/plan-share.js | 3 ++- frontend/src/sheets.jsx | 6 ++++-- frontend/src/views/Workout.jsx | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/frontend/src/lib/history.test.js b/frontend/src/lib/history.test.js index fd11334..0117e22 100644 --- a/frontend/src/lib/history.test.js +++ b/frontend/src/lib/history.test.js @@ -288,6 +288,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('repStep', () => { it('steps unilateral work in twos so the total stays splittable', () => { expect(repStep({ side: true })).toBe(2) diff --git a/frontend/src/lib/plan-share.js b/frontend/src/lib/plan-share.js index a09718b..c04acd1 100644 --- a/frontend/src/lib/plan-share.js +++ b/frontend/src/lib/plan-share.js @@ -36,7 +36,8 @@ function cleanEx(e) { // How the exercise is logged travels too (issues #31/#32) — the bodyweight flag only when // it disagrees with the catalogue, since agreeing is what the other end already assumes. if (e.bodyweight != null && e.bodyweight !== isBodyweightEq(e.id)) o.bodyweight = e.bodyweight - if (e.side) o.side = true + // Only on reps work — `side` counts reps, and a timed hold has none to split. + if (e.side && mode !== 'time' && mode !== 'cardio') o.side = true // Progression settings travel with the plan — a shared Greyskull routine that arrives // without its rule is just a list of weights. if (e.prog) o.prog = e.prog diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx index 8d0ce7a..83bdd94 100644 --- a/frontend/src/sheets.jsx +++ b/frontend/src/sheets.jsx @@ -504,9 +504,11 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine }) { if (c.inc > 0) prog.inc = c.inc // 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. const flags = {} if (bw !== isBodyweightEq(ex.id)) flags.bodyweight = bw - if (perSide) flags.side = true if (cardio) onSave({ sets, min: Math.max(1, Math.round(c.min) || 20), speed: Math.max(0, c.speed || 8) }) 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 }) else { @@ -514,7 +516,7 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine }) { // 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 - const out = { sets, mode: 'reps', reps, weight: Math.max(0, c.weight || 0), ...flags, ...prog } + const out = { sets, mode: 'reps', reps, weight: Math.max(0, c.weight || 0), ...flags, ...(perSide ? { side: true } : {}), ...prog } 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))) // 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)) diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx index c7446bb..3040bcc 100644 --- a/frontend/src/views/Workout.jsx +++ b/frontend/src/views/Workout.jsx @@ -118,7 +118,7 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov {cardio && {t('Cardio')}} {/* You log the total; this is the split, so the set in front of you is unambiguous without the rep count having to mean two different things (issue #31). */} - {isPerSide(cfg) && {t('{0} per side', fmtNum(sideReps(entry.sets.find(s => !s.done)?.r ?? entry.sets[0]?.r)))}} + {!cardio && !timed && isPerSide(cfg) && {t('{0} per side', fmtNum(sideReps(entry.sets.find(s => !s.done)?.r ?? entry.sets[0]?.r)))}} {(ex.tg || ex.bp) && {t(ex.tg || ex.bp)}} {ex.eq && {t(ex.eq)}} {best > 0 && {t('Best:')} {fmtNum(best)} {S.unit}}