fix: use exercise weight step for workout controls

This commit is contained in:
Manuel committed 2026-08-31 18:54:22 +02:00
1 parent 75fb168a03
commit 40ae5a6f9d
4 files changed
+58 -4

No files matched your search

+8 -1
View File
@@ -61,6 +61,11 @@ export function defaultIncrement(exId, unit) {
if (unit === 'lb') return heavy ? 10 : 5
return heavy ? 5 : 2.5
}
// Resolve the load step for reps-mode weight controls and progression. Timed exercises use
// `inc` for seconds, so their optional weight column must not call this helper.
export function weightIncrement(cfg, unit) {
return cfg && cfg.inc > 0 ? cfg.inc : defaultIncrement(cfg?.id, unit)
}
export const DEFAULT_SEC_INCREMENT = 5
// Where adding another set of push-ups stops being progress and starts being a way to spend
// an evening. Past this the honest advice is load or a harder variation (issue #33).
@@ -167,7 +172,9 @@ export function nextPrescription(S, cfg, routine) {
const mode = modeOf(cfg)
const policy = policyFor(cfg, routine, mode)
const unit = S.unit || 'kg'
const inc = cfg.inc > 0 ? cfg.inc : (mode === 'time' ? DEFAULT_SEC_INCREMENT : defaultIncrement(cfg.id, unit))
const inc = mode === 'time'
? (cfg.inc > 0 ? cfg.inc : DEFAULT_SEC_INCREMENT)
: weightIncrement(cfg, unit)
if (policy === 'off') return { policy, kind: 'off' }
const sessions = sessionsFor(S, cfg.id, cfg).filter(s => s.mode === mode)
+9 -1
View File
@@ -1,7 +1,7 @@
import { describe, it, expect } from 'vitest'
import {
readSession, sessionsFor, stallCount, nextPrescription, applyPrescription,
policyFor, defaultIncrement, POLICIES_FOR, DELOAD_AFTER, MAX_BW_SETS
policyFor, defaultIncrement, weightIncrement, POLICIES_FOR, DELOAD_AFTER, MAX_BW_SETS
} from './progression.js'
import { EXDB } from './exercises.js'
@@ -103,6 +103,14 @@ describe('defaultIncrement', () => {
})
})
describe('weightIncrement', () => {
it('uses a positive exercise override and otherwise the exercise/unit default', () => {
expect(weightIncrement({ id: LIFT, inc: 1 }, 'kg')).toBe(1)
expect(weightIncrement({ id: LIFT }, 'kg')).toBe(2.5)
expect(weightIncrement({ id: HEAVY, inc: 0 }, 'kg')).toBe(5)
})
})
describe('linear progression', () => {
const cfg = { id: LIFT, sets: 3, reps: 5, weight: 60, prog: 'linear' }