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.

Workout: a per-side hold can turn its switch-sides pause off on its own (#636)

Duarte Santos8339b51c2f62
diff --git a/frontend/src/lib/plan-share.js b/frontend/src/lib/plan-share.js
index 463086e81..fa2b1c489 100644
--- a/frontend/src/lib/plan-share.js
+++ b/frontend/src/lib/plan-share.js
@@ -133,7 +133,8 @@ function cleanEx(e) {
const subs = cleanBackups(e.subs, e.id, id => !!EXIDX[id] && !isCustomEx(EXIDX[id]))
if (subs.length) o.subs = subs
if (e.warmupRestOff === true) o.warmupRestOff = true
- if (e.side && e.sideRestSec > 0) o.sideRestSec = e.sideRestSec
+ if (e.side && e.sideRestOff === true) o.sideRestOff = true
+ else if (e.side && e.sideRestSec > 0) o.sideRestSec = e.sideRestSec
if (e.sg) {
o.sg = e.sg
// A superset's name and its rest between rounds (#292) ride on every member, so they travel
@@ -275,6 +276,7 @@ export function parsePlan(raw, destinationUnit = 'kg') {
const warmRest = cleanRestSec(e.warmupRestSec)
const warmOff = e.warmupRestOff === true
const sideRest = cleanRestSec(e.sideRestSec)
+ const sideOff = !!e.side && e.sideRestOff === true
const incline = clampIncline(e.incline)
// Planned substitutes: the catalogue's only, as they are exported.
const subs = cleanBackups(Array.isArray(e.subs) ? e.subs.map(x => (typeof x === 'string' ? canonicalExId(x) : x)) : [], known.has(e.id) ? e.id : canonicalExId(e.id), x => !known.has(x) && !!EXIDX[x] && !isCustomEx(EXIDX[x]))
@@ -284,9 +286,9 @@ export function parsePlan(raw, destinationUnit = 'kg') {
const pyramid = normalizePyramid(e.pyramid)
const pyramidRest = pyramid.length ? normalizePyramidRest(e.pyramidRest, pyramid.length) : []
const pyramidWeight = pyramid.length ? normalizePyramidWeight(e.pyramidWeight, pyramid.length) : []
- const { warmupSets, intensifier, restSec, warmupRestSec, warmupRestOff: _warmOff, sideRestSec: _sideRest, subs: _subs, pyramid: _pyramid, pyramidRest: _pyramidRest, pyramidWeight: _pyramidWeight, sgName: _sgName, sgRest: _sgRest, incline: _incline, ...passthrough } = e
+ const { warmupSets, intensifier, restSec, warmupRestSec, warmupRestOff: _warmOff, sideRestSec: _sideRest, sideRestOff: _sideOff, subs: _subs, pyramid: _pyramid, pyramidRest: _pyramidRest, pyramidWeight: _pyramidWeight, sgName: _sgName, sgRest: _sgRest, incline: _incline, ...passthrough } = e
if (!known.has(passthrough.id)) passthrough.id = canonicalExId(passthrough.id)
- return convertedExercise({ ...passthrough, ...(pyramid.length ? { pyramid } : {}), ...(pyramidRest.length ? { pyramidRest } : {}), ...(pyramidWeight.length ? { pyramidWeight } : {}), ...(warm ? { warmupSets: warm } : {}), ...(intens ? { intensifier: intens } : {}), ...(rest ? { restSec: rest } : {}), ...(warmOff ? { warmupRestOff: true } : warmRest ? { warmupRestSec: warmRest } : {}), ...(sideRest ? { sideRestSec: sideRest } : {}), ...(subs.length ? { subs } : {}), ...(sgName ? { sgName } : {}), ...(sgRest ? { sgRest } : {}), ...(incline > 0 ? { incline } : {}) }, sourceUnit || destination, destination)
+ return convertedExercise({ ...passthrough, ...(pyramid.length ? { pyramid } : {}), ...(pyramidRest.length ? { pyramidRest } : {}), ...(pyramidWeight.length ? { pyramidWeight } : {}), ...(warm ? { warmupSets: warm } : {}), ...(intens ? { intensifier: intens } : {}), ...(rest ? { restSec: rest } : {}), ...(warmOff ? { warmupRestOff: true } : warmRest ? { warmupRestSec: warmRest } : {}), ...(sideOff ? { sideRestOff: true } : sideRest ? { sideRestSec: sideRest } : {}), ...(subs.length ? { subs } : {}), ...(sgName ? { sgName } : {}), ...(sgRest ? { sgRest } : {}), ...(incline > 0 ? { incline } : {}) }, sourceUnit || destination, destination)
})
}))
return {
diff --git a/frontend/src/lib/plan-share.test.js b/frontend/src/lib/plan-share.test.js
index 3a3cad2f5..c9ff55f36 100644
--- a/frontend/src/lib/plan-share.test.js
+++ b/frontend/src/lib/plan-share.test.js
@@ -129,6 +129,13 @@ describe('what survives a shared plan', () => {
}
})
+ it('carries a hold\'s "no timer" between sides, over a time, and only on a per-side exercise (#636)', () => {
+ const out = roundTrip({ side: true, mode: 'time', sec: 30, sideRestOff: true, sideRestSec: 20 })
+ expect(out.sideRestOff).toBe(true)
+ expect('sideRestSec' in out).toBe(false)
+ for (const e of [{ sideRestOff: true }, { side: true, sideRestOff: 'yes' }]) expect('sideRestOff' in roundTrip(e), JSON.stringify(e)).toBe(false)
+ })
+
// The absence has to survive too: writing a 0 would pin the recipient's timer to "off"
// instead of letting the exercise keep inheriting whatever their own default is.
it('leaves an exercise that set no rest free of the field', () => {
diff --git a/frontend/src/lib/supersetFlow.js b/frontend/src/lib/supersetFlow.js
index f51f10e72..fed8607be 100644
--- a/frontend/src/lib/supersetFlow.js
+++ b/frontend/src/lib/supersetFlow.js
@@ -144,9 +144,11 @@ export function warmupRestSecFor(entry, setIdx, workRestSec, profileSec) {
* The break between the two sides of one per-side set, or null for none. An exercise may set its
* own `sideRestSec` (optional, Discord "set-specific rest timers"). Without it nothing changes:
* a timed hold pauses `switchSec` (capped at the set's rest, and none with the rest switched off),
- * and a reps set has no break between its sides, as before the field existed.
+ * and a reps set has no break between its sides, as before the field existed. `sideRestOff`
+ * is "no timer" for a hold that wants its switch pause gone but keeps its set rest (#636).
*/
export function sideRestFor(target, { timed, restAfter, switchSec }) {
+ if (target?.sideRestOff === true) return null
const own = Math.round(Number(target?.sideRestSec)) || 0
if (own > 0) return own
if (timed && restAfter > 0) return Math.min(switchSec, restAfter)
diff --git a/frontend/src/lib/supersetFlow.test.js b/frontend/src/lib/supersetFlow.test.js
index 52d2e14e4..1ac560ab2 100644
--- a/frontend/src/lib/supersetFlow.test.js
+++ b/frontend/src/lib/supersetFlow.test.js
@@ -156,6 +156,11 @@ describe('set-specific rests (Discord: rest for warm-ups and between sides)', ()
expect(sideRestFor({}, { timed: true, restAfter: 5, switchSec: 10 })).toBe(5)
expect(sideRestFor({ sideRestSec: 0 }, { timed: true, restAfter: 0, switchSec: 10 })).toBeNull()
})
+ it('"no timer" between sides turns a hold\'s switch pause off, set rest or not (#636)', () => {
+ expect(sideRestFor({ sideRestOff: true }, { timed: true, restAfter: 90, switchSec: 10 })).toBeNull()
+ expect(sideRestFor({ sideRestOff: true, sideRestSec: 20 }, { timed: true, restAfter: 90, switchSec: 10 })).toBeNull()
+ for (const v of [false, 'true', 1]) expect(sideRestFor({ sideRestOff: v }, { timed: true, restAfter: 90, switchSec: 10 })).toBe(10)
+ })
})
describe('warmupRestSecFor', () => {
diff --git a/frontend/src/sheets.config-rest.test.jsx b/frontend/src/sheets.config-rest.test.jsx
index 59f331295..22f80cd88 100644
--- a/frontend/src/sheets.config-rest.test.jsx
+++ b/frontend/src/sheets.config-rest.test.jsx
@@ -136,4 +136,25 @@ describe('exercise settings: rest for warm-ups and between sides', () => {
const out = onSave.mock.calls[0][0]
expect('warmupRestOff' in out || 'warmupRestSec' in out).toBe(false)
})
+
+ it('a per-side hold can turn its switch pause off on its own; a reps set never writes that (#636)', () => {
+ const onSave = vi.fn()
+ exConfigSheet(ex, { sets: 3, sec: 30, weight: 0, mode: 'time', side: true, restSec: 60 }, onSave)
+ const host = render(useUI.getState().sheets.at(-1))
+ expect(row(host, 'Rest between sides').querySelector('.lrow-v').textContent).toBe('Default (10s)')
+ act(() => row(host, 'Rest between sides').click())
+ const menu = render(lastMenuItems())
+ act(() => [...menu.querySelectorAll('.menu-item')].find(b => b.textContent.includes('No timer')).click())
+ expect(row(host, 'Rest between sides').querySelector('.lrow-v').textContent).toBe('No timer')
+ act(() => save(host))
+ expect(onSave.mock.calls[0][0]).toMatchObject({ mode: 'time', side: true, sideRestOff: true, restSec: 60 })
+ expect('sideRestSec' in onSave.mock.calls[0][0]).toBe(false)
+
+ const reps = vi.fn()
+ exConfigSheet(ex, { sets: 3, reps: 10, weight: 40, mode: 'reps', side: true, sideRestOff: true }, reps)
+ const host2 = render(useUI.getState().sheets.at(-1))
+ expect(row(host2, 'Rest between sides').querySelector('.lrow-v').textContent).toBe('No timer')
+ act(() => save(host2))
+ expect('sideRestOff' in reps.mock.calls[0][0]).toBe(false)
+ })
})
diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx
index 7bab9b31a..fe0e0304d 100644
--- a/frontend/src/sheets.jsx
+++ b/frontend/src/sheets.jsx
@@ -1754,6 +1754,8 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, i
// No warm-up rest of its own: the profile's (Settings > Workout) when it has one, else the work rest.
const warmAll = typeof st.warmupRestSec === 'number' ? st.warmupRestSec : null
const warmLikeAll = warmAll === null ? t('Like the work sets') : t('Default ({0})', warmAll > 0 ? fmtRest(warmAll) : t('No timer'))
+ // A hold's switch-sides pause when it has none of its own (Workout.jsx SWITCH_SIDES_SEC).
+ const sideDefault = t('Default ({0})', fmtRest(10))
// A catalogue cardio exercise logs intervals by default, but it can be counted in sets x reps
// or timed like any other (#678): jumping jacks and burpees are cardio and reps both.
const cardioEx = isCardio(ex.id)
@@ -1848,7 +1850,8 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, i
const withSubs = withBackups(c.subs, ex.id, id => !!EXIDX[id])
const withSetRests = {
...(c.warmupRestOff === true ? { warmupRestOff: true } : c.warmupRestSec > 0 ? { warmupRestSec: Math.round(c.warmupRestSec) } : {}),
- ...(perSide && c.sideRestSec > 0 ? { sideRestSec: Math.round(c.sideRestSec) } : {}),
+ ...(perSide && mode === 'time' && c.sideRestOff === true ? { sideRestOff: true }
+ : perSide && c.sideRestSec > 0 ? { sideRestSec: Math.round(c.sideRestSec) } : {}),
}
// The treadmill's grade, only when it has one, so a flat slot keeps the shape it had.
const incline = clampIncline(c.incline)
@@ -2049,12 +2052,24 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, i
switch pause for a hold, as before. */}
{!cardio && perSide && <>
<div className="sect-b cfg-rest" style={{ marginBottom: 6 }}>
+ {/* A reps set has no break by default, so 0:00 on the wheel is its "no timer". A hold's
+ default is the 10 s switch, so it gets the warm-ups' three choices to turn it off (#636). */}
<Row icon="sides" iconTint="var(--blue)" title={t('Rest between sides')} accessory="chevron"
- value={c.sideRestSec > 0 ? fmtRest(c.sideRestSec) : mode === 'time' ? t('Default ({0})', fmtRest(10)) : t('No timer')}
- onClick={() => durationSheet({
+ value={mode === 'time' && c.sideRestOff === true ? t('No timer') : c.sideRestSec > 0 ? fmtRest(c.sideRestSec) : mode === 'time' ? sideDefault : t('No timer')}
+ onClick={() => mode === 'time' ? menuSheet({
+ title: t('Rest between sides'),
+ items: [
+ { icon: 'timer', label: sideDefault, on: c.sideRestOff !== true && !(c.sideRestSec > 0), onClick: () => setC(x => { const { sideRestOff, sideRestSec, ...rest } = x; return rest }) },
+ { icon: 'pause', label: t('No timer'), on: c.sideRestOff === true, onClick: () => setC(x => { const { sideRestSec, ...rest } = x; return { ...rest, sideRestOff: true } }) },
+ { icon: 'clock', label: t('Pick a time'), on: c.sideRestOff !== true && c.sideRestSec > 0, onClick: () => durationSheet({
+ title: t('Rest between sides'), value: c.sideRestSec > 0 ? c.sideRestSec : 10, max: REST_MAX, off: t('No timer'),
+ onDone: v => setC(x => { const { sideRestOff, sideRestSec, ...rest } = x; return v > 0 ? { ...rest, sideRestSec: v } : { ...rest, sideRestOff: true } }),
+ }) },
+ ],
+ }) : durationSheet({
title: t('Rest between sides'), value: c.sideRestSec > 0 ? c.sideRestSec : 0, max: REST_MAX,
- off: mode === 'time' ? t('Default ({0})', fmtRest(10)) : t('No timer'),
- onDone: v => setC(x => { const { sideRestSec, ...rest } = x; return v > 0 ? { ...rest, sideRestSec: v } : rest }),
+ off: t('No timer'),
+ onDone: v => setC(x => { const { sideRestSec, sideRestOff, ...rest } = x; return v > 0 ? { ...rest, sideRestSec: v } : rest }),
})} />
</div>
<div className="small dim" style={{ marginBottom: 18 }}>
diff --git a/frontend/src/views/Workout.hold.test.jsx b/frontend/src/views/Workout.hold.test.jsx
index 52b4841a3..7e2b3d3e2 100644
--- a/frontend/src/views/Workout.hold.test.jsx
+++ b/frontend/src/views/Workout.hold.test.jsx
@@ -120,6 +120,17 @@ describe('a per-side hold', () => {
expect(tm.total).toBe(useStore.getState().S.restSec)
})
+ it('"no timer" between sides: no switch after the left, the full rest after the right (#636)', () => {
+ const plank = sidePlank()
+ plank.target.sideRestOff = true
+ renderWorkout([plank])
+ holdRow(0)
+ expect(doneOf()).toEqual([true, false, false, false])
+ expect(useUI.getState().timer).toBeNull()
+ holdRow(1)
+ expect(useUI.getState().timer.total).toBe(useStore.getState().S.restSec)
+ })
+
it('Left and Right pills carry both words, so they are one width (#322)', () => {
renderWorkout([sidePlank()])
const pills = [...container.querySelectorAll('.sidepill')]
diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx
index 5de8da424..67739164d 100644
--- a/frontend/src/views/Workout.jsx
+++ b/frontend/src/views/Workout.jsx
@@ -1807,6 +1807,8 @@ function ActiveWorkout() {
if (m === 'time' && partner && !partner.done) {
const pause = sideRestFor(fresh.entries[idx].target, { timed: true, restAfter, switchSec: SWITCH_SIDES_SEC })
if (pause > 0) { startRest(pause, idx, { kind: 'switch', forSet: i }); return }
+ // "No timer" between sides: straight on to the other side, the set's rest still to come.
+ if (fresh.entries[idx].target?.sideRestOff === true) { stopRest(); return }
}
// Singleton units are ordinary exercises: they rest between sets and after the closing