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
Warm-ups on an assistance machine ramp down from more help
lntvan1662cac8abac922
diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.jsindex a555bf589..562a539aa 100644--- a/frontend/src/lib/history.js+++ b/frontend/src/lib/history.js@@ -980,7 +980,21 @@ export function cascadeWeight(rows, from, value, side, backoffStep = 0) {// heaviest bell at or under it.const rungDown = (x, step) => (Array.isArray(step) ? ownedFloor(step, x) : Math.floor(x / step) * step)-export function rerampWarmups(rows, step = 2.5, floor = 0) {+// An assistance machine (exercises.js isAssisted) ramps from the other side: the stack carries+// part of your body weight, so less load is harder, and halving it made the warm-up harder than+// the work sets. Its warm-ups give MORE help instead: the first at 1.5× the work weight, each+// next one halving what is left down to it, rounded UP to the step (a notch more help is still a+// warm-up). `from` is the warm-up before it, 0 for the first. The step is never a dumbbell list+// here (ownedWeightsFor), but should one arrive the rung is kept as is rather than snapped down.+function assistedRung(from, to, step) {+ const top = from > 0 ? from : 2 * to+ if (!(top > to)) return to+ const x = to + (top - to) / 2+ if (Array.isArray(step)) return x+ return Math.max(to, Math.ceil(x / step - 1e-9) * step) // 1e-9: 37.5 / 2.5 must stay 15, not 16+}++export function rerampWarmups(rows, step = 2.5, floor = 0, assisted = false) {const firstWork = rows.findIndex(x => !isWarmupRow(x))if (firstWork <= 0) return rowsconst target = rows[firstWork].w || 0@@ -989,9 +1003,11 @@ export function rerampWarmups(rows, step = 2.5, floor = 0) {let from = 0for (let i = 0; i < firstWork; i++) {if (out[i].done) { from = out[i].w || 0; continue }- const w = target > from- ? Math.min(target, Math.max(0, floor, rungDown(from + (target - from) / 2, step)))- : target+ const w = assisted+ ? assistedRung(from, target, step)+ : target > from+ ? Math.min(target, Math.max(0, floor, rungDown(from + (target - from) / 2, step)))+ : target// A per-side warm-up ramps the same bar for both limbs: set each side's weight and resync// the aggregate, so the L/R rows and the row's own `w` agree. A straight row sets `w` alone.out[i] = isSideSet(out[i])@@ -1011,6 +1027,7 @@ export function insertWarmupRow(rows, mode, target, step = 2.5, floor = 0) {const from = prev ? (prev.w || 0) : 0// Nothing to ramp toward: bodyweight, cardio, a timed hold with no load.if (!(to > 0)) return 0+ if (isAssisted(target)) return assistedRung(from, to, step)// Already at or past the work weight — which happens when a warm-up was edited by hand// above it. Returning `from` here handed the next warm-up that same too-heavy number and// let it propagate down the block. A warm-up is never heavier than the set it warms up for.diff --git a/frontend/src/lib/history.test.js b/frontend/src/lib/history.test.jsindex 4743c1aeb..f41259a20 100644--- a/frontend/src/lib/history.test.js+++ b/frontend/src/lib/history.test.js@@ -494,6 +494,14 @@ describe('freestyleConfig', () => {expect(insertWarmupRow(rows, 'reps', bench, 5)[0].w).toBe(25)})+ it('an added warm-up on an assistance machine gives more help, ramping down to the work weight', () => {+ // 0017 assisted pull-up: 40 (1.5 × 25 rounded up to the step), then halfway down to 35+ const rows = [{ w: 25, r: 10, done: false }]+ const one = insertWarmupRow(rows, 'reps', { id: '0017' }, 5)+ expect(one[0].w).toBe(40)+ expect(insertWarmupRow(one, 'reps', { id: '0017' }, 5)[1].w).toBe(35)+ })+it('caps the planned warm-ups and ignores nonsense values', () => {const S = { exWeights: {}, workouts: [] }const base = { id: '0025', mode: 'reps', sets: 1, reps: 5, weight: 100 }diff --git a/frontend/src/lib/progression.js b/frontend/src/lib/progression.jsindex ca1568d99..64bb81ddd 100644--- a/frontend/src/lib/progression.js+++ b/frontend/src/lib/progression.js@@ -747,9 +747,10 @@ export function nextPrescription(S, cfg, routine) {/*** Apply a prescription to freshly built sets. Only the fields the policy actually decided* are touched, and only on sets that have not been logged yet. `floor` is the lift's bar- * (history.js barFloor), which the re-ramped warm-ups never go under.+ * (history.js barFloor), which the re-ramped warm-ups never go under. `assisted` (exercises.js+ * isAssisted): an assistance machine, whose warm-ups ramp down from more help instead.*/-export function applyPrescription(sets, p, step = 2.5, floor = 0) {+export function applyPrescription(sets, p, step = 2.5, floor = 0, assisted = false) {// A first session has nothing to prescribe from, except triple progression's start of a cycle.if (!p || p.kind === 'off' || (p.kind === 'first' && !p.rowReps)) return setsconst out = sets.map(s => {@@ -786,7 +787,7 @@ export function applyPrescription(sets, p, step = 2.5, floor = 0) {if (p.sets > workRows.length) {// An all-warm-up entry has no work row to seed growth from - growing warm-up copies// would both invent work and never terminate the loop. Leave the entry untouched.- if (!workRows.length) return rerampWarmups(out, step, floor)+ if (!workRows.length) return rerampWarmups(out, step, floor, assisted)const seed = workRows[workRows.length - 1]// A freshly appended row hasn't been performed, so it never inherits a seed's already-// logged drops/clusters — that would invent extra work the row never actually did. Its@@ -815,5 +816,5 @@ export function applyPrescription(sets, p, step = 2.5, floor = 0) {}// Last, because the work rows now carry their final weight: the warm-up block ramps toward// what you are actually about to lift, not toward what you lifted last time.- return rerampWarmups(out, step, floor)+ return rerampWarmups(out, step, floor, assisted)}diff --git a/frontend/src/lib/session-start.js b/frontend/src/lib/session-start.jsindex e8eff486c..3f4433889 100644--- a/frontend/src/lib/session-start.js+++ b/frontend/src/lib/session-start.js@@ -9,6 +9,7 @@ import { nextPrescription, applyPrescription, defaultIncrement, weightIncrement,import { dropGrid } from './plates.js'import { backoffStepOf, applyBackoff } from './backoff.js'import { dbLoadFor, historyAs, ownedWeightsFor } from './dumbbells.js'+import { isAssisted } from './exercises.js'/*** Where a planned session's reps come from (Settings → During a workout). 'plan', the default:@@ -45,7 +46,7 @@ export function buildPlannedEntry(stored, cfg, routine, { noProg = false } = {})const ramp = (modeOf(cfg) === 'reps' && ownedWeightsFor(st, cfg)) || step// Back-off sets step down from the top set by the exercise's own step (lib/backoff.js).const backoffStep = modeOf(cfg) === 'reps' && backoffStepOf(cfg, st.unit) ? step : 0- const built = applyPrescription(buildSets(st, cfg, { step: ramp, rid: routine?.id, useTarget: plan.kind === 'off', planReps }), plan, ramp, barFloor(st, cfg.id))+ const built = applyPrescription(buildSets(st, cfg, { step: ramp, rid: routine?.id, useTarget: plan.kind === 'off', planReps }), plan, ramp, barFloor(st, cfg.id), isAssisted(cfg))const rows = backoffStep ? applyBackoff(built, backoffStep) : builtconst sets = applyIntensifierPlan(rows, cfg, dropGrid(st, cfg))const target = { ...cfg }diff --git a/frontend/src/lib/session-start.test.js b/frontend/src/lib/session-start.test.jsindex 995341a10..feda533e0 100644--- a/frontend/src/lib/session-start.test.js+++ b/frontend/src/lib/session-start.test.js@@ -16,6 +16,29 @@ describe('buildSessionEntries', () => {expect(entries[0].sets.filter(s => !isWarmupRow(s)).every(s => s.w === 60)).toBe(true)})+ it('an assistance machine warms up with more help than its work sets, not less', () => {+ // 0017 assisted pull-up: 1.5 × 25 = 37.5, rounded up to the 5 kg step; then halfway down+ const r = { id: 'r', prog: 'off', ex: [{ id: '0017', sets: 3, reps: 10, weight: 25, inc: 5, warmupSets: 2 }] }+ expect(buildSessionEntries(st, r)[0].sets.filter(isWarmupRow).map(s => s.w)).toEqual([40, 35])+ // A normal lift still ramps up toward the work weight+ const bench = { id: 'r', prog: 'off', ex: [{ id: '0025', sets: 3, reps: 10, weight: 25, inc: 5, warmupSets: 1 }] }+ expect(buildSessionEntries(st, bench)[0].sets.find(isWarmupRow).w).toBeLessThan(25)+ })++ it('an assistance machine re-ramps its warm-up toward the prescribed weight, from above', () => {+ // Every set at the top of 8-12: double progression takes 5 kg of help away (25 → 20), and the+ // warm-up follows the new work weight: 1.5 × 20 = 30.+ const cfg = { id: '0017', sets: 3, reps: 12, repsMin: 8, weight: 25, inc: 5, warmupSets: 1 }+ const done = {+ unit: 'kg', exWeights: {}, routines: [],+ workouts: [{ d: '2026-01-01', routineIds: ['r'], entries: [{ id: '0017', target: { ...cfg }, sets: [12, 12, 12].map(r => ({ w: 25, r, done: true })) }] }],+ }+ const sets = buildSessionEntries(done, { id: 'r', prog: 'double', ex: [cfg] })[0].sets+ const work = sets.filter(s => !isWarmupRow(s)).map(s => s.w)+ expect(work.every(w => w === work[0] && w < 25)).toBe(true)+ expect(sets.find(isWarmupRow).w).toBe(work[0] * 1.5)+ })+it('keeps the unit default for timed exercises, whose inc is seconds', () => {const r = { id: 'r', prog: 'off', ex: [{ id: '0025', mode: 'time', sets: 2, sec: 30, inc: 10, weight: 0 }] }const entries = buildSessionEntries(st, r)diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsxindex ab8f2d316..417510d02 100644--- a/frontend/src/views/Workout.jsx+++ b/frontend/src/views/Workout.jsx@@ -1173,7 +1173,7 @@ function ActiveWorkout() {const m = modeOf({ ...(e.target || {}), id: e.id })// A warm-up of a dumbbell lift lands on a bell you own when the profile lists them (#376).const ramp = (m === 'reps' && ownedWeightsFor(S, { ...(e.target || {}), id: e.id })) || defaultIncrement(e.id, S.unit)- e.sets = insertWarmupRow(e.sets, m, e.target || {}, ramp, barFloor(S, e.id))+ e.sets = insertWarmupRow(e.sets, m, { ...(e.target || {}), id: e.id }, ramp, barFloor(S, e.id))})// The set-number menu's Remove and the swipe both go through deleteActiveSet, Undo and all.const removeSetAt = (idx, i) => deleteActiveSet(idx, i, { editing })