mrbatch: Listenmodus beendet den Workout nicht mehr zu frueh, Progression-Sheet speichert trotz Store-Clone, Progression-aus auch bei Swap/Sheet, Stepper snappt nur auf dem Raster, exWeights erst beim Abschluss
Aus dem Subagenten-Test der Workout-MRs: - !96 x !92: toggle() beurteilte die Einheit des Markers statt die des angetippten Satzes; im Listenmodus kam "That's the whole workout!" nach einem Satz einer anderen Uebung. - !77: Identitaetsvergleich scheitert an jedem Store-Clone (auch der Stangengewicht-Stepper im Sheet selbst) -> Vergleich auf Workout-Id, Listenlaenge und Uebung am Index. - !71: useTarget bei Progression 'aus' auch fuer swapActiveWorkoutExercise und das Progression-Sheet im Workout. - !84: stepWeight snappt nur, wenn der Wert schon auf dem Schrittraster liegt (62.5 +5 -> 67.5, nicht 70; 61.3 +1.25 -> 62.5 wie die Progression). - !92: exWeights werden nur noch beim Abschluss geschrieben (doFinishWorkout), nicht beim Abhaken - ein korrigierter Tippfehler oder ein verworfener Workout wird nie zum "Best".
This commit is contained in:
1 parent
80cccdd2e0
commit
0cbd32c0f5
4 files changed
+38
-9
No files matched your search
@@ -87,8 +87,14 @@ export function snapWeight(v, step) {
|
||||
if (!(step > 0)) return round1(v)
|
||||
return round1(Math.round(v / step) * step)
|
||||
}
|
||||
// A tap moves by one step. Snapping to the grid keeps the number identical to what progression
|
||||
// would prescribe (61.3 → 62.5 with a 1.25 step, not 62.55) — but only when the current value
|
||||
// already sits on that grid; from 62.5 with a 5 kg step a tap gives 67.5, not 70.
|
||||
export function stepWeight(value, step, direction) {
|
||||
return Math.max(0, snapWeight((Number(value) || 0) + direction * step, step))
|
||||
const v = Number(value) || 0
|
||||
const onGrid = step > 0 && Math.abs(v - Math.round(v / step) * step) <= 0.1
|
||||
const next = v + direction * step
|
||||
return Math.max(0, onGrid ? snapWeight(next, step) : round1(next))
|
||||
}
|
||||
// Back off by DELOAD_FACTOR, landing on something you can actually load. Rounding to the
|
||||
// nearest step keeps the cut close to the intended 10 %, but on small weights the nearest
|
||||
|
||||
@@ -851,7 +851,7 @@ export function swapActiveWorkoutExercise(index) {
|
||||
const freestyle = !st.active?.routineId
|
||||
const step = defaultIncrement(ex.id, st.unit)
|
||||
const plan = freestyle ? null : nextPrescription(st, full, st.routines.find(r => r.id === st.active.routineId))
|
||||
const built = buildSets(st, full, { step, ...(freestyle ? { preferLast: true } : {}) })
|
||||
const built = buildSets(st, full, { step, ...(freestyle ? { preferLast: true } : {}), ...(plan?.kind === 'off' ? { useTarget: true } : {}) })
|
||||
const replacement = {
|
||||
id: ex.id,
|
||||
target: { ...cfg },
|
||||
|
||||
@@ -490,13 +490,17 @@ function ActiveWorkout() {
|
||||
if (!entry) return
|
||||
const activeId = state.active.id
|
||||
const entryId = entry.id
|
||||
const entryCount = state.active.entries.length
|
||||
const routine = state.routines.find(r => r.id === state.active.routineId)
|
||||
exConfigSheet(exOr(entryId), entry.target, cfg => {
|
||||
// Store updates clone the state tree. If this exact object is no longer at the captured
|
||||
// index, the list changed while the sheet was open; an id check alone cannot distinguish
|
||||
// duplicate occurrences of the same exercise, so fail closed before cloning again.
|
||||
// Every store write clones the tree (the bar-weight stepper inside this very sheet does
|
||||
// one), so object identity is useless here. Same workout, same list length and the same
|
||||
// exercise at the captured index is what "nothing shifted" means.
|
||||
const current = useStore.getState().S
|
||||
if (current.active?.id !== activeId || current.active.entries?.[idx] !== entry) return
|
||||
if (current.active?.id !== activeId || current.active.entries?.length !== entryCount || current.active.entries?.[idx]?.id !== entryId) return
|
||||
update(s => {
|
||||
const activeEntry = s.active?.id === activeId ? s.active.entries?.[idx] : null
|
||||
// The sheet may outlive its workout or entry. Never apply its result to whatever later
|
||||
@@ -511,7 +515,7 @@ function ActiveWorkout() {
|
||||
// The sheet edits sets, reps, weight and warm-ups as well as the rule — so the rows are
|
||||
// rebuilt from the new config the way the session was, and only what you already logged
|
||||
// is kept in place (done warm-ups first, then done work sets, then the fresh remainder).
|
||||
const fresh = applyIntensifierPlan(applyPrescription(buildSets(s, full, { step }), plan, step), full)
|
||||
const fresh = applyIntensifierPlan(applyPrescription(buildSets(s, full, { step, useTarget: plan.kind === 'off' }), plan, step), full)
|
||||
const doneWarm = activeEntry.sets.filter(x => x.done && isWarmupRow(x))
|
||||
const doneWork = activeEntry.sets.filter(x => x.done && !isWarmupRow(x))
|
||||
const freshWarm = fresh.filter(isWarmupRow)
|
||||
@@ -577,13 +581,17 @@ function ActiveWorkout() {
|
||||
checked = e.sets[i].done
|
||||
if (e.sets[i].done) {
|
||||
beep(S.sound, 1040, 0.12); vibrate(30)
|
||||
const unitDone = unit.every(ui => (ui === idx ? e : A.entries[ui]).sets.every(x => x.done))
|
||||
// The unit that owns the ticked set — not the marked one. Since !92 the marker no longer
|
||||
// follows a finished exercise, and in list mode any exercise can be worked on, so judging
|
||||
// the marker's unit here declared the workout complete after one set elsewhere.
|
||||
const ownUnit = unitOf(units, idx)
|
||||
const unitDone = ownUnit.every(ui => (ui === idx ? e : A.entries[ui]).sets.every(x => x.done))
|
||||
if (unitDone) workoutDone = !nextUnfinishedUnit(A.entries, supersetUnits(A.entries), idx)
|
||||
if (e.sets.every(x => x.done)) {
|
||||
exJustDone = true
|
||||
const mx = bestWeightForEntry(e)
|
||||
e.topW = mx || null
|
||||
if (!s.active.backfill && mx > 0) { const cur = s.exWeights[e.id]; if (!cur || mx > cur.w) s.exWeights[e.id] = { w: mx, d: todayISO() } }
|
||||
// topW is captured now; exWeights only at the finish (doFinishWorkout), so a typo you
|
||||
// correct before finishing, or a discarded workout, never becomes the remembered best.
|
||||
e.topW = bestWeightForEntry(e) || null
|
||||
}
|
||||
}
|
||||
}, true)
|
||||
|
||||
@@ -219,7 +219,7 @@ describe('Workout set completion flow', () => {
|
||||
await toggleSet(0)
|
||||
|
||||
expect(mocks.S.active.entries[0].topW).toBe(60)
|
||||
expect(mocks.S.exWeights['plain-bench'].w).toBe(60)
|
||||
expect(mocks.S.exWeights['plain-bench']).toBeUndefined() // written at the finish, not while ticking
|
||||
expect(mocks.topWeightSheet).not.toHaveBeenCalled()
|
||||
expect(mocks.S.active.cur).toBe(0)
|
||||
expect(mocks.startRest).toHaveBeenCalledWith(90, expect.any(Number))
|
||||
@@ -903,6 +903,21 @@ describe('workout list view', () => {
|
||||
expect(mocks.startRest).toHaveBeenCalledWith(90, expect.any(Number))
|
||||
})
|
||||
|
||||
it('does not declare the workout complete after a set of a non-current exercise while sets remain', async () => {
|
||||
// The marker stays on the finished bench (!92); ticking the first of three row sets must
|
||||
// not open the completion sheet — the row's own unit still has two sets to go.
|
||||
await mount([
|
||||
exercise('plain-bench', [true], { asked: true }),
|
||||
exercise('plain-row', [false, false, false], { asked: true }),
|
||||
], 0, { workoutView: 'list' })
|
||||
|
||||
await toggleSet(1)
|
||||
|
||||
expect(mocks.S.active.entries[1].sets[0].done).toBe(true)
|
||||
expect(mocks.workoutCompleteSheet).not.toHaveBeenCalled()
|
||||
expect(mocks.startRest).toHaveBeenCalledWith(90, expect.any(Number))
|
||||
})
|
||||
|
||||
it('renders a superset as one grouped unit with its own unpair control', async () => {
|
||||
await mount([
|
||||
exercise('bench', [false], { sg: 'g1', asked: true }),
|
||||
|
||||
Reference in new issue
Block a user