From 6714b16e6ac8df20cd47ba56fc9ddab426bd16f4 Mon Sep 17 00:00:00 2001 From: Octavio Di Marco Date: Tue, 28 Jul 2026 17:10:03 +0200 Subject: [PATCH 1/5] Add optional RIR (reps in reserve) to reps-mode sets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a third stepper column, next to weight and reps, for logging RIR on strength sets — not shown for cardio or timed holds, where it has no meaning. RIR is purely a logging/display addition: it never touches the progression engine (linear/Greyskull/double progression only ever read weight/reps/seconds), and it round-trips through the existing whole-object backup export/import with no code changes there. The set object only gains an `rir` key once the user actually logs a value (buildSets/addSet don't pre-seed it), matching how missing fields already read as undefined elsewhere in the store — no schema version or migration needed for existing logged workouts. Fitting a third stepper next to weight+reps on narrow phones needed the same treatment as the exercise-config sheet's three-steppers-in-a-row (.cfgrow): narrower buttons and a smaller value font just for rows that show RIR, verified by hand at 360-390px with edge-case values (2-3 digit weight, double-digit reps, decimal RIR together). "Last time" summaries now append "(RIR n)" when a set has one logged, covered by new setLabel tests including the rir: 0 case (0 is a valid RIR and must not be treated as absent). --- frontend/src/index.css | 13 +++++++++++++ frontend/src/lib/history.js | 2 +- frontend/src/lib/history.test.js | 6 ++++++ frontend/src/views/Workout.jsx | 7 +++++-- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/frontend/src/index.css b/frontend/src/index.css index 386bd62..7cec074 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -539,6 +539,7 @@ h4.sec{ .sethead .n-sp{width:24px;flex:none} .sethead .w-sp{flex:1.4;text-align:center} .sethead .r-sp{flex:1;text-align:center} +.sethead .rir-sp{flex:1.1;text-align:center} .sethead .ck-sp{width:30px;flex:none} .setrow{display:flex;align-items:center;gap:8px;padding:7px 0;position:relative} .setrow+.setrow::before{ @@ -551,7 +552,19 @@ h4.sec{ } .setrow .stp.w{flex:1.4;min-width:0} .setrow .stp.r{flex:1;min-width:0} +.setrow .stp.rir{flex:1.1;min-width:0} .setrow .stp button{width:32px;height:40px} +/* a 3rd stepper (RIR) needs narrower buttons and a tighter row gap to fit next to weight+reps + on narrow phones, same technique as the exercise-config sheet's three-steppers-in-a-row + (.cfgrow below) — RIR's own value is short ("1.5") so its buttons shrink the most, weight/reps + just enough to make room since their values ("82.5", "12") need more of what's left. */ +.setrow.rir3{gap:6px} +.setrow.rir3 .stp.w{flex:1.2} +.setrow.rir3 .stp.r{flex:1} +.setrow.rir3 .stp.rir{flex:.85} +.setrow.rir3 .stp button{width:23px} +.setrow.rir3 .stp.rir button{width:20px} +.setrow.rir3 .stp .num{font-size:14px} .setrow.done .n{background:var(--acc);color:var(--on-acc)} .setrow.done{opacity:.45} /* why the next target is what it is (issue #17) */ diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.js index e9d7739..65e541e 100644 --- a/frontend/src/lib/history.js +++ b/frontend/src/lib/history.js @@ -29,7 +29,7 @@ export function setLabel(id, s, cfg) { const mode = modeOf(cfg || { id }) if (mode === 'cardio') return `${s.min || 0} min @ ${fmtNum(s.speed || 0)} km/h` if (mode === 'time') return fmtSec(s.sec) + (s.w > 0 ? ` · ${fmtNum(s.w)}` : '') - return `${fmtNum(s.w || 0)}×${s.r || 0}` + return `${fmtNum(s.w || 0)}×${s.r || 0}` + (s.rir != null ? ` (RIR ${fmtNum(s.rir)})` : '') } // Default config for a freshly added exercise. export function defaultConfig(id, mode) { diff --git a/frontend/src/lib/history.test.js b/frontend/src/lib/history.test.js index 19d3944..ec05d9a 100644 --- a/frontend/src/lib/history.test.js +++ b/frontend/src/lib/history.test.js @@ -63,6 +63,12 @@ describe('setLabel', () => { expect(setLabel(LIFT, { w: 0, r: 0 })).toBe('0×0') expect(setLabel(CARDIO, {})).toBe('0 min @ 0 km/h') }) + + it('appends RIR when present, including a valid 0', () => { + expect(setLabel(LIFT, { w: 60, r: 10, rir: 2 })).toBe('60×10 (RIR 2)') + expect(setLabel(LIFT, { w: 60, r: 10, rir: 1.5 })).toBe('60×10 (RIR 1.5)') + expect(setLabel(LIFT, { w: 60, r: 10, rir: 0 })).toBe('60×10 (RIR 0)') + }) }) describe('defaultConfig', () => { diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx index b5c2329..3dda366 100644 --- a/frontend/src/views/Workout.jsx +++ b/frontend/src/views/Workout.jsx @@ -75,6 +75,8 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov const col2 = cardio ? { f: 'speed', step: 0.5, dec: true, hd: t('Speed (km/h)') } : timed ? { f: 'w', step: 2.5, dec: true, hd: t('Weight ({0})', S.unit) } : { f: 'r', step: 1, dec: false, hd: t('Reps') } + // RIR (reps in reserve) only makes sense for weighted rep sets, not cardio/timed holds. + const col3 = mode === 'reps' ? { f: 'rir', step: 0.5, dec: true, hd: t('RIR') } : null // Uses the shared stepper markup so a set row picks up the same control styling // as every other +/- field in the app. const cell = (s, i, col, cls) => ( @@ -102,11 +104,12 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov {t(...plan.why)} }
-
{col1.hd}{col2.hd}{timed && }
- {entry.sets.map((s, i) =>
+
{col1.hd}{col2.hd}{col3 && {col3.hd}}{timed && }
+ {entry.sets.map((s, i) =>
{i + 1}
{cell(s, i, col1, 'w')} {cell(s, i, col2, 'r')} + {col3 && cell(s, i, col3, 'rir')} {/* A timed set is started, not typed: the timer counts the hold down and checks the set off itself. The checkbox stays for anyone who timed it on their own watch. */} {timed && - onField(i, col.f, v)} /> - -
- ) + const cell = (s, i, col, cls) => { + // Logging RIR is the last thing you do for a set — it means you just finished it, so it + // checks the set off by itself instead of making you tap Done separately. Only fires once + // (guarded by !s.done) so editing RIR on an already-done set doesn't re-trigger the beep/ + // rest timer, and never applies to weight/reps, which you can set before you've lifted. + const markDoneFromRir = () => { if (col.f === 'rir' && !s.done) onToggle(i) } + const set = v => { onField(i, col.f, v); markDoneFromRir() } + return ( +
+ + + +
+ ) + } return <>
From c3929b0a70ba1a5e0c8e6e10b8038f16663f9498 Mon Sep 17 00:00:00 2001 From: Octavio Di Marco Date: Thu, 30 Jul 2026 19:20:00 +0200 Subject: [PATCH 3/5] Remove RIR auto-check; gate the column behind a setting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two blockers from review: - NumberField.commit() fires onChange on every keystroke, so typing a decimal RIR (e.g. 1.5) committed the auto-check after the first character, before the value was finished — and the same auto-check turned a stray tap on an empty field's "−" (or clearing it) into a permanent "RIR 0", since 0 is indistinguishable from unset once the key exists on the set. Logging RIR is back to a plain field with no side effect; the checkbox is the only way to mark a set done, same as weight and reps. - The RIR stepper narrowed every reps-mode row's +/- buttons for everyone, including the majority not running an RIR-based program. It's now behind a `showRir` setting (Settings → Units & timer, default off), so the existing row is untouched unless opted in. --- frontend/src/store/useStore.js | 2 +- frontend/src/views/Settings.jsx | 3 +++ frontend/src/views/Workout.jsx | 27 ++++++++++----------------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/frontend/src/store/useStore.js b/frontend/src/store/useStore.js index 5004767..9bdb253 100644 --- a/frontend/src/store/useStore.js +++ b/frontend/src/store/useStore.js @@ -11,7 +11,7 @@ export const DEF = { theme: 'dark', accent: 'lime', body: 'male', targetW: null, bodyweight: [], routines: [], week: {}, dayPlan: {}, exWeights: {}, workouts: [], active: null, customEx: [], gifSize: 'full', - reminder: { on: false, time: '08:00', tz: null } + reminder: { on: false, time: '08:00', tz: null }, showRir: false } const clone = o => JSON.parse(JSON.stringify(o)) diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsx index 86f8763..59fee80 100644 --- a/frontend/src/views/Settings.jsx +++ b/frontend/src/views/Settings.jsx @@ -133,6 +133,9 @@ export default function Settings() { update(s => { s.sound = v })} /> + + update(s => { s.showRir = v })} /> + {(user || MOBILE) && } diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx index a3322c1..ba8b19f 100644 --- a/frontend/src/views/Workout.jsx +++ b/frontend/src/views/Workout.jsx @@ -75,25 +75,18 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov const col2 = cardio ? { f: 'speed', step: 0.5, dec: true, hd: t('Speed (km/h)') } : timed ? { f: 'w', step: 2.5, dec: true, hd: t('Weight ({0})', S.unit) } : { f: 'r', step: 1, dec: false, hd: t('Reps') } - // RIR (reps in reserve) only makes sense for weighted rep sets, not cardio/timed holds. - const col3 = mode === 'reps' ? { f: 'rir', step: 0.5, dec: true, hd: t('RIR') } : null + // RIR (reps in reserve) only makes sense for weighted rep sets, not cardio/timed holds, + // and is opt-in (Settings) since it adds a third stepper to every row. + const col3 = mode === 'reps' && S.showRir ? { f: 'rir', step: 0.5, dec: true, hd: t('RIR') } : null // Uses the shared stepper markup so a set row picks up the same control styling // as every other +/- field in the app. - const cell = (s, i, col, cls) => { - // Logging RIR is the last thing you do for a set — it means you just finished it, so it - // checks the set off by itself instead of making you tap Done separately. Only fires once - // (guarded by !s.done) so editing RIR on an already-done set doesn't re-trigger the beep/ - // rest timer, and never applies to weight/reps, which you can set before you've lifted. - const markDoneFromRir = () => { if (col.f === 'rir' && !s.done) onToggle(i) } - const set = v => { onField(i, col.f, v); markDoneFromRir() } - return ( -
- - - -
- ) - } + const cell = (s, i, col, cls) => ( +
+ + onField(i, col.f, v)} /> + +
+ ) return <>
From c5172d06331d6233ff35f9506c7c11b9fdd1307a Mon Sep 17 00:00:00 2001 From: Octavio Di Marco Date: Thu, 30 Jul 2026 19:20:00 +0200 Subject: [PATCH 4/5] i18n: add RIR strings to all 11 language packs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit t('RIR') and the new Settings toggle label had no entries in src/locales/ — RIR itself is kept as the acronym across languages (same treatment as 1RM), only the surrounding label text is translated. --- frontend/src/locales/de.js | 4 ++++ frontend/src/locales/es.js | 4 ++++ frontend/src/locales/fr.js | 4 ++++ frontend/src/locales/hi.js | 4 ++++ frontend/src/locales/it.js | 4 ++++ frontend/src/locales/ko.js | 4 ++++ frontend/src/locales/pl.js | 4 ++++ frontend/src/locales/pt.js | 4 ++++ frontend/src/locales/ru.js | 4 ++++ frontend/src/locales/tr.js | 4 ++++ frontend/src/locales/zh.js | 4 ++++ 11 files changed, 44 insertions(+) diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js index c21e195..b224935 100644 --- a/frontend/src/locales/de.js +++ b/frontend/src/locales/de.js @@ -511,4 +511,8 @@ export default { 'Missed reps last time — same weight again ({0} of {1} to go).': 'Letztes Mal Wiederholungen verfehlt — dasselbe Gewicht noch einmal (noch {0} von {1}).', 'Bodyweight — every rep last time, so go for {0} this time.': 'Körpergewicht — letztes Mal jede Wiederholung, also diesmal {0} anpeilen.', 'Bodyweight — same target again until every set is clean.': 'Körpergewicht — dieselbe Vorgabe, bis jeder Satz sauber sitzt.', + + // --- RIR (reps in reserve) --- + 'RIR': 'RIR', + 'Show RIR column': 'RIR-Spalte anzeigen', } diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js index e998b0a..93f8d6a 100644 --- a/frontend/src/locales/es.js +++ b/frontend/src/locales/es.js @@ -493,4 +493,8 @@ export default { 'Missed reps last time — same weight again ({0} of {1} to go).': 'Fallaste repeticiones la última vez: el mismo peso otra vez (quedan {0} de {1}).', 'Bodyweight — every rep last time, so go for {0} this time.': 'Peso corporal: la última vez todas las repeticiones, así que ve a por {0} esta vez.', 'Bodyweight — same target again until every set is clean.': 'Peso corporal: el mismo objetivo hasta que todas las series salgan limpias.', + + // --- RIR (reps in reserve) --- + 'RIR': 'RIR', + 'Show RIR column': 'Mostrar columna de RIR', } diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js index 3791da6..c4f59b7 100644 --- a/frontend/src/locales/fr.js +++ b/frontend/src/locales/fr.js @@ -493,4 +493,8 @@ export default { 'Missed reps last time — same weight again ({0} of {1} to go).': 'Répétitions manquées la dernière fois — même poids à nouveau ({0} sur {1} restants).', 'Bodyweight — every rep last time, so go for {0} this time.': 'Poids du corps — toutes les répétitions la dernière fois, alors vise {0} cette fois.', 'Bodyweight — same target again until every set is clean.': 'Poids du corps — même objectif jusqu’à ce que chaque série soit propre.', + + // --- RIR (reps in reserve) --- + 'RIR': 'RIR', + 'Show RIR column': 'Afficher la colonne RIR', } diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js index 8349e26..47e9e5e 100644 --- a/frontend/src/locales/hi.js +++ b/frontend/src/locales/hi.js @@ -493,4 +493,8 @@ export default { 'Missed reps last time — same weight again ({0} of {1} to go).': 'पिछली बार रेप्स चूके — वही वज़न दोबारा ({1} में से {0} बाकी)।', 'Bodyweight — every rep last time, so go for {0} this time.': 'बॉडीवेट — पिछली बार सारे रेप्स, तो इस बार {0} का लक्ष्य रखें।', 'Bodyweight — same target again until every set is clean.': 'बॉडीवेट — जब तक हर सेट साफ़ न हो, वही लक्ष्य।', + + // --- RIR (reps in reserve) --- + 'RIR': 'RIR', + 'Show RIR column': 'RIR कॉलम दिखाएं', } diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js index f6d6b1e..6ef1363 100644 --- a/frontend/src/locales/it.js +++ b/frontend/src/locales/it.js @@ -493,4 +493,8 @@ export default { 'Missed reps last time — same weight again ({0} of {1} to go).': 'Ripetizioni mancate l’ultima volta: stesso peso ancora ({0} di {1} rimasti).', 'Bodyweight — every rep last time, so go for {0} this time.': 'Corpo libero — l’ultima volta tutte le ripetizioni, quindi punta a {0} stavolta.', 'Bodyweight — same target again until every set is clean.': 'Corpo libero — stesso obiettivo finché ogni serie non è pulita.', + + // --- RIR (reps in reserve) --- + 'RIR': 'RIR', + 'Show RIR column': 'Mostra colonna RIR', } diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js index 9e0ff61..10f278b 100644 --- a/frontend/src/locales/ko.js +++ b/frontend/src/locales/ko.js @@ -493,4 +493,8 @@ export default { 'Missed reps last time — same weight again ({0} of {1} to go).': '지난번 목표 횟수 미달 — 같은 무게로 한 번 더 ({1}회 중 {0}회 남음).', 'Bodyweight — every rep last time, so go for {0} this time.': '맨몸 운동 — 지난번 전 세트 완수, 이번엔 {0}회를 노려보세요.', 'Bodyweight — same target again until every set is clean.': '맨몸 운동 — 모든 세트가 깔끔해질 때까지 같은 목표로.', + + // --- RIR (reps in reserve) --- + 'RIR': 'RIR', + 'Show RIR column': 'RIR 열 표시', } diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js index d529ecc..b5a5d03 100644 --- a/frontend/src/locales/pl.js +++ b/frontend/src/locales/pl.js @@ -493,4 +493,8 @@ export default { 'Missed reps last time — same weight again ({0} of {1} to go).': 'Ostatnio nieudane powtórzenia — ten sam ciężar jeszcze raz (zostało {0} z {1}).', 'Bodyweight — every rep last time, so go for {0} this time.': 'Masa własna — ostatnio wszystkie powtórzenia, więc tym razem celuj w {0}.', 'Bodyweight — same target again until every set is clean.': 'Masa własna — ten sam cel, dopóki każda seria nie będzie czysta.', + + // --- RIR (reps in reserve) --- + 'RIR': 'RIR', + 'Show RIR column': 'Pokaż kolumnę RIR', } diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js index 44dfb85..67f0a75 100644 --- a/frontend/src/locales/pt.js +++ b/frontend/src/locales/pt.js @@ -493,4 +493,8 @@ export default { 'Missed reps last time — same weight again ({0} of {1} to go).': 'Falhaste repetições da última vez — o mesmo peso outra vez (faltam {0} de {1}).', 'Bodyweight — every rep last time, so go for {0} this time.': 'Peso do corpo — da última vez todas as repetições, por isso vai a {0} desta vez.', 'Bodyweight — same target again until every set is clean.': 'Peso do corpo — o mesmo objetivo até todas as séries saírem limpas.', + + // --- RIR (reps in reserve) --- + 'RIR': 'RIR', + 'Show RIR column': 'Mostrar coluna de RIR', } diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js index af234b5..001291b 100644 --- a/frontend/src/locales/ru.js +++ b/frontend/src/locales/ru.js @@ -493,4 +493,8 @@ export default { 'Missed reps last time — same weight again ({0} of {1} to go).': 'В прошлый раз повторения не дались — тот же вес ещё раз (осталось {0} из {1}).', 'Bodyweight — every rep last time, so go for {0} this time.': 'Собственный вес — в прошлый раз все повторения, так что в этот раз целься на {0}.', 'Bodyweight — same target again until every set is clean.': 'Собственный вес — та же цель, пока все подходы не станут чистыми.', + + // --- RIR (reps in reserve) --- + 'RIR': 'RIR', + 'Show RIR column': 'Показывать столбец RIR', } diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js index cc17d37..de87f72 100644 --- a/frontend/src/locales/tr.js +++ b/frontend/src/locales/tr.js @@ -493,4 +493,8 @@ export default { 'Missed reps last time — same weight again ({0} of {1} to go).': 'Geçen sefer tekrarlar eksikti — aynı ağırlık bir kez daha ({1} denemeden {0} kaldı).', 'Bodyweight — every rep last time, so go for {0} this time.': 'Vücut ağırlığı — geçen sefer bütün tekrarlar tamamdı, bu sefer {0} hedefle.', 'Bodyweight — same target again until every set is clean.': 'Vücut ağırlığı — her set temiz çıkana kadar aynı hedef.', + + // --- RIR (reps in reserve) --- + 'RIR': 'RIR', + 'Show RIR column': 'RIR sütununu göster', } diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js index 0f85569..8b1f28d 100644 --- a/frontend/src/locales/zh.js +++ b/frontend/src/locales/zh.js @@ -493,4 +493,8 @@ export default { 'Missed reps last time — same weight again ({0} of {1} to go).': '上次次数未完成——再用同样的重量(还剩 {0}/{1} 次)。', 'Bodyweight — every rep last time, so go for {0} this time.': '徒手动作——上次全部完成,这次冲 {0} 次。', 'Bodyweight — same target again until every set is clean.': '徒手动作——保持同样的目标,直到每组都做干净。', + + // --- RIR (reps in reserve) --- + 'RIR': 'RIR', + 'Show RIR column': '显示RIR列', } From c08381e558329ece5569a1677edcc8e7fd44e22a Mon Sep 17 00:00:00 2001 From: Duarte Santos Date: Thu, 30 Jul 2026 19:53:14 +0200 Subject: [PATCH 5/5] RIR: an unlogged RIR stays unlogged, and the header lines up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A set that never had an RIR could still end up carrying one: NumberField mapped an empty field to 0 and the − button clamped to 0, so one stray tap stamped '(RIR 0)' — went to failure — on the set for good, in history and in backups, with no way back. An optional field now clears to null (the key is dropped), and stepping down from empty leaves it empty. A typed 0 still logs a real 0. The row's three-stepper sizing also has to reach the header, or the labels sit up to 5px off the columns they name. --- frontend/src/components/ui.jsx | 9 ++++++--- frontend/src/index.css | 13 +++++++------ frontend/src/lib/history.test.js | 6 ++++++ frontend/src/views/Workout.jsx | 28 +++++++++++++++++++++------- 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/ui.jsx b/frontend/src/components/ui.jsx index 0cd6404..3a1a672 100644 --- a/frontend/src/components/ui.jsx +++ b/frontend/src/components/ui.jsx @@ -21,15 +21,18 @@ import Icon from './Icon.jsx' // Numeric input accepting "," as decimal separator — iOS decimal keypads in many // locales only offer a comma, and type="number" reports "" for it (value snaps to // 0). Keeps a local string draft while focused so partial input like "33," survives. -export function NumberField({ value, onChange, decimal = true, className = '', ...rest }) { +// `nullable` is for fields where "nothing entered" and 0 mean different things (RIR: a +// logged 0 is a set taken to failure). Those clear back to null instead of snapping to 0. +export function NumberField({ value, onChange, decimal = true, nullable = false, className = '', ...rest }) { const [draft, setDraft] = useState(null) const committed = useRef(null) - if (draft !== null && committed.current !== value) { setDraft(null); committed.current = null } + // null and undefined are the same "empty" here — a nullable field's key is dropped once cleared. + if (draft !== null && (committed.current ?? null) !== (value ?? null)) { setDraft(null); committed.current = null } const commit = raw => { let s = raw.replace(/,/g, '.').replace(/[^0-9.]/g, '') const i = s.indexOf('.') if (i !== -1) s = decimal ? s.slice(0, i + 1) + s.slice(i + 1).replace(/\./g, '') : s.slice(0, i) - const n = s === '' || s === '.' ? 0 : Math.max(0, parseFloat(s)) + const n = s === '' || s === '.' ? (nullable ? null : 0) : Math.max(0, parseFloat(s)) committed.current = n setDraft(s) onChange(n) diff --git a/frontend/src/index.css b/frontend/src/index.css index 7cec074..5f74027 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -539,7 +539,7 @@ h4.sec{ .sethead .n-sp{width:24px;flex:none} .sethead .w-sp{flex:1.4;text-align:center} .sethead .r-sp{flex:1;text-align:center} -.sethead .rir-sp{flex:1.1;text-align:center} +.sethead .rir-sp{text-align:center} .sethead .ck-sp{width:30px;flex:none} .setrow{display:flex;align-items:center;gap:8px;padding:7px 0;position:relative} .setrow+.setrow::before{ @@ -557,11 +557,12 @@ h4.sec{ /* a 3rd stepper (RIR) needs narrower buttons and a tighter row gap to fit next to weight+reps on narrow phones, same technique as the exercise-config sheet's three-steppers-in-a-row (.cfgrow below) — RIR's own value is short ("1.5") so its buttons shrink the most, weight/reps - just enough to make room since their values ("82.5", "12") need more of what's left. */ -.setrow.rir3{gap:6px} -.setrow.rir3 .stp.w{flex:1.2} -.setrow.rir3 .stp.r{flex:1} -.setrow.rir3 .stp.rir{flex:.85} + just enough to make room since their values ("82.5", "12") need more of what's left. + The header shares the numbers so its labels stay centred over the steppers they name. */ +.setrow.rir3,.sethead.rir3{gap:6px} +.setrow.rir3 .stp.w,.sethead.rir3 .w-sp{flex:1.2} +.setrow.rir3 .stp.r,.sethead.rir3 .r-sp{flex:1} +.setrow.rir3 .stp.rir,.sethead.rir3 .rir-sp{flex:.85} .setrow.rir3 .stp button{width:23px} .setrow.rir3 .stp.rir button{width:20px} .setrow.rir3 .stp .num{font-size:14px} diff --git a/frontend/src/lib/history.test.js b/frontend/src/lib/history.test.js index ec05d9a..77bda11 100644 --- a/frontend/src/lib/history.test.js +++ b/frontend/src/lib/history.test.js @@ -69,6 +69,12 @@ describe('setLabel', () => { expect(setLabel(LIFT, { w: 60, r: 10, rir: 1.5 })).toBe('60×10 (RIR 1.5)') expect(setLabel(LIFT, { w: 60, r: 10, rir: 0 })).toBe('60×10 (RIR 0)') }) + + it('says nothing about RIR on a set that never logged one', () => { + expect(setLabel(LIFT, { w: 60, r: 10 })).toBe('60×10') + // cleared in the UI: the key is dropped, but a null must read the same as absent + expect(setLabel(LIFT, { w: 60, r: 10, rir: null })).toBe('60×10') + }) }) describe('defaultConfig', () => { diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx index ba8b19f..892deff 100644 --- a/frontend/src/views/Workout.jsx +++ b/frontend/src/views/Workout.jsx @@ -76,15 +76,24 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov : timed ? { f: 'w', step: 2.5, dec: true, hd: t('Weight ({0})', S.unit) } : { f: 'r', step: 1, dec: false, hd: t('Reps') } // RIR (reps in reserve) only makes sense for weighted rep sets, not cardio/timed holds, - // and is opt-in (Settings) since it adds a third stepper to every row. - const col3 = mode === 'reps' && S.showRir ? { f: 'rir', step: 0.5, dec: true, hd: t('RIR') } : null + // and is opt-in (Settings) since it adds a third stepper to every row. `opt` because an + // unlogged RIR is not the same as RIR 0 — 0 says the set went to failure. + const col3 = mode === 'reps' && S.showRir ? { f: 'rir', step: 0.5, dec: true, opt: true, hd: t('RIR') } : null + // Stepping an optional field that was never filled in stays empty rather than clamping to 0: + // otherwise one stray − on a fresh row stamps "(RIR 0)" on the set for good. Going down from + // 0.5 still reaches a real 0. + const bump = (s, i, col, dir) => { + const cur = s[col.f] + if (col.opt && cur == null && dir < 0) return + 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. const cell = (s, i, col, cls) => (
- - onField(i, col.f, v)} /> - + + onField(i, col.f, v)} /> +
) return <> @@ -105,7 +114,8 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov {t(...plan.why)}
}
-
{col1.hd}{col2.hd}{col3 && {col3.hd}}{timed && }
+ {/* the header carries the same rir3 sizing as the rows, or the labels drift off their columns */} +
{col1.hd}{col2.hd}{col3 && {col3.hd}}{timed && }
{entry.sets.map((s, i) =>
{i + 1}
{cell(s, i, col1, 'w')} @@ -143,7 +153,11 @@ function ActiveWorkout() { const done = setsDoneActive(A) const mutEntry = (idx, fn) => update(s => { fn(s.active.entries[idx]) }, true) - const setField = (idx, i, field, v) => mutEntry(idx, e => { e.sets[i][field] = v }) + // Clearing an optional field drops the key rather than storing null, so a set only carries + // what was actually logged — in the session, in history and in a backup. + const setField = (idx, i, field, v) => mutEntry(idx, e => { + if (v == null) delete e.sets[i][field]; else e.sets[i][field] = v + }) const modeAt = idx => modeOf({ ...(A.entries[idx].target || {}), id: A.entries[idx].id }) const addSet = idx => mutEntry(idx, e => { const l = e.sets[e.sets.length - 1]