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.

Follow-up to #204: a rest that ran out and only shows Ready no longer counts as running, so re-checking a finished set still starts the rest it owes

Duarte Santos0f18ea568ee1
diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx
index da6611af7..0e33df60c 100644
--- a/frontend/src/views/Workout.jsx
+++ b/frontend/src/views/Workout.jsx
@@ -970,9 +970,11 @@ function ActiveWorkout() {
const restAfter = warmupRestSecFor(fresh.entries[idx], i, restSec)
// 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.
+ // you a rest — see restOnRecheck, and the other half of issue #3. A rest that already ran
+ // out and only shows Ready is not running: it has nothing left to time.
if (!progress.isNew) {
- if (!restBeforeWarmup && restOnRecheck({ timerRunning: !!useUI.getState().timer, unitDone: freshUnitDone, lastUnit: freshWorkoutDone })) startRest(restAfter, idx)
+ const rest = useUI.getState().timer
+ if (!restBeforeWarmup && restOnRecheck({ timerRunning: !!(rest && !rest.ready), unitDone: freshUnitDone, lastUnit: freshWorkoutDone })) startRest(restAfter, idx)
return
}
diff --git a/frontend/src/views/Workout.test.jsx b/frontend/src/views/Workout.test.jsx
index e708ef9dc..6bcb13d19 100644
--- a/frontend/src/views/Workout.test.jsx
+++ b/frontend/src/views/Workout.test.jsx
@@ -386,6 +386,30 @@ describe('Workout set completion flow', () => {
expect(mocks.startRest).not.toHaveBeenCalled()
})
+ // A rest that ran out stays on screen as Ready (#204) until it is dismissed. It is not a rest
+ // counting down, so re-checking a finished set still owes the rest it always did (issue #3).
+ it('starts the rest a re-check owes while the last one only shows Ready', async () => {
+ await mount([exercise('current', [true, false, false])])
+ mocks.timer = { left: 0, total: 90, endsAt: Date.now() - 1000, forIdx: 0, ready: true }
+
+ await toggleSet(0)
+ await rerender()
+ await toggleSet(0)
+
+ expect(mocks.startRest).toHaveBeenCalledWith(90, 0)
+ })
+
+ it('leaves a rest that is still counting down alone on a re-check', async () => {
+ await mount([exercise('current', [true, false, false])])
+ mocks.timer = { left: 40, total: 90, endsAt: Date.now() + 40000, forIdx: 0 }
+
+ await toggleSet(0)
+ await rerender()
+ await toggleSet(0)
+
+ expect(mocks.startRest).not.toHaveBeenCalled()
+ })
+
it('leaves a completed superset selected without opening a top-weight sheet', async () => {
const group = 'superset-1'
await mount([