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(workout): skip rest before warmups

Space_Hermesb7631dc9a0a1
diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx
index 46c222f08..f2f3175f7 100644
--- a/frontend/src/views/Workout.jsx
+++ b/frontend/src/views/Workout.jsx
@@ -416,21 +416,24 @@ function ActiveWorkout() {
const freshUnitDone = freshUnit?.every(ui => fresh.entries[ui].sets.every(x => x.done))
const nextUnit = freshUnitDone ? nextUnfinishedUnit(fresh.entries, freshUnits, idx) : null
const freshWorkoutDone = freshUnitDone && !nextUnit
+ const restBeforeWarmup = nextUnit?.some(ui =>
+ fresh.entries[ui].sets.some(set => isWarmupRow(set) && !set.done),
+ )
// A re-check of finished work must not navigate or reopen a sheet, but it may still owe
// you a rest — see restOnRecheck, and the other half of issue #3.
if (!progress.isNew) {
- if (restOnRecheck({ timerRunning: !!useUI.getState().timer, unitDone: freshUnitDone, lastUnit: freshWorkoutDone })) startRest(S.restSec)
+ if (!restBeforeWarmup && restOnRecheck({ timerRunning: !!useUI.getState().timer, unitDone: freshUnitDone, lastUnit: freshWorkoutDone })) startRest(S.restSec)
return
}
// Singleton units are ordinary exercises: they rest between sets and after the closing
- // one, and never enter superset navigation. stopRest() first so the rest that belongs
- // after this set replaces the one that was running, rather than stacking on it.
+ // one unless the next unit has an unfinished warm-up, and never enter superset navigation.
+ // stopRest() first so a rest that belongs after this set replaces the one that was running.
if (freshUnitDone) stopRest()
if (!freshUnit || freshUnit.length <= 1) {
if (freshUnitDone && !askTop && nextUnit?.length) update(s => { if (s.active) s.active.cur = nextUnit[0] })
- if (restAfterSet({ unitDone: freshUnitDone, lastUnit: freshWorkoutDone })) startRest(S.restSec)
+ if (!restBeforeWarmup && restAfterSet({ unitDone: freshUnitDone, lastUnit: freshWorkoutDone })) startRest(S.restSec)
return
}
@@ -440,7 +443,7 @@ function ActiveWorkout() {
if (nextUnit?.length) {
// The top-weight sheet's explicit "Just close" path owns the choice not to advance.
if (!askTop) update(s => { if (s.active) s.active.cur = nextUnit[0] })
- startRest(S.restSec)
+ if (!restBeforeWarmup) startRest(S.restSec)
}
} else {
if (step.nextIdx != null) update(s => { if (s.active) s.active.cur = step.nextIdx })
diff --git a/frontend/src/views/Workout.test.jsx b/frontend/src/views/Workout.test.jsx
index ff9f8d5ab..60fa2881e 100644
--- a/frontend/src/views/Workout.test.jsx
+++ b/frontend/src/views/Workout.test.jsx
@@ -169,6 +169,85 @@ describe('Workout set completion flow', () => {
expect(mocks.startRest).not.toHaveBeenCalled()
})
+ it.each(['warmup', 'warm-up', 'warm_up'])(
+ 'does not start transition rest before an incomplete %s row in the next ordinary exercise',
+ async phase => {
+ await mount([
+ exercise('current', [false], { asked: true }),
+ exercise('next', [false, false], {
+ asked: true,
+ sets: [
+ { w: 30, r: 5, done: false, phase },
+ { w: 60, r: 5, done: false },
+ ],
+ }),
+ ])
+
+ await toggleSet(0)
+
+ expect(mocks.S.active.cur).toBe(1)
+ expect(mocks.startRest).not.toHaveBeenCalled()
+ },
+ )
+
+ it('does not start transition rest when a completed superset advances to an incomplete warm-up', async () => {
+ await mount([
+ exercise('superset-a', [true], { sg: 'group', asked: true }),
+ exercise('superset-b', [false], { sg: 'group', asked: true }),
+ exercise('next', [false, false], {
+ asked: true,
+ sets: [
+ { w: 30, r: 5, done: false, phase: 'warmup' },
+ { w: 60, r: 5, done: false },
+ ],
+ }),
+ ], 1)
+
+ await toggleSet(1)
+
+ expect(mocks.S.active.cur).toBe(2)
+ expect(mocks.startRest).not.toHaveBeenCalled()
+ })
+
+ it('does not start transition rest before a warm-up while top-weight confirmation owns navigation', async () => {
+ await mount([
+ exercise('current-loaded', [false]),
+ exercise('next', [false, false], {
+ asked: true,
+ sets: [
+ { w: 30, r: 5, done: false, phase: 'warmup' },
+ { w: 60, r: 5, done: false },
+ ],
+ }),
+ ])
+
+ await toggleSet(0)
+
+ expect(mocks.topWeightSheet).toHaveBeenCalledWith(0)
+ expect(mocks.S.active.cur).toBe(0)
+ expect(mocks.startRest).not.toHaveBeenCalled()
+ })
+
+ it('does not restart transition rest when re-checking a completed unit before an incomplete warm-up', async () => {
+ await mount([
+ exercise('current', [true], { asked: true }),
+ exercise('next', [false, false], {
+ asked: true,
+ sets: [
+ { w: 30, r: 5, done: false, phase: 'warmup' },
+ { w: 60, r: 5, done: false },
+ ],
+ }),
+ ])
+
+ await toggleSet(0)
+ await rerender()
+ await toggleSet(0)
+
+ expect(mocks.S.active.cur).toBe(0)
+ expect(mocks.startRest).not.toHaveBeenCalled()
+ })
+
it('leaves a completed superset selected while its top-weight sheet owns the advance choice', async () => {
const group = 'superset-1'
await mount([