workout: fix the warm-up weight and the missing rest after a final set

Two session bugs that users reported separately and that both sat in the
"what happens when a set ends" path.

insertWarmupRow read rows[at - 1] to find what to ramp from. For the FIRST
warm-up `at` is 0, so that is rows[-1] — undefined — and the `||` fallback
took the LAST row instead: the heaviest work set. "Add warm-up set" handed
you a warm-up at your full working weight, every time, and you corrected it
by hand. It now ramps from the first work row, each added row closing half
the remaining gap (50% / 75% / 87.5%), rounded DOWN to the exercise's own
loading step — a warm-up a notch light costs nothing, one a notch heavy is a
set you have to strip plates off. The step is passed in by the caller so
history.js keeps no dependency on progression.js, which already imports it.

Rest timers stopped at the end of an exercise: the singleton path called
stopRest() and then skipped startRest(), commented as "final sets finish
quietly". But another exercise follows that set, and you rest before it too —
a two-set exercise timed one rest instead of two (issue #3), and the rest
never carried across the gap. Supersets already had the right rule, so the
condition is now shared as restAfterSet(): rest after every completed set
except the last set of the last exercise, which is where zkssyth landed
independently in Discord.
This commit is contained in:
Duarte Santos committed 2026-08-25 19:59:31 +02:00
1 parent a04a5cab52
commit 0863aa73fb
5 files changed
+253 -21

No files matched your search

+89 -6
View File
@@ -217,6 +217,33 @@ export function lastEntryFor(S, exId) {
return null
}
/** How long any single note may get. Long enough for a paragraph, short enough to stay a note. */
export const NOTE_MAX = 500
/**
* The most recent session note the user pinned for this exercise, or null.
*
* A note written mid-session is about that session — "shoulder twinged today". Some of them are
* about the NEXT one instead: "go a notch narrower". The pin is how the user says which, at the
* moment of writing, when they are the only one who knows. Pinned notes surface again the next
* time the exercise comes up; unpinned ones stay in that day's history.
*
* Only the newest pinned note is returned: a pin is a message to your next self, and a stack of
* them from six sessions ago is noise, not context.
*/
export function pinnedNoteFor(S, exId) {
const workouts = S?.workouts || []
for (let i = workouts.length - 1; i >= 0; i--) {
const en = (workouts[i].entries || []).find(e => e.id === exId)
const note = (en?.note || '').trim()
if (note && en.notePin) return { note, d: workouts[i].d }
}
return null
}
/** The standing note for an exercise — the one that is true every session. */
export const exNoteFor = (S, exId) => ((S?.exNotes || {})[exId] || '').trim() || null
// A freestyle exercise starts with the last target the user actually trained, rather than the
// generic config sheet defaults used when there is no history. The set rows themselves are still
// built by buildSets(), which copies each completed set by position; only the target shape and
@@ -249,7 +276,30 @@ export function effectiveRoutine(S, iso) {
const id = effectiveRoutineId(S, iso)
return id ? S.routines.find(r => r.id === id) || null : null
}
/**
* Build the rows a planned exercise starts a session with: its work sets, preceded by however
* many warm-up sets the routine asks for (`cfg.warmupSets`, 0 by default so an existing plan
* behaves exactly as before).
*
* The warm-ups are stacked with insertWarmupRow, one call each, so the ramp is the same one
* the in-session "Add warm-up set" button produces: each row halves the gap left to the work
* weight, giving 50% / 75% / 87.5% for three. `options.step` is the exercise's loading step,
* passed in by the caller (see insertWarmupRow for why this module cannot read it itself).
*/
export function buildSets(S, cfg, options = {}) {
const rows = buildWorkSets(S, cfg, options)
const warm = Math.max(0, Math.min(MAX_PLANNED_WARMUPS, Math.round(cfg.warmupSets) || 0))
if (!warm) return rows
const mode = modeOf(cfg)
let out = rows
for (let i = 0; i < warm; i++) out = insertWarmupRow(out, mode, cfg, options.step)
return out
}
/** Beyond this a "warm-up" is its own workout; the config stepper stops here too. */
export const MAX_PLANNED_WARMUPS = 5
function buildWorkSets(S, cfg, options = {}) {
const last = lastEntryFor(S, cfg.id)
const n = Math.max(1, cfg.sets || 1)
const mode = modeOf(cfg)
@@ -388,16 +438,49 @@ export function cascadeWeight(rows, from, value) {
return next
}
/** Insert a warm-up row before the first work row, copying the preceding warm-up's values. */
export function insertWarmupRow(rows, mode, target) {
/**
* Insert a warm-up row at the end of the warm-up block, ramping toward the working weight.
*
* Each added row halves what is left between the last warm-up and the first work set, so the
* first one lands at half the working weight, a second at three quarters, and so on — and a
* row you edited by hand is what the next one ramps from. `step` is the exercise's own loading
* step (progression.js's defaultIncrement, passed in by the caller so this module keeps no
* dependency on progression — that one already imports from here): a warm-up you cannot
* actually load onto the bar is noise.
*
* The reference is the first WORK row, never `rows[at - 1]` alone: for the first warm-up
* `at` is 0, and reading `rows[-1]` used to fall through to the *last* row — the heaviest
* work set — so "add warm-up set" handed you a full-weight set to correct by hand.
*/
export function insertWarmupRow(rows, mode, target, step = 2.5) {
const firstWork = rows.findIndex(x => !isWarmupRow(x))
const at = firstWork === -1 ? rows.length : firstWork
const l = rows[at - 1] || rows[rows.length - 1]
const prev = at > 0 ? rows[at - 1] : null // the warm-up this one ramps from
const work = firstWork === -1 ? null : rows[firstWork]
const rampTo = to => {
const from = prev ? (prev.w || 0) : 0
if (!(to > 0) || to <= from) return from
// Rounded DOWN to the step: a warm-up that lands a notch light costs nothing, one that
// lands a notch heavy is a set you have to strip plates off before you can use it.
return Math.max(0, Math.min(to, Math.floor((from + (to - from) / 2) / step) * step))
}
const warm = mode === 'cardio'
? { min: l ? l.min : (target.min || 20), speed: l ? l.speed : (target.speed || 8), done: false, phase: 'warmup', warmup: true }
? {
min: prev ? prev.min : (work ? work.min : (target.min || 20)),
speed: prev ? prev.speed : (work ? work.speed : (target.speed || 8)),
done: false, phase: 'warmup', warmup: true,
}
: mode === 'time'
? { sec: l ? l.sec : (target.sec || 45), w: l ? (l.w || 0) : (target.weight || 0), done: false, phase: 'warmup', warmup: true }
: { w: l ? l.w : 0, r: l ? l.r : target.reps, done: false, phase: 'warmup', warmup: true }
? {
sec: prev ? prev.sec : (work ? work.sec : (target.sec || 45)),
w: rampTo(work ? (work.w || 0) : (target.weight || 0)),
done: false, phase: 'warmup', warmup: true,
}
: {
w: rampTo(work ? (work.w || 0) : (target.weight || 0)),
r: work ? work.r : (prev ? prev.r : target.reps),
done: false, phase: 'warmup', warmup: true,
}
const next = rows.slice()
next.splice(at, 0, warm)
return next
+101 -4
View File
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest'
import { modeOf, isTimed, fmtSec, setLabel, defaultConfig, buildSets, freestyleConfig, exLine, workoutVolume, bestWeightFor, bestWeightForEntry, effortOf, stepEffort, capEffort, isBw, isPerSide, sideReps, repStep, cascadeWeight, insertWarmupRow, removeRowAt, workSetsDone, pairAdjacent, unpairSuperset, supersetUnits, applyIntensifierPlan } from './history.js'
import { modeOf, isTimed, fmtSec, setLabel, defaultConfig, buildSets, freestyleConfig, exLine, workoutVolume, bestWeightFor, bestWeightForEntry, effortOf, stepEffort, capEffort, isBw, isPerSide, sideReps, repStep, cascadeWeight, insertWarmupRow, removeRowAt, workSetsDone, pairAdjacent, unpairSuperset, supersetUnits, applyIntensifierPlan, pinnedNoteFor, exNoteFor } from './history.js'
import { EXDB } from './exercises.js'
// Real ids out of the shipped catalogue, so the body-part fallback is exercised for real.
@@ -365,6 +365,42 @@ describe('freestyleConfig', () => {
])
})
// Planned warm-ups: the routine says how many, buildSets stacks them onto the work sets with
// the same ramp the in-session button uses. A plan without the field must not change shape.
it('adds no rows when the config asks for no warm-ups', () => {
const S = { exWeights: {}, workouts: [] }
const cfg = { id: '0025', mode: 'reps', sets: 2, reps: 5, weight: 100 }
expect(buildSets(S, cfg)).toEqual([
{ w: 100, r: 5, done: false },
{ w: 100, r: 5, done: false },
])
})
it('prepends the planned warm-ups as a ramp toward the work weight', () => {
const S = { exWeights: {}, workouts: [] }
const cfg = { id: '0025', mode: 'reps', sets: 2, reps: 5, weight: 100, warmupSets: 3 }
const rows = buildSets(S, cfg, { step: 2.5 })
expect(rows.map(r => r.w)).toEqual([50, 75, 87.5, 100, 100])
expect(rows.slice(0, 3).every(r => r.phase === 'warmup')).toBe(true)
expect(rows.slice(3).every(r => r.phase === undefined)).toBe(true)
})
it('caps the planned warm-ups and ignores nonsense values', () => {
const S = { exWeights: {}, workouts: [] }
const base = { id: '0025', mode: 'reps', sets: 1, reps: 5, weight: 100 }
expect(buildSets(S, { ...base, warmupSets: 99 }, { step: 2.5 }).filter(r => r.phase === 'warmup')).toHaveLength(5)
expect(buildSets(S, { ...base, warmupSets: -2 }, { step: 2.5 })).toHaveLength(1)
expect(buildSets(S, { ...base, warmupSets: 'x' }, { step: 2.5 })).toHaveLength(1)
})
it('keeps planned warm-ups out of the work-set count', () => {
const S = { exWeights: {}, workouts: [] }
const rows = buildSets(S, { id: '0025', mode: 'reps', sets: 3, reps: 5, weight: 100, warmupSets: 2 }, { step: 2.5 })
const logged = { entries: [{ id: '0025', sets: rows.map(r => ({ ...r, done: true })) }] }
expect(logged.entries[0].sets).toHaveLength(5)
expect(workSetsDone(logged)).toBe(3)
})
it('inherits the target for timed and cardio exercises too', () => {
const timed = {
exWeights: {},
@@ -705,19 +741,48 @@ describe('session row helpers', () => {
expect('w' in next[2]).toBe(false)
})
it('insertWarmupRow inserts before the first work row and copies the last warm-up values', () => {
it('insertWarmupRow inserts before the first work row, ramping toward the work weight', () => {
const rows = [
{ warmup: true, w: 20, r: 8, done: true },
{ warmup: true, w: 30, r: 8, done: false },
{ w: 60, r: 8, done: false },
]
const next = insertWarmupRow(rows, 'reps', { reps: 8 })
const next = insertWarmupRow(rows, 'reps', { reps: 8 }, 2.5)
expect(next.length).toBe(4)
expect(next[2].warmup).toBe(true)
expect(next[2].w).toBe(30) // copies the preceding warm-up
expect(next[2].w).toBe(45) // halfway from the last warm-up (30) to the work set (60)
expect(next[3].w).toBe(60) // work row still after the warm-up block
})
// The first warm-up is the case that was broken: `at` is 0, so the old code read rows[-1],
// fell through to `rows[rows.length - 1]` — the heaviest work set — and handed you a
// "warm-up" at your full working weight.
it('gives the first warm-up half the working weight, not the working weight itself', () => {
const next = insertWarmupRow([{ w: 100, r: 5, done: false }], 'reps', { reps: 5 }, 2.5)
expect(next.length).toBe(2)
expect(next[0]).toMatchObject({ w: 50, r: 5, phase: 'warmup', warmup: true, done: false })
expect(next[1].w).toBe(100)
})
it('rounds the ramp to the exercise loading step', () => {
// 0 -> 95 halves to 47.5, which is not loadable in 5 kg steps: 45 is.
expect(insertWarmupRow([{ w: 95, r: 5 }], 'reps', { reps: 5 }, 5)[0].w).toBe(45)
})
it('keeps bodyweight warm-ups at zero and never exceeds the work set', () => {
expect(insertWarmupRow([{ w: 0, r: 12 }], 'reps', { reps: 12 }, 2.5)[0].w).toBe(0)
// A warm-up already at the working weight cannot ramp any further.
const at100 = insertWarmupRow([{ warmup: true, w: 100, r: 5 }, { w: 100, r: 5 }], 'reps', { reps: 5 }, 2.5)
expect(at100[1].w).toBe(100)
})
it('ramps a timed hold the same way and leaves cardio on the work row values', () => {
expect(insertWarmupRow([{ sec: 45, w: 40, done: false }], 'time', { sec: 45 }, 2.5)[0])
.toMatchObject({ sec: 45, w: 20, phase: 'warmup' })
expect(insertWarmupRow([{ min: 20, speed: 10, done: false }], 'cardio', { min: 20 }, 2.5)[0])
.toMatchObject({ min: 20, speed: 10, phase: 'warmup' })
})
it('removeRowAt never empties an entry below one row', () => {
expect(removeRowAt([{ w: 60 }], 0).length).toBe(1)
const rows = [{ w: 60 }, { w: 70 }]
@@ -748,3 +813,35 @@ describe('warm-up rows identified by phase alone', () => {
expect(next[2].w).toBe(100)
})
})
describe('pinnedNoteFor', () => {
const S = {
workouts: [
{ d: '2026-08-01', entries: [{ id: '0025', note: 'felt heavy', notePin: true }] },
{ d: '2026-08-08', entries: [{ id: '0025', note: 'just a diary line' }] },
{ d: '2026-08-15', entries: [{ id: '0025', note: 'go narrower', notePin: true }] },
{ d: '2026-08-22', entries: [{ id: '0293', note: 'other exercise', notePin: true }] },
],
}
it('returns only the newest pinned note for that exercise', () => {
expect(pinnedNoteFor(S, '0025')).toEqual({ note: 'go narrower', d: '2026-08-15' })
})
it('ignores notes that were not pinned', () => {
expect(pinnedNoteFor({ workouts: [{ d: '2026-08-08', entries: [{ id: '0025', note: 'diary' }] }] }, '0025')).toBeNull()
})
it('is null for an exercise with no notes, and safe on empty state', () => {
expect(pinnedNoteFor(S, '9999')).toBeNull()
expect(pinnedNoteFor({}, '0025')).toBeNull()
})
})
describe('exNoteFor', () => {
it('reads the standing note and trims it away when blank', () => {
expect(exNoteFor({ exNotes: { '0025': ' seat 4, pin 7 ' } }, '0025')).toBe('seat 4, pin 7')
expect(exNoteFor({ exNotes: { '0025': ' ' } }, '0025')).toBeNull()
expect(exNoteFor({}, '0025')).toBeNull()
})
})
+15
View File
@@ -10,6 +10,21 @@ export function setProgressHighWater(entry, previous = 0) {
return { isNew: done > previous, highWater: Math.max(previous, done) }
}
/**
* Whether completing a set should start a rest timer.
*
* A rest belongs after every completed set — the last set of an exercise included, because
* another exercise follows it and you rest before that one too. The only set with nothing
* left to time is the last set of the last exercise, where the session is over.
*
* Ordinary exercises used to "finish quietly" instead: an exercise started no rest on its
* closing set, so a two-set exercise timed one rest instead of two (issue #3) and a rest
* never carried across the gap into the next exercise. Supersets already did it this way.
*/
export function restAfterSet({ unitDone, lastUnit }) {
return !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.
+18 -1
View File
@@ -1,8 +1,25 @@
import { describe, expect, it } from 'vitest'
import { setProgressHighWater, supersetFlowStep } from './supersetFlow.js'
import { setProgressHighWater, supersetFlowStep, restAfterSet } from './supersetFlow.js'
const entry = done => ({ sets: done.map(value => ({ done: value })) })
describe('restAfterSet', () => {
it('rests between the sets of an exercise', () => {
expect(restAfterSet({ unitDone: false, lastUnit: false })).toBe(true)
expect(restAfterSet({ unitDone: false, lastUnit: true })).toBe(true)
})
// Issue #3: a two-set exercise timed one rest instead of two, because the closing set
// "finished quietly". The next exercise still follows it, so the rest belongs there.
it('rests after the closing set when another exercise follows', () => {
expect(restAfterSet({ unitDone: true, lastUnit: false })).toBe(true)
})
it('stays quiet only on the very last set of the session', () => {
expect(restAfterSet({ unitDone: true, lastUnit: true })).toBe(false)
})
})
describe('supersetFlowStep', () => {
it('does not create navigation or rest flow for a normal singleton exercise', () => {
const entries = [entry([true]), entry([false])]
+30 -10
View File
@@ -3,17 +3,17 @@ import { useNavigate } from 'react-router-dom'
import { useStore } from '../store/useStore.js'
import { useUI } from '../store/useUI.js'
import { exOr } from '../lib/exercises.js'
import { effectiveRoutine, lastEntryFor, bestWeightFor, buildSets, freestyleConfig, defaultConfig, setsDoneActive, supersetUnits, unitOf, setLabel, modeOf, isBw, isPerSide, sideReps, repStep, EFFORT, effortOf, stepEffort, capEffort, cascadeWeight, insertWarmupRow, removeRowAt, pairAdjacent, unpairSuperset, cleanupSg, applyIntensifierPlan } from '../lib/history.js'
import { effectiveRoutine, lastEntryFor, bestWeightFor, buildSets, freestyleConfig, defaultConfig, setsDoneActive, supersetUnits, unitOf, setLabel, modeOf, isBw, isPerSide, sideReps, repStep, EFFORT, effortOf, stepEffort, capEffort, cascadeWeight, insertWarmupRow, removeRowAt, pairAdjacent, unpairSuperset, cleanupSg, applyIntensifierPlan, pinnedNoteFor, exNoteFor } from '../lib/history.js'
import { fmtNum, fmtDate, todayISO, exCount, DAYN } from '../lib/format.js'
import { beep, vibrate } from '../lib/sound.js'
import { t, exerciseNameFor } from '../lib/i18n.js'
import { api } from '../lib/api.js'
import { setProgressHighWater, supersetFlowStep } from '../lib/supersetFlow.js'
import { setProgressHighWater, supersetFlowStep, restAfterSet } from '../lib/supersetFlow.js'
import Media from '../components/Media.jsx'
import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, topWeightSheet, finishWorkout, workoutCompleteSheet, confirmSheet } from '../sheets.jsx'
import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, topWeightSheet, finishWorkout, workoutCompleteSheet, confirmSheet, exerciseNoteSheet } from '../sheets.jsx'
import Icon from '../components/Icon.jsx'
import { Button, Check, NumberField } from '../components/ui.jsx'
import { nextPrescription, applyPrescription } from '../lib/progression.js'
import { nextPrescription, applyPrescription, defaultIncrement } from '../lib/progression.js'
import { glyphOf } from '../lib/glyphs.js'
import { isWarmupRow, isDropSet, isRestPauseSet, dropsOf, clustersOf, addDrop, addCluster, removeDropAt, removeClusterAt, setDropAt, setClusterAt, nextDropWeight, nextBurstReps } from '../lib/workout-model.js'
@@ -96,6 +96,10 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov
const cardio = mode === 'cardio'
const timed = mode === 'time'
const last = lastEntryFor(S, entry.id)
const standingNote = exNoteFor(S, entry.id)
// Only worth surfacing while there is still work left: once the exercise is finished, a note
// telling you what to do in it is behind you, and the block is already long.
const pinnedNote = entry.sets.some(s => !s.done) ? pinnedNoteFor(S, entry.id) : null
// The same number the "confirm your working weight" sheet calls your best, so the two
// never disagree inside one session: heaviest logged set, or the working weight you kept.
const best = cardio ? 0 : Math.max(bestWeightFor(S, entry.id), (S.exWeights[entry.id] || {}).w || 0)
@@ -154,7 +158,12 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov
<Media ex={ex} key={entry.id} compact={compact} minimizable />
<div className="row between" style={{ marginBottom: 6 }}>
<div style={{ fontSize: compact ? 17 : 20, fontWeight: 600, letterSpacing: '-.02em', textTransform: 'capitalize', lineHeight: 1.2 }}>{exerciseNameFor(ex)}</div>
<button className="iconbtn" aria-label={t('Details')} onClick={() => exerciseDetailSheet(ex)}><Icon name="info" /></button>
<div className="row" style={{ gap: 2, flex: 'none' }}>
<button className="iconbtn" aria-label={t('Note')} title={t('Note')}
style={entry.note ? { color: 'var(--acc)' } : undefined}
onClick={() => exerciseNoteSheet(entryIdx)}><Icon name="pencil" /></button>
<button className="iconbtn" aria-label={t('Details')} onClick={() => exerciseDetailSheet(ex)}><Icon name="info" /></button>
</div>
</div>
{!compact && (onPairPrev || onPairNext) && <div className="row" style={{ gap: 6, flexWrap: 'wrap', marginBottom: 8 }}>
{onPairPrev && <Button size="xs" variant="tinted" icon="link" title={t('Make superset with previous')} onClick={onPairPrev}>{t('Make superset with previous')}</Button>}
@@ -169,7 +178,17 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov
{ex.eq && <span className="tag">{t(ex.eq)}</span>}
{best > 0 && <span className="tag nocap">{t('Best:')} {fmtNum(best)} {S.unit}</span>}
</div>
{/* Three notes can apply to one exercise and they are not interchangeable, so each keeps its
own line and its own icon: the plan's instruction (cfg.note, from the routine), the
standing fact about the movement (exNotes), and the message you pinned to yourself last
session. Today's own note is edited through the button in the header and shown last. */}
{cfg.note && <div className="exnote">{cfg.note}</div>}
{standingNote && <div className="exnote"><Icon name="info" style={{ fontSize: 13, marginRight: 5, verticalAlign: '-2px' }} />{standingNote}</div>}
{pinnedNote && <div className="exnote" style={{ color: 'var(--yellow)' }}>
<Icon name="flag" style={{ fontSize: 13, marginRight: 5, verticalAlign: '-2px' }} />
{t('From {0}:', fmtDate(pinnedNote.d, true))} {pinnedNote.note}
</div>}
{entry.note && <div className="exnote">{entry.note}</div>}
{last && <div className="small dim" style={{ marginBottom: 4 }}>{t('Last time')} ({fmtDate(last.d)}): {last.sets.map(s => setLabel(entry.id, s, last.target)).join(', ')}</div>}
{plan && plan.why && plan.kind !== 'off' && <div className={'progline' + (plan.kind === 'deload' ? ' warn' : '')}>
<Icon name={plan.kind === 'up' ? 'arrowUp' : plan.kind === 'deload' ? 'arrowDown' : 'lightbulb'} />
@@ -304,7 +323,7 @@ function ActiveWorkout() {
const removeSet = idx => mutEntry(idx, e => { if (e.sets.length > 1) e.sets.pop() })
const addWarmup = idx => mutEntry(idx, e => {
const m = modeOf({ ...(e.target || {}), id: e.id })
e.sets = insertWarmupRow(e.sets, m, e.target || {})
e.sets = insertWarmupRow(e.sets, m, e.target || {}, defaultIncrement(e.id, S.unit))
})
const removeSetAt = (idx, i) => mutEntry(idx, e => { e.sets = removeRowAt(e.sets, i) })
const pairAt = (first, second) => update(s => {
@@ -400,11 +419,12 @@ function ActiveWorkout() {
const freshLastUnit = freshUnitIdx >= freshUnits.length - 1
const freshUnitDone = freshUnit?.every(ui => fresh.entries[ui].sets.every(x => x.done))
// Singleton units are ordinary exercises: preserve their historical between-set rest,
// while final sets finish quietly and never enter superset navigation.
// 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.
if (freshUnitDone) stopRest()
if (!freshUnit || freshUnit.length <= 1) {
if (!freshUnitDone) startRest(S.restSec)
if (restAfterSet({ unitDone: freshUnitDone, lastUnit: freshLastUnit })) startRest(S.restSec)
return
}
@@ -493,7 +513,7 @@ function ActiveWorkout() {
exConfigSheet(ex, null, cfg => update(s => {
const full = { ...cfg, id: ex.id }
const plan = freestyle ? null : nextPrescription(s, full, s.routines.find(r => r.id === s.active.routineId))
const sets = buildSets(s, full, freestyle ? { preferLast: true } : undefined)
const sets = buildSets(s, full, { step: defaultIncrement(ex.id, s.unit), ...(freestyle ? { preferLast: true } : {}) })
const progressed = freestyle ? sets : applyPrescription(sets, plan)
s.active.entries.push({ id: ex.id, target: { ...cfg }, plan, sets: applyIntensifierPlan(progressed, full) })
s.active.cur = s.active.entries.length - 1