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.

Merge !84: fix: use exercise weight step for workout controls

Duarte Santosb301b8c81d26
diff --cc frontend/src/views/Workout.jsx
index 7206b16f9,e571a4207..e9f81e6b2
--- a/frontend/src/views/Workout.jsx
+++ b/frontend/src/views/Workout.jsx
@@@ -11,10 -10,10 +11,10 @@@ import { t, exerciseNameFor } from '../
import { api } from '../lib/api.js'
import { insertionIndexAfterCurrentUnit, nextUnfinishedUnit, setProgressHighWater, supersetFlowStep, restAfterSet, restOnRecheck, restSecFor } from '../lib/supersetFlow.js'
import Media from '../components/Media.jsx'
-import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, topWeightSheet, finishWorkout, workoutCompleteSheet, confirmSheet, exerciseNoteSheet, sessionNoteSheet, swapActiveWorkoutExercise } from '../sheets.jsx'
+import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, topWeightSheet, finishWorkout, workoutCompleteSheet, confirmSheet, exerciseNoteSheet, sessionNoteSheet, swapActiveWorkoutExercise, barWeightSheet } from '../sheets.jsx'
import Icon from '../components/Icon.jsx'
import { Button, Check, NumberField } from '../components/ui.jsx'
- import { nextPrescription, applyPrescription, defaultIncrement } from '../lib/progression.js'
+ import { nextPrescription, applyPrescription, defaultIncrement, weightIncrement, stepWeight } from '../lib/progression.js'
import { progressionGuidance } from '../lib/progression-copy.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'
@@@ -139,15 -139,9 +140,16 @@@ function ExerciseBlock({ entryIdx, comp
// The effort column walks its own scale — see stepEffort. Weight and reps step up from 0
// with no ceiling, as they always did.
const bump = (s, i, col, dir) => {
- if (col.eff) return onField(i, col.f, stepEffort(col.eff, s[col.f], dir))
- if (mode === 'reps' && col.f === 'w') return onField(i, col.f, stepWeight(s[col.f], col.step, dir))
- onField(i, col.f, Math.max(0, Math.round(((s[col.f] || 0) + dir * col.step) * 100) / 100))
+ // Read the current value directly from the store rather than from the render-time snapshot.
+ // In a superset both ExerciseBlock instances share the same store subscription, so when one
+ // member's field changes the partner re-renders too, replacing the closure's `s` reference
+ // with a fresh clone before the next tap fires. Reading from the store avoids that stale-
+ // closure problem entirely and keeps every tap operating on the real current value.
+ const fresh = useStore.getState().S.active?.entries[entryIdx]?.sets[i]
+ const cur = fresh ? fresh[col.f] : s[col.f]
+ if (col.eff) return onField(i, col.f, stepEffort(col.eff, cur, dir))
++ if (mode === 'reps' && col.f === 'w') return onField(i, col.f, stepWeight(cur, col.step, dir))
+ onField(i, col.f, Math.max(0, Math.round(((cur || 0) + dir * col.step) * 100) / 100))
}
// Uses the shared stepper markup so a set row picks up the same control styling
// as every other +/- field in the app.