Skip to content

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.

Back-off sets: every set one Step lighter than the one before

Dennis Mustafic24c48bdfcc4f
diff --git a/frontend/src/lib/backoff.js b/frontend/src/lib/backoff.js
new file mode 100644
index 000000000..db45e5c80
--- /dev/null
+++ b/frontend/src/lib/backoff.js
@@ -0,0 +1,77 @@
+// Back-off sets: every work set one weight step lighter than the one before it — with a 2 kg
+// step, a plan of 3 × 6 @ 26 kg trains as 26 → 24 → 22. The step is the exercise's own
+// progression step (cfg.inc, "Step" in its settings), so dumbbells drop by the 2 kg the rack
+// goes up in and a lever machine by its 5 kg, without a second number to keep in line.
+//
+// Only the first set's weight is planned and progressed; the others are derived from it every
+// time a session is built, so a raise of the top set carries the whole sequence with it
+// (26/24/22 → 28/26/24). Whether it is raised is the ordinary policy's call, which already
+// reads every planned set: one back-off set short of its reps holds the whole sequence.
+//
+// Imports nothing from history.js or progression.js — both import this module.
+import { isWarmupRow, isSideSet, syncSideAggregate } from './workout-model.js'
+import { defaultIncrement, isAssisted } from './exercises.js'
+
+const round1 = v => Math.round(v * 10) / 10
+
+/** Whether a plan asks for back-off sets. Off unless switched on, so every plan saved before
+ * this field existed builds exactly as it did. A pyramid owns each set already, and a
+ * rest-pause trains one work set, so neither has anything to step down. */
+export function isBackoff(cfg) {
+ return !!cfg && cfg.backoff === true && (cfg.mode || 'reps') === 'reps'
+ && !(Array.isArray(cfg.pyramid) && cfg.pyramid.length)
+ && cfg.intensifier?.type !== 'restpause'
+}
+
+/**
+ * The weight of work set `k` (0 = the top set) below a top set of `top`. The same grid rule a
+ * stepper tap uses: a top set on the step's grid lands every back-off set on it, one typed off
+ * the grid steps down from where it is. Never below one step — an empty bar is not a set — and
+ * never above the top set itself.
+ */
+export function backoffAt(top, k, step) {
+ const t = Number(top) || 0
+ const s = Number(step) || 0
+ if (!(t > 0) || !(s > 0) || !(k > 0)) return t
+ const raw = t - k * s
+ const onGrid = Math.abs(t - Math.round(t / s) * s) <= 0.1
+ const v = onGrid ? round1(Math.round(raw / s) * s) : round1(raw)
+ return Math.max(Math.min(t, s), v)
+}
+
+/** The step back-off sets use: the exercise's own (cfg.inc), else its default — the same
+ * number progression.js's weightIncrement gives, and 0 where back-off sets do not apply. An
+ * assistance machine is left out: less load is harder there, so "lighter" is the wrong way. */
+export function backoffStepOf(cfg, unit) {
+ if (!isBackoff(cfg) || isAssisted(cfg)) return 0
+ return cfg.inc > 0 ? cfg.inc : defaultIncrement(cfg.id, unit)
+}
+
+/** The planned weights for `n` work sets: "26 → 24 → 22". */
+export function backoffWeights(top, n, step) {
+ return Array.from({ length: Math.max(0, n) }, (_, k) => backoffAt(top, k, step))
+}
+
+/**
+ * Step the open work rows of a freshly built entry down from its first work row. Warm-ups are
+ * left alone (they ramp toward the top set), a logged row is never rewritten, and a per-side
+ * row steps both limbs.
+ */
+export function applyBackoff(rows, step) {
+ if (!(step > 0)) return rows
+ const first = rows.find(r => !isWarmupRow(r))
+ const top = first ? Number(first.w) || 0 : 0
+ if (!(top > 0)) return rows
+ let k = -1
+ return rows.map(row => {
+ if (isWarmupRow(row)) return row
+ k++
+ if (k === 0) return row
+ const w = backoffAt(top, k, step)
+ if (isSideSet(row)) {
+ const side = s => (s.done ? s : { ...s, w })
+ return syncSideAggregate({ ...row, sides: { L: side(row.sides.L), R: side(row.sides.R) } })
+ }
+ return row.done ? row : { ...row, w }
+ })
+}
diff --git a/frontend/src/lib/backoff.test.js b/frontend/src/lib/backoff.test.js
new file mode 100644
index 000000000..4e8f0843b
--- /dev/null
+++ b/frontend/src/lib/backoff.test.js
@@ -0,0 +1,212 @@
+// Back-off sets (lib/backoff.js): the top set is planned and progressed, every set after it is
+// one step lighter, and the sequence only moves up when every planned set reached its target.
+import { describe, it, expect } from 'vitest'
+import { isBackoff, backoffAt, backoffWeights, applyBackoff } from './backoff.js'
+import { buildSessionEntries } from './session-start.js'
+import { readSession, nextPrescription } from './progression.js'
+import { cascadeWeight } from './history.js'
+import { isWarmupRow, makeSideSet } from './workout-model.js'
+
+const LIFT = '0025'
+
+describe('backoffAt / backoffWeights', () => {
+ it('steps each set down by the step', () => {
+ expect(backoffWeights(26, 3, 2)).toEqual([26, 24, 22])
+ expect(backoffWeights(80, 4, 5)).toEqual([80, 75, 70, 65])
+ expect(backoffWeights(60, 3, 2.5)).toEqual([60, 57.5, 55])
+ })
+
+ it('stays on the grid the top set is on, and steps from an off-grid top set as typed', () => {
+ // one decimal, the way snapWeight and every stepper in the app show a 1.25 step
+ expect(backoffWeights(62.5, 3, 1.25)).toEqual([62.5, 61.3, 60])
+ expect(backoffWeights(27, 3, 2)).toEqual([27, 25, 23]) // a top set off the 2 kg grid
+ })
+
+ it('never goes below one step, and never above the top set', () => {
+ expect(backoffWeights(6, 5, 2)).toEqual([6, 4, 2, 2, 2])
+ expect(backoffAt(1, 3, 2)).toBe(1)
+ })
+
+ it('leaves a missing load alone', () => {
+ expect(backoffAt(0, 2, 2)).toBe(0)
+ expect(backoffAt(30, 2, 0)).toBe(30)
+ })
+})
+
+describe('isBackoff', () => {
+ it('is off unless switched on, so older plans build as before', () => {
+ expect(isBackoff({ id: LIFT, sets: 3, reps: 6, weight: 26 })).toBe(false)
+ expect(isBackoff({ id: LIFT, sets: 3, reps: 6, weight: 26, backoff: true })).toBe(true)
+ })
+ it('does not apply to a timed hold, a pyramid or a rest-pause', () => {
+ expect(isBackoff({ mode: 'time', backoff: true })).toBe(false)
+ expect(isBackoff({ backoff: true, pyramid: [12, 10, 8] })).toBe(false)
+ expect(isBackoff({ backoff: true, intensifier: { type: 'restpause' } })).toBe(false)
+ expect(isBackoff({ backoff: true, intensifier: { type: 'dropset', count: 1, pct: 20 } })).toBe(true)
+ })
+})
+
+describe('applyBackoff', () => {
+ it('steps the work rows from the first one and leaves warm-ups and logged rows alone', () => {
+ const rows = [
+ { w: 10, r: 6, phase: 'warmup', done: false },
+ { w: 26, r: 6, done: false },
+ { w: 26, r: 6, done: true },
+ { w: 26, r: 6, done: false },
+ ]
+ expect(applyBackoff(rows, 2).map(r => r.w)).toEqual([10, 26, 26, 22])
+ })
+ it('steps both sides of a per-side row', () => {
+ const rows = [makeSideSet({ w: 20, r: 12 }), makeSideSet({ w: 20, r: 12 })]
+ const out = applyBackoff(rows, 2)
+ expect(out[1].sides.L.w).toBe(18)
+ expect(out[1].sides.R.w).toBe(18)
+ expect(out[1].w).toBe(18)
+ })
+})
+
+// The spec's main acceptance criterion, walked through the same builder the app uses: build a
+// session, do it, save it, build the next one.
+describe('a routine with back-off sets, session by session', () => {
+ const cfg = { id: LIFT, sets: 3, reps: 6, weight: 26, inc: 2, backoff: true }
+ const routine = { id: 'r', prog: 'linear', ex: [cfg] }
+ const start = workouts => buildSessionEntries({ unit: 'kg', exWeights: {}, routines: [routine], workouts }, routine)[0]
+ const work = entry => entry.sets.filter(s => !isWarmupRow(s))
+ const weights = entry => work(entry).map(s => s.w)
+ // Log the session: `reps` per planned set, at the weights on the screen unless `ws` overrides.
+ const perform = (entry, reps, ws, extra = []) => ({
+ ...entry,
+ sets: [...work(entry).map((s, i) => ({ ...s, r: reps[i], w: ws ? ws[i] : s.w, done: true })), ...extra],
+ })
+ let day = 0
+ const save = (workouts, entry) => [...workouts, { d: `2026-01-${String(++day).padStart(2, '0')}`, routineIds: ['r'], entries: [entry] }]
+
+ it('opens at the plan with every set one step lighter', () => {
+ const first = start([])
+ expect(weights(first)).toEqual([26, 24, 22])
+ expect(first.target.backoffStep).toBe(2)
+ expect(work(first).every(s => s.r === 6)).toBe(true)
+ })
+
+ it('TEST 1: every planned set hit → the whole sequence goes up one step', () => {
+ const hist = save([], perform(start([]), [6, 6, 6]))
+ expect(weights(start(hist))).toEqual([28, 26, 24])
+ })
+
+ for (const [name, reps] of [['TEST 2: last back-off short', [6, 6, 5]], ['TEST 3: middle back-off short', [6, 5, 6]], ['TEST 4: top set short', [5, 6, 6]]]) {
+ it(`${name} → the same sequence again`, () => {
+ const hist = save([], perform(start([]), reps))
+ const next = start(hist)
+ expect(next.plan.kind).toBe('hold')
+ expect(weights(next)).toEqual([26, 24, 22])
+ })
+ }
+
+ it('TEST 5: an extra set on top does not count either way', () => {
+ const hist = save([], perform(start([]), [6, 6, 6], null, [{ w: 18, r: 3, done: true }]))
+ expect(weights(start(hist))).toEqual([28, 26, 24])
+ })
+
+ it('a back-off set taken lighter than planned is not the sequence done', () => {
+ const lighter = perform(start([]), [6, 6, 6], [26, 24, 20])
+ expect(readSession(lighter).ok).toBe(false)
+ expect(weights(start(save([], lighter)))).toEqual([26, 24, 22])
+ // heavier than planned is fine
+ expect(readSession(perform(start([]), [6, 6, 6], [26, 25, 24])).ok).toBe(true)
+ })
+
+ it('TEST 7: a failed session retries, and the next clean one moves on', () => {
+ let hist = save([], perform(start([]), [6, 6, 6])) // 26/24/22 clean
+ expect(weights(start(hist))).toEqual([28, 26, 24])
+ hist = save(hist, perform(start(hist), [6, 6, 5])) // 28/26/24, last one short
+ expect(weights(start(hist))).toEqual([28, 26, 24])
+ hist = save(hist, perform(start(hist), [6, 6, 6])) // clean
+ expect(weights(start(hist))).toEqual([30, 28, 26])
+ hist = save(hist, perform(start(hist), [6, 6, 5])) // 30 × 6, 28 × 6, 26 × 5
+ expect(weights(start(hist))).toEqual([30, 28, 26])
+ })
+
+ it('repeated misses fall into the existing deload, and the back-off sets follow it down', () => {
+ let hist = []
+ for (let i = 0; i < 3; i++) hist = save(hist, perform(start(hist), [6, 6, 4]))
+ const next = start(hist)
+ expect(next.plan.kind).toBe('deload')
+ const w = weights(next)
+ expect(w[0]).toBeLessThan(26)
+ expect(w).toEqual(backoffWeights(w[0], 3, 2))
+ })
+
+ it('uses the exercise step, whatever it is: a 5 kg lever machine', () => {
+ const lever = { ...cfg, weight: 80, inc: 5 }
+ const r = { ...routine, ex: [lever] }
+ const first = buildSessionEntries({ unit: 'kg', exWeights: {}, routines: [r], workouts: [] }, r)[0]
+ expect(weights(first)).toEqual([80, 75, 70])
+ })
+
+ it('warm-ups still ramp toward the top set', () => {
+ const r = { ...routine, ex: [{ ...cfg, weight: 40, warmupSets: 2 }] }
+ const entry = buildSessionEntries({ unit: 'kg', exWeights: {}, routines: [r], workouts: [] }, r)[0]
+ const warm = entry.sets.filter(isWarmupRow).map(s => s.w)
+ expect(warm.every(w => w < 40)).toBe(true)
+ expect(weights(entry)).toEqual([40, 38, 36])
+ })
+
+ it('works under double progression too: the top set moves when every set reaches the top of the range', () => {
+ const dbl = { ...cfg, prog: 'double', reps: 8, repsMin: 6 }
+ const r = { ...routine, ex: [dbl] }
+ const st = workouts => ({ unit: 'kg', exWeights: {}, routines: [r], workouts })
+ const go = workouts => buildSessionEntries(st(workouts), r)[0]
+ let hist = save([], perform(go([]), [7, 7, 6]))
+ expect(weights(go(hist))).toEqual([26, 24, 22])
+ hist = save(hist, perform(go(hist), [8, 8, 8]))
+ const up = go(hist)
+ expect(weights(up)).toEqual([28, 26, 24])
+ expect(work(up).every(s => s.r === 6)).toBe(true)
+ })
+})
+
+describe('TEST 8: nothing changes without the switch', () => {
+ it('a plan without back-off opens every set at the same weight and stamps no step', () => {
+ const cfg = { id: LIFT, sets: 3, reps: 6, weight: 26, inc: 2 }
+ const r = { id: 'r', prog: 'linear', ex: [cfg] }
+ const entry = buildSessionEntries({ unit: 'kg', exWeights: {}, routines: [r], workouts: [] }, r)[0]
+ expect(entry.sets.map(s => s.w)).toEqual([26, 26, 26])
+ expect(entry.target.backoffStep).toBeUndefined()
+ })
+ it('a session without a stamped step reads exactly as before, lighter sets and all', () => {
+ const entry = { id: LIFT, target: { sets: 3, reps: 6, weight: 26 }, sets: [26, 24, 20].map(w => ({ w, r: 6, done: true })) }
+ expect(readSession(entry).ok).toBe(true)
+ })
+ it('an assistance machine is left out, where lighter is harder', () => {
+ const r = { id: 'r', prog: 'linear', ex: [{ id: LIFT, assisted: true, sets: 3, reps: 6, weight: 30, inc: 5, backoff: true }] }
+ const entry = buildSessionEntries({ unit: 'kg', exWeights: {}, routines: [r], workouts: [] }, r)[0]
+ expect(entry.sets.map(s => s.w)).toEqual([30, 30, 30])
+ })
+})
+
+describe('editing a weight mid-session', () => {
+ const rows = () => [{ w: 26, r: 6, done: false }, { w: 24, r: 6, done: false }, { w: 22, r: 6, done: false }]
+ it('carries a top-set change down the sequence', () => {
+ expect(cascadeWeight(rows(), 0, 28, undefined, 2).map(r => r.w)).toEqual([26, 26, 24])
+ })
+ it('from a back-off set, steps down from there', () => {
+ expect(cascadeWeight(rows(), 1, 20, undefined, 2).map(r => r.w)).toEqual([26, 24, 18])
+ })
+ it('keeps the old flat cascade when the session has no back-off', () => {
+ expect(cascadeWeight(rows(), 0, 28).map(r => r.w)).toEqual([26, 28, 28])
+ })
+ it('a logged set in between keeps its place in the sequence', () => {
+ const r = rows(); r[1] = { ...r[1], done: true }
+ expect(cascadeWeight(r, 0, 30, undefined, 2).map(x => x.w)).toEqual([26, 24, 26])
+ })
+})
+
+describe('nextPrescription with back-off', () => {
+ it('decides only the top set; the rows derive the rest', () => {
+ const cfg = { id: LIFT, sets: 3, reps: 6, weight: 26, inc: 2, backoff: true, prog: 'linear' }
+ const S = { unit: 'kg', workouts: [{ d: '2026-01-01', entries: [{ id: LIFT, target: { ...cfg, backoffStep: 2 }, sets: [26, 24, 22].map(w => ({ w, r: 6, done: true })) }] }] }
+ const p = nextPrescription(S, cfg)
+ expect(p.kind).toBe('up')
+ expect(p.weight).toBe(28)
+ })
+})
diff --git a/frontend/src/lib/exercises.js b/frontend/src/lib/exercises.js
index ee4cd1540..db814b9fe 100644
--- a/frontend/src/lib/exercises.js
+++ b/frontend/src/lib/exercises.js
@@ -204,6 +204,19 @@ const assistedName = n => /\bassist(ed)?\b/i.test(String(n || ''))
// then the shape is read directly.
const assistedShape = ex => (typeof ex?.assisted === 'boolean' ? ex.assisted : ex?.eq === ASSISTED_EQ && assistedName(ex?.n))
+// Body parts where a 5 kg jump is normal rather than brutal.
+const HEAVY_BP = ['upper legs', 'lower legs', 'back', 'hips', 'glutes']
+
+// Default load step. Lower-body lifts take the bigger jump — that is the "lift-specific
+// increment" a linear program lives on; an exercise can override it with cfg.inc.
+// (progression.js re-exports this; it lives here so history.js can reach it without a cycle.)
+export function defaultIncrement(exId, unit) {
+ const ex = EXIDX[exId]
+ const heavy = ex && HEAVY_BP.includes(ex.bp)
+ if (unit === 'lb') return heavy ? 10 : 5
+ return heavy ? 5 : 2.5
+}
+
export function isAssisted(idOrEx) {
if (!idOrEx) return false
if (typeof idOrEx === 'string') return !!assistedShape(EXIDX[idOrEx])
diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.js
index 7247ac061..880d3b280 100644
--- a/frontend/src/lib/history.js
+++ b/frontend/src/lib/history.js
@@ -3,6 +3,7 @@ import { todayISO, isoOf, weekKey, weekStartOf, fmtNum } from './format.js'
import { fmtSpeed } from './speed.js'
import { isCardio, isBodyweightEq, isAssisted, betterWeight } from './exercises.js'
import { phaseForSet, modeForSet, modeForEntry, isWarmupRow, isDropSet, isRestPauseSet, normalizeMode, completedVolumeOf, hasCompletedWork, nextDropWeight, splitBurstReps, makeSideSet, isSideSet, syncSideAggregate, WEIGHT_ORIGIN_MANUAL, dropsOf, clustersOf } from './workout-model.js'
+import { backoffAt, backoffStepOf, backoffWeights } from './backoff.js'
const objectOf = value => value && typeof value === 'object' && !Array.isArray(value) ? value : {}
// Completed-state-independent work rows whose authoritative mode matches the requested mode.
const workRowsForMode = (entry = {}, mode = 'reps') => {
@@ -204,7 +205,11 @@ export function exLine(cfg, unit, speedUnit) {
const mode = modeOf(cfg)
const n = cfg.sets || 1
// 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 : ''
+ // Back-off sets read as the sequence they open at: "3 × 6 · 26 → 24 → 22 kg".
+ const backoff = mode === 'reps' && cfg.weight > 0 ? backoffStepOf(cfg, unit) : 0
+ const load = !cfg.weight ? ''
+ : backoff ? ' · ' + (isBw(cfg) ? '+' : '') + backoffWeights(cfg.weight, n, backoff).map(fmtNum).join(' → ') + ' ' + unit
+ : ' · ' + (isBw(cfg) ? '+' : '') + fmtNum(cfg.weight) + ' ' + unit
if (mode === 'cardio') return `${n} × ${cfg.min || 20} min @ ${fmtSpeed(cfg.speed || 8, speedUnit)}`
// 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.
@@ -811,17 +816,23 @@ export function streakWeeks(S) {
* `side` narrows a per-side edit to one limb; without it both limbs are eligible independently.
* Completed rows (and completed limbs) never get rewritten. Clearing an inherited load removes
* its `w` key just like a direct edit.
+ *
+ * `backoffStep` (an entry built with back-off sets, lib/backoff.js): each later work row lands
+ * one more step below the edited one rather than at the same load, so 26 → 27.5 on the top set
+ * makes the back-off sets 25.5 and 23.5, not 27.5 three times.
*/
-export function cascadeWeight(rows, from, value, side) {
+export function cascadeWeight(rows, from, value, side, backoffStep = 0) {
const source = rows[from]
if (!source) return rows.slice()
const warm = isWarmupRow(source)
const sides = isSideSet(source) ? (side ? [side] : ['L', 'R']) : null
const next = rows.slice()
+ const stepDown = !warm && backoffStep > 0 && value != null
+ let k = 0
const setWeight = row => {
const out = { ...row }
if (value == null) delete out.w
- else out.w = value
+ else out.w = stepDown ? backoffAt(value, k, backoffStep) : value
return out
}
const setSideWeight = (row, key) => {
@@ -833,6 +844,9 @@ export function cascadeWeight(rows, from, value, side) {
for (let j = from + 1; j < next.length; j++) {
const row = next[j]
if (isWarmupRow(row) !== warm) continue
+ // How many work sets below the edited one this row sits, done or not: a logged set in
+ // between still holds its place in the sequence.
+ k++
if (sides) {
if (!isSideSet(row)) continue
let out = row
diff --git a/frontend/src/lib/plan-share.js b/frontend/src/lib/plan-share.js
index 786c3ece6..0c972470d 100644
--- a/frontend/src/lib/plan-share.js
+++ b/frontend/src/lib/plan-share.js
@@ -13,6 +13,7 @@ import { cleanUrl } from './media-refs.js'
import { modeOf, exLine, MAX_PLANNED_WARMUPS } from './history.js'
import { deriveSessionName } from './session-merge.js'
import { isPyramid, normalizePyramid, normalizePyramidRest } from './pyramid.js'
+import { isBackoff } from './backoff.js'
import { uid, todayISO, DAYN, weekOrder, weekStartOf, exCount } from './format.js'
import { t, exerciseNameFor, exerciseNameClass, getLang, RTL_LANGS } from './i18n-core.js'
import { convertWeight } from './units.js'
@@ -94,6 +95,8 @@ function cleanEx(e) {
// without its rule is just a list of weights.
if (e.prog) o.prog = e.prog
if (e.inc > 0) o.inc = e.inc
+ // Back-off sets step down by that same step; written only when on (lib/backoff.js).
+ if (isBackoff(e)) o.backoff = true
// Epley deload factor is a per-occurrence progression setting. Omit the default so older
// exports remain compact and importing them preserves the default 90% behaviour.
if (e.deloadFactor != null && Number(e.deloadFactor) !== 0.9) o.deloadFactor = e.deloadFactor
diff --git a/frontend/src/lib/progression.js b/frontend/src/lib/progression.js
index 12b2dfda7..21b71b1a9 100644
--- a/frontend/src/lib/progression.js
+++ b/frontend/src/lib/progression.js
@@ -17,10 +17,11 @@
// So a session that fell apart can never advance the load as though it had succeeded.
import { modeOf, repStep, rerampWarmups, isBw, isPerSide, entryExcluded, entryRoutineId } from './history.js'
-import { EXIDX, isAssisted, isLoadedEq } from './exercises.js'
+import { EXIDX, isAssisted, isLoadedEq, defaultIncrement } from './exercises.js'
import { isWarmupRow, isSideSet, syncSideAggregate, makeSideSet } from './workout-model.js'
import { normalizeRepRange } from './rep-range.js'
import { isPyramid } from './pyramid.js'
+import { backoffAt } from './backoff.js'
export const POLICIES = ['off', 'linear', 'greyskull', 'double', 'time']
@@ -76,17 +77,9 @@ export function deloadTarget1RM(weight, reps, factor = DELOAD_FACTOR, perSide =
return base == null ? null : round1(base * f)
}
-// Body parts where a 5 kg jump is normal rather than brutal.
-const HEAVY_BP = ['upper legs', 'lower legs', 'back', 'hips', 'glutes']
-
-// Default load step. Lower-body lifts take the bigger jump — that is the "lift-specific
-// increment" a linear program lives on; an exercise can override it with cfg.inc.
-export function defaultIncrement(exId, unit) {
- const ex = EXIDX[exId]
- const heavy = ex && HEAVY_BP.includes(ex.bp)
- if (unit === 'lb') return heavy ? 10 : 5
- return heavy ? 5 : 2.5
-}
+// The default load step lives in exercises.js (it reads only the catalogue), so history.js can
+// use it too without importing this module; re-exported here, where every caller looks for it.
+export { defaultIncrement }
// Resolve the load step for reps-mode weight controls and progression. Timed exercises use
// `inc` for seconds, so their optional weight column must not call this helper.
export function weightIncrement(cfg, unit) {
@@ -296,7 +289,14 @@ export function readSession(entry, fallback) {
}
}
const goal = target.reps || 0
- const reps = sets.map(s => (s.done ? (s.r || 0) : 0))
+ // Back-off sets (lib/backoff.js): each planned set after the first is held to its own weight,
+ // stepped down from the top set as logged. Taking a back-off set lighter to get its reps is
+ // not the sequence done, so it reads like a set short of its reps. Only a session that was
+ // built with back-off sets carries the step; every other session reads exactly as before.
+ const step = entry && entry.target ? Number(entry.target.backoffStep) || 0 : 0
+ const top = step > 0 && sets.length ? Number(sets[0].w) || 0 : 0
+ const heavyEnough = (s, k) => !(top > 0) || k === 0 || (Number(s.w) || 0) >= backoffAt(top, k, step) - 0.05
+ const reps = sets.map((s, k) => (s.done && heavyEnough(s, k) ? (s.r || 0) : 0))
return {
mode, target, goal, reps,
weight: loadOf(entry, sets),
diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js
index 8fa4c3706..6ac00695b 100644
--- a/frontend/src/lib/pt-br-locale.test.js
+++ b/frontend/src/lib/pt-br-locale.test.js
@@ -41,7 +41,7 @@ describe('Brazilian Portuguese locale', () => {
// has to be taught is a number nobody reads. What the numbers stood for is asserted above.
// If the hash fails, review the changed keys and wording before accepting a new one. From
// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list
- expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('5304c30895afe32bf14334f32497355b645f481f695c582e3b28161a23cba864')
+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('3c3b1fce1161ef0b9d476a424cde59943f57c7643d729ff28e82d05334c4173d')
})
test('does not leak European Portuguese UI terms', () => {
diff --git a/frontend/src/lib/session-start.js b/frontend/src/lib/session-start.js
index d0d2d6ec3..0e360ce21 100644
--- a/frontend/src/lib/session-start.js
+++ b/frontend/src/lib/session-start.js
@@ -7,6 +7,7 @@ import { buildSets, applyIntensifierPlan, modeOf } from './history.js'
import { isWarmupRow } from './workout-model.js'
import { nextPrescription, applyPrescription, defaultIncrement, weightIncrement, plannedOf } from './progression.js'
import { dropGrid } from './plates.js'
+import { backoffStepOf, applyBackoff } from './backoff.js'
/**
* Where a planned session's reps come from (Settings → During a workout). 'plan', the default:
@@ -33,13 +34,20 @@ export function buildPlannedEntry(st, cfg, routine, { noProg = false } = {}) {
// default for its optional load.
const step = modeOf(cfg) === 'reps' ? weightIncrement(cfg, st.unit) : defaultIncrement(cfg.id, st.unit)
const planReps = !startsFromLast(st)
- const rows = applyPrescription(buildSets(st, cfg, { step, rid: routine?.id, useTarget: plan.kind === 'off', planReps }), plan, 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, rid: routine?.id, useTarget: plan.kind === 'off', planReps }), plan, step)
+ const rows = backoffStep ? applyBackoff(built, backoffStep) : built
const sets = applyIntensifierPlan(rows, cfg, dropGrid(st, cfg))
const target = { ...cfg }
if (plan.weight != null) target.weight = plan.weight
if (plan.reps != null) target.reps = plan.reps
if (plan.sec != null) target.sec = plan.sec
if (plan.sets != null) target.sets = plan.sets
+ // The step the back-off sets were built with, kept on the session so reading it back
+ // (progression.js readSession) holds each set to its own weight even after the plan changes.
+ if (backoffStep) target.backoffStep = backoffStep
+ else delete target.backoffStep
// 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.
diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.js
index b92f6745e..333bee871 100644
--- a/frontend/src/locales/ar.js
+++ b/frontend/src/locales/ar.js
@@ -2003,4 +2003,9 @@ export default {
'Greys show darker in light mode, so buttons don’t look switched off.': 'تظهر الألوان الرمادية أغمق في الوضع الفاتح، حتى لا تبدو الأزرار مُعطّلة.',
'custom color picker': 'لون خاص مخصص منتقي الألوان',
'Signed in from another tab. Your workout came along, keep going here.': 'تم تسجيل الدخول من علامة تبويب أخرى. تمرينك انتقل معك، تابعه هنا.',
+ 'Back-off sets': 'مجموعات تنازلية',
+ 'Each set one step lighter than the one before. The weight above is the first set.': 'كل مجموعة أخف بخطوة واحدة من التي قبلها. الوزن أعلاه هو المجموعة الأولى.',
+ 'Sets open at {0}. The first set goes up when every set reaches its reps, and the rest follow it.': 'تبدأ المجموعات عند {0}. يرتفع وزن المجموعة الأولى عندما تبلغ كل مجموعة تكراراتها، وتتبعها البقية.',
+ 'The first set goes up when every set reaches its reps, and the rest follow it.': 'يرتفع وزن المجموعة الأولى عندما تبلغ كل مجموعة تكراراتها، وتتبعها البقية.',
+ 'All sets at the same weight.': 'كل المجموعات بالوزن نفسه.',
}
diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js
index 7fdb20e04..e907c8576 100644
--- a/frontend/src/locales/de.js
+++ b/frontend/src/locales/de.js
@@ -1970,4 +1970,9 @@ export default {
'Greys show darker in light mode, so buttons don’t look switched off.': 'Grautöne werden im hellen Modus dunkler, damit Buttons nicht ausgeschaltet wirken.',
'custom color picker': 'eigene Farbe benutzerdefiniert Farbwähler Farbauswahl',
'Signed in from another tab. Your workout came along, keep going here.': 'In einem anderen Tab angemeldet. Dein Training ist mitgekommen, mach hier weiter.',
+ 'Back-off sets': 'Back-off-Sätze',
+ 'Each set one step lighter than the one before. The weight above is the first set.': 'Jeder Satz eine Stufe leichter als der davor. Das Gewicht oben ist der erste Satz.',
+ 'Sets open at {0}. The first set goes up when every set reaches its reps, and the rest follow it.': 'Sätze starten mit {0}. Der erste Satz steigt, wenn jeder Satz seine Wiederholungen erreicht, und die anderen ziehen mit.',
+ 'The first set goes up when every set reaches its reps, and the rest follow it.': 'Der erste Satz steigt, wenn jeder Satz seine Wiederholungen erreicht, und die anderen ziehen mit.',
+ 'All sets at the same weight.': 'Alle Sätze mit demselben Gewicht.',
}
diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js
index 592a333e1..7e444c906 100644
--- a/frontend/src/locales/es.js
+++ b/frontend/src/locales/es.js
@@ -1950,4 +1950,9 @@ export default {
'Greys show darker in light mode, so buttons don’t look switched off.': 'Los grises se ven más oscuros en modo claro, para que los botones no parezcan apagados.',
'custom color picker': 'color propio personalizado selector de color',
'Signed in from another tab. Your workout came along, keep going here.': 'Sesión iniciada en otra pestaña. Tu entreno vino contigo, sigue aquí.',
+ 'Back-off sets': 'Series descendentes',
+ 'Each set one step lighter than the one before. The weight above is the first set.': 'Cada serie un paso más ligera que la anterior. El peso de arriba es la primera serie.',
+ 'Sets open at {0}. The first set goes up when every set reaches its reps, and the rest follow it.': 'Las series empiezan en {0}. La primera serie sube cuando todas las series alcanzan sus repeticiones, y el resto la sigue.',
+ 'The first set goes up when every set reaches its reps, and the rest follow it.': 'La primera serie sube cuando todas las series alcanzan sus repeticiones, y el resto la sigue.',
+ 'All sets at the same weight.': 'Todas las series con el mismo peso.',
}
diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js
index a6c2a3d84..963612f15 100644
--- a/frontend/src/locales/fr.js
+++ b/frontend/src/locales/fr.js
@@ -1950,4 +1950,9 @@ export default {
'Greys show darker in light mode, so buttons don’t look switched off.': 'Les gris foncent en mode clair, pour que les boutons n’aient pas l’air éteints.',
'custom color picker': 'couleur perso personnalisée sélecteur nuancier',
'Signed in from another tab. Your workout came along, keep going here.': 'Connecté depuis un autre onglet. Ta séance a suivi, continue ici.',
+ 'Back-off sets': 'Séries dégressives',
+ 'Each set one step lighter than the one before. The weight above is the first set.': 'Chaque série un palier plus légère que la précédente. Le poids ci-dessus est celui de la première série.',
+ 'Sets open at {0}. The first set goes up when every set reaches its reps, and the rest follow it.': 'Les séries commencent à {0}. La première série monte quand chaque série atteint ses répétitions, et les autres suivent.',
+ 'The first set goes up when every set reaches its reps, and the rest follow it.': 'La première série monte quand chaque série atteint ses répétitions, et les autres suivent.',
+ 'All sets at the same weight.': 'Toutes les séries au même poids.',
}
diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js
index 8c05a4933..905a13c21 100644
--- a/frontend/src/locales/hi.js
+++ b/frontend/src/locales/hi.js
@@ -1950,4 +1950,9 @@ export default {
'Greys show darker in light mode, so buttons don’t look switched off.': 'लाइट मोड में ग्रे रंग गहरे दिखते हैं, ताकि बटन बंद जैसे न लगें।',
'custom color picker': 'अपना रंग कस्टम रंग चुनने वाला',
'Signed in from another tab. Your workout came along, keep going here.': 'दूसरे टैब से साइन इन हुआ। आपका वर्कआउट साथ आ गया, यहीं जारी रखें।',
+ 'Back-off sets': 'बैक-ऑफ़ सेट',
+ 'Each set one step lighter than the one before. The weight above is the first set.': 'हर सेट पिछले वाले से एक स्टेप हल्का। ऊपर वाला वज़न पहला सेट है।',
+ 'Sets open at {0}. The first set goes up when every set reaches its reps, and the rest follow it.': 'सेट {0} से शुरू होते हैं। जब हर सेट अपने रेप्स पूरे कर ले तो पहला सेट बढ़ता है, और बाकी उसके साथ चलते हैं।',
+ 'The first set goes up when every set reaches its reps, and the rest follow it.': 'जब हर सेट अपने रेप्स पूरे कर ले तो पहला सेट बढ़ता है, और बाकी उसके साथ चलते हैं।',
+ 'All sets at the same weight.': 'सभी सेट एक ही वज़न पर।',
}
diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js
index 3b8a3698f..ce520892b 100644
--- a/frontend/src/locales/hu.js
+++ b/frontend/src/locales/hu.js
@@ -1953,4 +1953,9 @@ export default {
'Greys show darker in light mode, so buttons don’t look switched off.': 'A szürkék világos módban sötétebbek, hogy a gombok ne tűnjenek kikapcsoltnak.',
'custom color picker': 'saját szín egyéni színválasztó',
'Signed in from another tab. Your workout came along, keep going here.': 'Bejelentkeztél egy másik lapon. Az edzésed is jött vele, folytasd itt.',
+ 'Back-off sets': 'Csökkenő sorozatok',
+ 'Each set one step lighter than the one before. The weight above is the first set.': 'Minden sorozat egy lépéssel könnyebb az előzőnél. A fenti súly az első sorozaté.',
+ 'Sets open at {0}. The first set goes up when every set reaches its reps, and the rest follow it.': 'A sorozatok kezdősúlya: {0}. Az első sorozat akkor nő, ha minden sorozat eléri az ismétlésszámát, és a többi követi.',
+ 'The first set goes up when every set reaches its reps, and the rest follow it.': 'Az első sorozat akkor nő, ha minden sorozat eléri az ismétlésszámát, és a többi követi.',
+ 'All sets at the same weight.': 'Minden sorozat ugyanazzal a súllyal.',
}
diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js
index 81f392217..b6e0a623c 100644
--- a/frontend/src/locales/it.js
+++ b/frontend/src/locales/it.js
@@ -1950,4 +1950,9 @@ export default {
'Greys show darker in light mode, so buttons don’t look switched off.': 'I grigi diventano più scuri in modalità chiara, così i pulsanti non sembrano spenti.',
'custom color picker': 'colore personalizzato proprio selettore colore',
'Signed in from another tab. Your workout came along, keep going here.': 'Accesso fatto da un’altra scheda. Il tuo allenamento è venuto con te, continua qui.',
+ 'Back-off sets': 'Serie a scalare',
+ 'Each set one step lighter than the one before. The weight above is the first set.': 'Ogni serie un passo più leggera della precedente. Il peso sopra è la prima serie.',
+ 'Sets open at {0}. The first set goes up when every set reaches its reps, and the rest follow it.': 'Le serie partono da {0}. La prima serie sale quando ogni serie raggiunge le sue ripetizioni, e le altre la seguono.',
+ 'The first set goes up when every set reaches its reps, and the rest follow it.': 'La prima serie sale quando ogni serie raggiunge le sue ripetizioni, e le altre la seguono.',
+ 'All sets at the same weight.': 'Tutte le serie con lo stesso peso.',
}
diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js
index fc4f356c8..730a40fec 100644
--- a/frontend/src/locales/ko.js
+++ b/frontend/src/locales/ko.js
@@ -1950,4 +1950,9 @@ export default {
'Greys show darker in light mode, so buttons don’t look switched off.': '라이트 모드에서는 버튼이 꺼진 것처럼 보이지 않게 회색을 어둡게 표시해요.',
'custom color picker': '나만의 색상 사용자 지정 색상 선택기',
'Signed in from another tab. Your workout came along, keep going here.': '다른 탭에서 로그인했어요. 운동도 함께 넘어왔으니 여기서 이어서 하세요.',
+ 'Back-off sets': '백오프 세트',
+ 'Each set one step lighter than the one before. The weight above is the first set.': '각 세트가 이전 세트보다 한 단계 가볍습니다. 위의 무게가 첫 세트입니다.',
+ 'Sets open at {0}. The first set goes up when every set reaches its reps, and the rest follow it.': '세트는 {0}(으)로 시작합니다. 모든 세트가 목표 반복수에 도달하면 첫 세트가 올라가고 나머지도 따라갑니다.',
+ 'The first set goes up when every set reaches its reps, and the rest follow it.': '모든 세트가 목표 반복수에 도달하면 첫 세트가 올라가고 나머지도 따라갑니다.',
+ 'All sets at the same weight.': '모든 세트를 같은 무게로.',
}
diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js
index 92579d18f..3124bfb8c 100644
--- a/frontend/src/locales/pl.js
+++ b/frontend/src/locales/pl.js
@@ -1950,4 +1950,9 @@ export default {
'Greys show darker in light mode, so buttons don’t look switched off.': 'Szarości są ciemniejsze w trybie jasnym, żeby przyciski nie wyglądały na wyłączone.',
'custom color picker': 'własny kolor niestandardowy próbnik wybór koloru',
'Signed in from another tab. Your workout came along, keep going here.': 'Zalogowano w innej karcie. Twój trening przeszedł razem z kontem, kontynuuj tutaj.',
+ 'Back-off sets': 'Serie zejściowe',
+ 'Each set one step lighter than the one before. The weight above is the first set.': 'Każda seria o jeden krok lżejsza od poprzedniej. Ciężar powyżej to pierwsza seria.',
+ 'Sets open at {0}. The first set goes up when every set reaches its reps, and the rest follow it.': 'Serie zaczynają od {0}. Pierwsza seria idzie w górę, gdy każda seria osiągnie swoje powtórzenia, a pozostałe idą za nią.',
+ 'The first set goes up when every set reaches its reps, and the rest follow it.': 'Pierwsza seria idzie w górę, gdy każda seria osiągnie swoje powtórzenia, a pozostałe idą za nią.',
+ 'All sets at the same weight.': 'Wszystkie serie z tym samym ciężarem.',
}
diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js
index c2c52d5f7..f7cb915ee 100644
--- a/frontend/src/locales/pt-BR.js
+++ b/frontend/src/locales/pt-BR.js
@@ -1212,6 +1212,8 @@ export const PT_BR_OVERRIDES = {
'Greys show lighter in dark mode, so buttons don’t look switched off.': 'Os cinzas ficam mais claros no modo escuro, para os botões não parecerem desligados.',
'Greys show darker in light mode, so buttons don’t look switched off.': 'Os cinzas ficam mais escuros no modo claro, para os botões não parecerem desligados.',
'Signed in from another tab. Your workout came along, keep going here.': 'Login feito em outra aba. Seu treino veio junto, continue por aqui.',
+ 'Sets open at {0}. The first set goes up when every set reaches its reps, and the rest follow it.': 'As séries começam em {0}. A primeira série sobe quando todas as séries atingem suas repetições, e as demais acompanham.',
+ 'The first set goes up when every set reaches its reps, and the rest follow it.': 'A primeira série sobe quando todas as séries atingem suas repetições, e as demais acompanham.',
}
export default { ...pt, ...PT_BR_OVERRIDES }
diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js
index ad06595ac..82d7f9a5d 100644
--- a/frontend/src/locales/pt.js
+++ b/frontend/src/locales/pt.js
@@ -1950,4 +1950,9 @@ export default {
'Greys show darker in light mode, so buttons don’t look switched off.': 'Os cinzentos ficam mais escuros no modo claro, para os botões não parecerem desligados.',
'custom color picker': 'cor própria personalizada seletor de cor',
'Signed in from another tab. Your workout came along, keep going here.': 'Sessão iniciada noutro separador. O teu treino veio junto, continua aqui.',
+ 'Back-off sets': 'Séries descendentes',
+ 'Each set one step lighter than the one before. The weight above is the first set.': 'Cada série um passo mais leve do que a anterior. O peso acima é a primeira série.',
+ 'Sets open at {0}. The first set goes up when every set reaches its reps, and the rest follow it.': 'As séries começam em {0}. A primeira série sobe quando todas as séries atingem as suas repetições, e as restantes acompanham.',
+ 'The first set goes up when every set reaches its reps, and the rest follow it.': 'A primeira série sobe quando todas as séries atingem as suas repetições, e as restantes acompanham.',
+ 'All sets at the same weight.': 'Todas as séries com o mesmo peso.',
}
diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js
index 576e5cbe6..5a7a8abdf 100644
--- a/frontend/src/locales/ru.js
+++ b/frontend/src/locales/ru.js
@@ -1954,4 +1954,9 @@ export default {
'Greys show darker in light mode, so buttons don’t look switched off.': 'Серые оттенки в светлой теме темнее, чтобы кнопки не казались выключенными.',
'custom color picker': 'свой цвет пользовательский палитра выбор цвета',
'Signed in from another tab. Your workout came along, keep going here.': 'Вход выполнен в другой вкладке. Тренировка сохранилась, продолжай здесь.',
+ 'Back-off sets': 'Сеты со снижением веса',
+ 'Each set one step lighter than the one before. The weight above is the first set.': 'Каждый подход на один шаг легче предыдущего. Вес выше — это первый подход.',
+ 'Sets open at {0}. The first set goes up when every set reaches its reps, and the rest follow it.': 'Подходы начинаются с {0}. Первый подход растёт, когда каждый подход выполнен на все повторения, остальные следуют за ним.',
+ 'The first set goes up when every set reaches its reps, and the rest follow it.': 'Первый подход растёт, когда каждый подход выполнен на все повторения, остальные следуют за ним.',
+ 'All sets at the same weight.': 'Все подходы с одним весом.',
}
diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js
index 1031f9448..c3e26d343 100644
--- a/frontend/src/locales/th.js
+++ b/frontend/src/locales/th.js
@@ -1961,4 +1961,9 @@ export default {
'Greys show darker in light mode, so buttons don’t look switched off.': 'สีเทาจะเข้มขึ้นในโหมดสว่าง ปุ่มจะได้ไม่ดูเหมือนถูกปิดอยู่',
'custom color picker': 'สีเอง กำหนดเอง ตัวเลือกสี',
'Signed in from another tab. Your workout came along, keep going here.': 'ลงชื่อเข้าใช้จากแท็บอื่นแล้ว การออกกำลังกายของคุณมาด้วย ทำต่อที่นี่ได้เลย',
+ 'Back-off sets': 'เซ็ตลดน้ำหนัก',
+ 'Each set one step lighter than the one before. The weight above is the first set.': 'แต่ละเซ็ตเบากว่าเซ็ตก่อนหน้าหนึ่งขั้น น้ำหนักด้านบนคือเซ็ตแรก',
+ 'Sets open at {0}. The first set goes up when every set reaches its reps, and the rest follow it.': 'เซ็ตเริ่มที่ {0} เซ็ตแรกจะเพิ่มเมื่อทุกเซ็ตทำครบจำนวนครั้ง และเซ็ตที่เหลือจะเพิ่มตาม',
+ 'The first set goes up when every set reaches its reps, and the rest follow it.': 'เซ็ตแรกจะเพิ่มเมื่อทุกเซ็ตทำครบจำนวนครั้ง และเซ็ตที่เหลือจะเพิ่มตาม',
+ 'All sets at the same weight.': 'ทุกเซ็ตใช้น้ำหนักเท่ากัน',
}
diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js
index d6fa067cf..ab8bf2f90 100644
--- a/frontend/src/locales/tr.js
+++ b/frontend/src/locales/tr.js
@@ -1950,4 +1950,9 @@ export default {
'Greys show darker in light mode, so buttons don’t look switched off.': 'Griler aydınlık modda daha koyu görünür, düğmeler kapalıymış gibi durmasın diye.',
'custom color picker': 'kendi renk özel renk seçici',
'Signed in from another tab. Your workout came along, keep going here.': 'Başka bir sekmede giriş yapıldı. Antrenmanın da geldi, buradan devam et.',
+ 'Back-off sets': 'Azalan setler',
+ 'Each set one step lighter than the one before. The weight above is the first set.': 'Her set bir öncekinden bir adım daha hafif. Yukarıdaki ağırlık ilk settir.',
+ 'Sets open at {0}. The first set goes up when every set reaches its reps, and the rest follow it.': 'Setler {0} ile başlar. Her set tekrarlarına ulaştığında ilk set artar, diğerleri onu izler.',
+ 'The first set goes up when every set reaches its reps, and the rest follow it.': 'Her set tekrarlarına ulaştığında ilk set artar, diğerleri onu izler.',
+ 'All sets at the same weight.': 'Tüm setler aynı ağırlıkta.',
}
diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.js
index a4a775ede..e73fb997d 100644
--- a/frontend/src/locales/uk.js
+++ b/frontend/src/locales/uk.js
@@ -1947,4 +1947,9 @@ export default {
'Greys show darker in light mode, so buttons don’t look switched off.': 'Сірі відтінки у світлій темі темніші, щоб кнопки не здавалися вимкненими.',
'custom color picker': 'свій колір власний палітра вибір кольору',
'Signed in from another tab. Your workout came along, keep going here.': 'Вхід виконано в іншій вкладці. Тренування збережено, продовжуй тут.',
+ 'Back-off sets': 'Підходи зі зниженням ваги',
+ 'Each set one step lighter than the one before. The weight above is the first set.': 'Кожен підхід на один крок легший за попередній. Вага вище — це перший підхід.',
+ 'Sets open at {0}. The first set goes up when every set reaches its reps, and the rest follow it.': 'Підходи починаються з {0}. Перший підхід зростає, коли кожен підхід виконано на всі повтори, решта йдуть за ним.',
+ 'The first set goes up when every set reaches its reps, and the rest follow it.': 'Перший підхід зростає, коли кожен підхід виконано на всі повтори, решта йдуть за ним.',
+ 'All sets at the same weight.': 'Усі підходи з однаковою вагою.',
}
diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.js
index 0ab17d0bf..e8203254d 100644
--- a/frontend/src/locales/zh-TW.js
+++ b/frontend/src/locales/zh-TW.js
@@ -1943,4 +1943,9 @@ export default {
'Greys show darker in light mode, so buttons don’t look switched off.': '淺色模式下灰色會調暗一些,免得按鈕看起來像被停用了。',
'custom color picker': '自訂顏色 自己的顏色 取色器 調色盤',
'Signed in from another tab. Your workout came along, keep going here.': '已在另一個分頁登入。你的訓練也一起帶過去了,在這裡繼續吧。',
+ 'Back-off sets': '遞減組',
+ 'Each set one step lighter than the one before. The weight above is the first set.': '每組比上一組輕一個級距。上面的重量是第一組。',
+ 'Sets open at {0}. The first set goes up when every set reaches its reps, and the rest follow it.': '各組從 {0} 開始。每組都達到目標次數時,第一組加重,其餘各組隨之調整。',
+ 'The first set goes up when every set reaches its reps, and the rest follow it.': '每組都達到目標次數時,第一組加重,其餘各組隨之調整。',
+ 'All sets at the same weight.': '所有組使用相同重量。',
}
diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js
index 07765586e..26c194423 100644
--- a/frontend/src/locales/zh.js
+++ b/frontend/src/locales/zh.js
@@ -1950,4 +1950,9 @@ export default {
'Greys show darker in light mode, so buttons don’t look switched off.': '浅色模式下灰色会调暗一些,免得按钮看起来像被停用了。',
'custom color picker': '自定义颜色 自己的颜色 取色器 调色板',
'Signed in from another tab. Your workout came along, keep going here.': '已在另一个标签页登录。你的训练也一起带过去了,在这里继续吧。',
+ 'Back-off sets': '递减组',
+ 'Each set one step lighter than the one before. The weight above is the first set.': '每组比上一组轻一个步长。上面的重量是第一组。',
+ 'Sets open at {0}. The first set goes up when every set reaches its reps, and the rest follow it.': '各组从 {0} 开始。每组都达到目标次数时,第一组加重,其余各组随之调整。',
+ 'The first set goes up when every set reaches its reps, and the rest follow it.': '每组都达到目标次数时,第一组加重,其余各组随之调整。',
+ 'All sets at the same weight.': '所有组使用相同重量。',
}
diff --git a/frontend/src/sheets.backoff.test.jsx b/frontend/src/sheets.backoff.test.jsx
new file mode 100644
index 000000000..14eff22b3
--- /dev/null
+++ b/frontend/src/sheets.backoff.test.jsx
@@ -0,0 +1,79 @@
+// @vitest-environment happy-dom
+import React, { act } from 'react'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { createRoot } from 'react-dom/client'
+import { EXDB } from './lib/exercises.js'
+import { useStore } from './store/useStore.js'
+import { useUI } from './store/useUI.js'
+import { exConfigSheet } from './sheets.jsx'
+import { exLine } from './lib/history.js'
+
+// Back-off sets (lib/backoff.js): a switch under the progression Step, saved as `backoff: true`.
+const ex = EXDB.find(e => e.id === '0025') // barbell bench press
+const assisted = EXDB.find(e => e.id === '0009') // assisted chest dip: less load is harder
+const mounted = []
+
+function render(sheet) {
+ const host = document.createElement('div')
+ document.body.appendChild(host)
+ const root = createRoot(host)
+ mounted.push([root, host])
+ act(() => root.render(sheet.render(() => useUI.getState().closeSheet(sheet.id))))
+ return host
+}
+const backoffRow = host => [...host.querySelectorAll('.lrow')].find(r => r.querySelector('.lrow-t')?.textContent === 'Back-off sets')
+const toggle = host => backoffRow(host).querySelector('button, [role=switch], input[type=checkbox]').click()
+const save = host => [...host.querySelectorAll('button')].find(b => b.textContent.trim() === 'Save').click()
+const open = (cfg, onSave) => {
+ exConfigSheet(ex, { sets: 3, reps: 6, weight: 26, mode: 'reps', inc: 2, ...cfg }, onSave)
+ return render(useUI.getState().sheets.at(-1))
+}
+
+describe('exercise settings: back-off sets', () => {
+ beforeEach(() => {
+ globalThis.IS_REACT_ACT_ENVIRONMENT = true
+ useUI.setState({ sheets: [] })
+ useStore.setState(s => ({ S: { ...s.S, unit: 'kg' } }))
+ document.body.innerHTML = ''
+ })
+ afterEach(() => { act(() => { mounted.splice(0).forEach(([root, host]) => { root.unmount(); host.remove() }) }) })
+
+ it('is off by default and saves no field, so the plan keeps its shape', () => {
+ const onSave = vi.fn()
+ const host = open({}, onSave)
+ expect(backoffRow(host)).toBeTruthy()
+ expect(host.textContent).toContain('All sets at the same weight.')
+ act(() => save(host))
+ expect('backoff' in onSave.mock.calls[0][0]).toBe(false)
+ })
+
+ it('switched on, previews the sets and saves the flag', () => {
+ const onSave = vi.fn()
+ const host = open({}, onSave)
+ act(() => toggle(host))
+ expect(host.textContent).toContain('Sets open at 26 → 24 → 22 kg.')
+ act(() => save(host))
+ const saved = onSave.mock.calls[0][0]
+ expect(saved.backoff).toBe(true)
+ expect(saved.inc).toBe(2)
+ expect(exLine({ id: ex.id, ...saved }, 'kg')).toBe('3 × 6 · 26 → 24 → 22 kg')
+ })
+
+ it('switched off again, drops the flag', () => {
+ const onSave = vi.fn()
+ const host = open({ backoff: true }, onSave)
+ act(() => toggle(host))
+ act(() => save(host))
+ expect('backoff' in onSave.mock.calls[0][0]).toBe(false)
+ })
+
+ it('is not offered on an assistance machine', () => {
+ exConfigSheet(assisted, { sets: 3, reps: 6, weight: 30, mode: 'reps' }, vi.fn())
+ expect(backoffRow(render(useUI.getState().sheets.at(-1)))).toBeUndefined()
+ })
+
+ it('is not offered for pyramid sets', () => {
+ const host = open({ pyramid: [12, 10, 8] }, vi.fn())
+ expect(backoffRow(host)).toBeUndefined()
+ })
+})
diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx
index e5e4a6928..4e65e1458 100644
--- a/frontend/src/sheets.jsx
+++ b/frontend/src/sheets.jsx
@@ -34,6 +34,7 @@ import { estimate1RM, best1RM, is1RMRecord, REP_CAP } from './lib/onerm.js'
import { exerciseHistory } from './lib/exercise-history.js'
import { policyFor, defaultIncrement, POLICIES_FOR, POLICY_NAME, POLICY_DESC, MAX_BW_SETS, weightIncrement } from './lib/progression.js'
import { normalizeRepRange } from './lib/rep-range.js'
+import { isBackoff, backoffWeights } from './lib/backoff.js'
import { isPyramid, normalizePyramid, normalizePyramidRest, pyramidFromFlat, flatFromPyramid, pyramidLabel, PYRAMID_MAX, MAX_PYRAMID_SETS, PYRAMID_PRESETS } from './lib/pyramid.js'
import { MOBILE, shareExport, printHtml } from './lib/mobile.js'
import { speedUnitOf, toSpeed, fromSpeed } from './lib/speed.js'
@@ -1394,16 +1395,28 @@ export const equipmentProfileSheet = profile => ui().openSheet(close => <Equipme
// on "follow the routine" it inherits, so most people never touch it.
const progressionStepOf = (c, mode, ex, unit) =>
c.inc >= 0 ? c.inc : (mode === 'time' ? 5 : defaultIncrement(ex.id, unit))
-const progressionStepIsValid = (step, policy) =>
- policy === 'off' || (Number.isFinite(step) && step > 0)
-
-function ProgressionFields({ ex, mode, c, setC, routine, unit, perSide }) {
+// Back-off sets step down by the same Step, so a plan using them needs one even with no rule.
+const progressionStepIsValid = (step, policy, backoff = false) =>
+ (policy === 'off' && !backoff) || (Number.isFinite(step) && step > 0)
+// Back-off sets (lib/backoff.js) are offered where there is a load to step down: rep work on a
+// loaded exercise, not a pyramid (it owns each set), not a rest-pause (one work set), not an
+// assistance machine (less load is harder there).
+const backoffOffered = (c, mode, ex, bw) => mode === 'reps' && !bw && !isAssisted({ ...c, id: ex.id })
+ && !(Array.isArray(c.pyramid) && c.pyramid.length) && c.intensifier?.type !== 'restpause'
+
+function ProgressionFields({ ex, mode, c, setC, routine, unit, perSide, bw }) {
const options = POLICIES_FOR[mode] || ['off']
if (options.length < 2) return null
const inherited = policyFor({ id: ex.id }, routine, mode)
const active = policyFor({ ...c, id: ex.id }, routine, mode)
const inc = progressionStepOf(c, mode, ex, unit)
- const invalid = !progressionStepIsValid(inc, active)
+ const canBackoff = backoffOffered(c, mode, ex, bw)
+ const backoff = canBackoff && c.backoff === true
+ const invalid = !progressionStepIsValid(inc, active, backoff)
+ // "26 → 24 → 22 kg": what the sets will open at, from the weight and step typed above.
+ const preview = backoff && c.weight > 0 && inc > 0
+ ? backoffWeights(c.weight, Math.max(1, Math.round(c.sets) || 1), inc).map(fmtNum).join(' → ') + ' ' + unit
+ : ''
const stride = mode === 'reps' && perSide ? 2 : 1
const range = active === 'double' ? normalizeRepRange(c.reps, c.repsMin, stride) : null
const epleyEligible = mode === 'reps' && !isBw({ ...c, id: ex.id }) && (active === 'linear' || active === 'double')
@@ -1426,7 +1439,7 @@ function ProgressionFields({ ex, mode, c, setC, routine, unit, perSide }) {
<div className="small dim" style={{ marginBottom: active === 'off' ? 18 : 10 }}>{t(POLICY_DESC[active])}</div>
{/* Double progression on a weighted exercise fills this row with four steppers; `cfgrow-4`
lets it wrap into two pairs on phones, where four abreast left the inputs a few px wide. */}
- {active !== 'off' && <div className={'row cfgrow' + (active === 'double' && epleyEligible ? ' cfgrow-4' : '')} style={{ marginBottom: 18 }}>
+ {(active !== 'off' || backoff) && <div className={'row cfgrow' + (active === 'double' && epleyEligible ? ' cfgrow-4' : '')} style={{ marginBottom: 18 }}>
<Stepper label={mode === 'time' ? t('Step (seconds)') : t('Step ({0})', unit)} value={inc}
step={mode === 'time' ? 5 : 1.25} decimal={mode !== 'time'} invalid={invalid} className={invalid ? 'invalid' : ''}
onChange={v => setC(x => ({ ...x, inc: v }))} />
@@ -1444,6 +1457,21 @@ function ProgressionFields({ ex, mode, c, setC, routine, unit, perSide }) {
{invalid && <div className="small" role="alert" style={{ color: 'var(--red)', marginTop: -10, marginBottom: 18 }}>
{t('Enter a positive step to use this progression rule.')}
</div>}
+ {/* Off by default and only written when on, so every plan saved before it stays the shape
+ it was. The step is the one above: the gear's own increment, set once per exercise. */}
+ {canBackoff && <>
+ <div className="sect-b" style={{ marginBottom: 8 }}>
+ <Row icon="steps" iconTint="var(--acc)" title={t('Back-off sets')}
+ subtitle={t('Each set one step lighter than the one before. The weight above is the first set.')}>
+ <Switch checked={backoff} onChange={v => setC(x => ({ ...x, backoff: v || undefined }))} />
+ </Row>
+ </div>
+ <div className="small dim" style={{ marginBottom: 18 }}>
+ {backoff
+ ? (preview ? t('Sets open at {0}. The first set goes up when every set reaches its reps, and the rest follow it.', preview) : t('The first set goes up when every set reaches its reps, and the rest follow it.'))
+ : t('All sets at the same weight.')}
+ </div>
+ </>}
</>
}
@@ -1477,7 +1505,7 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, i
const pyramid = mode === 'reps' && isPyramid({ ...c, mode })
const setPyramidAt = (i, v) => setC(x => ({ ...x, pyramid: x.pyramid.map((p, j) => (j === i ? v : p)) }))
const progressionPolicy =policyFor({ ...c, id: ex.id }, routine, mode)
- const progressionStepInvalid = !progressionStepIsValid(progressionStepOf(c, mode, ex, st.unit), progressionPolicy)
+ const progressionStepInvalid = !progressionStepIsValid(progressionStepOf(c, mode, ex, st.unit), progressionPolicy, c.backoff === true && backoffOffered(c, mode, ex, bw))
const activePolicy = policyFor({ ...c, id: ex.id }, routine, mode)
const double = mode === 'reps' && activePolicy === 'double'
// Keep whatever the other mode already had (sets, weight) and fill only what is missing.
@@ -1550,6 +1578,8 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, i
// Every set in this exercise becomes a drop-set/rest-pause (buildSets stamps the rows) —
// decided here, in the plan, not re-decided live each time you train it.
if (!list.length && c.intensifier && c.intensifier.type) out.intensifier = intensifierToSave(c.intensifier)
+ // Back-off sets: written only when on, and only where the sheet offered them.
+ if (c.backoff === true && backoffOffered(out, 'reps', ex, bw) && isBackoff({ ...out, backoff: true })) out.backoff = true
onSave(out)
}
}
@@ -1770,7 +1800,7 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, i
</>}
{pyramid
? <div className="small dim" style={{ marginBottom: 18 }}>{t('Weight is up to you: pyramid sets are not progressed automatically.')}</div>
- : <ProgressionFields ex={ex} mode={mode} c={c} setC={setC} routine={routine} unit={st.unit} perSide={perSide} />}
+ : <ProgressionFields ex={ex} mode={mode} c={c} setC={setC} routine={routine} unit={st.unit} perSide={perSide} bw={bw} />}
<textarea className="input" rows={3} maxLength={500} style={{ marginBottom: 18 }}
placeholder={t('Note (optional): loading cues, "bar only, then +1 plate/side each set", anything worth remembering')}
value={c.note || ''} onChange={e => setC(x => ({ ...x, note: e.target.value }))} />
diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx
index 39a96e3d8..a023db125 100644
--- a/frontend/src/views/Workout.jsx
+++ b/frontend/src/views/Workout.jsx
@@ -149,7 +149,7 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSi
const row = setSideField(e.sets[i], side, field, v)
row.sides[side].weightOrigin = WEIGHT_ORIGIN_MANUAL
e.sets[i] = row
- e.sets = cascadeWeight(e.sets, i, v, side)
+ e.sets = cascadeWeight(e.sets, i, v, side, e.target?.backoffStep)
}, true)
}
// Drop/burst edits accept an optional `side` ('L'|'R'): present for a per-side row (edits that
@@ -1084,7 +1084,7 @@ function ActiveWorkout() {
// carries through without retyping every row while explicit manual exceptions stay put.
if (field === 'w') {
e.sets[i].weightOrigin = WEIGHT_ORIGIN_MANUAL
- e.sets = cascadeWeight(e.sets, i, v)
+ e.sets = cascadeWeight(e.sets, i, v, undefined, e.target?.backoffStep)
}
})
const modeAt = idx => modeOf({ ...(A.entries[idx].target || {}), id: A.entries[idx].id })