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
Workout: an exercise kept out by hand keeps today's prescription when its Progression settings are saved or it is swapped, so its Undo counts the right numbers (Discord)
Duarte Santosbf0f4fdfd04d
diff --git a/frontend/src/lib/session-start.js b/frontend/src/lib/session-start.jsindex ae725a165..6b311e3f5 100644--- a/frontend/src/lib/session-start.js+++ b/frontend/src/lib/session-start.js@@ -72,6 +72,19 @@ export function plannedConfigOf(entry) {return out}+/**+ * Whether an entry is rebuilt the way an excluded routine builds its exercises: at the routine's+ * own numbers, with no prescription (buildPlannedEntry's `noProg`).+ *+ * `entry.noProg` comes from two places. A deload or rehab routine freezes it onto every exercise+ * it starts, and those are built without a prescription. An exercise's ⋯ menu sets it by hand for+ * one session, and that only stops the session from counting: its rows stay at the prescription.+ * Read as the first kind, a hand-set flag made a rebuild (Progression settings saved, a swap) drop+ * today's 102.5 to the routine's own 60, and its Undo then let those 60 count as progress. So only+ * an entry whose routine is itself kept out is built that way.+ */+export const builtOutOfProgression = (entry, routine) => entry?.noProg === true && routine?.excludeFromProgression === true+// Returns a bare array of session entries. "Excluded from progression" is per-entry now// (`entry.noProg`, written only when true) rather than a wrapper flag — a rehab routine merged// into real work must exclude only its own exercises. The merge helper (lib/session-merge.js)diff --git a/frontend/src/lib/session-start.test.js b/frontend/src/lib/session-start.test.jsindex bd2365b40..f7b2365fe 100644--- a/frontend/src/lib/session-start.test.js+++ b/frontend/src/lib/session-start.test.js@@ -1,5 +1,5 @@import { describe, it, expect } from 'vitest'-import { buildSessionEntries, plannedConfigOf } from './session-start.js'+import { buildSessionEntries, plannedConfigOf, builtOutOfProgression } from './session-start.js'import { readSession } from './progression.js'import { isWarmupRow } from './workout-model.js'@@ -167,3 +167,24 @@ describe('plannedConfigOf', () => {expect(plannedConfigOf({ target })).not.toBe(target)})})++// An exercise's ⋯ menu sets `noProg` by hand; a deload or rehab routine freezes it onto its+// exercises. Only the second is rebuilt without a prescription.+describe('builtOutOfProgression', () => {+ const deload = { id: 'd', excludeFromProgression: true }+ const main = { id: 'm' }++ it('is an exercise of a routine kept out of progression', () => {+ expect(builtOutOfProgression({ noProg: true, rid: 'd' }, deload)).toBe(true)+ })++ it('is not an exercise kept out by hand in a routine that counts', () => {+ expect(builtOutOfProgression({ noProg: true, rid: 'm' }, main)).toBe(false)+ })++ it('is not an exercise with no routine, nor one that was never kept out', () => {+ expect(builtOutOfProgression({ noProg: true }, null)).toBe(false)+ expect(builtOutOfProgression({ rid: 'd' }, deload)).toBe(false)+ expect(builtOutOfProgression(null, deload)).toBe(false)+ })+})diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsxindex 90871a73a..5cc1c9498 100644--- a/frontend/src/sheets.jsx+++ b/frontend/src/sheets.jsx@@ -34,7 +34,7 @@ import { nextUnfinishedUnit } from './lib/supersetFlow.js'import { swapActiveExercise } from './lib/active-exercise-swap.js'import { useSheetKeyboard, useRevealActiveChip, tappable } from './lib/use-sheet-keyboard.js'import { isFav, toggleFav, sortFavouritesFirst } from './lib/favourites.js'-import { buildSessionEntries, buildPlannedEntry } from './lib/session-start.js'+import { buildSessionEntries, buildPlannedEntry, builtOutOfProgression } from './lib/session-start.js'import { buildCombinedEntries, deriveSessionName } from './lib/session-merge.js'import { workoutsOn, backfillStart, backfillEnd, completeBackfill } from './lib/backfill.js'@@ -1027,14 +1027,16 @@ export function swapActiveWorkoutExercise(index) {const step = modeOf(full) === 'reps' ? weightIncrement(full, st.unit) : defaultIncrement(ex.id, st.unit)const built = freestyle? { target: { ...cfg }, plan: null, sets: applyIntensifierPlan(buildSets(st, full, { step, preferLast: true }), full) }- : buildPlannedEntry(st, full, slotRoutine, { noProg: current.noProg === true })+ : buildPlannedEntry(st, full, slotRoutine, { noProg: builtOutOfProgression(current, slotRoutine) })const replacement = {id: ex.id,...built,...(current.rid ? { rid: current.rid } : {}),// A slot kept out of progression stays out once swapped. Replaced in place the entry keeps// it anyway; inserted beside logged sets, the replacement would otherwise count as a- // regular session of the new exercise.+ // regular session of the new exercise. Only a deload or rehab slot is built without a+ // prescription (above): one kept out by hand keeps the marker and its Undo on the card,+ // and an Undo must leave numbers that are right to count....(current.noProg === true ? { noProg: true } : {}),}diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsxindex d3a810596..72c908d80 100644--- a/frontend/src/views/Workout.jsx+++ b/frontend/src/views/Workout.jsx@@ -18,7 +18,7 @@ import Icon from '../components/Icon.jsx'import { Button, Check, NumberField } from '../components/ui.jsx'import { defaultIncrement, weightIncrement, stepWeight } from '../lib/progression.js'import { progressionGuidance } from '../lib/progression-copy.js'-import { buildPlannedEntry, plannedConfigOf } from '../lib/session-start.js'+import { buildPlannedEntry, plannedConfigOf, builtOutOfProgression } from '../lib/session-start.js'import { glyphOf } from '../lib/glyphs.js'import { isWarmupRow, isDropSet, isRestPauseSet, dropsOf, clustersOf, addDrop, addCluster, removeDropAt, removeClusterAt, setDropAt, setClusterAt, nextDropWeight, nextBurstReps, isSideSet, makeSideSet, setSideField, toggleSide, addSideDrop, removeSideDropAt, setSideDropAt, addSideCluster, removeSideClusterAt, setSideClusterAt } from '../lib/workout-model.js'import { canMoveActiveWorkoutUnit, moveActiveWorkoutUnit } from '../lib/active-workout-order.js'@@ -729,6 +729,8 @@ function ActiveWorkout() {// It stamps the entry's `noProg`, the flag a deload routine freezes onto its entries: the saved// workout keeps it (finish-workout.js), and the next prescription and "last time" read past// this entry (history.js entryExcluded). This exercise, this session; the routine is untouched.+ // Unlike a deload's, its rows keep the prescription through any rebuild (builtOutOfProgression),+ // so switching it off again leaves the numbers this session should count at.const setNoProg = (idx, on) => update(s => {const e = s.active?.entries?.[idx]if (!e) return@@ -858,7 +860,9 @@ function ActiveWorkout() {// rebuilt from the new config exactly the way the session start builds them (same reps// source, same prescription, same stamped target), and only what you already logged is// kept in place (done warm-ups first, then done work sets, then the fresh remainder).- const built = buildPlannedEntry(s, full, activeRoutine, { noProg: activeEntry.noProg === true })+ // Without a prescription only in a routine kept out of progression: an exercise kept out+ // by hand keeps its prescription, so its Undo leaves the numbers it should count at.+ const built = buildPlannedEntry(s, full, activeRoutine, { noProg: builtOutOfProgression(activeEntry, activeRoutine) })const fresh = built.setsconst doneWarm = activeEntry.sets.filter(x => x.done && isWarmupRow(x))const doneWork = activeEntry.sets.filter(x => x.done && !isWarmupRow(x))@@ -1194,7 +1198,7 @@ function ActiveWorkout() {const curRid = curEntry?.ridconst routine = curRid ? S.routines.find(r => r.id === curRid) : nullconst freestyle = !routine- const noProg = !freestyle && curEntry?.noProg === true && routine.excludeFromProgression === true+ const noProg = !freestyle && builtOutOfProgression(curEntry, routine)// Freestyle has no routine prescription to apply: show the last target in the config// sheet and carry its completed rows forward. A planned session uses its configured// target when progression is off, while progression-enabled sessions keep their path.diff --git a/frontend/src/views/Workout.noprog.test.jsx b/frontend/src/views/Workout.noprog.test.jsxindex 72ed578ba..a6399682e 100644--- a/frontend/src/views/Workout.noprog.test.jsx+++ b/frontend/src/views/Workout.noprog.test.jsx@@ -12,6 +12,9 @@ import { useUI } from '../store/useUI.js'import { buildCompletedWorkout } from '../lib/finish-workout.js'import { nextPrescription } from '../lib/progression.js'import { lastEntryFor } from '../lib/history.js'+import { buildSessionEntries } from '../lib/session-start.js'+import { swapActiveWorkoutExercise } from '../sheets.jsx'+import { EXDB } from '../lib/exercises.js'vi.mock('../lib/sound.js', () => ({ beep: vi.fn(), chime: vi.fn(), vibrate: vi.fn(), unlock: vi.fn() }))vi.mock('../lib/api.js', () => ({ api: vi.fn(() => Promise.resolve({})), appBase: () => '/' }))@@ -35,10 +38,10 @@ let containerlet sheetRootlet sheetContainer-function renderWorkout(entries) {+function renderWorkout(entries, { withRoutines = routines, withHistory = history } = {}) {const S = clone(DEF)- S.routines = clone(routines)- S.workouts = clone(history)+ S.routines = clone(withRoutines)+ S.workouts = clone(withHistory)S.active = { id: 'noprog-test', d: '2026-09-23', start: Date.now(), routineIds: ['main'], routineId: 'main', name: 'Main', bw: null, cur: 0, entries }useStore.setState({ S, user: null })container = document.createElement('div')@@ -141,6 +144,92 @@ describe('don’t count this session for progression', () => {expect(lastEntryFor(S, BENCH, 'main').d).toBe('2026-09-20')})+ // The flag set by hand only stops the session from counting; the rows stay at the+ // prescription. A rebuild that read it as "a deload routine's exercise" put them back at the+ // routine's own numbers with no prescription, and the Undo then let those numbers count.+ describe('a rebuild of an exercise kept out by hand keeps its prescription', () => {+ // Main plans 60; the last session that counted was 100 × 5, so today opens at 102.5.+ const planned = [{ id: 'main', name: 'Main', ex: [{ id: BENCH, sets: 1, reps: 5, weight: 60 }, { id: ROW, sets: 1, reps: 8, weight: 30 }] }]+ const logged = [{+ id: 'w1', d: '2026-09-20', routineIds: ['main'],+ entries: [+ { id: BENCH, rid: 'main', target: { sets: 1, reps: 5, weight: 100 }, sets: [{ w: 100, r: 5, done: true }] },+ { id: ROW, rid: 'main', target: { sets: 1, reps: 8, weight: 70 }, sets: [{ w: 70, r: 8, done: true }] },+ ],+ }]+ const start = () => {+ const S = { ...clone(DEF), routines: clone(planned), workouts: clone(logged) }+ const [bench] = buildSessionEntries(S, planned[0]).map(e => ({ ...e, rid: 'main' }))+ renderWorkout([bench], { withRoutines: planned, withHistory: logged })+ expect(active().entries[0].sets.map(set => set.w)).toEqual([102.5])+ const keepOut = menuItem(openMenu(), 'Don’t count for progression')+ act(() => keepOut.click())+ expect(active().entries[0].noProg).toBe(true)+ }+ const undoAndFinish = () => {+ const undo = [...marker().querySelectorAll('button')].find(b => b.textContent === 'Undo')+ act(() => undo.click())+ expect(active().entries[0].noProg).toBeUndefined()+ useStore.getState().update(s => { s.active.entries[0].sets.forEach(set => { set.done = true }) })+ const saved = buildCompletedWorkout(active(), { end: Date.now() })+ return { ...useStore.getState().S, active: null, workouts: [...logged, saved] }+ }++ it('Progression settings saved unchanged, then Undo: the session counts at 102.5 and the next one goes on from there', () => {+ start()+ const settings = menuItem(openMenu(), 'Progression settings')+ act(() => settings.click())+ const sheet = renderTopSheet()+ const save = [...sheet.querySelectorAll('button')].find(b => b.textContent.trim() === 'Save')+ act(() => save.click())++ const [bench] = active().entries+ expect(bench.noProg).toBe(true)+ expect(bench.sets.map(set => set.w)).toEqual([102.5])+ expect(bench.target.weight).toBe(102.5)+ expect(bench.plan.kind).not.toBe('off')++ const S = undoAndFinish()+ expect(nextPrescription(S, planned[0].ex[0], planned[0]).weight).toBe(105)+ })++ it('a swap, then Undo: the replacement counts at its own prescription, not the routine’s numbers', () => {+ start()+ swapActiveWorkoutExercise(0)+ const picker = useUI.getState().sheets.at(-1)+ act(() => picker.render(picker.close).props.onPick(EXDB.find(e => e.id === ROW)))+ const config = useUI.getState().sheets.at(-1)+ act(() => config.render(config.close).props.onSave({ ...planned[0].ex[1] }))++ const [row] = active().entries+ expect(row.id).toBe(ROW)+ // The mark stays on the slot, with its Undo on the card.+ expect(row.noProg).toBe(true)+ // 70 × 8 last time, and a row goes up in 5s: 75, the way the routine's own start builds it.+ const S0 = { ...clone(DEF), routines: clone(planned), workouts: clone(logged) }+ expect(buildSessionEntries(S0, planned[0])[1].sets.map(set => set.w)).toEqual([75])+ expect(row.sets.map(set => set.w)).toEqual([75])+ expect(row.plan.kind).not.toBe('off')++ const S = undoAndFinish()+ expect(nextPrescription(S, planned[0].ex[1], planned[0]).weight).toBe(80)+ })+ })++ it('a deload routine’s exercise saved in Progression settings stays at the routine’s own numbers', () => {+ // 70 × 8 in Main would put a counting row at 75; the deload keeps its 40.+ const rowInMain = { id: 'w0', d: '2026-09-18', routineIds: ['main'], entries: [{ id: ROW, rid: 'main', target: { sets: 1, reps: 8, weight: 70 }, sets: [{ w: 70, r: 8, done: true }] }] }+ renderWorkout([{ ...entry(ROW, 'deload', 40, { noProg: true }), target: { sets: 1, reps: 8, weight: 40 }, sets: [{ w: 40, r: 8, done: false }] }], { withHistory: [...history, rowInMain] })+ const settings = menuItem(openMenu(), 'Progression settings')+ act(() => settings.click())+ const save = [...renderTopSheet().querySelectorAll('button')].find(b => b.textContent.trim() === 'Save')+ act(() => save.click())+ const [row] = active().entries+ expect(row.noProg).toBe(true)+ expect(row.plan.kind).toBe('off')+ expect(row.sets.map(set => set.w)).toEqual([40])+ })+it('a deload routine’s exercise shows the marker but offers neither the switch nor an undo', () => {renderWorkout([entry(ROW, 'deload', 40, { noProg: true })])expect(marker().textContent).toContain('Not counted for progression')