diff --git a/frontend/src/index.css b/frontend/src/index.css index b7ad710..3556f68 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -674,7 +674,8 @@ body.chips-dragging *{cursor:inherit} .setph{margin:8px 0 2px;font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--dim);display:flex;align-items:center;gap:10px} .setph::after{content:'';flex:1;height:1px;background:var(--sep)} .setsep{height:1px;background:var(--sep);margin:9px 0} -.setrow .n{ +/* the per-side wrapper carries its own .n (the set number in front of the L/R rows) */ +.setrow .n,.setrow-side>.n{ width:24px;height:24px;border-radius:50%;background:var(--surface-2);color:var(--label-2); display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:500;flex:none; position:relative;padding:0;border:0;font-family:inherit;cursor:pointer; @@ -1168,7 +1169,7 @@ body.chips-dragging *{cursor:inherit} #modal-root .list,.narrow .list{display:flex;flex-direction:column} .narrow{max-width:640px;margin:0 auto} .tiles{grid-template-columns:repeat(4,1fr)} - .cols .tiles{grid-template-columns:1fr 1fr} + .cols .tiles,.center .tiles{grid-template-columns:1fr 1fr} /* a 300px dialog has no room for four */ #tabbar{ left:50%;right:auto;bottom:16px;transform:translateX(-50%);width:520px; border:var(--hair) solid var(--sep-op);border-radius:var(--r-xl); diff --git a/frontend/src/lib/format.js b/frontend/src/lib/format.js index d15f7ee..374d540 100644 --- a/frontend/src/lib/format.js +++ b/frontend/src/lib/format.js @@ -26,6 +26,9 @@ export function fmtDur(ms) { export const durPart = ms => (ms >= 60000 ? [fmtDur(ms)] : []) // Numbers follow the UI language, like the dates above — a hardcoded locale put Swiss // apostrophes ("7'535 kg") in front of every user, in every language. +// Exercise names are stored lower-case and shown through CSS `capitalize`; text that has no +// element of its own (a toast) capitalises here instead. +export const capWords = s => String(s || '').replace(/(^|[\s(\-\/])(\p{Ll})/gu, (m, pre, ch) => pre + ch.toUpperCase()) export const fmtNum = n => (Math.round(n * 10) / 10).toLocaleString(dateLocale()) // Volume stays in the profile's unit throughout: the old shorthand turned anything over // 10 000 into "t", which is wrong for a pound profile and made one list mix "18.8t" with diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.js index a529098..3e910d5 100644 --- a/frontend/src/lib/history.js +++ b/frontend/src/lib/history.js @@ -107,7 +107,10 @@ const effortTail = s => { // entry or a workout entry); passing an id alone keeps the old body-part behaviour. export function setLabel(id, s, cfg) { const c = cfg || { id } - const mode = modeOf(c) + let mode = modeOf(c) + // A set saved by an older build carries no target with it; the set's own fields still say what + // it was — seconds for a timed set, minutes for cardio — so those are not read back as "0 reps". + if (!cfg && !(s.r > 0)) { if (s.min > 0 || s.speed > 0) mode = 'cardio'; else if (s.sec > 0) mode = 'time' } 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)}` : '') const bw = isBw({ ...c, id: c.id ?? id }) @@ -483,8 +486,13 @@ export function workoutVolume(w) { // does it; this line was the one that did not, which only stopped being harmless when a // routine started planning warm-ups by default. The number is written into the saved // workout, so an inflated one would stay wrong forever. + // A per-side row's mirror is `w = max(L, R), r = L + R` (workout-model syncSideAggregate) — + // right for a headline, wrong for a product: 14×10 left and 12.5×6 right is 215, not 14×16. + // Each side is its own weight × reps, with its own drops and bursts. w.entries.forEach(e => e.sets.forEach(s => { - if (s.done && !isWarmupRow(s)) v += (s.w || 0) * (s.r || 0) + extraVolumeOf(s) + if (!s.done || isWarmupRow(s)) return + if (isSideSet(s)) { for (const side of [s.sides.L, s.sides.R]) v += (side.w || 0) * (side.r || 0) + extraVolumeOf(side); return } + v += (s.w || 0) * (s.r || 0) + extraVolumeOf(s) })) return v } diff --git a/frontend/src/lib/history.test.js b/frontend/src/lib/history.test.js index bc1eb4b..5fd3eda 100644 --- a/frontend/src/lib/history.test.js +++ b/frontend/src/lib/history.test.js @@ -1161,3 +1161,18 @@ describe('lastEntryFor / buildSets skip a noProg entry', () => { expect(bestWeightFor(S, LIFT2)).toBe(140) }) }) + +describe('per-side volume and legacy timed sets (QA round 2026-09-12)', () => { + it('sums each side of a unilateral set on its own instead of max weight × total reps', () => { + const w = { entries: [{ id: 'x', sets: [ + { done: true, sides: { L: { w: 14, r: 10, done: true }, R: { w: 12.5, r: 6, done: true } }, w: 14, r: 16 }, + { done: true, w: 100, r: 10 } + ] }] } + expect(workoutVolume(w)).toBe(14 * 10 + 12.5 * 6 + 1000) + }) + it('reads a timed or cardio set saved without a target from the set itself', () => { + expect(setLabel('0001', { sec: 45, done: true })).toBe('0:45') + expect(setLabel('0001', { min: 20, speed: 8, done: true })).toBe('20 min @ 8 km/h') + expect(setLabel('0025', { w: 60, r: 10, done: true })).toBe('60×10') + }) +}) diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx index 8b1f548..520c1ca 100644 --- a/frontend/src/sheets.jsx +++ b/frontend/src/sheets.jsx @@ -3,7 +3,7 @@ import { useStore } from './store/useStore.js' 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 { fmtDate, fmtNum, capWords, fmtVol, fmtDur, durPart, todayISO, isoOf, uid, exCount, DAYN, DAYS, weekOrder, weekStartOf, weekDayOffset, MONTHS_LONG, ACCENTS } from './lib/format.js' import { lastEntryFor, bestWeightFor, bestWeightForEntry, buildSets, effectiveRoutineIds, workoutVolume, setsDone, setsDoneActive, setUnitsTotal, 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' @@ -61,7 +61,7 @@ function ConfirmDialog({ title, message, confirmText, cancelText, danger, onConf // items: [{ icon, label, sub, onClick, danger, disabled, on }] — `on` draws a check for toggles. function MenuSheet({ title, subtitle, items, close }) { return <> - {title &&