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
Stats: a per-set view of exercise progress, one line per set number (#145)
iamtechnoanaffcaf67cac8d
diff --git a/frontend/src/components/LineChart.jsx b/frontend/src/components/LineChart.jsxindex 219bf013b..546b4e418 100644--- a/frontend/src/components/LineChart.jsx+++ b/frontend/src/components/LineChart.jsx@@ -9,10 +9,13 @@ const W = 340 // viewBox width; the svg stretches to its container, height com// more of it). Used for effort on the weight curve, where the two belong on one line:// the same weight with less left in the tank is not the same session.// note extra text for that point's tooltip.-// opts: { h, unit, color, axes, goal, invert }+// opts: { h, unit, color, axes, goal, invert, series }// invert flips the y axis, for a scale that counts down as it gets harder (RIR). Without it// a curve of reps-in-reserve reads upside down, with the hardest sets at the floor.-export default function LineChart({ points, h = 150, unit = '', color = 'var(--acc)', axes = true, goal = null, invert = false }) {+// series draws several lines instead of one: [{ points, color }] (issue #145, one per set+// number). `points` then only anchors the hover — one per date, its `note` the tooltip — and+// the y axis spans every series.+export default function LineChart({ points, h = 150, unit = '', color = 'var(--acc)', axes = true, goal = null, invert = false, series = null }) {const svgRef = useRef(null)const wrapRef = useRef(null)const tipRef = useRef(null)@@ -48,7 +51,8 @@ export default function LineChart({ points, h = 150, unit = '', color = 'var(--aconst P = { l: axes ? 34 : 8, r: 12, t: 10, b: axes ? 22 : 8 }const single = points.length === 1const pts = single ? [points[0], points[0]] : points- const ys = pts.map(p => p.y)+ const multi = Array.isArray(series) && series.length > 0+ const ys = multi ? series.flatMap(s => s.points.map(p => p.y)) : pts.map(p => p.y)let ymin = Math.min(...ys), ymax = Math.max(...ys)if (goal != null && isFinite(goal)) { ymin = Math.min(ymin, goal); ymax = Math.max(ymax, goal) }if (ymin === ymax) { ymin -= 1; ymax += 1 }@@ -103,7 +107,7 @@ export default function LineChart({ points, h = 150, unit = '', color = 'var(--aconst hoverSource = single ? [points[0]] : pointsconst hoverDates = hoverSource.map(p => p.d || isoOf(new Date(p.t)))const showYear = new Set(hoverDates.map(iso => new Date(iso + 'T12:00:00').getFullYear())).size > 1- const hoverPts = hoverSource.map((p, i) => ({ x: X(p.t), y: Y(p.y), iso: hoverDates[i], v: p.y, note: p.note }))+ const hoverPts = hoverSource.map((p, i) => ({ x: X(p.t), y: Y(p.y), t: p.t, iso: hoverDates[i], v: p.y, note: p.note }))const marked = points.some(p => p.m != null)const onMove = e => {@@ -132,19 +136,37 @@ export default function LineChart({ points, h = 150, unit = '', color = 'var(--a<line x1={P.l} y1={Y(goal)} x2={W - P.r} y2={Y(goal)} stroke="var(--yellow)" strokeWidth="1.6" strokeDasharray="7 4" /><text x={W - P.r - 2} y={Y(goal) - 5} textAnchor="end" fontSize="9.5" fontWeight="700" fill="var(--yellow)">{fmtNum(goal)}</text></>}- <polygon points={`${P.l},${H - P.b} ${poly} ${X(last.t).toFixed(1)},${H - P.b}`} fill={`url(#${gid})`} />- <polyline points={poly} fill="none" stroke={color} strokeWidth="2.5" strokeLinejoin="round" strokeLinecap="round" />- {marked && pts.map((p, i) => (p.m == null ? null :- <circle key={'m' + i} cx={X(p.t)} cy={Y(p.y)} r={2.4 + p.m * 3} fill={color} opacity={0.3 + p.m * 0.7} />))}- <circle cx={X(last.t)} cy={Y(last.y)} r="4" fill={color} />+ {/* The first series is drawn widest and underneath, each next one thinner on top, so+ lines that share their values show as nested stripes instead of hiding each other. */}+ {multi ? series.map((s, k) => {+ const sw = 2 + (series.length - 1 - k) * 2.4+ return <g key={'s' + k}>+ {s.points.length > 1 && <polyline points={s.points.map(p => X(p.t).toFixed(1) + ',' + Y(p.y).toFixed(1)).join(' ')}+ fill="none" stroke={s.color} strokeWidth={sw} strokeLinejoin="round" strokeLinecap="round" />}+ {s.points.map((p, i) => <circle key={i} cx={X(p.t)} cy={Y(p.y)} r={sw / 2 + 1.2} fill={s.color} />)}+ </g>+ }) : <>+ <polygon points={`${P.l},${H - P.b} ${poly} ${X(last.t).toFixed(1)},${H - P.b}`} fill={`url(#${gid})`} />+ <polyline points={poly} fill="none" stroke={color} strokeWidth="2.5" strokeLinejoin="round" strokeLinecap="round" />+ {marked && pts.map((p, i) => (p.m == null ? null :+ <circle key={'m' + i} cx={X(p.t)} cy={Y(p.y)} r={2.4 + p.m * 3} fill={color} opacity={0.3 + p.m * 0.7} />))}+ <circle cx={X(last.t)} cy={Y(last.y)} r="4" fill={color} />+ </>}{hover && <g><line className="cvl" x1={hover.x} y1={P.t} x2={hover.x} y2={H - P.b} stroke="var(--label-3)" strokeWidth="1" strokeDasharray="3 3" />- <line className="chl" x1={P.l} y1={hover.y} x2={W - P.r} y2={hover.y} stroke="var(--label-3)" strokeWidth="1" strokeDasharray="3 3" />- <circle cx={hover.x} cy={hover.y} r="5" fill={color} stroke="var(--bg)" strokeWidth="2" />+ {multi+ ? series.map((s, k) => s.points.filter(p => p.t === hover.t).map((p, i) =>+ <circle key={k + '_' + i} cx={X(p.t)} cy={Y(p.y)} r="4.5" fill={s.color} stroke="var(--bg)" strokeWidth="2" />))+ : <>+ <line className="chl" x1={P.l} y1={hover.y} x2={W - P.r} y2={hover.y} stroke="var(--label-3)" strokeWidth="1" strokeDasharray="3 3" />+ <circle cx={hover.x} cy={hover.y} r="5" fill={color} stroke="var(--bg)" strokeWidth="2" />+ </>}</g>}</svg>{hover && <div className="ctip" ref={tipRef}>- {fmtDate(hover.iso, true, showYear)} · {fmtNum(hover.v)}{unit ? ' ' + unit : ''}{hover.note ? ' · ' + hover.note : ''}+ {multi+ ? <>{fmtDate(hover.iso, true, showYear)}{hover.note ? ' · ' + hover.note : ''}</>+ : <>{fmtDate(hover.iso, true, showYear)} · {fmtNum(hover.v)}{unit ? ' ' + unit : ''}{hover.note ? ' · ' + hover.note : ''}</>}</div>}</div>)diff --git a/frontend/src/lib/per-set.js b/frontend/src/lib/per-set.jsnew file mode 100644index 000000000..f2c35546c--- /dev/null+++ b/frontend/src/lib/per-set.js@@ -0,0 +1,78 @@+/* Per-set progress (issue #145): Stats → Exercise progress drawn as one line per set number, so+ * the set you drop off on shows up — which is often not the last one.+ *+ * A set's number is its place among the session's working sets of this exercise, in reps mode:+ * warm-ups are not counted, a set left undone keeps its number (set 4 never reads as set 3), a+ * per-side set is one set, and a drop set or rest-pause set is plotted at its main set. The same+ * exercise twice in one workout keeps counting across both entries. Pure, so the chart and the+ * tests read the same thing. */+import { entriesForExercise, completedRepsOf } from './history.js'+import { phaseForSet, modeForSet, hasCompletedWork, isSideSet } from './workout-model.js'+import { estimate1RM } from './onerm.js'++export const PER_SET_MAX = 5++const doneSides = set => [set.sides.L, set.sides.R].filter(side => side?.done === true)+const weightOf = set => (isSideSet(set) ? Math.max(0, ...doneSides(set).map(side => Number(side.w) || 0)) : Number(set.w) || 0)++/** Each session with plottable sets: [{ t, d, sets: [{ n, y, w, r }] }], in workout order.+ * `metric`: 'weight' (default), 'reps', or 'e1rm' — the estimated 1RM of the set itself, which+ * is what tells straight sets apart: at one weight their lines would lie on top of each other,+ * and the rep that went missing in the last set is the thing to see. A set past the estimate's+ * rep cap has no point, as on the Est. 1RM curve. A per-side set is estimated from one side's+ * reps, not both added up. */+export function perSetSessions(workouts, exId, { metric = 'weight' } = {}) {+ const out = []+ for (const w of workouts || []) {+ let n = 0+ const sets = []+ for (const entry of entriesForExercise(w, exId)) {+ const target = entry.target || entry+ for (const set of Array.isArray(entry.sets) ? entry.sets : []) {+ if (phaseForSet(set) !== 'work' || modeForSet(set, target) !== 'reps') continue+ n+++ if (!hasCompletedWork(set)) continue+ const wt = weightOf(set), r = completedRepsOf(set)+ const perSide = isSideSet(set) ? r / doneSides(set).length : r+ const y = metric === 'reps' ? r : metric === 'e1rm' ? estimate1RM(wt, perSide) || 0 : wt+ if (y > 0) sets.push({ n, y, w: wt, r })+ }+ }+ if (sets.length) out.push({ t: w.start, d: w.d, sets })+ }+ return out+}++/** One line per set number for the chart, at most PER_SET_MAX of them: { lines, hidden }, where+ * `hidden` counts the set numbers left out, so the card can say so instead of dropping them quietly. */+export function perSetLines(sessions) {+ const byN = new Map()+ for (const s of sessions) {+ for (const set of s.sets) {+ if (!byN.has(set.n)) byN.set(set.n, [])+ byN.get(set.n).push({ t: s.t, y: set.y, d: s.d })+ }+ }+ const all = [...byN.keys()].sort((a, b) => a - b).map(n => ({ n, points: byN.get(n) }))+ const lines = all.slice(0, PER_SET_MAX)+ return { lines, hidden: all.length - lines.length }+}++/** The set that most often is the first to fall below set 1, as { n, count, of } — `of` being+ * the sessions with a set 1 and at least one more. Null with fewer than three such sessions (too+ * few to call it a pattern) or when no session dropped. Ties go to the earlier set. */+export function dropOffSet(sessions) {+ const multi = sessions.filter(s => s.sets.length >= 2 && s.sets[0].n === 1)+ if (multi.length < 3) return null+ const counts = new Map()+ for (const s of multi) {+ const first = s.sets[0].y+ const drop = s.sets.slice(1).find(set => set.y < first)+ if (drop) counts.set(drop.n, (counts.get(drop.n) || 0) + 1)+ }+ let best = null+ for (const [n, count] of counts) {+ if (!best || count > best.count || (count === best.count && n < best.n)) best = { n, count }+ }+ return best && { ...best, of: multi.length }+}diff --git a/frontend/src/lib/per-set.test.js b/frontend/src/lib/per-set.test.jsnew file mode 100644index 000000000..956e471f1--- /dev/null+++ b/frontend/src/lib/per-set.test.js@@ -0,0 +1,117 @@+import { describe, expect, it } from 'vitest'+import { perSetSessions, perSetLines, dropOffSet, PER_SET_MAX } from './per-set.js'++// Issue #145: Stats → Exercise progress, one line per set number, so you can see which set+// you drop off on. A set's number is its place among that session's working sets.+const LIFT = '0025'+const done = (w, r, extra = {}) => ({ w, r, done: true, ...extra })+const workout = (t, d, ...entries) => ({ start: t, d, entries })+const entry = (sets, id = LIFT) => ({ id, sets })++describe('perSetSessions', () => {+ it('numbers the working sets of a session and reads each one\'s weight', () => {+ const ws = [workout(1, '2026-09-01', entry([done(60, 8), done(60, 8), done(55, 6)]))]+ expect(perSetSessions(ws, LIFT)).toEqual([+ { t: 1, d: '2026-09-01', sets: [{ n: 1, y: 60, w: 60, r: 8 }, { n: 2, y: 60, w: 60, r: 8 }, { n: 3, y: 55, w: 55, r: 6 }] },+ ])+ })++ it('leaves warm-ups out of the count', () => {+ const ws = [workout(1, '2026-09-01', entry([done(20, 10, { phase: 'warmup' }), done(40, 5, { warmup: true }), done(60, 8), done(57.5, 7)]))]+ expect(perSetSessions(ws, LIFT)[0].sets.map(s => [s.n, s.y])).toEqual([[1, 60], [2, 57.5]])+ })++ it('a set that was not done keeps its number, so set 4 never reads as set 3', () => {+ const ws = [workout(1, '2026-09-01', entry([done(60, 8), done(60, 8), { w: 60, r: 8, done: false }, done(50, 8)]))]+ expect(perSetSessions(ws, LIFT)[0].sets.map(s => [s.n, s.y])).toEqual([[1, 60], [2, 60], [4, 50]])+ })++ it('a per-side set is one set: its heavier done side, and the reps of both sides', () => {+ const side = (lw, rw, extraR = {}) => ({ sides: { L: done(lw, 8), R: { ...done(rw, 7), ...extraR } } })+ const ws = [workout(1, '2026-09-01', entry([side(20, 20), side(18, 22, { done: false })]))]+ expect(perSetSessions(ws, LIFT)[0].sets).toEqual([{ n: 1, y: 20, w: 20, r: 15 }, { n: 2, y: 18, w: 18, r: 8 }])+ })++ it('a drop set is plotted at its main set; the drops do not become sets of their own', () => {+ const ws = [workout(1, '2026-09-01', entry([done(60, 8), done(60, 6, { type: 'dropset', drops: [{ w: 45, r: 6 }, { w: 30, r: 8 }] })]))]+ expect(perSetSessions(ws, LIFT)[0].sets.map(s => [s.n, s.y])).toEqual([[1, 60], [2, 60]])+ })++ it('the same exercise twice in one workout keeps counting across both entries', () => {+ const ws = [workout(1, '2026-09-01', entry([done(60, 8), done(60, 8)]), entry([done(40, 12)], '0001'), entry([done(50, 10)]))]+ expect(perSetSessions(ws, LIFT)[0].sets.map(s => [s.n, s.y])).toEqual([[1, 60], [2, 60], [3, 50]])+ })++ it('reads reps instead of weight when asked, for unloaded work', () => {+ const ws = [workout(1, '2026-09-01', entry([done(0, 12), done(0, 10), done(0, 7)]))]+ expect(perSetSessions(ws, LIFT, { metric: 'reps' })[0].sets.map(s => s.y)).toEqual([12, 10, 7])+ })++ it('e1rm tells apart sets at the same weight, and skips a set too long to estimate', () => {+ // Straight sets share a weight, so a weight line per set would lie on top of each other;+ // the rep that went missing in set 3 is what this chart is for.+ const ws = [workout(1, '2026-09-01', entry([done(100, 10), done(100, 10), done(100, 8), done(60, 20)]))]+ const sets = perSetSessions(ws, LIFT, { metric: 'e1rm' })[0].sets+ expect(sets.map(s => s.n)).toEqual([1, 2, 3])+ expect(sets[0].y).toBe(sets[1].y)+ expect(sets[2].y).toBeLessThan(sets[1].y)+ })++ it('e1rm of a per-side set reads the reps of one side, not both added up', () => {+ const ws = [workout(1, '2026-09-01', entry([{ sides: { L: done(20, 8), R: done(20, 8) } }, done(20, 8)]))]+ const [a, b] = perSetSessions(ws, LIFT, { metric: 'e1rm' })[0].sets+ expect(a.y).toBe(b.y)+ })++ it('skips sessions with nothing plottable, other exercises, and timed or cardio rows', () => {+ const ws = [+ workout(1, '2026-09-01', entry([{ w: 60, r: 8, done: false }])),+ workout(2, '2026-09-02', entry([done(60, 8)], '0001')),+ workout(3, '2026-09-03', entry([{ sec: 45, done: true, mode: 'time' }])),+ workout(4, '2026-09-04', entry([done(0, 8)])),+ ]+ expect(perSetSessions(ws, LIFT)).toEqual([])+ })+})++describe('perSetLines', () => {+ const sessions = [+ { t: 1, d: '2026-09-01', sets: [{ n: 1, y: 60 }, { n: 2, y: 60 }, { n: 3, y: 55 }] },+ { t: 2, d: '2026-09-08', sets: [{ n: 1, y: 62.5 }, { n: 3, y: 57.5 }] },+ ]+ it('one line per set number, in order, each point dated by its session', () => {+ expect(perSetLines(sessions)).toEqual({+ lines: [+ { n: 1, points: [{ t: 1, y: 60, d: '2026-09-01' }, { t: 2, y: 62.5, d: '2026-09-08' }] },+ { n: 2, points: [{ t: 1, y: 60, d: '2026-09-01' }] },+ { n: 3, points: [{ t: 1, y: 55, d: '2026-09-01' }, { t: 2, y: 57.5, d: '2026-09-08' }] },+ ],+ hidden: 0,+ })+ })+ it(`draws at most ${PER_SET_MAX} lines and says how many sets were left out`, () => {+ const many = [{ t: 1, d: '2026-09-01', sets: Array.from({ length: PER_SET_MAX + 2 }, (_, i) => ({ n: i + 1, y: 50 })) }]+ const { lines, hidden } = perSetLines(many)+ expect(lines.map(l => l.n)).toEqual(Array.from({ length: PER_SET_MAX }, (_, i) => i + 1))+ expect(hidden).toBe(2)+ })+})++describe('dropOffSet', () => {+ const s = (...ys) => ({ t: 0, d: '', sets: ys.map((y, i) => ({ n: i + 1, y })) })+ it('the set that most often first falls below set 1, and in how many sessions', () => {+ expect(dropOffSet([s(60, 60, 55), s(60, 60, 57.5), s(60, 55, 55), s(60, 60, 60)])).toEqual({ n: 3, count: 2, of: 4 })+ })+ it('ties go to the earlier set', () => {+ expect(dropOffSet([s(60, 55, 55), s(60, 60, 55), s(60, 60, 60)])).toEqual({ n: 2, count: 1, of: 3 })+ })+ it('nothing to say when no session dropped, or with fewer than three sessions of two or more sets', () => {+ expect(dropOffSet([s(60, 60), s(60, 60), s(60, 60)])).toBeNull()+ expect(dropOffSet([s(60, 55), s(60, 55)])).toBeNull()+ expect(dropOffSet([s(60), s(60), s(60)])).toBeNull()+ })+ it('a session without a set 1 has nothing to compare against and is not counted', () => {+ const later = { t: 0, d: '', sets: [{ n: 2, y: 60 }, { n: 3, y: 50 }] }+ expect(dropOffSet([s(60, 60, 55), s(60, 60, 55), later, s(60, 60, 60)])).toEqual({ n: 3, count: 2, of: 3 })+ })+})diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.jsindex b92f6745e..c30c57f79 100644--- a/frontend/src/locales/ar.js+++ b/frontend/src/locales/ar.js@@ -1766,6 +1766,11 @@ export default {'Record: {0} rep': 'الرقم القياسي: {0} تكرار','Max reps': 'تكرارات أقصى','Most reps in a Max set per workout': 'أكبر عدد تكرارات في مجموعة أقصى لكل تمرين',+ 'Per set': 'لكل مجموعة',+ 'Estimated 1RM of each working set, one line per set number': '1RM المقدّر لكل مجموعة عمل، خط لكل رقم مجموعة',+ 'Reps in each working set, one line per set number': 'تكرارات كل مجموعة عمل، خط لكل رقم مجموعة',+ 'Where you most often drop off: set {0} ({1} of {2} workouts)': 'أكثر مكان تتراجع فيه: المجموعة {0} ({1} من {2} تمارين)',+ 'Only the first {0} sets are drawn.': 'تُرسم أول {0} مجموعات فقط.','A set left at 0 rest uses the exercise’s rest.': 'المجموعة ذات الراحة 0 تستخدم راحة التمرين.',// --- update a routine from a running workout ---'Update routine': 'تحديث الروتين',diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex 7fdb20e04..0772363fb 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -1733,6 +1733,11 @@ export default {'Record: {0} rep': 'Rekord: {0} Wdh.','Max reps': 'Max-Wdh.','Most reps in a Max set per workout': 'Meiste Wiederholungen in einem Max-Satz pro Training',+ 'Per set': 'Pro Satz',+ 'Estimated 1RM of each working set, one line per set number': 'Geschätztes 1RM jedes Arbeitssatzes, eine Linie pro Satznummer',+ 'Reps in each working set, one line per set number': 'Wiederholungen jedes Arbeitssatzes, eine Linie pro Satznummer',+ 'Where you most often drop off: set {0} ({1} of {2} workouts)': 'Wo du am häufigsten nachlässt: Satz {0} ({1} von {2} Trainings)',+ 'Only the first {0} sets are drawn.': 'Nur die ersten {0} Sätze werden gezeichnet.','A set left at 0 rest uses the exercise’s rest.': 'Ein Satz mit 0 Pause nutzt die Pause der Übung.',// --- update a routine from a running workout ---'Update routine': 'Routine aktualisieren',diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex 592a333e1..b745eef6e 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -1713,6 +1713,11 @@ export default {'Record: {0} rep': 'Récord: {0} rep','Max reps': 'Reps Máx','Most reps in a Max set per workout': 'Más repeticiones en una serie Máx por entrenamiento',+ 'Per set': 'Por serie',+ 'Estimated 1RM of each working set, one line per set number': '1RM estimado de cada serie efectiva, una línea por número de serie',+ 'Reps in each working set, one line per set number': 'Repeticiones de cada serie efectiva, una línea por número de serie',+ 'Where you most often drop off: set {0} ({1} of {2} workouts)': 'Donde más sueles flojear: serie {0} ({1} de {2} entrenamientos)',+ 'Only the first {0} sets are drawn.': 'Solo se dibujan las primeras {0} series.','A set left at 0 rest uses the exercise’s rest.': 'Una serie con descanso 0 usa el descanso del ejercicio.',// --- update a routine from a running workout ---'Update routine': 'Actualizar rutina',diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex a6c2a3d84..fe56c963c 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -1713,6 +1713,11 @@ export default {'Record: {0} rep': 'Record : {0} rep','Max reps': 'Reps Max','Most reps in a Max set per workout': 'Le plus de répétitions sur une série Max par séance',+ 'Per set': 'Par série',+ 'Estimated 1RM of each working set, one line per set number': '1RM estimé de chaque série de travail, une ligne par numéro de série',+ 'Reps in each working set, one line per set number': 'Répétitions de chaque série de travail, une ligne par numéro de série',+ 'Where you most often drop off: set {0} ({1} of {2} workouts)': 'Là où vous lâchez le plus souvent : série {0} ({1} séances sur {2})',+ 'Only the first {0} sets are drawn.': 'Seules les {0} premières séries sont tracées.','A set left at 0 rest uses the exercise’s rest.': 'Une série avec 0 de repos utilise le repos de l’exercice.',// --- update a routine from a running workout ---'Update routine': 'Mettre à jour la routine',diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex 8c05a4933..3e356a72e 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -1713,6 +1713,11 @@ export default {'Record: {0} rep': 'रिकॉर्ड: {0} रेप','Max reps': 'मैक्स रेप','Most reps in a Max set per workout': 'हर वर्कआउट में मैक्स सेट के सबसे ज़्यादा रेप',+ 'Per set': 'प्रति सेट',+ 'Estimated 1RM of each working set, one line per set number': 'हर वर्किंग सेट का अनुमानित 1RM, हर सेट नंबर की एक लाइन',+ 'Reps in each working set, one line per set number': 'हर वर्किंग सेट के रेप, हर सेट नंबर की एक लाइन',+ 'Where you most often drop off: set {0} ({1} of {2} workouts)': 'आप सबसे ज़्यादा कहाँ पीछे रह जाते हैं: सेट {0} ({2} में से {1} वर्कआउट)',+ 'Only the first {0} sets are drawn.': 'सिर्फ़ पहले {0} सेट दिखाए गए हैं।','A set left at 0 rest uses the exercise’s rest.': '0 आराम वाला सेट एक्सरसाइज़ का आराम इस्तेमाल करता है।',// --- update a routine from a running workout ---'Update routine': 'रूटीन अपडेट करें',diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex 3b8a3698f..d0be0ac6c 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -1716,6 +1716,11 @@ export default {'Record: {0} rep': 'Rekord: {0} ism.','Max reps': 'Max ism.','Most reps in a Max set per workout': 'A legtöbb ismétlés egy Max sorozatban edzésenként',+ 'Per set': 'Sorozatonként',+ 'Estimated 1RM of each working set, one line per set number': 'Minden munkasorozat becsült 1RM-je, sorozatszámonként egy vonal',+ 'Reps in each working set, one line per set number': 'Minden munkasorozat ismétlései, sorozatszámonként egy vonal',+ 'Where you most often drop off: set {0} ({1} of {2} workouts)': 'Ahol a leggyakrabban visszaesel: {0}. sorozat ({2} edzésből {1})',+ 'Only the first {0} sets are drawn.': 'Csak az első {0} sorozat látható.','A set left at 0 rest uses the exercise’s rest.': 'A 0 pihenőjű sorozat a gyakorlat pihenőjét használja.',// --- update a routine from a running workout ---'Update routine': 'Rutin frissítése',diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 81f392217..60646b5a6 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -1713,6 +1713,11 @@ export default {'Record: {0} rep': 'Record: {0} rip','Max reps': 'Rip Max','Most reps in a Max set per workout': 'Più ripetizioni in una serie Max per allenamento',+ 'Per set': 'Per serie',+ 'Estimated 1RM of each working set, one line per set number': '1RM stimato di ogni serie allenante, una linea per numero di serie',+ 'Reps in each working set, one line per set number': 'Ripetizioni di ogni serie allenante, una linea per numero di serie',+ 'Where you most often drop off: set {0} ({1} of {2} workouts)': 'Dove cali più spesso: serie {0} ({1} su {2} allenamenti)',+ 'Only the first {0} sets are drawn.': 'Sono disegnate solo le prime {0} serie.','A set left at 0 rest uses the exercise’s rest.': 'Una serie con riposo 0 usa il riposo dell’esercizio.',// --- update a routine from a running workout ---'Update routine': 'Aggiorna la routine',diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex fc4f356c8..138f37ae8 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -1713,6 +1713,11 @@ export default {'Record: {0} rep': '기록: {0}회','Max reps': '최대 반복','Most reps in a Max set per workout': '운동마다 최대 세트의 최다 반복 수',+ 'Per set': '세트별',+ 'Estimated 1RM of each working set, one line per set number': '각 본세트의 추정 1RM, 세트 번호마다 선 하나',+ 'Reps in each working set, one line per set number': '각 본세트의 반복 수, 세트 번호마다 선 하나',+ 'Where you most often drop off: set {0} ({1} of {2} workouts)': '가장 자주 떨어지는 세트: {0}세트 ({2}번 중 {1}번)',+ 'Only the first {0} sets are drawn.': '처음 {0}세트만 표시됩니다.','A set left at 0 rest uses the exercise’s rest.': '휴식이 0인 세트는 운동의 휴식 시간을 사용합니다.',// --- update a routine from a running workout ---'Update routine': '루틴 업데이트',diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex 92579d18f..6172253ed 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -1713,6 +1713,11 @@ export default {'Record: {0} rep': 'Rekord: {0} powt.','Max reps': 'Powt. Maks','Most reps in a Max set per workout': 'Najwięcej powtórzeń w serii Maks na trening',+ 'Per set': 'Na serię',+ 'Estimated 1RM of each working set, one line per set number': 'Szacowany 1RM każdej serii roboczej, jedna linia na numer serii',+ 'Reps in each working set, one line per set number': 'Powtórzenia w każdej serii roboczej, jedna linia na numer serii',+ 'Where you most often drop off: set {0} ({1} of {2} workouts)': 'Gdzie najczęściej słabniesz: seria {0} ({1} z {2} treningów)',+ 'Only the first {0} sets are drawn.': 'Rysowane jest tylko pierwszych {0} serii.','A set left at 0 rest uses the exercise’s rest.': 'Seria z przerwą 0 używa przerwy ćwiczenia.',// --- update a routine from a running workout ---'Update routine': 'Zaktualizuj plan',diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.jsindex c2c52d5f7..100eb2cca 100644--- a/frontend/src/locales/pt-BR.js+++ b/frontend/src/locales/pt-BR.js@@ -1059,6 +1059,11 @@ export const PT_BR_OVERRIDES = {'Max: as many reps as you can': 'Máx: o máximo de repetições que você conseguir','Weight is up to you: pyramid sets are not progressed automatically.': 'Você escolhe o peso: as séries em pirâmide não progridem automaticamente.','Most reps in a Max set per workout': 'Mais repetições em uma série Máx por treino',+ 'Per set': 'Por série',+ 'Estimated 1RM of each working set, one line per set number': '1RM estimado de cada série de trabalho, uma linha por número de série',+ 'Reps in each working set, one line per set number': 'Repetições de cada série de trabalho, uma linha por número de série',+ 'Where you most often drop off: set {0} ({1} of {2} workouts)': 'Onde você mais cai de rendimento: série {0} ({1} de {2} treinos)',+ 'Only the first {0} sets are drawn.': 'Só as primeiras {0} séries são desenhadas.',// --- update a routine from a running workout ---'Update routine': 'Atualizar rotina','Update “{0}”?': 'Atualizar “{0}”?',diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex ad06595ac..407956539 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -1713,6 +1713,11 @@ export default {'Record: {0} rep': 'Recorde: {0} rep','Max reps': 'Reps Máx','Most reps in a Max set per workout': 'Mais repetições numa série Máx por treino',+ 'Per set': 'Por série',+ 'Estimated 1RM of each working set, one line per set number': '1RM estimado de cada série de trabalho, uma linha por número de série',+ 'Reps in each working set, one line per set number': 'Repetições de cada série de trabalho, uma linha por número de série',+ 'Where you most often drop off: set {0} ({1} of {2} workouts)': 'Onde a quebra é mais frequente: série {0} ({1} de {2} treinos)',+ 'Only the first {0} sets are drawn.': 'Só são desenhadas as primeiras {0} séries.','A set left at 0 rest uses the exercise’s rest.': 'Uma série com descanso 0 usa o descanso do exercício.',// --- update a routine from a running workout ---'Update routine': 'Atualizar rotina',diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex 576e5cbe6..9088d6471 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -1717,6 +1717,11 @@ export default {'Record: {0} rep': 'Рекорд: {0} повт.','Max reps': 'Повт. Макс','Most reps in a Max set per workout': 'Больше всего повторов в подходе Макс за тренировку',+ 'Per set': 'По подходам',+ 'Estimated 1RM of each working set, one line per set number': 'Расчётный 1ПМ каждого рабочего подхода, одна линия на номер подхода',+ 'Reps in each working set, one line per set number': 'Повторы в каждом рабочем подходе, одна линия на номер подхода',+ 'Where you most often drop off: set {0} ({1} of {2} workouts)': 'Где вы чаще всего сдаёте: подход {0} ({1} из {2} тренировок)',+ 'Only the first {0} sets are drawn.': 'Показаны только первые {0} подходов.','A set left at 0 rest uses the exercise’s rest.': 'Подход с отдыхом 0 использует отдых упражнения.',// --- update a routine from a running workout ---'Update routine': 'Обновить программу',diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex 1031f9448..671f96097 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -1724,6 +1724,11 @@ export default {'Record: {0} rep': 'สถิติ: {0} ครั้ง','Max reps': 'ครั้งสูงสุด','Most reps in a Max set per workout': 'จำนวนครั้งมากที่สุดในเซ็ตสูงสุดต่อการฝึก',+ 'Per set': 'ต่อเซ็ต',+ 'Estimated 1RM of each working set, one line per set number': '1RM โดยประมาณของแต่ละเซ็ตทำงาน หนึ่งเส้นต่อหมายเลขเซ็ต',+ 'Reps in each working set, one line per set number': 'จำนวนครั้งในแต่ละเซ็ตทำงาน หนึ่งเส้นต่อหมายเลขเซ็ต',+ 'Where you most often drop off: set {0} ({1} of {2} workouts)': 'จุดที่คุณแผ่วบ่อยที่สุด: เซ็ต {0} ({1} จาก {2} ครั้ง)',+ 'Only the first {0} sets are drawn.': 'แสดงเฉพาะ {0} เซ็ตแรกเท่านั้น','A set left at 0 rest uses the exercise’s rest.': 'เซ็ตที่พัก 0 จะใช้เวลาพักของท่านั้น',// --- update a routine from a running workout ---'Update routine': 'อัปเดตรูทีน',diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex d6fa067cf..1adf4321f 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -1713,6 +1713,11 @@ export default {'Record: {0} rep': 'Rekor: {0} tekrar','Max reps': 'Maks tekrar','Most reps in a Max set per workout': 'Antrenman başına bir Maks setteki en çok tekrar',+ 'Per set': 'Set bazında',+ 'Estimated 1RM of each working set, one line per set number': 'Her çalışma setinin tahmini 1RM değeri, her set numarası için bir çizgi',+ 'Reps in each working set, one line per set number': 'Her çalışma setindeki tekrar sayısı, her set numarası için bir çizgi',+ 'Where you most often drop off: set {0} ({1} of {2} workouts)': 'En sık düştüğünüz set: {0}. set ({2} antrenmanın {1} tanesinde)',+ 'Only the first {0} sets are drawn.': 'Yalnızca ilk {0} set çiziliyor.','A set left at 0 rest uses the exercise’s rest.': 'Dinlenmesi 0 olan set, egzersizin dinlenmesini kullanır.',// --- update a routine from a running workout ---'Update routine': 'Rutini güncelle',diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.jsindex a4a775ede..37409f9a8 100644--- a/frontend/src/locales/uk.js+++ b/frontend/src/locales/uk.js@@ -1710,6 +1710,11 @@ export default {'Record: {0} rep': 'Рекорд: {0} повт.','Max reps': 'Повт. Макс','Most reps in a Max set per workout': 'Найбільше повторів у підході Макс за тренування',+ 'Per set': 'По підходах',+ 'Estimated 1RM of each working set, one line per set number': 'Розрахунковий 1ПМ кожного робочого підходу, одна лінія на номер підходу',+ 'Reps in each working set, one line per set number': 'Повтори в кожному робочому підході, одна лінія на номер підходу',+ 'Where you most often drop off: set {0} ({1} of {2} workouts)': 'Де ти найчастіше здаєш: підхід {0} ({1} з {2} тренувань)',+ 'Only the first {0} sets are drawn.': 'Показано лише перші {0} підходів.','A set left at 0 rest uses the exercise’s rest.': 'Підхід із відпочинком 0 використовує відпочинок вправи.',// --- update a routine from a running workout ---'Update routine': 'Оновити програму',diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.jsindex 0ab17d0bf..7989cc39c 100644--- a/frontend/src/locales/zh-TW.js+++ b/frontend/src/locales/zh-TW.js@@ -1686,6 +1686,11 @@ export default {'Record: {0} rep': '紀錄:{0} 下','Max reps': '力竭次數','Most reps in a Max set per workout': '每次訓練中力竭組的最多次數',+ 'Per set': '每組',+ 'Estimated 1RM of each working set, one line per set number': '每個正式組的預估 1RM,每個組號一條線',+ 'Reps in each working set, one line per set number': '每個正式組的次數,每個組號一條線',+ 'Where you most often drop off: set {0} ({1} of {2} workouts)': '最常掉的組:第 {0} 組({2} 次訓練中 {1} 次)',+ 'Only the first {0} sets are drawn.': '只繪製前 {0} 組。','A set left at 0 rest uses the exercise’s rest.': '休息設為 0 的組會使用該動作的休息時間。','Show less': '顯示更少','Completed': '已完成',diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex 07765586e..c7f4d7010 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -1713,6 +1713,11 @@ export default {'Record: {0} rep': '纪录:{0} 次','Max reps': '力竭次数','Most reps in a Max set per workout': '每次训练中力竭组的最多次数',+ 'Per set': '每组',+ 'Estimated 1RM of each working set, one line per set number': '每个正式组的预估 1RM,每个组号一条线',+ 'Reps in each working set, one line per set number': '每个正式组的次数,每个组号一条线',+ 'Where you most often drop off: set {0} ({1} of {2} workouts)': '最常掉的组:第 {0} 组({2} 次训练中 {1} 次)',+ 'Only the first {0} sets are drawn.': '只绘制前 {0} 组。','A set left at 0 rest uses the exercise’s rest.': '休息为 0 的组使用该动作的休息时间。',// --- update a routine from a running workout ---'Update routine': '更新训练日',diff --git a/frontend/src/views/Stats.jsx b/frontend/src/views/Stats.jsxindex 57ea85e53..dc242de6b 100644--- a/frontend/src/views/Stats.jsx+++ b/frontend/src/views/Stats.jsx@@ -1,7 +1,7 @@import { useEffect, useMemo, useState } from 'react'import { useNavigate } from 'react-router-dom'import { useStore } from '../store/useStore.js'-import { EXIDX, matchExercise, betterWeight } from '../lib/exercises.js'+import { EXIDX, matchExercise, betterWeight, isAssisted } from '../lib/exercises.js'import { lastBW, streakWeeks, setLabel, modeOf, effortOf, entriesForExercise, metricEntriesForExercise, metricModeForEntry, bestWeightForEntry, completedRepsOf, workoutDay } from '../lib/history.js'import { fmtNum, fmtDate, fmtVol, todayISO, isoOf, weekKey, weekStartOf, exerciseNameText } from '../lib/format.js'import { speedUnitOf, speedLabel, toSpeed } from '../lib/speed.js'@@ -17,6 +17,7 @@ import { strengthExerciseRowsForMuscle } from '../lib/strength-exercises.js'import { fatigueStateOf } from '../lib/recovery-view.js'import { e1rmSeries, best1RM } from '../lib/onerm.js'import { maxRepsSeries } from '../lib/pyramid.js'+import { perSetSessions, perSetLines, dropOffSet } from '../lib/per-set.js'import {hasEffort, displayScale, scaleName, toScale, avgRir, effortSummary, effortWeeks,effortHistogram, isHardSet, HARD_RIR@@ -25,6 +26,9 @@ import { Button, Segmented, SelectRow } from '../components/ui.jsx'import { tappable } from '../lib/use-sheet-keyboard.js'import { isWarmupRow } from '../lib/workout-model.js'+// Set 1 to 5 on the per-set chart — system colours, so each line keeps its hue in dark mode.+const SET_COLORS = ['var(--blue)', 'var(--green)', 'var(--orange)', 'var(--purple)', 'var(--pink)']+// Which muscles the training in a window actually hit — and, the point of the card,// which ones it keeps missing. Shading is relative within the window (lib/muscles.js).function latestMuscleTraining(workouts) {@@ -538,6 +542,34 @@ export default function Stats() {)const showMax = maxPts.length > 0const maxBest = showMax ? Math.max(...maxPts.map(p => p.y)) : 0+ // Per set (issue #145): one line per set number, to see which set you drop off on — often not+ // the last. Offered once two sessions are logged and one of them has two sets or more.+ // Memoised like e1Pts: LineChart drops its hover whenever `points` changes identity.+ // Loaded work is drawn as each set's estimated 1RM, so straight sets at one weight still part+ // where reps were lost. Reps instead for unloaded work, an assistance machine (where a 1RM+ // reads backwards), or a history of sets all past the estimate's rep cap.+ const perSet = useMemo(() => {+ if (!curEx || curMode !== 'reps') return null+ const usable = list => list.length >= 2 && list.some(s => s.sets.length >= 2)+ let metric = repsOnly || isAssisted(curEx) ? 'reps' : 'e1rm'+ let sessions = perSetSessions(workouts, curEx, { metric })+ if (metric === 'e1rm' && !usable(sessions)) sessions = perSetSessions(workouts, curEx, { metric: metric = 'reps' })+ if (!usable(sessions)) return null+ const { lines, hidden } = perSetLines(sessions)+ const shown = new Set(lines.map(l => l.n))+ return {+ series: lines.map(l => ({ points: l.points, color: SET_COLORS[l.n - 1] })),+ anchors: sessions.map(s => ({+ t: s.t, d: s.d, y: Math.max(...s.sets.map(x => x.y)),+ note: s.sets.filter(x => shown.has(x.n)).map(x => x.n + ': ' + (repsOnly ? x.r : fmtNum(x.w) + '×' + x.r)).join(' · '),+ })),+ ns: lines.map(l => l.n),+ hidden,+ metric,+ drop: dropOffSet(sessions),+ }+ }, [workouts, curEx, curMode, repsOnly])+ const onSets = !!perSet && exMetric === 'sets'const onE1 = showE1 && exMetric === 'e1rm'const onEff = showEff && exMetric === 'effort'const onMax = showMax && exMetric === 'max'@@ -548,6 +580,7 @@ export default function Stats() {note: exRir[i] == null ? undefined : hd + ' ' + fmtNum(toScale(kind, exRir[i]))}))const exOpts = [{ value: 'top', label: t('Top set') }]+ if (perSet) exOpts.push({ value: 'sets', label: t('Per set') })if (showE1) exOpts.push({ value: 'e1rm', label: t('Est. 1RM') })if (showEff) exOpts.push({ value: 'effort', label: t('Effort') })if (showMax) exOpts.push({ value: 'max', label: t('Max reps') })@@ -619,24 +652,36 @@ export default function Stats() {match: (option, query) => matchExercise(matcherOf(option.value), query),}} /></div>- {exOpts.length > 1 && <Segmented className="seg-range" value={onMax ? 'max' : onEff ? 'effort' : onE1 ? 'e1rm' : 'top'} onChange={setExMetric} options={exOpts} />}+ {exOpts.length > 1 && <Segmented className="seg-range" value={onMax ? 'max' : onEff ? 'effort' : onE1 ? 'e1rm' : onSets ? 'sets' : 'top'} onChange={setExMetric} options={exOpts} />}<div className="chart">- {onMax+ {onSets+ ? <LineChart points={perSet.anchors} series={perSet.series} h={150} unit={perSet.metric === 'reps' ? t('reps') : S.unit} />+ : onMax? <LineChart points={maxPts} h={150} unit={t('reps')} color="var(--blue)" />: onEff? <LineChart points={effPts} h={150} unit={hd} color="var(--yellow)" invert={kind === 'rir'} />: <LineChart points={onE1 ? e1ChartPts : topPts} h={150} unit={exUnit} color="var(--blue)" />}</div>+ {onSets && <div className="row small" style={{ gap: 12, flexWrap: 'wrap', marginTop: 6 }}>+ {perSet.ns.map(n => <span key={n} className="row" style={{ gap: 5, alignItems: 'center' }}>+ <span aria-hidden="true" style={{ width: 8, height: 8, borderRadius: 4, background: SET_COLORS[n - 1] }} />{t('Set {0}', n)}+ </span>)}+ </div>}<div style={{ marginTop: 8 }}>{exList.map((p, i) => <div key={i} className="row between small" style={{ padding: '6px 0', borderBottom: 'var(--hair) solid var(--sep)' }}><span className="muted">{fmtDate(p.d, true)}</span><span>{p.sets.map(s => setLabel(curEx, s, p.target, speedUnit)).join(' ')}</span></div>)}</div><div className="small dim" style={{ marginTop: 8 }}>- {onMax ? <>{t('Most reps in a Max set per workout')} · {t('Best:')}{' '}<b className="accent">{maxBest} {t('reps')}</b></> : onEff ? t('Average effort per workout') : onE1 ? t('Estimated 1RM per workout') : curCardio ? t('Top speed per workout') : curTimed ? t('Longest hold per workout') : repsOnly ? t('Most reps in a set per workout') : t('Best set weight per workout')}- {onEff || onMax ? '' : <> · {t('Best:')}{' '}<b className="accent">{fmtNum(onE1 ? e1Best.est : exBest)} {onE1 ? S.unit : exUnit}</b></>}+ {onSets ? (perSet.metric === 'reps' ? t('Reps in each working set, one line per set number') : t('Estimated 1RM of each working set, one line per set number')) : onMax ? <>{t('Most reps in a Max set per workout')} · {t('Best:')}{' '}<b className="accent">{maxBest} {t('reps')}</b></> : onEff ? t('Average effort per workout') : onE1 ? t('Estimated 1RM per workout') : curCardio ? t('Top speed per workout') : curTimed ? t('Longest hold per workout') : repsOnly ? t('Most reps in a set per workout') : t('Best set weight per workout')}+ {onEff || onMax || onSets ? '' : <> · {t('Best:')}{' '}<b className="accent">{fmtNum(onE1 ? e1Best.est : exBest)} {onE1 ? S.unit : exUnit}</b></>}</div>+ {onSets && (perSet.drop || perSet.hidden > 0) && <div className="small dim" style={{ marginTop: 4 }}>+ {perSet.drop && t('Where you most often drop off: set {0} ({1} of {2} workouts)', perSet.drop.n, perSet.drop.count, perSet.drop.of)}+ {perSet.drop && perSet.hidden > 0 ? ' · ' : ''}+ {perSet.hidden > 0 && t('Only the first {0} sets are drawn.', perSet.ns.length)}+ </div>}{onE1 && <div className="small dim" style={{ marginTop: 4 }}>{t('Best estimate from {0} on {1}. An estimate, not a tested max.', fmtNum(e1Best.w) + ' ' + S.unit + ' × ' + e1Best.r, fmtDate(e1Best.d, true))}</div>}- {!onEff && !onE1 && !onMax && showEff && <div className="small dim" style={{ marginTop: 4 }}>+ {!onEff && !onE1 && !onMax && !onSets && showEff && <div className="small dim" style={{ marginTop: 4 }}>{t('A fuller dot means less left in the tank. The same weight at a lower {0} is progress the line alone doesn’t show.', hd)}</div>}</> : <div className="muted small">{t('Finish your first workout and your progress curves will show up here.')}</div>}