Add planned drop-sets and rest-pause/myo-reps intensifiers

An exercise's set config can now plan a drop-set (N drops, weight
decrement % per drop) or rest-pause (a total rep count split into
descending, roughly-halving bursts) via a new "Intensifier" picker in
the routine editor / exercise config sheet. The guided workout screen
pre-fills the resulting rows already computed and editable, no live
sheet or timer required; a plain set can still grow a drop/burst on
the spot too.

Rest-pause collapses the exercise to exactly two sets (a warm-up at
its own reps, then one rest-pause work set whose own reps ARE the
configured total) rather than repeating the full protocol per set.

Volume, fatigue tonnage, 1RM estimation and progression all continue
to read a set row's own w/r directly, so most of the app needed no
changes; the few that sum across a row's extras (workoutVolume,
setTonnage, applyPrescription's set-growth path) got small, targeted
fixes to avoid double-counting. Full design writeup in
PROJECT_CONTEXT.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
JoseviandClaude Sonnet 5 committed 2026-08-24 20:36:25 +02:00
1 parent 41061c1754
commit 02ea938b2c
17 files changed
+874 -18

No files matched your search

+55 -3
View File
@@ -3,7 +3,7 @@ import { useStore } from './store/useStore.js'
import { useUI } from './store/useUI.js'
import { EXDB, EXIDX, BODYPARTS, isCardio, isBodyweightEq, allExercises, equipmentOf, smOf } from './lib/exercises.js'
import { fmtDate, fmtNum, fmtVol, fmtDur, durPart, todayISO, uid, exCount, DAYN, MONTHS_LONG, ACCENTS } from './lib/format.js'
import { lastEntryFor, bestWeightFor, buildSets, effectiveRoutineId, workoutVolume, setsDone, setsDoneActive, lastBW, supersetUnits, unitOf, setLabel, defaultConfig, cleanupSg, modeOf, effortOf, isBw, isPerSide, sideReps, workSetsDone } from './lib/history.js'
import { lastEntryFor, bestWeightFor, buildSets, effectiveRoutineId, workoutVolume, setsDone, setsDoneActive, lastBW, supersetUnits, unitOf, setLabel, defaultConfig, cleanupSg, modeOf, effortOf, isBw, isPerSide, sideReps, workSetsDone, applyIntensifierPlan } from './lib/history.js'
import { beep, vibrate } from './lib/sound.js'
import { t, instrFor, getLang, INSTR_LANGS } from './lib/i18n.js'
import { nav } from './lib/nav.js'
@@ -527,6 +527,9 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {
if (policyFor({ ...c, id: ex.id }, routine, 'reps') === 'double') out.repsMin = Math.min(reps, Math.max(1, Math.round(c.repsMin) || Math.max(1, reps - 2)))
// A ceiling below the working reps would tell you to add a set on day one.
if (bw && !(out.weight > 0) && c.repsMax > 0) out.repsMax = Math.max(reps, Math.round(c.repsMax))
// 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 (c.intensifier && c.intensifier.type) out.intensifier = c.intensifier
onSave(out)
}
}
@@ -552,13 +555,19 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {
<Stepper label={t('Seconds')} value={c.sec} step={5} decimal={false} onChange={v => setC(x => ({ ...x, sec: v }))} />
<Stepper label={t('Weight ({0})', st.unit)} value={c.weight} step={2.5} onChange={v => setC(x => ({ ...x, weight: v }))} />
</> : <>
<Stepper label={t('Sets')} value={c.sets} step={1} decimal={false} onChange={v => setC(x => ({ ...x, sets: v }))} />
{/* Rest-pause always trains as exactly two rows — a warm-up at this rep count, then one
rest-pause work set — so "Sets" has nothing left to mean and only invites a mismatch. */}
{c.intensifier?.type !== 'restpause' &&
<Stepper label={t('Sets')} value={c.sets} step={1} decimal={false} onChange={v => setC(x => ({ ...x, sets: v }))} />}
<Stepper label={t('Reps')} value={c.reps} step={perSide ? 2 : 1} decimal={false} onChange={v => setC(x => ({ ...x, reps: v }))} />
{/* On bodyweight work the weight stepper is the click #32 is about, so it is not here
until there is a belt to describe — see the added-weight row below. */}
{!bw && <Stepper label={t('Weight ({0})', st.unit)} value={c.weight} step={2.5} onChange={v => setC(x => ({ ...x, weight: v }))} />}
</>}
</div>
{c.intensifier?.type === 'restpause' && <div className="small dim" style={{ marginTop: -10, marginBottom: 18 }}>
{t('Rest-pause always trains as one warm-up set at this rep count, then one rest-pause work set — "Sets" is not used.')}
</div>}
{mode === 'time' && !bw && <div className="small dim" style={{ marginBottom: 18 }}>
{t('A timer runs while you hold the set. Leave the weight at 0 for bodyweight holds.')}
</div>}
@@ -597,6 +606,43 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {
? t('Reps climb to {0}, then a set is added and the reps start over. At {1} sets it asks you to add weight instead.', c.repsMax, MAX_BW_SETS)
: t('Reps climb by one whenever every set was clean. Set a ceiling to add sets instead of reps forever.')}
</div>}
{mode === 'reps' && <>
<h4 className="sec">{t('Drop-set / rest-pause')}</h4>
<div className="sect-b" style={{ marginBottom: 8 }}>
<SelectRow title={t('Intensifier')} sheetTitle={t('Intensifier')} value={c.intensifier?.type || ''}
onChange={v => setC(x => ({
...x,
intensifier: !v ? undefined : v === 'dropset'
? { type: 'dropset', count: x.intensifier?.count || 1, pct: x.intensifier?.pct || 20 }
// The activation set's own reps are whatever "Reps" above already says — a
// rest-pause plan only adds two new numbers: the total extra reps wanted past
// it, and the rest between the bursts that total gets split into.
: { type: 'restpause', totalReps: x.intensifier?.totalReps || x.reps || 8, restSec: x.intensifier?.restSec || st.restPauseSec || 15 },
}))}
options={[
{ value: '', label: t('None') },
{ value: 'dropset', label: t('Drop-set') },
{ value: 'restpause', label: t('Rest-pause') },
]} />
</div>
{c.intensifier?.type === 'dropset' && <div className="row cfgrow" style={{ marginBottom: 8 }}>
<Stepper label={t('Drops')} value={c.intensifier.count} step={1} decimal={false}
onChange={v => setC(x => ({ ...x, intensifier: { ...x.intensifier, count: Math.max(1, v) } }))} />
<Stepper label={t('Weight drop (%)')} value={c.intensifier.pct} step={5} decimal={false}
onChange={v => setC(x => ({ ...x, intensifier: { ...x.intensifier, pct: Math.max(5, v) } }))} />
</div>}
{c.intensifier?.type === 'restpause' && <div className="row cfgrow" style={{ marginBottom: 8 }}>
<Stepper label={t('Rest-pause reps')} value={c.intensifier.totalReps} step={1} decimal={false}
onChange={v => setC(x => ({ ...x, intensifier: { ...x.intensifier, totalReps: Math.max(1, v) } }))} />
<Stepper label={t('Rest (s)')} value={c.intensifier.restSec} step={5} decimal={false}
onChange={v => setC(x => ({ ...x, intensifier: { ...x.intensifier, restSec: Math.max(5, v) } }))} />
</div>}
{c.intensifier?.type && <div className="small dim" style={{ marginTop: -2, marginBottom: 18 }}>
{c.intensifier.type === 'dropset'
? t('Every set becomes a drop-set: after the main set, {0} drop(s) with no rest, each about {1}% lighter.', c.intensifier.count, c.intensifier.pct)
: t('Every set becomes rest-pause: {0} reps to start, then {1} more split into short bursts, {2}s rest before each, roughly halving each time.', c.reps || 0, c.intensifier.totalReps, c.intensifier.restSec)}
</div>}
</>}
<ProgressionFields ex={ex} mode={mode} c={c} setC={setC} routine={routine} unit={st.unit} />
<Button variant="primary" onClick={save}>{existing ? t('Save') : t('Add to routine')}</Button>
{ex.custom && <><div style={{ height: 8 }} /><Button icon="pencil" onClick={() => { close(); customExSheet(ex) }}>{t('Edit or delete this exercise')}</Button></>}
@@ -838,7 +884,8 @@ export function beginWorkout(routineId, bw) {
// kept on the entry purely so the workout can explain the number it chose.
const entries = (r ? r.ex : []).map(cfg => {
const plan = nextPrescription(st, cfg, r)
return { id: cfg.id, sg: cfg.sg, target: { ...cfg }, plan, sets: applyPrescription(buildSets(st, cfg), plan) }
const sets = applyIntensifierPlan(applyPrescription(buildSets(st, cfg), plan), cfg)
return { id: cfg.id, sg: cfg.sg, target: { ...cfg }, plan, sets }
})
update(s => {
s.active = { id: uid(), d: todayISO(), start: Date.now(), routineId, name: r ? r.name : t('Freestyle'), bw: bw || null, cur: 0, entries }
@@ -896,6 +943,11 @@ function TopWeight({ entryIdx, close }) {
}
export const topWeightSheet = entryIdx => ui().openSheet(close => <TopWeight entryIdx={entryIdx} close={close} />)
/* Drop-set drops and rest-pause bursts are edited inline on the set row itself (Workout.jsx) —
no sheet, no timer. A planned exercise (see the "Intensifier" config below) arrives with them
already computed via applyIntensifierPlan; an unplanned straight set can still grow one live
by tapping "+ Drop"/"+ Burst", which appends with the same suggested-next-value math. */
// Shown when the last exercise's last set is checked — finish, or keep going.
function WorkoutComplete({ close }) {
return <div style={{ textAlign: 'center', padding: '8px 0' }}>