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
Merge !91: feat(workout): colour-coded RIR/RPE quick picker
Duarte Santos3773f65355eb
diff --cc frontend/src/lib/pt-br-locale.test.jsindex d84f00de7,d5f48e0c0..bd9f68985--- a/frontend/src/lib/pt-br-locale.test.js+++ b/frontend/src/lib/pt-br-locale.test.js@@@ -27,11 -27,11 +27,11 @@@ describe('Brazilian Portuguese locale'.sort(byCodeUnit)const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex')- expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(617)- expect(inherited).toHaveLength(592)- expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(343)- expect(inherited).toHaveLength(467)++ expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(618)++ expect(inherited).toHaveLength(596)// If this fails, review the changed keys and wording before accepting a new hash. From// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list- expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('088bb72a6ce33793bcc81215c2e7fc036226d8f144c53a633982e5b336226293')- expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('091fdc0f54dd211f04986afd906513a906989cbc241f0aafca6fc69570f3c70b')++ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('1f6ae623aa2a6234b7454b5b6b59512e66a03b39dda46b1b0f359942b970907d')})test('does not leak European Portuguese UI terms', () => {diff --cc frontend/src/locales/pt-BR.jsindex 7bb27528f,e88661a0b..e26afa584--- a/frontend/src/locales/pt-BR.js+++ b/frontend/src/locales/pt-BR.js@@@ -611,38 -358,8 +611,40 @@@ export const PT_BR_OVERRIDES ='Set to 0 to go back to the default ({0}).': 'Defina 0 para voltar ao padrão ({0}).','Applies to this exercise everywhere, not just this plan.': 'Vale para este exercício em todos os lugares, não só neste plano.','You still log the total weight — the bar only feeds the per-side plate math.': 'Você continua registrando o peso total — a barra só entra no cálculo das anilhas por lado.',+ // Gym check-in (mobile-only) — only where pt-BR differs from pt (inherited via ...pt)+ 'At the gym': 'Na academia',+ 'Show this at the gym': 'Mostre isto na academia',+ 'Add your gym card': 'Adicione seu cartão da academia',+ 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'Digite o número do seu cartão de sócio, importe uma foto ou escaneie com a câmera. Não é preciso outro app na academia — é só abrir esta tela.',+ 'Scan it, import a photo, or type the code by hand.': 'Escaneie, importe uma foto ou digite o código à mão.',+ 'Scan': 'Escanear',+ 'e.g. FitZone downtown': 'ex. FitZone centro',+ 'Gym card': 'Cartão da academia',+ 'Could not read that image': 'Não foi possível ler essa imagem',+ 'Camera permission is needed to scan. Enable it in Settings.': 'É necessária a permissão da câmera para escanear. Ative-a nos Ajustes.',+ 'Scanning is not available on this device.': 'O escaneamento não está disponível neste dispositivo.',+ 'Could not start the scanner': 'Não foi possível iniciar o scanner',+ 'Gym check-in': 'Check-in na academia',+ 'Show a card on Home with your membership QR codes.': 'Mostra no Início um cartão com seus códigos QR de sócio.',+ 'Point the camera at the QR code': 'Aponte a câmera para o código QR',+ 'Camera is not available here — import a photo or type the code instead.': 'A câmera não está disponível aqui — importe uma foto ou digite o código.',+ 'Camera access was denied — allow it in your browser and try again.': 'O acesso à câmera foi negado — permita-o no navegador e tente de novo.',++// --- muscle explorer ---+ 'By muscle': 'Por músculo',+ 'Explore muscles': 'Explorar músculos',+ 'Choose a muscle to see exercises that train it.': 'Escolha um músculo para ver os exercícios que o treinam.',+ 'Exercises for {0}': 'Exercícios para {0}',+ 'Clear selection': 'Limpar seleção',+ 'Primary target': 'Músculo principal',+ 'Also trains': 'Também trabalha',+ 'Progression settings': 'Configurações de progressão',+ 'Workout controls': 'Controles durante o treino',+ 'Off: tap the number and type it': 'Desligado: toque no número e digite',+ 'Move, swap and remove buttons below the exercise': 'Botões mover, trocar e remover abaixo do exercício',+ 'Everything hidden here stays one tap away: the ⋯ button of an exercise and the number of a set.': 'Tudo o que você esconde aqui fica a um toque: o botão ⋯ de um exercício e o número de uma série.',+ // effort quick picker — pt-PT uses "toca"/"escreve"; Brazilian uses "toque"/"digite"+ 'Tap how many reps you had left, or type an exact {0}.': 'Toque em quantas repetições você ainda tinha, ou digite um {0} exato.'}export default { ...pt, ...PT_BR_OVERRIDES }diff --cc frontend/src/sheets.jsxindex c16534c1e,0f5fcf45b..392940119--- a/frontend/src/sheets.jsx+++ b/frontend/src/sheets.jsx@@@ -4,19 -4,19 +4,20 @@@ import { useUI } from './store/useUI.jsimport { 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, bestWeightForEntry, buildSets, effectiveRoutineId, workoutVolume, setsDone, setsDoneActive, lastBW, supersetUnits, unitOf, setLabel, defaultConfig, cleanupSg, modeOf, effortOf, 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 { lastEntryFor, bestWeightFor, bestWeightForEntry, 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'-import { t, instrFor, exerciseNameFor, getLang, INSTR_LANGS } from './lib/i18n.js'+import { t, dateLocale, instrFor, exerciseNameFor, getLang, INSTR_LANGS } from './lib/i18n.js'import { nav } from './lib/nav.js'-import { starterRoutines } from './lib/starter.js'+import { buildStarterPlan, starterPlanDays, starterPlanOptions } from './lib/starter.js'import Media, { Thumb } from './components/Media.jsx'import Stepper from './components/Stepper.jsx'import Icon from './components/Icon.jsx'- import { Button, Slider, Switch, Segmented, SelectRow, Row, TextField, MultiSelectRow } from './components/ui.jsx'+ import { Button, Slider, Switch, Segmented, SelectRow, Row, TextField, NumberField, MultiSelectRow } from './components/ui.jsx'import { glyphOf, GLYPH_GROUPS, DEFAULT_GLYPH } from './lib/glyphs.js'import BodyMap from './components/BodyMap.jsx'+import MuscleExplorer from './components/MuscleExplorer.jsx'import { exerciseMuscleSnapshot, loadOfWorkouts, MUSCLES, MUSCLE_NAME, normalizeMuscleGroups, hasExplicitMuscleMetadata } from './lib/muscles.js'import { parseImport, mergeImport } from './lib/import-csv.js'import { importHevyData, HevyApiError, HEVY_DEV_SETTINGS, mergeHevyRoutines } from './lib/import-hevy.js'diff --cc frontend/src/views/Workout.jsxindex c16255eec,617feb638..69b91e127--- a/frontend/src/views/Workout.jsx+++ b/frontend/src/views/Workout.jsx@@@ -12,10 -11,11 +12,11 @@@ import { t, exerciseNameFor } from '../import { api } from '../lib/api.js'import { insertionIndexAfterCurrentUnit, nextUnfinishedUnit, setProgressHighWater, supersetFlowStep, restAfterSet, restOnRecheck, restSecFor } from '../lib/supersetFlow.js'import Media from '../components/Media.jsx'- import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, finishWorkout, workoutCompleteSheet, confirmSheet, exerciseNoteSheet, sessionNoteSheet, swapActiveWorkoutExercise, barWeightSheet, menuSheet } from '../sheets.jsx'-import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, topWeightSheet, finishWorkout, workoutCompleteSheet, confirmSheet, exerciseNoteSheet, sessionNoteSheet, swapActiveWorkoutExercise, barWeightSheet, effortPickerSheet } from '../sheets.jsx'++import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, finishWorkout, workoutCompleteSheet, confirmSheet, exerciseNoteSheet, sessionNoteSheet, swapActiveWorkoutExercise, barWeightSheet, menuSheet, effortPickerSheet } from '../sheets.jsx'+ import { effortColor } from '../lib/effort.js'import Icon from '../components/Icon.jsx'import { Button, Check, NumberField } from '../components/ui.jsx'-import { nextPrescription, applyPrescription, defaultIncrement } from '../lib/progression.js'+import { nextPrescription, applyPrescription, defaultIncrement, weightIncrement, stepWeight } from '../lib/progression.js'import { progressionGuidance } from '../lib/progression-copy.js'import { glyphOf } from '../lib/glyphs.js'import { isWarmupRow, isDropSet, isRestPauseSet, dropsOf, clustersOf, addDrop, addCluster, removeDropAt, removeClusterAt, setDropAt, setClusterAt, nextDropWeight, nextBurstReps } from '../lib/workout-model.js'@@@ -136,84 -136,56 +137,107 @@@ function ExerciseBlock({ entryIdx, comp// because an unlogged effort is not the same as 0 — RIR 0 says the set went to failure.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 carries the scale key (`eff`) and its field name; unlike weight/reps it+ // is not a stepper — it opens a colour-coded picker (see effortCell). `f` is s.rir or s.rpe.+ const col3 = mode === 'reps' && eff ? { f: eff.f, eff: kind, hd: t(eff.hd) } : null- // Weight and reps step up from 0 with no ceiling, as they always did.- const bump = (s, i, col, dir) =>- onField(i, col.f, Math.max(0, Math.round(((s[col.f] || 0) + dir * col.step) * 100) / 100))+ // 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) => {+ // Read the current value directly from the store rather than from the render-time snapshot.+ // In a superset both ExerciseBlock instances share the same store subscription, so when one+ // member's field changes the partner re-renders too, replacing the closure's `s` reference+ // with a fresh clone before the next tap fires. Reading from the store avoids that stale-+ // closure problem entirely and keeps every tap operating on the real current value.+ const fresh = useStore.getState().S.active?.entries[entryIdx]?.sets[i]+ const cur = fresh ? fresh[col.f] : s[col.f]- if (col.eff) return onField(i, col.f, stepEffort(col.eff, cur, dir))+ if (mode === 'reps' && col.f === 'w') return onField(i, col.f, stepWeight(cur, col.step, dir))+ 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.+ // Which of the optional control groups this profile wants on screen (Settings → During a+ // workout → Workout controls). The lean default keeps the sets and one "more" button; each+ // switch brings one of the old always-visible button rows back.+ const wc = workoutControls(S)const cell = (s, i, col, cls) => (- <div className={'stp ' + cls}>- <button aria-label="Decrease" onClick={() => bump(s, i, col, -1)}><Icon name="minus" /></button>+ <div className={'stp ' + cls + (wc.steppers ? '' : ' plain')}>+ {wc.steppers && <button aria-label="Decrease" onClick={() => bump(s, i, col, -1)}><Icon name="minus" /></button>}- {/* a typed effort is capped — there is no RPE 12, and 12 reps in reserve is a warm-up */}<span className="val"><NumberField decimal={col.dec} nullable={col.opt} value={s[col.f] ?? ''}- onChange={v => onField(i, col.f, col.eff ? capEffort(col.eff, v) : v)} /></span>+ onChange={v => onField(i, col.f, v)} /></span>- <button aria-label="Increase" onClick={() => bump(s, i, col, 1)}><Icon name="plus" /></button>+ {wc.steppers && <button aria-label="Increase" onClick={() => bump(s, i, col, 1)}><Icon name="plus" /></button>}</div>)+ // Everything about this exercise that is not a set you are logging right now lives behind one+ // button. What used to be a row of buttons in the header, a chip under the bar, a strip of+ // three under the sets and four more below the card is a single list you open once a session.+ const barInfo = (!cardio && !(bw && !added) && usesBar(ex)) ? (() => {+ const bar = barWeightFor(S, entry.id)+ if (!(bar > 0)) return null+ const nextW = entry.sets.find(s => !s.done)?.w+ const refW = nextW > 0 ? nextW : Math.max(0, ...entry.sets.map(s => s.w || 0))+ const split = plateSplit(refW, bar)+ return { bar, text: t('Bar {0}', fmtNum(bar) + ' ' + S.unit) + (split != null ? ' · ' + t('{0} per side', fmtNum(split) + ' ' + S.unit) : '') }+ })() : null+ const openMore = () => menuSheet({+ title: exerciseNameFor(ex),+ items: [+ { icon: 'pencil', label: entry.note ? t('Edit note') : t('Add note'), sub: entry.note || undefined, onClick: () => exerciseNoteSheet(entryIdx) },+ { icon: 'info', label: t('Details'), onClick: () => exerciseDetailSheet(ex) },+ onProgressionSettings && { icon: 'chartLine', label: t('Progression settings'), sub: guidance ? t(guidance.policyLabel) : undefined, onClick: onProgressionSettings },+ barInfo && { icon: 'barbell', label: t('Bar weight'), sub: barInfo.text, onClick: () => barWeightSheet(entry.id) },+ { icon: 'flame', label: t('Add warm-up set'), onClick: onAddWarmup },+ onPairPrev && { icon: 'link', label: t('Make superset with previous'), onClick: onPairPrev },+ onPairNext && { icon: 'link', label: t('Make superset with next'), onClick: onPairNext },+ onSwap && { icon: 'shuffle', label: t('Swap exercise'), onClick: onSwap, disabled: busy },+ onMoveUp && { icon: 'chevronUp', label: t('Move up'), onClick: onMoveUp, disabled: busy || !canMoveUp },+ onMoveDown && { icon: 'chevronDown', label: t('Move down'), onClick: onMoveDown, disabled: busy || !canMoveDown },+ onRemoveExercise && { icon: 'trash', label: t('Remove exercise'), onClick: onRemoveExercise, danger: true, disabled: busy },+ ],+ })+ // The set number is the set's own menu: drop / burst / remove — three things that used to+ // sit as chips and an X on every single row.+ const openSetMenu = (s, i) => {+ const warm = isWarmupRow(s)+ menuSheet({+ title: (warm ? t('Warm-up') : t('Set {0}', entry.sets.slice(0, i + 1).filter(x => isWarmupRow(x) === warm).length)),+ subtitle: setLabel(entry.id, s, entry.target),+ items: [+ !warm && mode === 'reps' && !isRestPauseSet(s) && { icon: 'arrowDown', label: t('Drop set'), sub: t('+ Drop'), onClick: () => addDropRow(i) },+ !warm && mode === 'reps' && !isDropSet(s) && { icon: 'bolt', label: t('Rest-pause burst'), sub: t('+ Burst'), onClick: () => addBurstRow(i) },+ { icon: 'trash', label: t('Remove this set'), danger: true, disabled: entry.sets.length <= 1, onClick: () => onRemoveSetAt(i) },+ ],+ })+ }+ // The effort cell is a single button, not a stepper: it shows the rating in the profile's+ // scale, tinted by how close to failure it was, and opens the picker on tap — to set a- // rating or change one. Empty reads as a neutral dash; rirOf-via-effortColor keeps the- // colour identical whether the value is logged as RIR or RPE.++ // rating or change one. rirOf-via-effortColor keeps the colour identical whether the value++ // is logged as RIR or RPE. With the +/- buttons switched off (Workout controls) a logged++ // rating is just the tinted value, which still opens the picker.+ const effortCell = (s, i, col) => {+ const v = s[col.f] ?? null+ const rir = col.eff === 'rpe' ? (v == null ? null : 10 - v) : v+ const color = effortColor(rir)+ 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"++ <div className={'stp effcell-stp' + (wc.steppers ? '' : ' plain')}+ 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>++ {wc.steppers && <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>++ {wc.steppers && <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.- const miniStepper = (value, step, dec, onChange) => (+ const miniStepper = (value, step, dec, onChange, snapWeightStep = false) => (<div className="stp mini">- <button aria-label="Decrease" onClick={() => onChange(Math.max(0, Math.round(((value || 0) - step) * 100) / 100))}><Icon name="minus" /></button>+ <button aria-label="Decrease" onClick={() => onChange(snapWeightStep ? stepWeight(value, step, -1) : Math.max(0, Math.round(((value || 0) - step) * 100) / 100))}><Icon name="minus" /></button><span className="val"><NumberField decimal={dec} value={value ?? ''} onChange={onChange} /></span>- <button aria-label="Increase" onClick={() => onChange(Math.max(0, Math.round(((value || 0) + step) * 100) / 100))}><Icon name="plus" /></button>+ <button aria-label="Increase" onClick={() => onChange(snapWeightStep ? stepWeight(value, step, 1) : Math.max(0, Math.round(((value || 0) + step) * 100) / 100))}><Icon name="plus" /></button></div>)return <>@@@ -276,10 -259,10 +300,10 @@@{isFirstWarmup && <div className="setph">{t('Warm-up')}</div>}{!warm && warmBefore && <div className="setsep" />}<div ref={el => onSetRowRef?.(i, el)} className={'setrow' + (s.done ? ' done' : '') + (col3 ? ' eff3' : '')}>- <div className="n">{phaseNum}</div>+ <button type="button" className="n" aria-label={t('Set {0}', phaseNum)} title={t('More')} onClick={() => openSetMenu(s, i)}>{phaseNum}</button>{cell(s, i, col1, 'w')}{col2 && cell(s, i, col2, 'r')}- {col3 && cell(s, i, col3, 'eff')}+ {col3 && effortCell(s, i, col3)}{/* A timed set is started, not typed: the timer counts the hold down and checks theset off itself. The checkbox stays for anyone who timed it on their own watch. */}{timed && <button className="setgo" aria-label={t('Start set')} disabled={s.done || !!working}diff --cc frontend/src/views/Workout.test.jsxindex dc2872272,c05a664f9..72ba57203--- a/frontend/src/views/Workout.test.jsx+++ b/frontend/src/views/Workout.test.jsx@@@ -21,7 -20,7 +21,8 @@@ const mocks = vi.hoisted(() =>toast: vi.fn(),scrollCalls: [],swapActiveWorkoutExercise: vi.fn(),+ menuSheet: vi.fn(),+ effortPickerSheet: vi.fn(),}state.stopRest = vi.fn(() => { state.timer = null })state.stopWork = vi.fn(() => { state.work = null })@@@ -68,7 -67,7 +69,8 @@@ vi.mock('../sheets.jsx', () => (workoutCompleteSheet: mocks.workoutCompleteSheet,confirmSheet: mocks.confirmSheet,swapActiveWorkoutExercise: mocks.swapActiveWorkoutExercise,+ menuSheet: mocks.menuSheet,+ barWeightSheet: vi.fn(),// Both note sheets belong here even though the tests never open one: Workout.jsx reads// sessionNoteSheet during render, so a missing export is a render crash, not a no-op.exerciseNoteSheet: vi.fn(),