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
fix(workout): open progression settings from guidance
Space_Hermes23b1b719a8a2
diff --git a/frontend/src/index.css b/frontend/src/index.cssindex a34845995..71efe1f8e 100644--- a/frontend/src/index.css+++ b/frontend/src/index.css@@ -631,8 +631,8 @@ h4.sec{.setextra .chip.add:disabled{opacity:.35}/* why the next target is what it is (issue #17) */.progline{- display:flex;align-items:flex-start;gap:7px;margin:6px 0 2px;- font-size:13px;line-height:1.38;color:var(--acc);+ width:100%;display:flex;align-items:flex-start;gap:7px;margin:6px 0 2px;padding:0;+ text-align:left;font-size:13px;line-height:1.38;color:var(--acc);}.progline.warn{color:var(--yellow)}.progline svg{flex:none;margin-top:2px}diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsxindex 860f03812..b645c92a5 100644--- a/frontend/src/views/Workout.jsx+++ b/frontend/src/views/Workout.jsx@@ -57,7 +57,7 @@ function Elapsed({ start }) {}/* ---------- one exercise block (reps: weight×reps · time: a held duration · cardio: duration+speed) ---------- */-function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemoveSet, onAddWarmup, onRemoveSetAt, onStartTimed, onPairPrev, onPairNext }) {+function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemoveSet, onAddWarmup, onRemoveSetAt, onStartTimed, onPairPrev, onPairNext, onProgressionSettings }) {const S = useStore(s => s.S)const update = useStore(s => s.update)const working = useUI(s => s.work)@@ -192,10 +192,11 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov</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>}- {guidance && <div className={'progline' + (plan.kind === 'deload' ? ' warn' : '')}>+ {guidance && <button type="button" className={'progline' + (plan.kind === 'deload' ? ' warn' : '')}+ aria-label={t('Open progression settings')} onClick={onProgressionSettings}><Icon name={plan.kind === 'up' ? 'arrowUp' : plan.kind === 'deload' ? 'arrowDown' : 'lightbulb'} /><span><strong>{t(guidance.policyLabel)}</strong> · {t(...guidance.why)}</span>- </div>}+ </button>}<div className="card" style={{ marginTop: 10, marginBottom: 0 }}>{/* the header carries the same eff3 sizing as the rows, or the labels drift off their columns */}<div className={'sethead' + (col3 ? ' eff3' : '')}><span className="n-sp" /><span className="w-sp">{col1.hd}</span>{col2 && <span className="r-sp">{col2.hd}</span>}{col3 && <span className="eff-sp">{col3.hd}</span>}{timed && <span className="ck-sp" />}<span className="ck-sp" /></div>@@ -337,6 +338,23 @@ function ActiveWorkout() {const onPairPrev = !isSuperset && cur > 0 ? () => pairAt(cur - 1, cur) : nullconst onPairNext = !isSuperset && cur < A.entries.length - 1 ? () => pairAt(cur, cur + 1) : null+ const openProgressionSettings = idx => {+ const state = useStore.getState().S+ const entry = state.active?.entries?.[idx]+ if (!entry) return+ const routine = state.routines.find(r => r.id === state.active.routineId)+ exConfigSheet(exOr(entry.id), entry.target, cfg => update(s => {+ const activeEntry = s.active?.entries?.[idx]+ if (!activeEntry) return+ const full = { ...cfg, id: activeEntry.id }+ const activeRoutine = s.routines.find(r => r.id === s.active.routineId)+ const plan = nextPrescription(s, full, activeRoutine)+ activeEntry.target = { ...cfg }+ activeEntry.plan = plan+ activeEntry.sets = applyPrescription(activeEntry.sets, plan, defaultIncrement(activeEntry.id, s.unit))+ }), null, routine)+ }+// Remove a whole exercise from the session. The confirmation always asks first; in a// superset it asks WHICH exercise of the group to remove.const removeExercise = removeActiveExercise@@ -498,11 +516,11 @@ function ActiveWorkout() {{unit.map((idx, k) => <div key={idx} ref={el => { exRefs.current[idx] = el }} className="ss-ex" data-exidx={idx}>{k > 0 && <div className="ss-amp">+</div>}<ExerciseBlock entryIdx={idx} compact- onToggle={i => toggle(idx, i)} onField={(i, f, v) => setField(idx, i, f, v)} onAddSet={() => addSet(idx)} onRemoveSet={() => removeSet(idx)} onAddWarmup={() => addWarmup(idx)} onRemoveSetAt={i => removeSetAt(idx, i)} onStartTimed={i => startTimed(idx, i)} />+ onToggle={i => toggle(idx, i)} onField={(i, f, v) => setField(idx, i, f, v)} onAddSet={() => addSet(idx)} onRemoveSet={() => removeSet(idx)} onAddWarmup={() => addWarmup(idx)} onRemoveSetAt={i => removeSetAt(idx, i)} onStartTimed={i => startTimed(idx, i)} onProgressionSettings={() => openProgressionSettings(idx)} /></div>)}</div>) : (- <ExerciseBlock entryIdx={cur} onToggle={i => toggle(cur, i)} onField={(i, f, v) => setField(cur, i, f, v)} onAddSet={() => addSet(cur)} onRemoveSet={() => removeSet(cur)} onAddWarmup={() => addWarmup(cur)} onRemoveSetAt={i => removeSetAt(cur, i)} onStartTimed={i => startTimed(cur, i)} onPairPrev={onPairPrev} onPairNext={onPairNext} />+ <ExerciseBlock entryIdx={cur} onToggle={i => toggle(cur, i)} onField={(i, f, v) => setField(cur, i, f, v)} onAddSet={() => addSet(cur)} onRemoveSet={() => removeSet(cur)} onAddWarmup={() => addWarmup(cur)} onRemoveSetAt={i => removeSetAt(cur, i)} onStartTimed={i => startTimed(cur, i)} onPairPrev={onPairPrev} onPairNext={onPairNext} onProgressionSettings={() => openProgressionSettings(cur)} />)}</> : <div className="empty"><div className="ico"><Icon name="shuffle" /></div>{t('Freestyle workout — add your first exercise.')}</div>}diff --git a/frontend/src/views/Workout.test.jsx b/frontend/src/views/Workout.test.jsxindex bc1c37a6a..7f8286fb9 100644--- a/frontend/src/views/Workout.test.jsx+++ b/frontend/src/views/Workout.test.jsx@@ -9,6 +9,7 @@ const mocks = vi.hoisted(() => {S: null,startRest: vi.fn(),stopRest: vi.fn(),+ exConfigSheet: vi.fn(),topWeightSheet: vi.fn(),}state.storeSnapshot = () => ({@@ -40,7 +41,7 @@ vi.mock('react-router-dom', () => ({ useNavigate: () => () => {} }))vi.mock('../sheets.jsx', () => ({startFlow: vi.fn(),exercisePicker: vi.fn(),- exConfigSheet: vi.fn(),+ exConfigSheet: mocks.exConfigSheet,exerciseDetailSheet: vi.fn(),topWeightSheet: mocks.topWeightSheet,finishWorkout: vi.fn(),@@ -73,10 +74,14 @@ function exercise(id, sets, extra = {}) {}function workout(entries, cur = 0) {+ const routine = {+ id: 'routine-1', name: 'Test routine', prog: 'linear',+ ex: entries.map(entry => ({ id: entry.id, ...entry.target })),+ }return {unit: 'kg', restSec: 90, sound: false, effort: 'none', gifSize: 'full',- workouts: [], exWeights: {}, routines: [],- active: { id: 'active', name: 'Test workout', start: Date.now(), cur, entries },+ workouts: [], exWeights: {}, routines: [routine],+ active: { id: 'active', routineId: routine.id, name: 'Test workout', start: Date.now(), cur, entries },}}@@ -112,6 +117,13 @@ async function toggleSet(index) {await act(async () => { checkbox.dispatchEvent(new dom.Event('click', { bubbles: true })) })}+async function pressProgression(index = 0) {+ const button = container.querySelectorAll('.progline')[index]+ expect(button).toBeTruthy()+ await act(async () => { button.dispatchEvent(new dom.Event('click', { bubbles: true })) })+ return button+}+beforeEach(() => {vi.clearAllMocks()})@@ -169,6 +181,90 @@ describe('progression guidance', () => {expect(container.querySelector('.progline')?.textContent).toContain('Linear progression · Every rep last time — 2.5 kg more.')})++ it('is a keyboard-accessible button that opens settings for the pressed grouped entry', async () => {+ const plan = {+ policy: 'linear', kind: 'up', weight: 62.5,+ why: ['Every rep last time — {0} {1} more.', 2.5, 'kg'],+ }+ const first = exercise('plain-bench', [false], { sg: 'group', plan })+ const second = exercise('plain-bench', [false], {+ sg: 'group', plan, target: { mode: 'reps', reps: 8, weight: 80, bodyweight: false },+ })+ await mount([first, second])+ const firstBefore = JSON.stringify(mocks.S.active.entries[0])++ const button = await pressProgression(1)++ expect(button.tagName).toBe('BUTTON')+ expect(button.getAttribute('type')).toBe('button')+ expect(button.getAttribute('aria-label')).toBe('Open progression settings')+ expect(mocks.exConfigSheet).toHaveBeenCalledOnce()+ expect(mocks.exConfigSheet.mock.calls[0][1]).toBe(second.target)+ expect(mocks.exConfigSheet.mock.calls[0][4]).toBe(mocks.S.routines[0])++ mocks.exConfigSheet.mock.calls[0][2]({ ...second.target, prog: 'double', repsMin: 6 })+ expect(JSON.stringify(mocks.S.active.entries[0])).toBe(firstBefore)+ expect(mocks.S.active.entries[1].target.prog).toBe('double')+ expect(mocks.S.active.cur).toBe(0)+ })++ it('leaves the active entry unchanged when progression settings are cancelled', async () => {+ const entry = exercise('plain-bench', [true, false], {+ plan: {+ policy: 'linear', kind: 'up', weight: 62.5,+ why: ['Every rep last time — {0} {1} more.', 2.5, 'kg'],+ },+ })+ await mount([entry])+ const before = JSON.stringify(mocks.S.active.entries[0])++ await pressProgression()++ expect(JSON.stringify(mocks.S.active.entries[0])).toBe(before)+ })++ it('saves the active policy, preserves completed rows, and refreshes guidance immediately', async () => {+ const entry = exercise('plain-bench', [true, false], {+ plan: {+ policy: 'linear', kind: 'up', weight: 62.5,+ why: ['Every rep last time — {0} {1} more.', 2.5, 'kg'],+ },+ })+ await mount([entry])+ mocks.S.workouts = [{+ d: '2026-08-27',+ entries: [{+ id: entry.id,+ target: { sets: 2, reps: 5, weight: 60 },+ sets: [{ w: 60, r: 5, done: true }, { w: 60, r: 5, done: true }],+ }],+ }]+ const completed = mocks.S.active.entries[0].sets[0]+ await pressProgression()+ const save = mocks.exConfigSheet.mock.calls[0][2]++ await act(async () => {+ save({ ...entry.target, prog: 'double', repsMin: 3 })+ root.render(React.createElement(Workout))+ })++ const saved = mocks.S.active.entries[0]+ expect(saved.target.prog).toBe('double')+ expect(saved.sets[0]).toBe(completed)+ expect(saved.sets[0]).toEqual({ w: 60, r: 5, done: true })+ expect(saved.sets[1]).toEqual({ w: 62.5, r: 3, done: false })+ expect(container.querySelector('.progline')?.textContent)+ .toContain('Double progression · Top of the rep range in every set — 2.5 kg more, back to 3 reps.')++ const persisted = JSON.parse(JSON.stringify(mocks.S))+ await unmount()+ mocks.S = persisted+ installDom()+ await act(async () => { root.render(React.createElement(Workout)) })+ expect(container.querySelector('.progline')?.textContent)+ .toContain('Double progression · Top of the rep range in every set — 2.5 kg more, back to 3 reps.')+ })})describe('superset flow survives an exercise being removed mid-session', () => {