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.

fix: track unilateral warm-ups per side and keep RIR +/- in paired sets (issue #60 / 1.1, 1.2)

Sebastian G6934e0551776
diff --git a/frontend/src/index.css b/frontend/src/index.css
index a167187e5..b70128499 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -1065,17 +1065,21 @@ body.chips-dragging *{cursor:inherit}
.setrow.side .effcell-stp>button[aria-label="Increase"]{min-width:12px}
}
/* An L/R row with an effort column inside a superset in the list view sits behind three insets
- (unit, superset card, sets card): at 412 px the row is 260 px wide, and with the logged
- effort's −/+ its cells want 277 (badge, tick and gaps, weight 77, reps 66, effort 64). The
- −/+ give way; the value stays, still opens the picker on tap, and the picker's exact row steps
- in halves as before. The header's effort slot follows the cell's floor.
- Only while the row is that narrow — the insets are fixed, so it is 1 px short at 428 px and
- fits from 430 px up, where it keeps the −/+ like the plain row above it. The 34 px floor
- belongs to the same query: on its own it clips the cell by 27 px. */
+ (unit, superset card, sets card). It used to drop the RIR −/+ here and hand the width to an
+ oversized weight cell — but the rating is the field you reach for most on a unilateral set, so
+ it keeps the same −/+ stepper a normal row has, just shrunk, and the weight cell pays for it
+ instead. The effort cell reserves its 28 px value plus two 12 px button floors (≈54 px); the
+ weight column gives up the matching width (a per-side weight is one limb's load, so its 48 px
+ reserve was generous), so the row's total is unchanged and everything still fits at 412 px. */
@media (max-width:429px){
.wl-unit .ss-card .setrow.side .effcell-stp>button[aria-label="Decrease"],
- .wl-unit .ss-card .setrow.side .effcell-stp>button[aria-label="Increase"]{display:none}
- .wl-unit .ss-card .setrow.side .effcell,.wl-unit .ss-card .setrow.side .effcell-stp,.wl-unit .ss-card .sethead.per-side .eff-sp{min-width:34px}
+ .wl-unit .ss-card .setrow.side .effcell-stp>button[aria-label="Increase"]{min-width:12px}
+ .wl-unit .ss-card .setrow.side .effcell,.wl-unit .ss-card .setrow.side .effcell-stp,.wl-unit .ss-card .sethead.per-side .eff-sp{min-width:54px}
+ /* reclaim the +/-'s room from the weight column: a slimmer number reserve and tighter button
+ floors, the same shape the 320 px step-down below already gives weight on these rows */
+ .wl-unit .ss-card .setrow.side.eff3 .stp.w:not(.plain),.wl-unit .ss-card .sethead.per-side.eff3:not(.plain) .w-sp{--btn-floor:12px}
+ .wl-unit .ss-card .setrow.side.eff3 .stp.w,.wl-unit .ss-card .sethead.per-side.eff3 .w-sp{--num:33px}
+ .wl-unit .ss-card .setrow.side.eff3 .stp.w button{width:18px}
}
/* Below 360 px a row with an effort column cannot hold three numbers and six buttons: with the
set number, tick and gaps gone a card leaves ~178 px, and 102.5 / 12 / 8.5 at their floors need
diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.js
index 4bcf90565..6f7f7792d 100644
--- a/frontend/src/lib/history.js
+++ b/frontend/src/lib/history.js
@@ -578,7 +578,9 @@ export function applyIntensifierPlan(sets, cfg, grid) {
w: source?.sides?.[key]?.w ?? w, r: reps, done: false, type: 'restpause',
clusters: splitBurstReps(reps).map(r => ({ r, restSec })),
})
- return [warmup, syncSideAggregate({ ...work, sides: {
+ // The warm-up is per side too (issue #60): makeSideSet splits its combined reps the same
+ // way the work set's are, each side its own reps/weight/effort and done tick.
+ return [makeSideSet(warmup), syncSideAggregate({ ...work, sides: {
L: side('L', Math.ceil(totalReps / 2)), R: side('R', Math.floor(totalReps / 2)),
} })]
}
@@ -797,7 +799,11 @@ export function rerampWarmups(rows, step = 2.5) {
const w = target > from
? Math.max(0, Math.min(target, Math.floor((from + (target - from) / 2) / step) * step))
: target
- out[i] = { ...out[i], w }
+ // A per-side warm-up ramps the same bar for both limbs: set each side's weight and resync
+ // the aggregate, so the L/R rows and the row's own `w` agree. A straight row sets `w` alone.
+ out[i] = isSideSet(out[i])
+ ? syncSideAggregate({ ...out[i], sides: { L: { ...out[i].sides.L, w }, R: { ...out[i].sides.R, w } } })
+ : { ...out[i], w }
from = w
}
return out
@@ -837,8 +843,15 @@ export function insertWarmupRow(rows, mode, target, step = 2.5) {
r: work ? work.r : (prev ? prev.r : target.reps),
done: false, phase: 'warmup', warmup: true,
}
+ // A unilateral exercise warms up per side too (issue #60): the warm-up row splits into L/R
+ // like the work sets it ramps toward, each side logged and ticked on its own with its own
+ // reps and effort. The reps `r` above is the combined total (the work set's, or the plan's
+ // even target), so makeSideSet halves it the same way a work row is split; both sides share
+ // the ramped weight. Only reps-mode warm-ups split — a timed hold or a cardio warm-up is not
+ // per-side. makeSideSet spreads the row, so `phase`/`warmup` carry onto the side set.
+ const warmRow = mode === 'reps' && isPerSide(target) ? makeSideSet(warm) : warm
const next = rows.slice()
- next.splice(at, 0, warm)
+ next.splice(at, 0, warmRow)
return next
}
diff --git a/frontend/src/lib/warmup-invariants.test.js b/frontend/src/lib/warmup-invariants.test.js
index 8ee3e1ced..18143c09d 100644
--- a/frontend/src/lib/warmup-invariants.test.js
+++ b/frontend/src/lib/warmup-invariants.test.js
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest'
-import { workoutVolume, insertWarmupRow, buildSets } from './history.js'
+import { workoutVolume, insertWarmupRow, buildSets, applyIntensifierPlan } from './history.js'
import { applyPrescription } from './progression.js'
+import { isSideSet } from './workout-model.js'
// The config sheet tells users warm-ups are "left out of volume, records and progression",
// and history.js repeats that as an invariant in a comment. Volume was the one place it
@@ -74,3 +75,86 @@ describe('the ramp follows the prescribed weight', () => {
expect(rows.filter(r => r.phase === 'warmup').map(r => r.w)).toEqual([75, 112.5])
})
})
+
+// A unilateral exercise warms up per side too (issue #60): the warm-up row is split into L/R
+// like the work sets it ramps toward, each side its own reps/weight/effort and done tick —
+// not one scalar row where "12 reps" is silently 6 per side and both sides share one RIR.
+// insertWarmupRow is also the in-session "Add warm-up set" path, so this covers both.
+describe('a unilateral warm-up is logged per side', () => {
+ it('insertWarmupRow builds a side set, splitting the combined reps across L and R', () => {
+ const rows = [{ w: 100, r: 12, done: false }]
+ const out = insertWarmupRow(rows, 'reps', { reps: 12, side: true }, 2.5)
+ expect(isSideSet(out[0])).toBe(true)
+ expect(out[0].sides.L).toMatchObject({ w: 50, r: 6, done: false })
+ expect(out[0].sides.R).toMatchObject({ w: 50, r: 6, done: false })
+ // the warm-up markers survive makeSideSet, and the scalar mirror stays correct
+ expect(out[0]).toMatchObject({ w: 50, r: 12, phase: 'warmup', warmup: true, done: false })
+ // no single shared RIR on the row — effort is per side now
+ expect(out[0].rir).toBeUndefined()
+ expect(out[0].rpe).toBeUndefined()
+ })
+
+ it('leaves a straight (two-sided) exercise as a scalar warm-up row', () => {
+ const out = insertWarmupRow([{ w: 100, r: 12, done: false }], 'reps', { reps: 12 }, 2.5)
+ expect(isSideSet(out[0])).toBe(false)
+ expect(out[0]).toMatchObject({ w: 50, r: 12, phase: 'warmup' })
+ })
+
+ it('does not split a timed hold or cardio warm-up', () => {
+ // only reps-mode warm-ups are per side; a per-side flag on a timed hold must not split it
+ expect(isSideSet(insertWarmupRow([{ sec: 45, w: 40 }], 'time', { sec: 45, side: true }, 2.5)[0])).toBe(false)
+ expect(isSideSet(insertWarmupRow([{ min: 20, speed: 10 }], 'cardio', { min: 20, side: true }, 2.5)[0])).toBe(false)
+ })
+
+ it('buildSets prepends per-side warm-ups that ramp per side toward the work weight', () => {
+ const S = { workouts: [], exWeights: {}, routines: [] }
+ const cfg = { id: 'curl', mode: 'reps', sets: 2, reps: 16, weight: 100, warmupSets: 2, side: true }
+ const rows = buildSets(S, cfg, { step: 2.5 })
+ const warm = rows.filter(r => r.phase === 'warmup')
+ expect(warm).toHaveLength(2)
+ for (const row of warm) {
+ expect(isSideSet(row)).toBe(true)
+ // both sides share the same ramped weight (same bar, both limbs) and half the reps
+ expect(row.sides.L.w).toBe(row.sides.R.w)
+ expect(row.sides.L.r + row.sides.R.r).toBe(16)
+ }
+ // the ramp itself is unchanged by the split: 50% then 75% of the 100 work weight
+ expect(warm.map(r => r.w)).toEqual([50, 75])
+ // and the per-side work sets follow (every row is a side set)
+ expect(rows.every(r => isSideSet(r))).toBe(true)
+ })
+
+ it('re-ramps a per-side warm-up on both sides, keeping the aggregate in step', () => {
+ const S = { workouts: [], exWeights: {}, routines: [] }
+ const cfg = { id: 'curl', mode: 'reps', sets: 2, reps: 16, weight: 100, warmupSets: 2, side: true }
+ // a deload rewrites the work rows to 50; rerampWarmups (end of applyPrescription) must bring
+ // the warm-ups down with it, on BOTH sides, or the L/R rows would disagree with the row's w.
+ const rows = applyPrescription(buildSets(S, cfg, { step: 2.5 }), { kind: 'deload', weight: 50 })
+ const warm = rows.filter(r => r.phase === 'warmup')
+ for (const row of warm) {
+ expect(row.sides.L.w).toBe(row.w)
+ expect(row.sides.R.w).toBe(row.w)
+ expect(row.w).toBeLessThanOrEqual(50)
+ }
+ expect(warm.map(r => r.w)).toEqual([25, 37.5])
+ })
+})
+
+// Rest-pause builds its own two rows (one warm-up, one rest-pause work set). On a unilateral
+// exercise the warm-up is per side too, the same as the work set below it.
+describe('a unilateral rest-pause warm-up is per side', () => {
+ it('splits the activation warm-up across L and R', () => {
+ const sets = [{ w: 60, r: 8, done: false, sides: { L: { w: 60, r: 4, done: false }, R: { w: 60, r: 4, done: false } } }]
+ const out = applyIntensifierPlan(sets, { reps: 8, side: true, intensifier: { type: 'restpause', totalReps: 12, restSec: 15 } })
+ expect(out).toHaveLength(2)
+ const warm = out[0]
+ expect(warm.phase).toBe('warmup')
+ expect(isSideSet(warm)).toBe(true)
+ expect(warm.sides.L.r + warm.sides.R.r).toBe(8)
+ expect(warm.sides.L.w).toBe(60)
+ expect(warm.sides.R.w).toBe(60)
+ // the work set stays per side with its bursts on each limb
+ expect(isSideSet(out[1])).toBe(true)
+ expect(out[1].type).toBe('restpause')
+ })
+})
diff --git a/frontend/src/superset-side-effort.test.js b/frontend/src/superset-side-effort.test.js
new file mode 100644
index 000000000..2de32fffa
--- /dev/null
+++ b/frontend/src/superset-side-effort.test.js
@@ -0,0 +1,65 @@
+// The RIR stepper on a unilateral row inside a superset (issue #60 / 1.2). happy-dom and
+// linkedom apply neither media queries nor layout, so — like list-columns.test.js and
+// android-system-bars.test.js — this reads the rule out of index.css as text.
+//
+// The regression: at the narrow widths where a superset nests three insets deep, the effort
+// cell used to DROP its −/+ buttons (display:none) and hand the freed width to an already
+// oversized weight column. A unilateral set is logged per side, so the rating is the field you
+// reach for most; it must keep the same +/- stepper a normal exercise row has, with the weight
+// column paying for it instead.
+import { describe, expect, it } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { resolve } from 'node:path'
+
+const css = readFileSync(resolve(process.cwd(), 'src/index.css'), 'utf8')
+
+// The inside of one @media block, by brace depth (same helper shape as list-columns.test.js).
+function mediaBody(query) {
+ const at = css.indexOf(`@media ${query}{`)
+ expect(at, query).toBeGreaterThanOrEqual(0)
+ let depth = 0
+ const open = css.indexOf('{', at)
+ for (let i = open; i < css.length; i++) {
+ if (css[i] === '{') depth++
+ else if (css[i] === '}' && --depth === 0) return css.slice(open + 1, i)
+ }
+ throw new Error('unclosed ' + query)
+}
+
+// The block that governs an L/R row in a superset in the list view: wide enough that the row's
+// three insets still leave room to shuffle width between columns (below 360px every row, normal
+// ones included, drops its effort +/- — that is the shared narrow-screen behaviour, not this bug).
+const body = mediaBody('(max-width:429px)')
+
+// A declaration block for one of the superset per-side selectors, by the text that targets it.
+const declsFor = needle => {
+ const rules = [...body.matchAll(/([^{}]+)\{([^{}]*)\}/g)]
+ const hit = rules.find(m => m[1].includes(needle) && m[1].includes('.ss-card') && m[1].includes('.setrow.side'))
+ return hit ? hit[2] : null
+}
+
+describe('a superset L/R row keeps its RIR +/- stepper', () => {
+ it('does not hide the effort +/- buttons the way it used to', () => {
+ const effortButtons = declsFor('effcell-stp>button')
+ expect(effortButtons, 'the effort +/- rule for a superset L/R row should exist').toBeTruthy()
+ // the bug was `display:none` on these buttons; now they stay, just shrunk to a floor
+ expect(effortButtons).not.toMatch(/display\s*:\s*none/)
+ expect(effortButtons).toMatch(/min-width\s*:\s*\d+px/)
+ })
+
+ it('gives the effort cell room for the value plus both buttons, not a bare value', () => {
+ const cell = declsFor('.effcell-stp,') || declsFor('.effcell,')
+ expect(cell, 'the effort cell min-width rule should exist').toBeTruthy()
+ const min = Number(cell.match(/min-width\s*:\s*(\d+)px/)?.[1])
+ // 28px value + two button floors + borders; the old collapsed value-only floor was 34px
+ expect(min).toBeGreaterThanOrEqual(50)
+ })
+
+ it('reclaims that width from the weight column instead', () => {
+ // the weight cell for these rows gives up reserve (--num) and/or button floor inside the
+ // same media block, so the row total is unchanged and still fits
+ const weight = [...body.matchAll(/([^{}]+)\{([^{}]*)\}/g)]
+ .find(m => m[1].includes('.ss-card') && m[1].includes('.stp.w') && /--num|--btn-floor/.test(m[2]))
+ expect(weight, 'the weight column should shrink to pay for the effort stepper').toBeTruthy()
+ })
+})
diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx
index 39340a4ed..adc771a8b 100644
--- a/frontend/src/views/Workout.jsx
+++ b/frontend/src/views/Workout.jsx
@@ -563,9 +563,11 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSi
return <div key={i}>
{isFirstWarmup && <div className="setph">{t('Warm-up')}</div>}
{!warm && warmBefore && <div className="setsep" />}
- {perSide && !warm && isSideSet(s) ? (
- // Unilateral work set: the number sits beside a two-row L/R stack, each side logged
- // and ticked on its own (issue #60).
+ {perSide && isSideSet(s) ? (
+ // Unilateral set: the number sits beside a two-row L/R stack, each side logged and
+ // ticked on its own (issue #60). Warm-ups split the same way as the work sets they
+ // ramp toward — their rows are side sets too — so the `!warm` exclusion is gone; a
+ // warm-up side set has no drops/bursts, so sideExtras renders nothing under it.
<div ref={el => onSetRowRef?.(i, el)} className={'setrow-side' + (s.done ? ' done' : '')}>
<button type="button" className="n" aria-label={t('Set {0}', phaseNum)} title={t('More')} onClick={() => openSetMenu(s, i)}>{phaseNum}</button>
<div className="side-rows">
diff --git a/frontend/src/views/Workout.test.jsx b/frontend/src/views/Workout.test.jsx
index f9413ea94..f8127b4fd 100644
--- a/frontend/src/views/Workout.test.jsx
+++ b/frontend/src/views/Workout.test.jsx
@@ -1906,6 +1906,29 @@ describe('set-row column header', () => {
expect(container.querySelector('.setrow-side .sidetag')).toBeTruthy()
})
+ // A unilateral warm-up is a side set too (issue #60), so it renders as the L/R stack like the
+ // work set below it — not the old single scalar row where 12 reps meant 6 per side on one line
+ // with one shared RIR. The render guard dropped its `!warm` exclusion for exactly this.
+ it('renders a per-side warm-up as its own L/R stack, not a single scalar row', async () => {
+ const side = (r) => ({ w: 20, r, done: false })
+ await mount([
+ exercise('side-curl', [], {
+ target: { mode: 'reps', side: true, reps: 16, weight: 20, bodyweight: false },
+ sets: [
+ // a per-side warm-up (half the reps on each side) ...
+ { w: 10, r: 16, phase: 'warmup', warmup: true, done: false, sides: { L: side(8), R: side(8) } },
+ // ... and a per-side work set
+ { w: 20, r: 16, done: false, sides: { L: side(8), R: side(8) } },
+ ],
+ }),
+ ])
+ // both the warm-up and the work set render as L/R stacks: two side rows, four L/R badges
+ expect(container.querySelectorAll('.setrow-side').length).toBe(2)
+ expect(container.querySelectorAll('.setrow-side .sidetag').length).toBe(4)
+ // the warm-up phase label is present, and no warm-up fell through to a scalar .setrow
+ expect(container.querySelector('.setph')).toBeTruthy()
+ })
+
// A weighted hold's row has the play button in front of the tick, so its cells get less room than
// a straight row's and the CSS sizes them (and the header over them) by the `timed` marker.
it('marks a timed hold\'s rows and header, and neither on a rep set', async () => {