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
improved RIR edit handling
Sebastian Gab95bacaa1be
diff --git a/frontend/src/index.css b/frontend/src/index.cssindex c9cbf4057..5a478b152 100644--- a/frontend/src/index.css+++ b/frontend/src/index.css@@ -662,14 +662,36 @@ h4.sec{}.effcell:active{transform:scale(.94)}.effcell.is-empty{color:var(--label-2);font-weight:500;font-size:12px;letter-spacing:.02em}+/* a logged rating becomes a −/value/+ stepper, tinted by its effort band: the band colour+ fills the cell at low opacity (set inline via color-mix), borders it, and colours the value.+ the +/− buttons step 0.5 on the profile's scale; the value opens the picker. it carries the+ same column flex as the plain .effcell so the row does not jump when a rating is added. */+.setrow .effcell-stp,.setrow.eff3 .effcell-stp{+ height:44px;border-radius:10px;border:1.5px solid transparent;+ transition:background var(--fast),border-color var(--fast);+}+.effcell-stp button{color:inherit}+.effcell-stp>button[aria-label="Decrease"],+.effcell-stp>button[aria-label="Increase"]{width:26px;height:44px;font-size:15px;opacity:.85}+.effcell-stp .val{+ flex:1;min-width:0;display:flex;align-items:center;justify-content:center;+ font-size:15px;font-weight:600;letter-spacing:-.01em;+ font-variant-numeric:tabular-nums;line-height:1;align-self:stretch;color:inherit;+}+.effcell-stp .val:active{background:var(--surface-3)}/* the effort cell needs less room now (one short value, no +/- buttons), so weight/reps keepmore of the row on narrow phones than they did when three steppers had to share it */+.setrow .effcell-stp,.setrow.eff3 .effcell-stp{flex:.8 1 0;min-width:0}+.setrow.eff3 .effcell-stp{flex:.7 1 0}.setrow.eff3,.sethead.eff3{gap:6px}.setrow.eff3 .stp.w,.sethead.eff3 .w-sp{flex:1.4}.setrow.eff3 .stp.r,.sethead.eff3 .r-sp{flex:1.1}.setrow.eff3 .effcell,.sethead.eff3 .eff-sp{flex:.7 1 0}.setrow.eff3 .stp.w button,.setrow.eff3 .stp.r button{width:26px}.setrow.eff3 .stp .num{font-size:14px}+.setrow.eff3 .effcell-stp>button[aria-label="Decrease"],+.setrow.eff3 .effcell-stp>button[aria-label="Increase"]{width:22px}+.setrow.eff3 .effcell-stp .val{font-size:14px}/* effort quick picker sheet: colour-coded preset buttons, hardest (purple) first */.effpick{display:grid;grid-template-columns:repeat(2,1fr);gap:9px;margin-bottom:16px}.effpick-b{@@ -683,20 +705,34 @@ h4.sec{.effpick-b.on{background:color-mix(in srgb,var(--bc) 16%,var(--surface));border-color:var(--bc)}.effpick-n{font-size:20px;font-weight:700;color:var(--bc);line-height:1;font-variant-numeric:tabular-nums}.effpick-f{font-size:12px;color:var(--label-2);line-height:1.25}-/* the free field sits as a full-width row the same size as a preset button: its label on the- left, a large right-aligned input on the right, same padding and radius as .effpick-b */+/* the free field sits as a full-width row the same size as a preset button: its "Exact RIR"+ label on the left, a −/value/+ group in the middle, and the scale name on the right, same+ padding and radius as .effpick-b. the whole row borders in the current band colour. */.effpick-free{- display:flex;align-items:center;justify-content:space-between;gap:12px;- padding:12px 14px;border-radius:13px;margin-top:2px;+ display:flex;align-items:center;justify-content:space-between;gap:10px;+ padding:10px 14px;border-radius:13px;margin-top:2px;background:var(--surface);border:1.5px solid var(--sep-op);+ transition:border-color var(--fast);+}+.effpick-free-l{font-size:14px;color:var(--label-2);flex:none}+.effpick-free-unit{font-size:13px;font-weight:600;color:var(--label-3);flex:none}+/* the −/value/+ group: a rounded surface holding a big tappable number between two step+ buttons. tinted (color:inherit) to the band colour when a value is set. */+.effpick-step{+ display:flex;align-items:center;gap:2px;flex:none;+ background:var(--surface-2);border-radius:10px;overflow:hidden;+}+.effpick-step button{+ width:38px;height:40px;flex:none;color:currentColor;font-size:16px;--icon-stroke:2.2;+ display:flex;align-items:center;justify-content:center;transition:background var(--fast);}-.effpick-free-l{font-size:14px;color:var(--label-2)}+.effpick-step button:active{background:var(--surface-3)}/* the `.num` base styling (transparent bg, no border) is scoped to `.stp .num`; this input is- not in a stepper, so it must set its own or the browser paints a native white field. */+ not in a `.stp`, so it must set its own or the browser paints a native white field. */.effpick-free-in.num{- flex:none;width:90px;text-align:right;padding:0;- background:none;border:none;outline:none;- font-size:20px;font-weight:700;color:var(--label);+ flex:none;width:64px;text-align:center;padding:0;height:40px;+ background:none;border:none;outline:none;color:currentColor;+ font-size:20px;font-weight:700;font-variant-numeric:tabular-nums;-moz-appearance:textfield;appearance:textfield;}.effpick-free-in.num::-webkit-inner-spin-button{display:none}diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsxindex e47d2147f..0f5fcf45b 100644--- a/frontend/src/sheets.jsx+++ b/frontend/src/sheets.jsx@@ -4,7 +4,7 @@ import { useUI } from './store/useUI.js'import { EXDB, EXIDX, BODYPARTS, isCardio, isBodyweightEq, allExercises, equipmentOf, smOf, matchExercise, exOr } from './lib/exercises.js'import { activeProfile, exAvailable, ALL_EQUIPMENT, newProfile } from './lib/equipment.js'import { fmtDate, fmtNum, fmtVol, fmtDur, durPart, todayISO, isoOf, uid, exCount, DAYN, DAYS, weekOrder, weekStartOf, weekDayOffset, MONTHS_LONG, ACCENTS } from './lib/format.js'-import { lastEntryFor, bestWeightFor, buildSets, effectiveRoutineId, workoutVolume, setsDone, setsDoneActive, lastBW, supersetUnits, unitOf, setLabel, defaultConfig, cleanupSg, modeOf, effortOf, EFFORT, capEffort, isBw, isPerSide, sideReps, workSetsDone, applyIntensifierPlan, MAX_PLANNED_WARMUPS, NOTE_MAX } from './lib/history.js'+import { lastEntryFor, bestWeightFor, buildSets, effectiveRoutineId, workoutVolume, setsDone, setsDoneActive, lastBW, supersetUnits, unitOf, setLabel, defaultConfig, cleanupSg, modeOf, effortOf, EFFORT, capEffort, stepEffort, isBw, isPerSide, sideReps, workSetsDone, applyIntensifierPlan, MAX_PLANNED_WARMUPS, NOTE_MAX } from './lib/history.js'import { usesBar, barWeightFor, defaultBarWeight, hasBarOverride } from './lib/bar.js'import { toScale, rirOf, EFFORT_PRESETS, effortColor } from './lib/effort.js'import { beep, vibrate } from './lib/sound.js'@@ -1205,6 +1205,9 @@ function EffortPicker({ kind, value, onPick, close }) {// RIR so the highlighted preset is right on either scale, and so a typed RPE colours the// same as the RIR it equals.const curRir = rirOf(kind === 'rpe' ? { rpe: v } : { rir: v })+ // The band colour for the value currently on the field, so the exact-value row is tinted the+ // same way the presets and the workout row cell are — null (nothing typed) stays neutral.+ const curColor = effortColor(curRir)const commit = nv => { close(); onPick(nv) }const pick = rir => commit(toScale(kind, rir))return <>@@ -1225,12 +1228,20 @@ function EffortPicker({ kind, value, onPick, close }) {</div>{/* The free field keeps the flexibility the stepper had: a value between two presets, inthe profile's own scale, capped to the top of it (there is no RPE 12). Sized like a- preset so it reads as the seventh option — "or type your own" — not an afterthought. */}- <label className="effpick-free">+ preset so it reads as the seventh option — "or type your own" — not an afterthought.+ A −/+ pair flanks the number for 0.5-step nudging without leaving the sheet, coloured+ by the band the current value falls in (the same colour the presets and the row cell+ use); tapping the number itself still types an exact value. */}+ <div className="effpick-free" style={curColor ? { borderColor: curColor } : undefined}><span className="effpick-free-l">{t('Exact {0}', EFFORT[kind].hd)}</span>- <NumberField className="effpick-free-in" decimal nullable value={v ?? ''}- placeholder={EFFORT[kind].hd} onChange={nv => set(capEffort(kind, nv))} />- </label>+ <div className="effpick-step" style={curColor ? { color: curColor } : undefined}>+ <button aria-label="Decrease" onClick={() => set(stepEffort(kind, v, -1))}><Icon name="minus" /></button>+ <NumberField className="effpick-free-in" decimal nullable value={v ?? ''}+ placeholder={EFFORT[kind].hd} onChange={nv => set(capEffort(kind, nv))} />+ <button aria-label="Increase" onClick={() => set(stepEffort(kind, v, 1))}><Icon name="plus" /></button>+ </div>+ <span className="effpick-free-unit">{EFFORT[kind].hd}</span>+ </div><div style={{ height: 10 }} />{v != null && <Button variant="ghost" className="dim" icon="xmark" onClick={() => commit(null)}>{t('Clear rating')}</Button>}<div style={{ height: 4 }} />diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsxindex 15159f0ae..617feb638 100644--- a/frontend/src/views/Workout.jsx+++ b/frontend/src/views/Workout.jsx@@ -4,7 +4,7 @@ import { useStore } from '../store/useStore.js'import { useUI } from '../store/useUI.js'import { exOr } from '../lib/exercises.js'import { usesBar, barWeightFor, plateSplit } from '../lib/bar.js'-import { effectiveRoutine, lastEntryFor, bestWeightFor, buildSets, freestyleConfig, defaultConfig, setsDoneActive, supersetUnits, unitOf, setLabel, modeOf, isBw, isPerSide, sideReps, repStep, EFFORT, effortOf, cascadeWeight, insertWarmupRow, removeRowAt, pairAdjacent, unpairSuperset, cleanupSg, applyIntensifierPlan, pinnedNoteFor, exNoteFor } from '../lib/history.js'+import { effectiveRoutine, lastEntryFor, bestWeightFor, buildSets, freestyleConfig, defaultConfig, setsDoneActive, supersetUnits, unitOf, setLabel, modeOf, isBw, isPerSide, sideReps, repStep, EFFORT, effortOf, stepEffort, cascadeWeight, insertWarmupRow, removeRowAt, pairAdjacent, unpairSuperset, cleanupSg, applyIntensifierPlan, pinnedNoteFor, exNoteFor } from '../lib/history.js'import { fmtNum, fmtDate, todayISO, exCount, DAYN } from '../lib/format.js'import { beep, vibrate } from '../lib/sound.js'import { t, exerciseNameFor } from '../lib/i18n.js'@@ -160,12 +160,24 @@ 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)- return <button className={'effcell' + (v == null ? ' is-empty' : '')}- style={color ? { color, borderColor: color } : undefined}- aria-label={col.hd}- onClick={() => effortPickerSheet(col.eff, v, nv => onField(i, col.f, nv))}>- {v == null ? col.hd : fmtNum(v)}- </button>+ const open = () => effortPickerSheet(col.eff, v, nv => onField(i, col.f, nv))+ // Empty: a plain neutral button that opens the picker — one tap to log a rating.+ if (v == null) return (+ <button className="effcell is-empty" aria-label={col.hd} onClick={open}>{col.hd}</button>+ )+ // Logged: a −/value/+ stepper tinted by the band colour, with the band tinting the whole+ // cell at low opacity (colour-mix). +/− step 0.5 on the profile's scale; the value button+ // still opens the picker. stepEffort walks the profile's own scale (RIR or RPE) and clears+ // the cell when stepped off the floor.+ const step = dir => onField(i, col.f, stepEffort(col.eff, v, dir))+ return (+ <div className="stp effcell-stp"+ style={color ? { color, borderColor: color, background: `color-mix(in srgb, ${color} 20%, var(--surface-2))` } : undefined}>+ <button aria-label="Decrease" onClick={() => step(-1)}><Icon name="minus" /></button>+ <button className="val" aria-label={col.hd} onClick={open}>{fmtNum(v)}</button>+ <button aria-label="Increase" onClick={() => step(1)}><Icon name="plus" /></button>+ </div>+ )}// A smaller stepper for a drop's weight/reps or a burst's reps — editing what the plan (or a// live "+ Drop"/"+ Burst" tap) already put on the row, not typing into a fresh field.diff --git a/frontend/src/views/Workout.test.jsx b/frontend/src/views/Workout.test.jsxindex 02e2e6298..c05a664f9 100644--- a/frontend/src/views/Workout.test.jsx+++ b/frontend/src/views/Workout.test.jsx@@ -546,7 +546,14 @@ describe('effort cell (colour-coded RIR/RPE quick picker)', () => {target: { mode: 'reps', reps: 5, weight: 60, bodyweight: false },sets: rirs.map(rir => ({ w: 60, r: 5, done: false, ...(rir == null ? {} : { rir }) })),})- const effCells = () => [...container.querySelectorAll('.effcell')]+ // A cell is one of two shapes: an empty `.effcell` button (label, opens picker) or, once a+ // rating is logged, a `.effcell-stp` −/value/+ group. `.effcell-list` returns the outer+ // element of each (carrying the colour on the logged one); `effCells` normalises them to the+ // value-bearing, picker-opening element so the existing assertions read the same either way:+ // for the empty button that is the button itself, for the stepper it is the `.val` button.+ const effCellList = () => [...container.querySelectorAll('.effcell,.effcell-stp')]+ const effCells = () => effCellList().map(el =>+ el.classList.contains('effcell-stp') ? el.querySelector('.val') : el)async function mountEffort(rirs, scale = 'rir') {mocks.S = workout([effExercise(rirs)])@@ -580,13 +587,16 @@ describe('effort cell (colour-coded RIR/RPE quick picker)', () => {it('shows a logged rating as its number, tinted by the band it falls in', async () => {await mountEffort([0, 2, null])const cells = effCells()+ const outer = effCellList()expect(cells[0].textContent).toBe('0')- expect(cells[0].className).not.toContain('is-empty')- // 0 RIR = to failure = purple; 2 RIR = yellow (the colours effortColor assigns)- expect(cells[0].getAttribute('style')).toContain('--purple')+ expect(outer[0].className).toContain('effcell-stp') // logged: the stepper, not the label+ // 0 RIR = to failure = purple; 2 RIR = yellow (the colours effortColor assigns) — the+ // colour rides the outer stepper (border + tinted background), not the inner value button+ expect(outer[0].getAttribute('style')).toContain('--purple')expect(cells[1].textContent).toBe('2')- expect(cells[1].getAttribute('style')).toContain('--yellow')+ expect(outer[1].getAttribute('style')).toContain('--yellow')expect(cells[2].textContent).toBe('RIR') // the unrated one stays a label+ expect(outer[2].className).toContain('is-empty')})it('displays a logged value on the profile scale — RIR 2 reads as RPE 8', async () => {@@ -599,10 +609,9 @@ describe('effort cell (colour-coded RIR/RPE quick picker)', () => {mocks.S.effort = 'rpe'installDom()await act(async () => { root.render(React.createElement(Workout)) })- const cell = effCells()[0]- expect(cell.textContent).toBe('8')+ expect(effCells()[0].textContent).toBe('8')// RPE 8 == RIR 2 == yellow: the colour is the effort, independent of the scale shown- expect(cell.getAttribute('style')).toContain('--yellow')+ expect(effCellList()[0].getAttribute('style')).toContain('--yellow')})it('opens the picker for the set on tap, passing scale, current value and a writer', async () => {@@ -620,6 +629,37 @@ describe('effort cell (colour-coded RIR/RPE quick picker)', () => {onPick(null)expect('rir' in mocks.S.active.entries[0].sets[0]).toBe(false)})++ // The mock store is a plain snapshot with no subscription, so a click updates mocks.S but+ // does not re-render on its own; each step is checked from its own mount rather than chained.+ const clickStep = async label => {+ await act(async () => {+ effCellList()[0].querySelector(`button[aria-label="${label}"]`)+ .dispatchEvent(new dom.Event('click', { bubbles: true }))+ })+ }++ it('steps a logged rating up 0.5 on the scale with the + button, not through the picker', async () => {+ await mountEffort([2])+ expect(effCellList()[0].querySelectorAll('button[aria-label="Increase"],button[aria-label="Decrease"]')).toHaveLength(2)+ await clickStep('Increase')+ expect(mocks.S.active.entries[0].sets[0].rir).toBe(2.5)+ expect(mocks.effortPickerSheet).not.toHaveBeenCalled()+ })++ it('steps a logged rating down 0.5 with the − button', async () => {+ await mountEffort([2])+ await clickStep('Decrease')+ expect(mocks.S.active.entries[0].sets[0].rir).toBe(1.5)+ })++ it('clears the rating when stepped down off the floor', async () => {+ // RIR 0 is the bottom of the scale — one more − is a mistap-undo, dropping the key rather+ // than sticking at 0 (which reads as "went to failure")+ await mountEffort([0])+ await clickStep('Decrease')+ expect('rir' in mocks.S.active.entries[0].sets[0]).toBe(false)+ })})describe('superset flow survives an exercise being removed mid-session', () => {