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.

feat(checkin): per-side drop-sets and rest-pause bursts

Sebastian Ga284017a8455
diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.js
index 78b3d7b3a..cd267e6dc 100644
--- a/frontend/src/lib/history.js
+++ b/frontend/src/lib/history.js
@@ -412,12 +412,19 @@ export function applyIntensifierPlan(sets, cfg) {
if (kind === 'dropset') {
const count = Math.max(1, Math.round(cfg.intensifier.count) || 1)
const pct = cfg.intensifier.pct
+ // Stamp a descending chain of drops onto a row (or one side of a per-side row): each drop is
+ // pct% lighter than the last, at that row/side's own rep count.
+ const withDrops = row => {
+ const drops = []
+ let w = row.w || 0
+ for (let k = 0; k < count; k++) { w = nextDropWeight(w, pct); drops.push({ w, r: row.r }) }
+ return { ...row, type: 'dropset', drops }
+ }
return sets.map(s => {
if (isWarmupRow(s)) return s
- const drops = []
- let w = s.w || 0
- for (let k = 0; k < count; k++) { w = nextDropWeight(w, pct); drops.push({ w, r: s.r }) }
- return { ...s, type: 'dropset', drops }
+ // A unilateral set drops per side (issue #60): stamp each side, then resync the aggregate.
+ if (isSideSet(s)) return syncSideAggregate({ ...s, sides: { L: withDrops(s.sides.L), R: withDrops(s.sides.R) } })
+ return withDrops(s)
})
}
// Rest-pause trains as exactly two sets, not one per configured `sets` count: a warm-up at
diff --git a/frontend/src/lib/workout-model.js b/frontend/src/lib/workout-model.js
index c2e06532e..e66e89508 100644
--- a/frontend/src/lib/workout-model.js
+++ b/frontend/src/lib/workout-model.js
@@ -56,7 +56,14 @@ export function clustersOf(set) {
* `clustersOf(set)` here as well would double-count the same reps twice.
*/
export function extraVolumeOf(set) {
- const drops = dropsOf(set)
+ const source = objectOf(set)
+ // A per-side set carries its drops on each side (issue #60), so the extra volume is the sum of
+ // both sides' drops — the row itself has no `drops`. dropsOf reads a side's own {type,drops}.
+ if (isSideSet(source)) {
+ return [source.sides.L, source.sides.R].reduce(
+ (v, side) => v + dropsOf(side).reduce((n, d) => n + (Number(d?.w) || 0) * (Number(d?.r) || 0), 0), 0)
+ }
+ const drops = dropsOf(source)
return drops.reduce((v, d) => v + (Number(d?.w) || 0) * (Number(d?.r) || 0), 0)
}
@@ -153,6 +160,12 @@ const sideOf = value => {
const out = { w: Number(v.w) || 0, r: Number(v.r) || 0, done: v.done === true }
if (v.rir != null) out.rir = v.rir
if (v.rpe != null) out.rpe = v.rpe
+ // A side can carry its own intensifier (issue #60): drop-sets and rest-pause bursts are logged
+ // per limb, exactly like the main set, so the same {type, drops, clusters} shape rides on the
+ // side. Reuses the row-level helpers below (addDrop/dropsOf/…), which read this very shape.
+ if (v.type === 'dropset' || v.type === 'restpause') out.type = v.type
+ if (Array.isArray(v.drops)) out.drops = v.drops
+ if (Array.isArray(v.clusters)) out.clusters = v.clusters
return out
}
@@ -185,6 +198,11 @@ export function syncSideAggregate(row) {
const rpes = [L.rpe, R.rpe].filter(v => v != null)
if (rirs.length) out.rir = Math.min(...rirs)
else if (rpes.length) out.rpe = Math.max(...rpes)
+ // Drops/clusters live on the sides now, so the row itself never carries them — only the shared
+ // `type` so isDropSet/isRestPauseSet still classify the set. extraVolumeOf reads the sides.
+ delete out.drops; delete out.clusters; delete out.type
+ const sideType = setType(L) !== 'straight' ? setType(L) : setType(R)
+ if (sideType !== 'straight') out.type = sideType
return out
}
@@ -207,6 +225,65 @@ export function toggleSide(row, side) {
return syncSideAggregate({ ...base, sides: { ...base.sides, [side]: cur } })
}
+// --- per-side intensifiers (drop-sets / rest-pause) --------------------------------------------
+//
+// On a unilateral set the intensifier is logged per limb too. The structure stays symmetric —
+// both sides always carry the same number of drops/bursts — while each side's weights and reps
+// are edited independently, mirroring how the main set works. These reuse the side-agnostic
+// helpers above (addDrop/dropsOf/setDropAt/…) on each side object, then resync the aggregate.
+
+// Apply an editing fn to a single side and resync (used to edit one side's drop/burst).
+function patchSide(row, side, fn) {
+ const base = objectOf(row)
+ if (!isSideSet(base) || (side !== 'L' && side !== 'R')) return { ...base }
+ return syncSideAggregate({ ...base, sides: { ...base.sides, [side]: fn(sideOf(base.sides[side])) } })
+}
+// Apply an editing fn to both sides and resync (used to add/remove a drop/burst symmetrically).
+function patchBothSides(row, fn) {
+ const base = objectOf(row)
+ if (!isSideSet(base)) return { ...base }
+ return syncSideAggregate({ ...base, sides: { L: fn(sideOf(base.sides.L), 'L'), R: fn(sideOf(base.sides.R), 'R') } })
+}
+
+// Append a drop to both sides, each seeded from its own side's weight (pct lighter) and reps.
+export function addSideDrop(row, pct) {
+ return patchBothSides(row, side => {
+ const drops = dropsOf(side)
+ const base = drops.length ? drops[drops.length - 1].w : (side.w || 0)
+ return addDrop(side, { w: nextDropWeight(base, pct), r: side.r })
+ })
+}
+export function removeSideDropAt(row, i) {
+ return patchBothSides(row, side => removeDropAt(side, i))
+}
+export function setSideDropAt(row, side, i, patch) {
+ return patchSide(row, side, sd => setDropAt(sd, i, patch))
+}
+
+// Append a rest-pause burst to both sides, each seeded from its own side's rep count. The side's
+// own `r` grows by the added burst, mirroring the non-per-side rule that a rest-pause row's `r`
+// is the running total across its bursts.
+export function addSideCluster(row, restSec) {
+ return patchBothSides(row, side => {
+ const clusters = clustersOf(side)
+ const base = clusters.length ? clusters[clusters.length - 1].r : (side.r || 0)
+ const added = nextBurstReps(base)
+ return { ...addCluster(side, { r: added, restSec }), r: (side.r || 0) + added }
+ })
+}
+export function removeSideClusterAt(row, i) {
+ return patchBothSides(row, side => {
+ const removed = clustersOf(side)[i]?.r || 0
+ return { ...removeClusterAt(side, i), r: Math.max(0, (side.r || 0) - removed) }
+ })
+}
+export function setSideClusterAt(row, side, i, r) {
+ return patchSide(row, side, sd => {
+ const delta = (Number(r) || 0) - (clustersOf(sd)[i]?.r || 0)
+ return { ...setClusterAt(sd, i, { r }), r: Math.max(0, (sd.r || 0) + delta) }
+ })
+}
+
export function normalizeMode(value, fallback = 'reps') {
const token = typeof value === 'string' ? value.trim().toLowerCase() : ''
if (MODES.includes(token)) return token
diff --git a/frontend/src/lib/workout-model.test.js b/frontend/src/lib/workout-model.test.js
index b85f08426..0b83cad32 100644
--- a/frontend/src/lib/workout-model.test.js
+++ b/frontend/src/lib/workout-model.test.js
@@ -5,6 +5,7 @@ import {
addDrop, addCluster, removeDropAt, removeClusterAt, setDropAt, setClusterAt,
nextDropWeight, nextBurstReps, splitBurstReps,
isSideSet, makeSideSet, syncSideAggregate, setSideField, toggleSide,
+ addSideDrop, removeSideDropAt, setSideDropAt, addSideCluster, removeSideClusterAt, setSideClusterAt,
} from './workout-model.js'
describe('phaseForSet / isWarmupRow', () => {
@@ -70,6 +71,14 @@ describe('extraVolumeOf', () => {
expect(extraVolumeOf({ w: 100, r: 5 })).toBe(0)
expect(extraVolumeOf({ phase: 'warmup', w: 20, r: 8 })).toBe(0)
})
+
+ it('sums both sides drops for a per-side drop-set (issue #60)', () => {
+ let s = addSideDrop(makeSideSet({ w: 20, r: 16 }), 20) // each side: one 16×8 drop
+ expect(extraVolumeOf(s)).toBe(16 * 8 * 2) // L + R
+ // an asymmetric edit is reflected
+ s = setSideDropAt(s, 'R', 0, { w: 10, r: 6 })
+ expect(extraVolumeOf(s)).toBe(16 * 8 + 10 * 6)
+ })
})
describe('addDrop / addCluster', () => {
@@ -277,3 +286,62 @@ describe('toggleSide', () => {
expect(s.done).toBe(false) // un-tick one side → row no longer done
})
})
+
+// Per-side intensifiers: a unilateral set's drop-sets and rest-pause bursts are logged per limb
+// too (issue #60). The structure stays symmetric (both sides carry the same count) while each
+// side's numbers are edited independently; drops/clusters live on the sides, and the aggregate's
+// extra volume sums both.
+describe('addSideDrop / removeSideDropAt / setSideDropAt', () => {
+ it('adds a drop to both sides, each seeded from its own side weight and reps', () => {
+ let s = makeSideSet({ w: 20, r: 16 }) // sides: 20×8 each
+ s = setSideField(s, 'R', 'w', 18) // make the sides asymmetric first
+ s = addSideDrop(s, 20) // 20% lighter
+ expect(s.sides.L.drops).toEqual([{ w: 16, r: 8 }]) // 20 → 16
+ expect(s.sides.R.drops).toEqual([{ w: 14.5, r: 8 }]) // 18 → 14.4 → rounds to 14.5
+ expect(s.type).toBe('dropset') // aggregate mirrors the intensifier type
+ expect(s.drops).toBeUndefined() // drops live on the sides, not the row
+ })
+
+ it('edits one side drop independently, leaving the other side untouched', () => {
+ let s = addSideDrop(makeSideSet({ w: 20, r: 16 }), 20)
+ s = setSideDropAt(s, 'L', 0, { w: 12 })
+ expect(s.sides.L.drops[0].w).toBe(12)
+ expect(s.sides.R.drops[0].w).toBe(16)
+ })
+
+ it('removes a drop from both sides, reverting to straight when the last goes', () => {
+ let s = addSideDrop(makeSideSet({ w: 20, r: 16 }), 20)
+ s = removeSideDropAt(s, 0)
+ expect(s.sides.L.drops).toEqual([])
+ expect(s.sides.R.drops).toEqual([])
+ expect(s.type).toBeUndefined() // no side is a drop-set anymore
+ })
+})
+
+describe('addSideCluster / removeSideClusterAt / setSideClusterAt', () => {
+ it('adds a burst to both sides and grows each side reps by its own added burst', () => {
+ let s = makeSideSet({ w: 20, r: 16 }) // 8 per side
+ s = addSideCluster(s, 15) // nextBurstReps(8) = 4
+ expect(s.sides.L.clusters).toEqual([{ r: 4, restSec: 15 }])
+ expect(s.sides.L.r).toBe(12) // 8 + 4
+ expect(s.sides.R.r).toBe(12)
+ expect(s.r).toBe(24) // aggregate total across both sides
+ expect(s.type).toBe('restpause')
+ })
+
+ it('editing one side burst keeps that side reps in step and leaves the other alone', () => {
+ let s = addSideCluster(makeSideSet({ w: 20, r: 16 }), 15) // L/R: r 12, burst 4
+ s = setSideClusterAt(s, 'L', 0, 6) // +2 on L
+ expect(s.sides.L.clusters[0].r).toBe(6)
+ expect(s.sides.L.r).toBe(14) // 12 + 2
+ expect(s.sides.R.r).toBe(12) // untouched
+ })
+
+ it('removing a burst subtracts its reps from that side', () => {
+ let s = addSideCluster(makeSideSet({ w: 20, r: 16 }), 15) // r 12 each
+ s = removeSideClusterAt(s, 0)
+ expect(s.sides.L.clusters).toEqual([])
+ expect(s.sides.L.r).toBe(8) // back to the base
+ expect(s.type).toBeUndefined()
+ })
+})
diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx
index 45d5719ec..5de4a3103 100644
--- a/frontend/src/views/Workout.jsx
+++ b/frontend/src/views/Workout.jsx
@@ -19,7 +19,7 @@ import { Button, Check, NumberField } from '../components/ui.jsx'
import { nextPrescription, applyPrescription, defaultIncrement, weightIncrement, stepWeight } from '../lib/progression.js'
import { progressionGuidance } from '../lib/progression-copy.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 } from '../lib/workout-model.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'
const SWIPE_MIN_DISTANCE = 48
@@ -75,6 +75,11 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onToggleSide, onField, onA
// 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 => {
+ // A unilateral set drops per side (issue #60): addSideDrop seeds each side from its own weight.
+ if (isSideSet(row)) {
+ const pct = entry.target?.intensifier?.type === 'dropset' ? entry.target.intensifier.pct : undefined
+ return addSideDrop(row, pct)
+ }
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
@@ -84,9 +89,10 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onToggleSide, onField, onA
// 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 restSec = entry.target?.intensifier?.type === 'restpause' ? entry.target.intensifier.restSec : (S.restPauseSec || 15)
+ if (isSideSet(row)) return addSideCluster(row, restSec) // per side, each keeps its own r in step
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 }
})
@@ -95,13 +101,18 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onToggleSide, onField, onA
// stays right. The done tick goes through onToggleSide → toggle() instead, so ticking a side
// still fires the rest timer / auto-advance / workout-complete flow.
const setSide = (i, side, field, v) => mutSet(i, row => setSideField(row, side, field, v))
- const removeDrop = (i, di) => mutSet(i, row => removeDropAt(row, di))
+ // Drop/burst edits accept an optional `side` ('L'|'R'): present for a per-side row (edits that
+ // one limb's drop/burst), absent for a straight row (edits the row's own).
+ const removeDrop = (i, di) => mutSet(i, row => isSideSet(row) ? removeSideDropAt(row, di) : removeDropAt(row, di))
const removeCluster = (i, ci) => mutSet(i, row => {
+ if (isSideSet(row)) return removeSideClusterAt(row, ci)
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 setDropField = (i, di, field, v, side) => mutSet(i, row =>
+ isSideSet(row) ? setSideDropAt(row, side, di, { [field]: v }) : setDropAt(row, di, { [field]: v }))
+ const setClusterField = (i, ci, v, side) => mutSet(i, row => {
+ if (isSideSet(row)) return setSideClusterAt(row, side, ci, v)
const delta = (Number(v) || 0) - (clustersOf(row)[ci]?.r || 0)
return { ...setClusterAt(row, ci, { r: v }), r: Math.max(0, (row.r || 0) + delta) }
})
@@ -211,8 +222,8 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onToggleSide, onField, onA
title: (warm ? t('Warm-up') : t('Set {0}', entry.sets.slice(0, i + 1).filter(x => isWarmupRow(x) === warm).length)),
subtitle: setLabel(entry.id, s, entry.target),
items: [
- !warm && mode === 'reps' && !perSide && !isRestPauseSet(s) && { icon: 'arrowDown', label: t('Drop set'), sub: t('+ Drop'), onClick: () => addDropRow(i) },
- !warm && mode === 'reps' && !perSide && !isDropSet(s) && { icon: 'bolt', label: t('Rest-pause burst'), sub: t('+ Burst'), onClick: () => addBurstRow(i) },
+ !warm && mode === 'reps' && !isRestPauseSet(s) && { icon: 'arrowDown', label: t('Drop set'), sub: t('+ Drop'), onClick: () => addDropRow(i) },
+ !warm && mode === 'reps' && !isDropSet(s) && { icon: 'bolt', label: t('Rest-pause burst'), sub: t('+ Burst'), onClick: () => addBurstRow(i) },
{ icon: 'trash', label: t('Remove this set'), danger: true, disabled: entry.sets.length <= 1, onClick: () => onRemoveSetAt(i) },
],
})
@@ -289,6 +300,30 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onToggleSide, onField, onA
<Check checked={sd.done} onChange={() => onToggleSide(i, side)} />
</div>
}
+ // A side's own drop-set/rest-pause sub-rows (issue #60): the intensifier is logged per limb, so
+ // the drops and bursts hang under that side's row, each editable, exactly like a straight set's
+ // do under its row. Reads the side object, not the aggregate.
+ const sideExtras = (s, i, side) => {
+ const sd = (s.sides && s.sides[side]) || {}
+ return <>
+ {dropsOf(sd).map((d, di) => (
+ <div className="subrow" key={'d' + di}>
+ <span className="subn">{t('Drop {0}', di + 1)}</span>
+ {miniStepper(d.w, loadStep, true, v => setDropField(i, di, 'w', v, side), true)}
+ {miniStepper(d.r, 1, false, v => setDropField(i, di, 'r', v, side))}
+ <button className="iconbtn" aria-label={t('Remove drop')} onClick={() => removeDrop(i, di)}><Icon name="xmark" /></button>
+ </div>
+ ))}
+ {clustersOf(sd).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, side))}
+ <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>
+ ))}
+ </>
+ }
// 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, snapWeightStep = false) => (
@@ -365,7 +400,9 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onToggleSide, onField, onA
<button type="button" className="n" aria-label={t('Set {0}', phaseNum)} title={t('More')} onClick={() => openSetMenu(s, i)}>{phaseNum}</button>
<div className="side-rows">
{sideRow(s, i, 'L', col1, col2, col3)}
+ {sideExtras(s, i, 'L')}
{sideRow(s, i, 'R', col1, col2, col3)}
+ {sideExtras(s, i, 'R')}
</div>
</div>
) : (
@@ -384,7 +421,7 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onToggleSide, onField, onA
{/* 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' && !perSide && <>
+ {!warm && mode === 'reps' && <>
{dropsOf(s).map((d, di) => (
<div className="subrow" key={'d' + di}>
<span className="subn">{t('Drop {0}', di + 1)}</span>