diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.js index 64789ff..fbe2df9 100644 --- a/frontend/src/lib/history.js +++ b/frontend/src/lib/history.js @@ -27,11 +27,32 @@ export function fmtSec(sec) { // their own fields: RIR counts the reps still in the tank, RPE reads the same effort off a // 10-point scale from the top (RPE 8 ≈ RIR 2). A set logged on one scale is never silently // rewritten as the other — switching the setting changes what new sets ask for, nothing else. -// `start` is where the first + tap lands: a typical working set, not the end of the scale. +// `min`..`max` is the range the stepper walks. RIR bottoms out at 0 (a set taken to failure); +// RPE bottoms out at 6, since the scale is only meaningful for working sets and anything +// lighter is a warm-up nobody rates. export const EFFORT = { - rir: { f: 'rir', hd: 'RIR', step: 0.5, max: 10, start: 2 }, - rpe: { f: 'rpe', hd: 'RPE', step: 0.5, max: 10, start: 8 } + rir: { f: 'rir', hd: 'RIR', step: 0.5, min: 0, max: 10 }, + rpe: { f: 'rpe', hd: 'RPE', step: 0.5, min: 6, max: 10 } } +// One tap of an effort stepper. Empty is not 0 — an unlogged effort must not become "went to +// failure" from one stray tap — so − on an empty cell leaves it empty, and + starts at the +// bottom of the scale and walks up from there in even steps. Stepping back off the bottom +// clears the cell again, so a mistap is undoable. null means "nothing logged"; the caller +// stores that by dropping the key rather than writing a null. +export function stepEffort(kind, cur, dir) { + const e = EFFORT[kind] + if (!e) return cur ?? null + if (cur == null) return dir < 0 ? null : e.min + const n = Math.round((cur + dir * e.step) * 100) / 100 + if (dir < 0 && n < e.min) return null + // only the ceiling is enforced on the way up: a value typed below the floor (nothing stops + // someone entering RPE 3) still steps in even increments instead of snapping to the floor. + return dir > 0 ? Math.min(e.max, n) : Math.max(e.min, n) +} +// A typed effort is capped but not floored — clamping up while someone types "10" would turn +// the first keystroke into the floor and fight the input. +export const capEffort = (kind, v) => + (v == null || !EFFORT[kind] ? v : Math.min(EFFORT[kind].max, v)) // Which scale a profile logs. `showRir` is the boolean this replaced and is only consulted // when the profile has no answer of its own — an explicit 'none' has to win over it, or a // backup or another device that still carries the old flag would switch the column back on. diff --git a/frontend/src/lib/history.test.js b/frontend/src/lib/history.test.js index a577c4a..fac4207 100644 --- a/frontend/src/lib/history.test.js +++ b/frontend/src/lib/history.test.js @@ -1,5 +1,5 @@ import { describe, it, expect } from 'vitest' -import { modeOf, isTimed, fmtSec, setLabel, defaultConfig, buildSets, exLine, workoutVolume, effortOf } from './history.js' +import { modeOf, isTimed, fmtSec, setLabel, defaultConfig, buildSets, exLine, workoutVolume, effortOf, stepEffort, capEffort } from './history.js' import { EXDB } from './exercises.js' // Real ids out of the shipped catalogue, so the body-part fallback is exercised for real. @@ -108,6 +108,145 @@ describe('effortOf', () => { expect(effortOf({ showRir: true, effort: 'rpe' })).toBe('rpe') expect(effortOf({ showRir: true, effort: 'none' })).toBe('none') }) + + // The store cannot be imported here (it reaches for `navigator` at module load), so the + // overlay it performs is reproduced literally: stored profile spread over the defaults. + // DEF.effort is null precisely so this lands on the showRir fallback rather than on 'none'. + const overlay = stored => ({ unit: 'kg', effort: null, ...stored }) + + it('survives the overlay every load path performs', () => { + // upgrading with the column on: local state, a server pull and a restored backup all + // arrive as a stored object spread over the defaults, and all must keep the column + expect(effortOf(overlay({ showRir: true }))).toBe('rir') + expect(effortOf(overlay({ showRir: false }))).toBe('none') + // a profile predating the RIR feature entirely + expect(effortOf(overlay({}))).toBe('none') + // and one written by this version + expect(effortOf(overlay({ effort: 'rpe' }))).toBe('rpe') + // an old backup restored over a profile that had already chosen: the file wins, because + // an import replaces state wholesale rather than merging + expect(effortOf(overlay({ showRir: true, effort: undefined }))).toBe('rir') + }) + + it('is not fooled by a junk value', () => { + expect(effortOf({ effort: 'rpe10' })).toBe('none') + expect(effortOf({ effort: 'RIR' })).toBe('none') + expect(effortOf({ effort: 'f' })).toBe('none') + expect(effortOf(null)).toBe('none') + expect(effortOf(undefined)).toBe('none') + // a junk value with the old flag still set falls back rather than showing nothing + expect(effortOf({ effort: 'nope', showRir: true })).toBe('rir') + }) +}) + +describe('stepEffort', () => { + it('starts at the bottom of the scale and walks up', () => { + // the first + on an empty cell lands on the lowest value, not on some "typical" middle: + // the stepper counts up from the floor the way every other stepper in the app does + expect(stepEffort('rir', null, 1)).toBe(0) + expect(stepEffort('rpe', null, 1)).toBe(6) + // and then in even steps + expect(stepEffort('rir', 0, 1)).toBe(0.5) + expect(stepEffort('rir', 0.5, 1)).toBe(1) + expect(stepEffort('rpe', 6, 1)).toBe(6.5) + }) + + it('leaves an untouched cell unlogged when stepped down', () => { + // one stray − on a fresh row must not stamp "(RIR 0)" — went to failure — on the set + expect(stepEffort('rir', null, -1)).toBe(null) + expect(stepEffort('rpe', null, -1)).toBe(null) + expect(stepEffort('rir', undefined, -1)).toBe(null) + }) + + it('clears the cell again when stepped back off the floor', () => { + // so a mistap is undoable rather than sticking at the floor for good + expect(stepEffort('rir', 0, -1)).toBe(null) + expect(stepEffort('rpe', 6, -1)).toBe(null) + // but a step that stays inside the scale is an ordinary step + expect(stepEffort('rir', 0.5, -1)).toBe(0) + expect(stepEffort('rpe', 6.5, -1)).toBe(6) + }) + + it('stops at the top of the scale', () => { + expect(stepEffort('rir', 9.5, 1)).toBe(10) + expect(stepEffort('rir', 10, 1)).toBe(10) + expect(stepEffort('rpe', 10, 1)).toBe(10) + }) + + it('keeps halves clean instead of drifting into float dust', () => { + let v = null + for (let i = 0; i < 6; i++) v = stepEffort('rpe', v, 1) + expect(v).toBe(8.5) + expect(stepEffort('rir', 0.1 + 0.2, 1)).toBe(0.8) + }) + + it('steps evenly from a value typed below the floor rather than snapping', () => { + // nothing stops someone typing RPE 3; the stepper must not jump them to 6 on one tap + expect(stepEffort('rpe', 3, 1)).toBe(3.5) + // stepping down out of the scale from there just clears it + expect(stepEffort('rpe', 3, -1)).toBe(null) + }) + + it('does nothing when the profile logs no effort at all', () => { + expect(stepEffort('none', null, 1)).toBe(null) + expect(stepEffort('none', 2, 1)).toBe(2) + expect(stepEffort(undefined, 2, -1)).toBe(2) + }) +}) + +describe('capEffort', () => { + it('caps a typed value at the top of the scale', () => { + expect(capEffort('rir', 12)).toBe(10) + expect(capEffort('rpe', 99)).toBe(10) + expect(capEffort('rpe', 8)).toBe(8) + }) + + it('does not floor a typed value, so typing "10" survives its first keystroke', () => { + // clamping up would turn the "1" of "10" into 6 and fight the input + expect(capEffort('rpe', 1)).toBe(1) + expect(capEffort('rir', 0)).toBe(0) + }) + + it('passes an emptied field through untouched', () => { + expect(capEffort('rir', null)).toBe(null) + expect(capEffort('rpe', undefined)).toBe(undefined) + expect(capEffort('none', 12)).toBe(12) + }) +}) + +// End-to-end on the data, not the pixels: what a set carries after the taps a real session +// makes, and what it reads back as afterwards. +describe('logging effort across a session', () => { + it('logs a working set on the chosen scale', () => { + // four + taps from empty on an RPE profile: 6, 6.5, 7, 7.5 + let v = null + for (let i = 0; i < 4; i++) v = stepEffort('rpe', v, 1) + expect(setLabel(LIFT, { w: 80, r: 5, rpe: v })).toBe('80×5 (RPE 7.5)') + }) + + it('a set taken to failure is logged, not left blank', () => { + const v = stepEffort('rir', null, 1) // one + on an RIR profile + expect(v).toBe(0) + expect(setLabel(LIFT, { w: 100, r: 3, rir: v })).toBe('100×3 (RIR 0)') + }) + + it('switching the setting mid-history rewrites nothing', () => { + const old = { w: 60, r: 10, rir: 2 } // logged while the profile was on RIR + const fresh = { w: 60, r: 10, rpe: 8 } // logged after switching to RPE + expect(effortOf({ effort: 'rpe' })).toBe('rpe') + expect(setLabel(LIFT, old)).toBe('60×10 (RIR 2)') + expect(setLabel(LIFT, fresh)).toBe('60×10 (RPE 8)') + // turning the column off entirely hides the control but keeps both sets readable + expect(effortOf({ effort: 'none' })).toBe('none') + expect(setLabel(LIFT, old)).toBe('60×10 (RIR 2)') + }) + + it('never attaches effort to a mode that has no place for it', () => { + // cardio and timed sets have no third stepper, and their labels ignore the field even + // if an import or an old file put one there + expect(setLabel(CARDIO, { min: 20, speed: 9, rpe: 8 })).toBe('20 min @ 9 km/h') + expect(setLabel(LIFT, { sec: 45, rir: 2 }, { id: LIFT, mode: 'time' })).toBe('0:45') + }) }) describe('defaultConfig', () => { diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js index a6cdc7f..de8d5c2 100644 --- a/frontend/src/locales/de.js +++ b/frontend/src/locales/de.js @@ -525,5 +525,5 @@ export default { 'Three more reps': 'Drei Wiederholungen übrig', 'Easy — warm-up territory': 'Locker — Aufwärmbereich', 'RIR counts the reps you left; RPE reads the same effort off a 10-point scale — so RPE ≈ 10 − RIR. Pick the one you already think in.': 'RIR zählt die Wiederholungen, die du übrig lässt; RPE liest dieselbe Anstrengung auf einer 10er-Skala ab — also RPE ≈ 10 − RIR. Nimm die Skala, in der du ohnehin denkst.', - 'The highlighted row is where the first + lands. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': 'Die hervorgehobene Zeile ist der Wert, auf dem das erste + landet. Bereits protokollierte Sätze behalten ihre eigene Skala, und sonst liest den Wert nichts — Progression und geschätztes 1RM bleiben unberührt.', + 'The highlighted row is where most working sets land. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': 'Die hervorgehobene Zeile ist der Bereich, in dem die meisten Arbeitssätze landen. Bereits protokollierte Sätze behalten ihre eigene Skala, und sonst liest den Wert nichts — Progression und geschätztes 1RM bleiben unberührt.', } diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js index d17d7c9..daffa75 100644 --- a/frontend/src/locales/es.js +++ b/frontend/src/locales/es.js @@ -507,5 +507,5 @@ export default { 'Three more reps': 'Tres repeticiones más', 'Easy — warm-up territory': 'Fácil — zona de calentamiento', 'RIR counts the reps you left; RPE reads the same effort off a 10-point scale — so RPE ≈ 10 − RIR. Pick the one you already think in.': 'El RIR cuenta las repeticiones que dejas; el RPE lee ese mismo esfuerzo en una escala de 10 — así que RPE ≈ 10 − RIR. Elige la que ya usas para pensar.', - 'The highlighted row is where the first + lands. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': 'La fila resaltada es donde cae el primer +. Las series ya registradas conservan su escala, y nada más lee el valor: la progresión y el 1RM estimado no cambian.', + 'The highlighted row is where most working sets land. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': 'La fila resaltada es donde cae la mayoría de las series efectivas. Las series ya registradas conservan su escala, y nada más lee el valor: la progresión y el 1RM estimado no cambian.', } diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js index bc47976..6909b09 100644 --- a/frontend/src/locales/fr.js +++ b/frontend/src/locales/fr.js @@ -507,5 +507,5 @@ export default { 'Three more reps': 'Encore trois répétitions', 'Easy — warm-up territory': 'Facile — zone d’échauffement', 'RIR counts the reps you left; RPE reads the same effort off a 10-point scale — so RPE ≈ 10 − RIR. Pick the one you already think in.': 'Le RIR compte les répétitions qu’il te restait ; le RPE lit le même effort sur une échelle de 10 — donc RPE ≈ 10 − RIR. Prends celle dans laquelle tu penses déjà.', - 'The highlighted row is where the first + lands. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': 'La ligne mise en avant est celle où tombe le premier +. Les séries déjà enregistrées gardent leur échelle, et rien d’autre ne lit la valeur — la progression et le 1RM estimé ne changent pas.', + 'The highlighted row is where most working sets land. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': 'La ligne mise en avant est celle où tombent la plupart des séries de travail. Les séries déjà enregistrées gardent leur échelle, et rien d’autre ne lit la valeur — la progression et le 1RM estimé ne changent pas.', } diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js index 1bb6991..1264124 100644 --- a/frontend/src/locales/hi.js +++ b/frontend/src/locales/hi.js @@ -507,5 +507,5 @@ export default { 'Three more reps': 'तीन रेप और बाकी', 'Easy — warm-up territory': 'आसान — वॉर्म-अप का दायरा', 'RIR counts the reps you left; RPE reads the same effort off a 10-point scale — so RPE ≈ 10 − RIR. Pick the one you already think in.': 'RIR बचे हुए रेप्स गिनता है; RPE उसी मेहनत को 10 के पैमाने पर पढ़ता है — यानी RPE ≈ 10 − RIR. वही चुनें जिसमें आप पहले से सोचते हैं।', - 'The highlighted row is where the first + lands. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': 'हाइलाइट की गई पंक्ति वहीं है जहाँ पहला + पहुँचता है। पहले दर्ज किए सेट अपना पैमाना बनाए रखते हैं, और इस मान को और कुछ नहीं पढ़ता — प्रोग्रेशन और अनुमानित 1RM अछूते रहते हैं।', + 'The highlighted row is where most working sets land. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': 'हाइलाइट की गई पंक्ति वह है जहाँ ज़्यादातर वर्किंग सेट आते हैं। पहले दर्ज किए सेट अपना पैमाना बनाए रखते हैं, और इस मान को और कुछ नहीं पढ़ता — प्रोग्रेशन और अनुमानित 1RM अछूते रहते हैं।', } diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js index c93d1cd..2a44b9c 100644 --- a/frontend/src/locales/it.js +++ b/frontend/src/locales/it.js @@ -507,5 +507,5 @@ export default { 'Three more reps': 'Altre tre ripetizioni', 'Easy — warm-up territory': 'Facile — zona riscaldamento', 'RIR counts the reps you left; RPE reads the same effort off a 10-point scale — so RPE ≈ 10 − RIR. Pick the one you already think in.': 'Il RIR conta le ripetizioni che ti restavano; l’RPE legge lo stesso sforzo su una scala da 10 — quindi RPE ≈ 10 − RIR. Scegli quella con cui già ragioni.', - 'The highlighted row is where the first + lands. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': 'La riga evidenziata è dove atterra il primo +. Le serie già registrate mantengono la loro scala, e nient’altro legge il valore: progressione e 1RM stimato non cambiano.', + 'The highlighted row is where most working sets land. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': 'La riga evidenziata è dove finisce la maggior parte delle serie di lavoro. Le serie già registrate mantengono la loro scala, e nient’altro legge il valore: progressione e 1RM stimato non cambiano.', } diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js index f32ace1..8cb8d22 100644 --- a/frontend/src/locales/ko.js +++ b/frontend/src/locales/ko.js @@ -507,5 +507,5 @@ export default { 'Three more reps': '세 개 더 남았음', 'Easy — warm-up territory': '가벼움 — 웜업 구간', 'RIR counts the reps you left; RPE reads the same effort off a 10-point scale — so RPE ≈ 10 − RIR. Pick the one you already think in.': 'RIR은 남긴 횟수를 세고, RPE는 같은 노력을 10점 척도로 읽습니다 — 즉 RPE ≈ 10 − RIR. 평소에 쓰던 쪽을 고르세요.', - 'The highlighted row is where the first + lands. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': '강조된 줄이 첫 + 를 눌렀을 때 들어가는 값입니다. 이미 기록한 세트는 원래 척도를 그대로 유지하며, 이 값을 읽는 곳은 없습니다 — 프로그레션과 예상 1RM은 영향을 받지 않습니다.', + 'The highlighted row is where most working sets land. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': '강조된 줄은 대부분의 본세트가 들어가는 구간입니다. 이미 기록한 세트는 원래 척도를 그대로 유지하며, 이 값을 읽는 곳은 없습니다 — 프로그레션과 예상 1RM은 영향을 받지 않습니다.', } diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js index e1f8d7e..3253f17 100644 --- a/frontend/src/locales/pl.js +++ b/frontend/src/locales/pl.js @@ -507,5 +507,5 @@ export default { 'Three more reps': 'Jeszcze trzy powtórzenia', 'Easy — warm-up territory': 'Lekko — poziom rozgrzewki', 'RIR counts the reps you left; RPE reads the same effort off a 10-point scale — so RPE ≈ 10 − RIR. Pick the one you already think in.': 'RIR liczy powtórzenia, które zostały w zapasie; RPE odczytuje ten sam wysiłek w skali 10 — czyli RPE ≈ 10 − RIR. Wybierz tę, w której już myślisz.', - 'The highlighted row is where the first + lands. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': 'Wyróżniony wiersz to miejsce, w które trafia pierwsze +. Zapisane wcześniej serie zachowują swoją skalę, a wartości nic więcej nie czyta — progresja i szacowany 1RM pozostają bez zmian.', + 'The highlighted row is where most working sets land. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': 'Wyróżniony wiersz to miejsce, w które trafia większość serii roboczych. Zapisane wcześniej serie zachowują swoją skalę, a wartości nic więcej nie czyta — progresja i szacowany 1RM pozostają bez zmian.', } diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js index 7d06007..1b098d3 100644 --- a/frontend/src/locales/pt.js +++ b/frontend/src/locales/pt.js @@ -507,5 +507,5 @@ export default { 'Three more reps': 'Mais três repetições', 'Easy — warm-up territory': 'Fácil — zona de aquecimento', 'RIR counts the reps you left; RPE reads the same effort off a 10-point scale — so RPE ≈ 10 − RIR. Pick the one you already think in.': 'O RIR conta as repetições que deixaste; o RPE lê o mesmo esforço numa escala de 10 — ou seja, RPE ≈ 10 − RIR. Escolhe aquela em que já pensas.', - 'The highlighted row is where the first + lands. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': 'A linha destacada é onde cai o primeiro +. As séries já registadas mantêm a sua escala, e mais nada lê o valor — a progressão e o 1RM estimado não mudam.', + 'The highlighted row is where most working sets land. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': 'A linha destacada é onde cai a maioria das séries de trabalho. As séries já registadas mantêm a sua escala, e mais nada lê o valor — a progressão e o 1RM estimado não mudam.', } diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js index 7cb169e..99de948 100644 --- a/frontend/src/locales/ru.js +++ b/frontend/src/locales/ru.js @@ -507,5 +507,5 @@ export default { 'Three more reps': 'Ещё три повторения', 'Easy — warm-up territory': 'Легко — разминочная зона', 'RIR counts the reps you left; RPE reads the same effort off a 10-point scale — so RPE ≈ 10 − RIR. Pick the one you already think in.': 'RIR считает повторения, оставшиеся в запасе; RPE читает то же усилие по 10-балльной шкале — то есть RPE ≈ 10 − RIR. Выберите ту, в которой вы уже думаете.', - 'The highlighted row is where the first + lands. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': 'Выделенная строка — это значение, на которое попадает первое +. Уже записанные подходы сохраняют свою шкалу, и больше это значение нигде не используется: прогрессия и расчётный 1ПМ не меняются.', + 'The highlighted row is where most working sets land. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': 'Выделенная строка — это диапазон, в который попадает большинство рабочих подходов. Уже записанные подходы сохраняют свою шкалу, и больше это значение нигде не используется: прогрессия и расчётный 1ПМ не меняются.', } diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js index f06f68d..02d0f8f 100644 --- a/frontend/src/locales/tr.js +++ b/frontend/src/locales/tr.js @@ -507,5 +507,5 @@ export default { 'Three more reps': 'Üç tekrar daha vardı', 'Easy — warm-up territory': 'Kolay — ısınma bölgesi', 'RIR counts the reps you left; RPE reads the same effort off a 10-point scale — so RPE ≈ 10 − RIR. Pick the one you already think in.': 'RIR yedekte bıraktığın tekrarları sayar; RPE aynı eforu 10’luk ölçekte okur — yani RPE ≈ 10 − RIR. Zaten hangisiyle düşünüyorsan onu seç.', - 'The highlighted row is where the first + lands. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': 'Vurgulanan satır, ilk + dokunuşunun geldiği yerdir. Daha önce kaydettiğin setler kendi ölçeğini korur ve bu değeri başka hiçbir şey okumaz — ilerleme ve tahmini 1RM etkilenmez.', + 'The highlighted row is where most working sets land. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': 'Vurgulanan satır, çalışma setlerinin çoğunun denk geldiği yerdir. Daha önce kaydettiğin setler kendi ölçeğini korur ve bu değeri başka hiçbir şey okumaz — ilerleme ve tahmini 1RM etkilenmez.', } diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js index 27350cf..f4e656e 100644 --- a/frontend/src/locales/zh.js +++ b/frontend/src/locales/zh.js @@ -507,5 +507,5 @@ export default { 'Three more reps': '还能再做三次', 'Easy — warm-up territory': '轻松——热身区间', 'RIR counts the reps you left; RPE reads the same effort off a 10-point scale — so RPE ≈ 10 − RIR. Pick the one you already think in.': 'RIR 数的是你还留了几次;RPE 把同样的吃力程度换成 10 分制来读——所以 RPE ≈ 10 − RIR。选你习惯的那一种。', - 'The highlighted row is where the first + lands. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': '高亮那一行就是第一次点 + 落在的位置。已经记录的组保留原来的标度,而且这个值不会被别处读取——进阶计划和预估 1RM 都不受影响。', + 'The highlighted row is where most working sets land. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.': '高亮那一行是大多数正式组落在的位置。已经记录的组保留原来的标度,而且这个值不会被别处读取——进阶计划和预估 1RM 都不受影响。', } diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsx index 7d67b5f..d191764 100644 --- a/frontend/src/views/Settings.jsx +++ b/frontend/src/views/Settings.jsx @@ -185,7 +185,8 @@ const EFFORT_ROWS = [ ['3', '7', 'Three more reps'], ['4+', '≤6', 'Easy — warm-up territory'], ] -// RIR 2 / RPE 8: the row a working set usually lands on, and where the first + puts you. +// RIR 2 / RPE 8: the row a working set usually lands on — the anchor the others are read +// against. Not where the stepper starts; + walks up from the bottom of the scale. const EFFORT_TYPICAL = 2 function effortHelpSheet() { @@ -204,7 +205,7 @@ function effortHelpSheet() {
{t('RIR counts the reps you left; RPE reads the same effort off a 10-point scale — so RPE ≈ 10 − RIR. Pick the one you already think in.')}
-
{t('The highlighted row is where the first + lands. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.')}
+
{t('The highlighted row is where most working sets land. Sets you have already logged keep their own scale, and nothing else reads the value — progression and estimated 1RM are unaffected.')}
) diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx index 07a739a..3e50f98 100644 --- a/frontend/src/views/Workout.jsx +++ b/frontend/src/views/Workout.jsx @@ -3,7 +3,7 @@ import { useNavigate } from 'react-router-dom' import { useStore } from '../store/useStore.js' import { useUI } from '../store/useUI.js' import { exOr } from '../lib/exercises.js' -import { effectiveRoutine, lastEntryFor, bestWeightFor, buildSets, setsDoneActive, supersetUnits, unitOf, setLabel, modeOf, EFFORT, effortOf } from '../lib/history.js' +import { effectiveRoutine, lastEntryFor, bestWeightFor, buildSets, setsDoneActive, supersetUnits, unitOf, setLabel, modeOf, EFFORT, effortOf, stepEffort, capEffort } from '../lib/history.js' import { fmtNum, fmtDate, todayISO, exCount, DAYN } from '../lib/format.js' import { beep, vibrate } from '../lib/sound.js' import { t } from '../lib/i18n.js' @@ -78,25 +78,23 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov // Effort (RIR or RPE, whichever the profile logs) only makes sense for weighted rep sets, // not cardio/timed holds, and is opt-in since it adds a third stepper to every row. `opt` // because an unlogged effort is not the same as 0 — RIR 0 says the set went to failure. - const eff = EFFORT[effortOf(S)] - const col3 = mode === 'reps' && eff ? { ...eff, dec: true, opt: true, hd: t(eff.hd) } : null - // Stepping an optional field that was never filled in must not clamp to 0: one stray − on a - // fresh row would stamp "(RIR 0)" — to failure — on the set for good. − leaves it empty, and - // the first + lands on a typical working set (RIR 2 / RPE 8) rather than the end of the scale. + const kind = effortOf(S) + const eff = EFFORT[kind] + const col3 = mode === 'reps' && eff ? { ...eff, eff: kind, dec: true, opt: true, hd: t(eff.hd) } : null + // 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) => { - const cur = s[col.f] - if (col.opt && cur == null) return dir < 0 ? undefined : onField(i, col.f, col.start) - const n = Math.round(((cur || 0) + dir * col.step) * 100) / 100 - onField(i, col.f, Math.min(col.max ?? Infinity, Math.max(0, n))) + if (col.eff) return onField(i, col.f, stepEffort(col.eff, s[col.f], dir)) + onField(i, col.f, Math.max(0, Math.round(((s[col.f] || 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) => (
- {/* a typed value is capped too — RPE has no 12, and 12 reps in reserve is a warm-up */} + {/* a typed effort is capped — there is no RPE 12, and 12 reps in reserve is a warm-up */} onField(i, col.f, v == null || col.max == null ? v : Math.min(col.max, v))} /> + onChange={v => onField(i, col.f, col.eff ? capEffort(col.eff, v) : v)} />
)