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.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
feat/auto-end set when setting RIR/RPE
Sebastian G085dd25150c9
diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsxindex a9f8a09b9..7937b308b 100644--- a/frontend/src/views/Workout.jsx+++ b/frontend/src/views/Workout.jsx@@ -218,7 +218,18 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemovconst v = s[col.f] ?? nullconst rir = col.eff === 'rpe' ? (v == null ? null : 10 - v) : vconst color = effortColor(rir)- const open = () => effortPickerSheet(col.eff, v, nv => onField(i, col.f, nv))+ // Logging an effort concludes the set (issue #64): once you rate how a set felt, it is done —+ // so picking a value also ticks the set and starts the rest timer, sparing the redundant+ // second confirmation. Clearing a rating (null) never un-ticks: ending a set stays a manual+ // undo via the checkmark. Reads `done` live from the store, since a superset re-render can+ // stale the closure's `s`, and only ticks a set that is not already done.+ const pickEffort = nv => {+ onField(i, col.f, nv)+ if (nv == null) return+ const fresh = useStore.getState().S.active?.entries[entryIdx]?.sets[i]+ if (fresh && !fresh.done) onToggle(i)+ }+ const open = () => effortPickerSheet(col.eff, v, pickEffort)if (v == null) return (<button className="effcell is-empty" aria-label={col.hd} onClick={open}>{col.hd}</button>)diff --git a/frontend/src/views/Workout.test.jsx b/frontend/src/views/Workout.test.jsxindex 140d4ca18..1c3dd81dc 100644--- a/frontend/src/views/Workout.test.jsx+++ b/frontend/src/views/Workout.test.jsx@@ -1148,3 +1148,52 @@ describe('workout controls: the more menu and the set menu', () => {expect(container.querySelector('.setrow .stp.plain .num')).toBeTruthy()})})++// Rating a set's effort concludes it (issue #64): picking an RIR/RPE value ticks the set and+// starts the rest timer, so you don't confirm a finished set twice.+describe('effort rating auto-ends the set', () => {+ // Open the effort picker for set `index` and return the onPick callback the cell handed it.+ async function openEffortPicker(index = 0) {+ const cell = container.querySelectorAll('.setrow .effcell.is-empty, .setrow .effcell-stp .val')[index]+ expect(cell).toBeTruthy()+ await act(async () => { cell.dispatchEvent(new dom.Event('click', { bubbles: true })) })+ const call = mocks.effortPickerSheet.mock.calls.at(-1)+ expect(call?.[2]).toEqual(expect.any(Function))+ return call[2]+ }++ it('ticks the set and starts the rest timer when a rating is picked', async () => {+ await mount([exercise('plain-bench', [false, false])], 0, { effort: 'rir' })+ const onPick = await openEffortPicker(0)++ await act(async () => { onPick(2) })++ expect(mocks.S.active.entries[0].sets[0].rir).toBe(2)+ expect(mocks.S.active.entries[0].sets[0].done).toBe(true)+ expect(mocks.startRest).toHaveBeenCalledWith(90, expect.any(Number))+ })++ it('does not re-toggle a set that is already done — a rating change leaves it done', async () => {+ await mount([exercise('plain-bench', [true, false])], 0, { effort: 'rir' })+ const onPick = await openEffortPicker(0)++ await act(async () => { onPick(1) })++ expect(mocks.S.active.entries[0].sets[0].rir).toBe(1)+ expect(mocks.S.active.entries[0].sets[0].done).toBe(true) // stays done, not toggled off+ // No rest timer for a re-rate of already-finished work (would have been the "recheck" path).+ expect(mocks.startRest).not.toHaveBeenCalled()+ })++ it('clearing a rating never un-ticks the set — ending a set stays a manual undo', async () => {+ await mount([exercise('plain-bench', [false]), exercise('next', [false])], 0, { effort: 'rir' })+ const onPick = await openEffortPicker(0)++ await act(async () => { onPick(3) }) // rate → done+ expect(mocks.S.active.entries[0].sets[0].done).toBe(true)++ await act(async () => { onPick(null) }) // clear the number+ expect(mocks.S.active.entries[0].sets[0].rir).toBeUndefined()+ expect(mocks.S.active.entries[0].sets[0].done).toBe(true) // still done+ })+})