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

+6
View File
@@ -120,6 +120,12 @@ export default function Settings() {
<SelectRow icon="timer" iconTint="var(--orange)" title={t('Rest timer')}
value={S.restSec} onChange={v => update(s => { s.restSec = v })}
options={[60, 90, 120, 150, 180].map(v => ({ value: v, label: v + 's' }))} />
{/* Default for a rest-pause burst added live on a plain set — a planned exercise's own
"Rest (s)" (in its Intensifier config) overrides this, same as the main rest timer
is the fallback whenever an exercise has no progression rule of its own. */}
<SelectRow icon="bolt" iconTint="var(--acc)" title={t('Rest-pause rest')}
value={S.restPauseSec} onChange={v => update(s => { s.restPauseSec = v })}
options={[10, 15, 20, 30].map(v => ({ value: v, label: v + 's' }))} />
{(wakeOK || !MOBILE) && (
<Row icon="sun" iconTint="var(--yellow)" title={t('Keep screen awake')}
subtitle={wakeOK ? null : t('Not supported in this browser.')}>
+69 -3
View File
@@ -3,7 +3,7 @@ import { useNavigate } from 'react-router-dom'
import { useStore } from '../store/useStore.js'
import { useUI } from '../store/useUI.js'
import { exOr } from '../lib/exercises.js'
import { effectiveRoutine, lastEntryFor, bestWeightFor, buildSets, freestyleConfig, defaultConfig, setsDoneActive, supersetUnits, unitOf, setLabel, modeOf, isBw, isPerSide, sideReps, repStep, EFFORT, effortOf, stepEffort, capEffort, cascadeWeight, insertWarmupRow, removeRowAt, pairAdjacent, unpairSuperset, cleanupSg } from '../lib/history.js'
import { effectiveRoutine, lastEntryFor, bestWeightFor, buildSets, freestyleConfig, defaultConfig, setsDoneActive, supersetUnits, unitOf, setLabel, modeOf, isBw, isPerSide, sideReps, repStep, EFFORT, effortOf, stepEffort, capEffort, cascadeWeight, insertWarmupRow, removeRowAt, pairAdjacent, unpairSuperset, cleanupSg, applyIntensifierPlan } from '../lib/history.js'
import { fmtNum, fmtDate, todayISO, exCount, DAYN } from '../lib/format.js'
import { beep, vibrate } from '../lib/sound.js'
import { t } from '../lib/i18n.js'
@@ -15,7 +15,7 @@ import Icon from '../components/Icon.jsx'
import { Button, Check, NumberField } from '../components/ui.jsx'
import { nextPrescription, applyPrescription } from '../lib/progression.js'
import { glyphOf } from '../lib/glyphs.js'
import { isWarmupRow } from '../lib/workout-model.js'
import { isWarmupRow, isDropSet, isRestPauseSet, dropsOf, clustersOf, addDrop, addCluster, removeDropAt, removeClusterAt, setDropAt, setClusterAt, nextDropWeight, nextBurstReps } from '../lib/workout-model.js'
/* ---------- start chooser (no active workout) ---------- */
function StartChooser() {
@@ -58,8 +58,39 @@ function Elapsed({ start }) {
/* ---------- one exercise block (reps: weight×reps · time: a held duration · cardio: duration+speed) ---------- */
function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemoveSet, onAddWarmup, onRemoveSetAt, onStartTimed, onPairPrev, onPairNext }) {
const S = useStore(s => s.S)
const update = useStore(s => s.update)
const working = useUI(s => s.work)
const entry = S.active.entries[entryIdx]
// Drops/bursts mutate the row in place — same card, not a new set with its own long rest.
// A planned exercise (see the exercise's "Intensifier" config) arrives with these already
// filled in by applyIntensifierPlan; these only add/edit/remove entries live from here on.
const mutSet = (i, fn) => update(s => { const row = s.active.entries[entryIdx].sets[i]; s.active.entries[entryIdx].sets[i] = fn(row) }, true)
const addDropRow = i => mutSet(i, row => {
const drops = dropsOf(row)
const base = drops.length ? drops[drops.length - 1].w : (row.w || 0)
const pct = entry.target?.intensifier?.type === 'dropset' ? entry.target.intensifier.pct : undefined
return addDrop(row, { w: nextDropWeight(base, pct), r: row.r })
})
// A rest-pause row's own reps are always the total across every burst (see
// applyIntensifierPlan/history.js) — clusters are the breakdown of that total, not extra on
// top of it — so adding, removing or editing one keeps `r` in step by the same delta.
const addBurstRow = i => mutSet(i, row => {
const clusters = clustersOf(row)
const base = clusters.length ? clusters[clusters.length - 1].r : (row.r || 0)
const restSec = entry.target?.intensifier?.type === 'restpause' ? entry.target.intensifier.restSec : (S.restPauseSec || 15)
const added = nextBurstReps(base)
return { ...addCluster(row, { r: added, restSec }), r: (row.r || 0) + added }
})
const removeDrop = (i, di) => mutSet(i, row => removeDropAt(row, di))
const removeCluster = (i, ci) => mutSet(i, row => {
const removed = clustersOf(row)[ci]?.r || 0
return { ...removeClusterAt(row, ci), r: Math.max(0, (row.r || 0) - removed) }
})
const setDropField = (i, di, field, v) => mutSet(i, row => setDropAt(row, di, { [field]: v }))
const setClusterField = (i, ci, v) => mutSet(i, row => {
const delta = (Number(v) || 0) - (clustersOf(row)[ci]?.r || 0)
return { ...setClusterAt(row, ci, { r: v }), r: Math.max(0, (row.r || 0) + delta) }
})
const ex = exOr(entry.id)
const mode = modeOf({ ...(entry.target || {}), id: entry.id })
const cardio = mode === 'cardio'
@@ -110,6 +141,15 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov
<button aria-label="Increase" onClick={() => bump(s, i, col, 1)}><Icon name="plus" /></button>
</div>
)
// A smaller stepper for a drop's weight/reps or a burst's reps — editing what the plan (or a
// live "+ Drop"/"+ Burst" tap) already put on the row, not typing into a fresh field.
const miniStepper = (value, step, dec, onChange) => (
<div className="stp mini">
<button aria-label="Decrease" onClick={() => onChange(Math.max(0, Math.round(((value || 0) - step) * 100) / 100))}><Icon name="minus" /></button>
<span className="val"><NumberField decimal={dec} value={value ?? ''} onChange={onChange} /></span>
<button aria-label="Increase" onClick={() => onChange(Math.max(0, Math.round(((value || 0) + step) * 100) / 100))}><Icon name="plus" /></button>
</div>
)
return <>
<Media ex={ex} key={entry.id} compact={compact} minimizable />
<div className="row between" style={{ marginBottom: 6 }}>
@@ -159,6 +199,31 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov
disabled={entry.sets.length <= 1} onClick={() => onRemoveSetAt(i)}><Icon name="xmark" /></button>}
<Check checked={s.done} onChange={() => onToggle(i)} />
</div>
{/* Drop-sets and rest-pause bursts extend this same row — no long rest, no new set.
A planned exercise arrives with these already filled in (applyIntensifierPlan);
every value here is just as editable as the main row's own weight/reps. */}
{!warm && mode === 'reps' && <>
{dropsOf(s).map((d, di) => (
<div className="subrow" key={'d' + di}>
<span className="subn">{t('Drop {0}', di + 1)}</span>
{miniStepper(d.w, 2.5, true, v => setDropField(i, di, 'w', v))}
{miniStepper(d.r, 1, false, v => setDropField(i, di, 'r', v))}
<button className="iconbtn" aria-label={t('Remove drop')} onClick={() => removeDrop(i, di)}><Icon name="xmark" /></button>
</div>
))}
{clustersOf(s).map((c, ci) => (
<div className="subrow" key={'c' + ci}>
<span className="subn">{t('Burst {0}', ci + 1)}</span>
{miniStepper(c.r, 1, false, v => setClusterField(i, ci, v))}
<span className="dim small">{c.restSec}s</span>
<button className="iconbtn" aria-label={t('Remove burst')} onClick={() => removeCluster(i, ci)}><Icon name="xmark" /></button>
</div>
))}
<div className="setextra">
{!isRestPauseSet(s) && <button className="chip add" onClick={() => addDropRow(i)}><Icon name="arrowDown" />{t('+ Drop')}</button>}
{!isDropSet(s) && <button className="chip add" onClick={() => addBurstRow(i)}><Icon name="bolt" />{t('+ Burst')}</button>}
</div>
</>}
</div>
})}
<div style={{ height: 8 }} />
@@ -428,7 +493,8 @@ function ActiveWorkout() {
const full = { ...cfg, id: ex.id }
const plan = freestyle ? null : nextPrescription(s, full, s.routines.find(r => r.id === s.active.routineId))
const sets = buildSets(s, full, freestyle ? { preferLast: true } : undefined)
s.active.entries.push({ id: ex.id, target: { ...cfg }, plan, sets: freestyle ? sets : applyPrescription(sets, plan) })
const progressed = freestyle ? sets : applyPrescription(sets, plan)
s.active.entries.push({ id: ex.id, target: { ...cfg }, plan, sets: applyIntensifierPlan(progressed, full) })
s.active.cur = s.active.entries.length - 1
}), null, routine, seed)
})} icon="plus">{t('Add exercise')}</Button>