workout: give back the rest a re-checked set used to swallow

The other half of issue #3. "Breaks sometimes not shown after finished set
(first / last)" — the last-set half was the quiet-finish rule, already fixed.
This is the first-set half.

Completing a set only counts as progress when it goes beyond the most sets this
exercise has had done at once, so that unchecking and re-checking finished work
does not replay navigation or reopen sheets. Correct, but it returned before
anything could time a rest: uncheck a set to fix the reps, check it again, and
nothing starts. If the original rest had already run out, you get no break at
all — which is exactly what was reported, and why it reads as "sometimes".

A re-check now fills that gap and only that gap: it starts a rest when none is
running, and never touches one that is still counting down, because a running
timer belongs to the set you finished most recently. Navigation and sheets stay
gated exactly as before.
This commit is contained in:
Duarte Santos committed 2026-08-25 20:51:18 +02:00
1 parent 5ff6b7d0a8
commit b28115a8f9
3 files changed
+47 -3

No files matched your search

+17
View File
@@ -25,6 +25,23 @@ export function restAfterSet({ unitDone, lastUnit }) {
return !unitDone || !lastUnit
}
/**
* Whether re-checking an already-completed set should start a rest.
*
* The high-water rule deliberately swallows a re-check so that unchecking and re-checking
* finished work does not replay navigation or reopen sheets. But a re-check is still you
* telling the app a set is done, and that is the other half of issue #3 — "after the first
* set, sometimes a break doesn't appear". That is what it looks like when you uncheck a set
* to correct the reps after its rest has already run out: nothing times the rest you are
* actually about to take.
*
* So: fill a gap, never disturb a rest that is already counting down. A timer that is running
* belongs to the set you finished most recently, which is a better answer than restarting it.
*/
export function restOnRecheck({ timerRunning, unitDone, lastUnit }) {
return !timerRunning && restAfterSet({ unitDone, lastUnit })
}
// Decide where a newly completed superset set goes next. Spent members are skipped, including
// across the wrap. A round ends when no later member in display order has work left; this makes
// the last *active* member the boundary rather than blindly using the group's last array index.
+22 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { setProgressHighWater, supersetFlowStep, restAfterSet } from './supersetFlow.js'
import { setProgressHighWater, supersetFlowStep, restAfterSet, restOnRecheck } from './supersetFlow.js'
const entry = done => ({ sets: done.map(value => ({ done: value })) })
@@ -51,3 +51,24 @@ describe('supersetFlowStep', () => {
})
})
})
// Issue #3 has two halves. restAfterSet covers "no break after the LAST set of an exercise";
// this covers "after the first set, sometimes a break doesn't appear" — the uncheck/re-check
// that the high-water rule swallows.
describe('rest on a re-check', () => {
it('starts the rest a swallowed re-check would otherwise cost you', () => {
expect(restOnRecheck({ timerRunning: false, unitDone: false, lastUnit: false })).toBe(true)
})
it('leaves a rest that is already counting alone', () => {
expect(restOnRecheck({ timerRunning: true, unitDone: false, lastUnit: false })).toBe(false)
})
it('still stays quiet on the last set of the last exercise', () => {
expect(restOnRecheck({ timerRunning: false, unitDone: true, lastUnit: true })).toBe(false)
})
it('rests after closing an exercise that is not the last one', () => {
expect(restOnRecheck({ timerRunning: false, unitDone: true, lastUnit: false })).toBe(true)
})
})