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
The workout card shows the plan — "Plan: 2 × 10" — and says when today's rows open elsewhere (#275)
Duarte Santosa1fb8c40b6f2
diff --git a/frontend/src/lib/active-exercise-swap.js b/frontend/src/lib/active-exercise-swap.jsindex 3b22710bc..bbabe5a0f 100644--- a/frontend/src/lib/active-exercise-swap.js+++ b/frontend/src/lib/active-exercise-swap.js@@ -20,7 +20,7 @@ export function swapActiveExercise(active, index, replacement, {const current = active.entries[index]if (!hasLoggedSet(current)) {const metadata = Object.fromEntries(Object.entries(current).filter(([key]) => (- !['id', 'target', 'plan', 'planned', 'sets', 'sg'].includes(key)+ !['id', 'target', 'plan', 'planned', 'carried', 'sets', 'sg'].includes(key))))active.entries[index] = { ...metadata, ...replacement, ...(current.sg ? { sg: current.sg } : {}) }active.cur = indexdiff --git a/frontend/src/lib/session-start.js b/frontend/src/lib/session-start.jsindex a71b49942..d0a33fb28 100644--- a/frontend/src/lib/session-start.js+++ b/frontend/src/lib/session-start.js@@ -4,6 +4,7 @@// Imports both history.js and progression.js (which itself imports history.js); nothing in// either imports this file, so there is no cycle.import { buildSets, applyIntensifierPlan, modeOf } from './history.js'+import { isWarmupRow } from './workout-model.js'import { nextPrescription, applyPrescription, defaultIncrement, weightIncrement, plannedOf } from './progression.js'/**@@ -30,16 +31,22 @@ export function buildPlannedEntry(st, cfg, routine, { noProg = false } = {}) {// plates exist), not the unit default; a timed exercise's `inc` is seconds, so it keeps the// default for its optional load.const step = modeOf(cfg) === 'reps' ? weightIncrement(cfg, st.unit) : defaultIncrement(cfg.id, st.unit)- const rows = buildSets(st, cfg, { step, rid: routine?.id, useTarget: plan.kind === 'off', planReps: !startsFromLast(st) })- const sets = applyIntensifierPlan(applyPrescription(rows, plan, step), cfg)+ const planReps = !startsFromLast(st)+ const rows = applyPrescription(buildSets(st, cfg, { step, rid: routine?.id, useTarget: plan.kind === 'off', planReps }), plan, step)+ const sets = applyIntensifierPlan(rows, cfg)const target = { ...cfg }if (plan.weight != null) target.weight = plan.weightif (plan.reps != null) target.reps = plan.repsif (plan.sec != null) target.sec = plan.secif (plan.sets != null) target.sets = plan.sets+ // Rows that opened at last session's reps rather than the plan's ("Your last session", and no+ // policy that decided reps), so the workout card can say where the number came from. Written+ // only when true, and never saved with the finished workout.+ const carried = !planReps && plan.kind !== 'off' && plan.reps == null && modeOf(cfg) === 'reps'+ && rows.some(s => !isWarmupRow(s) && s.r !== cfg.reps)// `planned` is what the routine asked for, kept apart from the target the prescription moved,// so the next session can tell an edited plan from a progressed one (nextPrescription).- return { target, plan, sets, planned: plannedOf(cfg) }+ return { target, plan, sets, planned: plannedOf(cfg), ...(carried ? { carried: true } : {}) }}// Returns a bare array of session entries. "Excluded from progression" is per-entry now@@ -52,7 +59,7 @@ export function buildSessionEntries(st, r) {// right weight already on the screen instead of being told about it afterwards.const noProg = r?.excludeFromProgression === truereturn (r ? r.ex : []).map(cfg => {- const { target, plan, sets, planned } = buildPlannedEntry(st, cfg, r, { noProg })- return { id: cfg.id, sg: cfg.sg, target, plan, sets, planned, ...(noProg ? { noProg: true } : {}) }+ const built = buildPlannedEntry(st, cfg, r, { noProg })+ return { id: cfg.id, sg: cfg.sg, ...built, ...(noProg ? { noProg: true } : {}) }})}diff --git a/frontend/src/lib/session-start.test.js b/frontend/src/lib/session-start.test.jsindex b94feec6c..b774e3d2d 100644--- a/frontend/src/lib/session-start.test.js+++ b/frontend/src/lib/session-start.test.js@@ -74,6 +74,10 @@ describe('buildSessionEntries', () => {const [entry] = buildSessionEntries(history([15, 15], { startFrom: 'last' }), { id: 'r', prog: 'linear', ex: [cfg] })expect(entry.sets.map(s => [s.w, s.r])).toEqual([[42.5, 15], [42.5, 15]])expect(entry.target.reps).toBe(10)+ // …and marks the entry, so the workout card can say where the 15 came from.+ expect(entry.carried).toBe(true)+ expect(buildSessionEntries(history([15, 15]), { id: 'r', prog: 'linear', ex: [cfg] })[0].carried).toBeUndefined()+ expect(buildSessionEntries(history([10, 10], { startFrom: 'last' }), { id: 'r', prog: 'linear', ex: [cfg] })[0].carried).toBeUndefined()})it('warms up at the plan\'s reps, not at last session\'s', () => {diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsxindex f4e6bd85d..4b51e8a53 100644--- a/frontend/src/views/Workout.jsx+++ b/frontend/src/views/Workout.jsx@@ -5,7 +5,7 @@ import { workoutControls } from '../lib/workout-controls.js'import { useUI } from '../store/useUI.js'import { exOr, betterWeight } from '../lib/exercises.js'import { usesBar, barWeightFor, plateSplit } from '../lib/bar.js'-import { effectiveRoutines, effectiveRoutineIds, lastEntryFor, bestWeightFor, bestWeightForEntry, buildSets, freestyleConfig, defaultConfig, setsDoneActive, setUnitsTotal, supersetUnits, unitOf, setLabel, modeOf, isBw, isPerSide, repStep, EFFORT, effortOf, stepEffort, capEffort, cascadeWeight, insertWarmupRow, removeRowAt, pairAdjacent, unpairSuperset, cleanupSg, applyIntensifierPlan, pinnedNoteFor, exNoteFor } from '../lib/history.js'+import { effectiveRoutines, effectiveRoutineIds, lastEntryFor, bestWeightFor, bestWeightForEntry, buildSets, freestyleConfig, defaultConfig, setsDoneActive, setUnitsTotal, supersetUnits, unitOf, setLabel, modeOf, isBw, isPerSide, repStep, EFFORT, effortOf, stepEffort, capEffort, cascadeWeight, insertWarmupRow, removeRowAt, pairAdjacent, unpairSuperset, cleanupSg, applyIntensifierPlan, pinnedNoteFor, exNoteFor, setsRepsOf } from '../lib/history.js'import { fmtNum, capWords, fmtDate, todayISO, exCount, DAYN } from '../lib/format.js'import { beep, vibrate, unlock } from '../lib/sound.js'import { t, exerciseNameFor } from '../lib/i18n.js'@@ -72,7 +72,8 @@ function Elapsed({ start }) {/* ---------- one exercise block (reps: weight×reps · time: a held duration · cardio: duration+speed) ---------- */// `compact` shrinks the block for a superset member; `dense` (compact view) goes further and// drops everything that is not a set you are logging — media, tag chips, the note lines, the-// "last time" recap and the progression line — leaving the name, the ⋯ menu and the sets.+// "last time" recap and the progression line — leaving the name, the ⋯ menu, the one-line plan+// the rows are measured against, and the sets.// Nothing dropped is lost: it is all still on the ⋯ menu, or one ⋮ switch back to list/cards.function ExerciseBlock({ entryIdx, compact, dense, onToggle, onToggleSide, onField, onAddSet, onRemoveSet, onAddWarmup, onRemoveSetAt, onStartTimed, onPairPrev, onPairNext, onSetRowRef, onProgressionSettings, onSwap, onMoveUp, onMoveDown, canMoveUp, canMoveDown, onRemoveExercise, busy }) {const S = useStore(s => s.S)@@ -147,6 +148,26 @@ function ExerciseBlock({ entryIdx, compact, dense, onToggle, onToggleSide, onFie// the session was built so the reason matches the numbers already in the rows.const plan = entry.planconst guidance = progressionGuidance(plan)+ // The plan this exercise was built from (issue #275), on one quiet line in every view — the+ // routine's "2 × 10" is the thing the rows are measured against. When today's rows open+ // somewhere else, the same line says so: progression moved the sets or reps (a bodyweight+ // climb, a deload, an added set), or they carry last session's reps ("Your last session").+ // An entry built before plans were stamped, and a freestyle one, has no plan to show.+ const planned = entry.planned && mode !== 'cardio' ? entry.planned : null+ const planLine = (() => {+ if (!planned) return null+ const today = entry.target || {}+ const todaySets = today.sets || planned.sets || 1+ const inPlan = timed+ ? today.sec == null || today.sec === planned.sec+ : today.reps == null || (planned.repsMin > 0 ? today.reps >= planned.repsMin && today.reps <= planned.reps : today.reps === planned.reps)+ const note = todaySets !== (planned.sets || 1) || !inPlan+ ? t('today {0}', setsRepsOf({ mode, sets: todaySets, reps: today.reps, sec: today.sec }))+ : entry.carried ? t('reps from your last session') : null+ return <div className="small dim planline" style={{ marginBottom: 4 }}>+ {t('Plan: {0}', setsRepsOf({ ...planned, mode }))}{note ? ' · ' + note : ''}+ </div>+ })()// A bodyweight set has no weight to type, so the column is not there (issue #32) — one// stepper instead of two, which is the whole point of the flag. Adding a belt weight in the// config brings it back, now labelled as the addition it is.@@ -378,6 +399,8 @@ function ExerciseBlock({ entryIdx, compact, dense, onToggle, onToggleSide, onFie<button className="iconbtn" aria-label={t('More')} title={t('More')} onClick={openMore}><Icon name="more" /></button></div></div>+ {/* compact view keeps the plan line: it is what the rows are measured against */}+ {dense && planLine}{wc.pairButtons && !compact && !dense && (onPairPrev || onPairNext) && <div className="row" style={{ gap: 6, flexWrap: 'wrap', marginBottom: 8 }}>{onPairPrev && <Button size="xs" variant="tinted" icon="link" title={t('Make superset with previous')} onClick={onPairPrev}>{t('Make superset with previous')}</Button>}{onPairNext && <Button size="xs" variant="tinted" icon="link" title={t('Make superset with next')} onClick={onPairNext}>{t('Make superset with next')}</Button>}@@ -406,6 +429,7 @@ function ExerciseBlock({ entryIdx, compact, dense, onToggle, onToggleSide, onFie{t('From {0}:', fmtDate(pinnedNote.d, true))} {pinnedNote.note}</div>}{entry.note && <div className="exnote">{entry.note}</div>}+ {planLine}{last && <div className="small dim" style={{ marginBottom: 4 }}>{t('Last time')} ({fmtDate(last.d)}): {last.sets.map(s => setLabel(entry.id, s, last.target)).join(', ')}</div>}{/* Bar + plates for barbell work: what to load per side for the set in front of you(first undone set; the heaviest row once everything is checked). The logged number@@ -537,7 +561,7 @@ function ActiveWorkout() {// the whole session is visible and scrollable (Settings → During a workout → Workout view,// seeded onto s.active and overridable for this session from the header ⋮). compact is list// with the per-exercise media, tag chips, note lines, "last time" and progression line- // stripped — just names and set rows. Every set handler below is already entry-index+ // stripped — just names, the one-line plan and set rows. Every set handler below is already entry-index// parameterised, so these only change what is rendered — completion, rest, top-weight and// auto-advance share one path. Unknown/absent values read as cards, keeping every// pre-existing profile (and a session started before this field) as it was.@@ -812,6 +836,8 @@ function ActiveWorkout() {activeEntry.target = built.targetactiveEntry.plan = built.planactiveEntry.planned = built.planned+ if (built.carried) activeEntry.carried = true+ else delete activeEntry.carriedactiveEntry.sets = [...doneWarm, ...freshWarm.slice(doneWarm.length), ...doneWork, ...freshWork.slice(doneWork.length)]})}, null, routine)diff --git a/frontend/src/views/Workout.test.jsx b/frontend/src/views/Workout.test.jsxindex 4d6638826..5599be4aa 100644--- a/frontend/src/views/Workout.test.jsx+++ b/frontend/src/views/Workout.test.jsx@@ -1257,6 +1257,48 @@ describe('workout compact view', () => {})})+// Issue #275: the card says what the routine planned, in every view, and when the rows opened+// somewhere else — progression moved them, or they carry last session's reps.+describe('the plan line', () => {+ const planned = (extra = {}) => exercise('plain-bench', [false, false], {+ planned: { sets: 2, reps: 10, weight: 60 },+ target: { mode: 'reps', sets: 2, reps: 10, weight: 62.5, bodyweight: false },+ ...extra,+ })+ const line = () => container.querySelector('.planline')?.textContent++ it('shows the plan quietly when the rows are the plan', async () => {+ await mount([planned()])+ expect(line()).toBe('Plan: 2 × 10')+ })++ it('says when progression moved the sets or reps', async () => {+ await mount([planned({ target: { mode: 'reps', sets: 3, reps: 10, weight: 0, bodyweight: true } })])+ expect(line()).toBe('Plan: 2 × 10 · today 3 × 10')+ })++ it('says when the reps were carried over from the last session', async () => {+ await mount([planned({ carried: true, sets: [{ w: 62.5, r: 15, done: false }, { w: 62.5, r: 15, done: false }] })])+ expect(line()).toBe('Plan: 2 × 10 · reps from your last session')+ })++ it('reads a double-progression aim inside the range as the plan', async () => {+ await mount([planned({ planned: { sets: 3, reps: 12, repsMin: 8, weight: 40 }, target: { mode: 'reps', sets: 3, reps: 11, repsMin: 8, weight: 40 } })])+ expect(line()).toBe('Plan: 3 × 8–12')+ })++ it('stays in compact view, where the last-time recap and progression line go', async () => {+ await mount([planned()], 0, { workoutView: 'compact' })+ expect(line()).toBe('Plan: 2 × 10')+ expect(container.textContent).not.toContain('Last time')+ })++ it('is not there for an entry with no plan (freestyle, or started before plans were kept)', async () => {+ await mount([exercise('plain-bench', [false])])+ expect(container.querySelector('.planline')).toBeNull()+ })+})+describe('workout view header menu', () => {const openMenu = async () => {const btn = container.querySelector('button[aria-label="Workout view"]')