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
Add estimated RIR statistics
Сергей Горбатенко79823b960bac
diff --git a/docs/dev/FATIGUE_SETS_MODEL.md b/docs/dev/FATIGUE_SETS_MODEL.mdindex b8b3c275f..fd4a0ccd7 100644--- a/docs/dev/FATIGUE_SETS_MODEL.md+++ b/docs/dev/FATIGUE_SETS_MODEL.md@@ -118,7 +118,19 @@ Measured on the same state: gluteal 0.533 fatigued, hamstring/quads/calvesdiscounted), chest 0.156 ready (upper 1.9d ago). Phase 1 read 0.54-0.66/0.251on the same day; the direction is the same, the magnitudes now respect quality.-## Files touched (phase 2 adds)+## Follow-up: estimated effort in the Stats Effort card++`EffortCard` only rendered on logged ratings, so import histories saw nothing.+It now falls back to estimates with the same precedence fatigue uses (logged >+Epley-inverse vs 90-day anchor > nothing), sharing `anchorsByWorkout` /+`resolveSetRir` from `recovery.js` (no import cycle: the view wires both,+`effort.js` takes an injected resolver defaulting to logged-only, so default-path+numbers are byte-identical). Well-rated windows (`rated >= MIN_RATED`) keep+logged numbers; the badge `· estimated` plus the `{rated} · {estimated} of+{sets}` denominator keep estimates labeled. Two new locale strings in all 16+packs, pt-BR fingerprint refreshed. Measured on the reporter's history (30d):+358 estimated of 407 sets, avg RIR ~5.3, 37% hard — the Jefit pyramids read+exactly as trained: heavy top sets plus light ramp volume.- `frontend/src/lib/recovery.js` — phase 1: sets stimulus + per-muscle HL; phase 2:RIR weighting, 90-day anchors (kg-canonical), acute:chronic gain, 120d info pool.@@ -135,7 +147,8 @@ on the same day; the direction is the same, the magnitudes now respect quality.tree too).- `npm run test:fatigue-probe` — PASS (108000 time + 1800 latest-deletioncomparisons; contract changed, see above).-- `node scripts/check-locales.mjs` — clean (no UI strings changed).+- `node scripts/check-locales.mjs` — clean (2 new strings in all 16 packs,+ pt-BR fingerprint refreshed).- `cd api && npm test` — 471 pass / 2 fail, identical on clean tree(password-hash timing tests, unrelated).- `cd mcp && TZ=UTC npm test` — 63/63 (bare `npm test` fails on +07 machinesdiff --git a/frontend/src/lib/effort.js b/frontend/src/lib/effort.jsindex 9649f358a..079343244 100644--- a/frontend/src/lib/effort.js+++ b/frontend/src/lib/effort.js@@ -9,6 +9,7 @@import { EFFORT, effortOf } from './history.js'import { weekKey, weekStartOf, startOfWeek } from './format.js'import { isWarmupRow } from './workout-model.js'+import { isAssisted } from './exercises.js'// At or below this a set is close enough to failure to be the kind that drives adaptation.// 3 rather than 2: the line is a convention, and drawn one rep too generously it still@@ -53,6 +54,16 @@ function eachDoneSet(S, fn) {const inWindow = (w, days) =>!days || (w.start || new Date(w.d).getTime()) > Date.now() - days * 86400000+// A set's RIR plus where it came from. The default resolver is logged effort only+// (historical behaviour, unchanged); pass a resolver built on+// recovery.js:resolveSetRir for the estimated fallback, which keeps stats and the+// fatigue map in agreement about every set.+const normRir = r => {+ if (r == null) return null+ if (typeof r === 'number') return { rir: r, estimated: false }+ return { rir: r.rir, estimated: r.source ? r.source !== 'logged' : !!r.estimated }+}+export const avgRir = sets => {const vs = (sets || []).map(rirOf).filter(v => v != null)return vs.length ? vs.reduce((a, b) => a + b, 0) / vs.length : null@@ -62,22 +73,26 @@ export const avgRir = sets => {* The headline numbers for a window: how hard, how much of it was hard, and — the part that* keeps the rest honest — how much of the training was rated at all. Effort is optional and* off by default, so partial coverage is the normal case; an average without its denominator- * would quietly speak for sets that were never rated.+ * would quietly speak for sets that were never rated. `resolve` maps (set, workout, entry)+ * to RIR; estimates flow through it flagged, so the caller can label them honestly.*/-export function effortSummary(S, days) {- let done = 0, rated = 0, sum = 0, hard = 0- eachDoneSet(S, (s, w) => {+export function effortSummary(S, days, resolve = rirOf) {+ let done = 0, rated = 0, est = 0, sum = 0, hard = 0+ eachDoneSet(S, (s, w, e) => {if (!inWindow(w, days)) returndone++- const r = rirOf(s)- if (r == null) return- rated++; sum += r- if (r <= HARD_RIR) hard+++ const r = normRir(resolve(s, w, e))+ if (r == null || r.rir == null) return+ if (r.estimated) est+++ else rated+++ sum += r.rir+ if (r.rir <= HARD_RIR) hard++})+ const covered = rated + estreturn {- done, rated, hard,- avg: rated >= MIN_RATED ? sum / rated : null,- hardPct: rated >= MIN_RATED ? hard / rated : null+ done, rated, est, covered, hard,+ avg: covered >= MIN_RATED ? sum / covered : null,+ hardPct: covered >= MIN_RATED ? hard / covered : null}}@@ -88,26 +103,45 @@ export function hasEffort(S) {return any}+/**+ * Could any set be RIR-estimated (load, reps in estimator range, non-assisted)?+ * Decides whether the estimated-fallback UI exists for histories nobody rated -+ * Jefit/Hevy imports carry loads but no ratings. Warm-ups don't count: estimating+ * them would fill the card with discounted ramp rows instead of training.+ */+export function hasEstimableEffort(S) {+ let any = false+ eachDoneSet(S, (s, w, e) => {+ if (any) return+ const wgt = Number(s?.w)+ const reps = Number(s?.r)+ if (!(wgt > 0) || !(reps >= 1) || reps > 12) return+ if (isAssisted(e?.id ? { id: e.id } : e)) return+ any = true+ })+ return any+}+/*** Average effort per calendar week, with the week's set count alongside: the pair is the* point. Volume up with effort up is fatigue accumulating; volume up with effort flat is the* adaptation you were training for. Weeks with a single rated set are dropped rather than* drawn — one tap should not become a peak in the curve.*/-export function effortWeeks(S, days) {+export function effortWeeks(S, days, resolve = rirOf) {const ws = weekStartOf(S)const wk = new Map()- eachDoneSet(S, (s, w) => {+ eachDoneSet(S, (s, w, entry) => {if (!inWindow(w, days)) returnconst k = weekKey(w.d, ws)- let e = wk.get(k)- if (!e) wk.set(k, e = { k, t: startOfWeek(w.d, ws).getTime(), sum: 0, n: 0, sets: 0 })- e.sets++- const r = rirOf(s)- if (r != null) { e.sum += r; e.n++ }+ let b = wk.get(k)+ if (!b) wk.set(k, b = { k, t: startOfWeek(w.d, ws).getTime(), sum: 0, n: 0, est: 0, sets: 0 })+ b.sets+++ const r = normRir(resolve(s, w, entry))+ if (r != null && r.rir != null) { b.sum += r.rir; b.n++; if (r.estimated) b.est++ }})return [...wk.values()].filter(e => e.n >= 2).sort((a, b) => a.t - b.t)- .map(e => ({ t: e.t, rir: e.sum / e.n, n: e.n, sets: e.sets }))+ .map(e => ({ t: e.t, rir: e.sum / e.n, n: e.n, est: e.est, sets: e.sets }))}/**@@ -117,15 +151,15 @@ export function effortWeeks(S, days) {* half the sets at 0 and half at 4 average to a healthy-looking 2.*/export const BUCKETS = 4 // 0,1,2,3 and a "4+" tail-export function effortHistogram(S, days) {+export function effortHistogram(S, days, resolve = rirOf) {const bins = new Array(BUCKETS + 1).fill(0)let rated = 0- eachDoneSet(S, (s, w) => {+ eachDoneSet(S, (s, w, e) => {if (!inWindow(w, days)) return- const r = rirOf(s)- if (r == null) return+ const r = normRir(resolve(s, w, e))+ if (r == null || r.rir == null) returnrated++- bins[Math.min(BUCKETS, Math.max(0, Math.floor(r)))]+++ bins[Math.min(BUCKETS, Math.max(0, Math.floor(r.rir)))]++})return bins.map((n, i) => ({ rir: i, tail: i === BUCKETS, n, pct: rated ? n / rated : 0 }))}diff --git a/frontend/src/lib/effort.test.js b/frontend/src/lib/effort.test.jsindex c21b16647..693998a5e 100644--- a/frontend/src/lib/effort.test.js+++ b/frontend/src/lib/effort.test.js@@ -5,6 +5,7 @@ import {effortColor, EFFORT_BANDS, EFFORT_PRESETS} from './effort.js'import { isoOf } from './format.js'+import { anchorsByWorkout, resolveSetRir } from './recovery.js'const daysAgo = n => { const d = new Date(); d.setDate(d.getDate() - n); return d }// One workout on a day, with the sets given. Everything here is a finished set unless a set@@ -115,7 +116,7 @@ describe('effortSummary', () => {})it('survives a profile with no training at all', () => {- expect(effortSummary({ workouts: [] }, 30)).toEqual({ done: 0, rated: 0, hard: 0, avg: null, hardPct: null })+ expect(effortSummary({ workouts: [] }, 30)).toEqual({ done: 0, rated: 0, est: 0, covered: 0, hard: 0, avg: null, hardPct: null })})it('uses phase as authoritative while retaining legacy boolean warm-up fallback', () => {@@ -260,3 +261,52 @@ describe('picker preset labels', () => {expect(EFFORT_PRESETS.map(p => toScale('rpe', p.rir))).toEqual([10, 9.5, 9, 8, 7, 6])})})++describe('estimated fallback resolver', () => {+ // Built the way Stats.jsx builds it: 90-day anchors, logged first, estimate second.+ const resolving = st => {+ const anchors = anchorsByWorkout(st.workouts, {})+ return (s, w, e) => resolveSetRir(s, s, e, w, anchors.get(w), {})+ }++ it('fills an unrated history with estimates, flagged', () => {+ const st = S(W(2, [{}, {}, {}, {}, {}])) // five unrated 60x8 sets, self-anchored at RIR 0+ const r = effortSummary(st, 0, resolving(st))+ expect(r.done).toBe(5)+ expect(r.rated).toBe(0)+ expect(r.est).toBe(5)+ expect(r.covered).toBe(5)+ expect(r.avg).toBe(0)+ expect(r.hardPct).toBe(1)+ })++ it('reports zero estimates on the default logged-only path', () => {+ const st = S(W(2, [{}, {}, {}, {}, {}]))+ const r = effortSummary(st, 0)+ expect(r.rated).toBe(0)+ expect(r.est).toBe(0)+ expect(r.avg).toBe(null)+ })++ it('prefers a logged rating over any estimate', () => {+ // 100x8 anchors at ~127: unrated top sets estimate RIR 0, while the 60x8 sets+ // keep their logged RIR 8 instead of the estimated ~10.+ const st = S(W(2, [{ w: 100, r: 8 }, { w: 100, r: 8 }, { w: 100, r: 8 }, { w: 60, r: 8, rir: 8 }, { w: 60, r: 8, rir: 8 }]))+ const r = effortSummary(st, 0, resolving(st))+ expect(r.rated).toBe(2)+ expect(r.est).toBe(3)+ expect(r.covered).toBe(5)+ expect(r.avg).toBeCloseTo(16 / 5, 1) // top sets estimate ~0.01, not exactly 0: e1RM rounds to 1 decimal+ })++ it('carries estimates through weeks and histogram', () => {+ const st = S(W(2, [{}, {}, {}, {}, {}]))+ const resolve = resolving(st)+ const weeks = effortWeeks(st, 0, resolve)+ expect(weeks).toHaveLength(1)+ expect(weeks[0]).toMatchObject({ rir: 0, n: 5, est: 5, sets: 5 })+ const hist = effortHistogram(st, 0, resolve)+ expect(hist[0].n).toBe(5)+ expect(hist.slice(1).every(b => b.n === 0)).toBe(true)+ })+})diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.jsindex 890175234..b730dad07 100644--- a/frontend/src/lib/pt-br-locale.test.js+++ b/frontend/src/lib/pt-br-locale.test.js@@ -41,7 +41,7 @@ describe('Brazilian Portuguese locale', () => {// has to be taught is a number nobody reads. What the numbers stood for is asserted above.// If the hash fails, review the changed keys and wording before accepting a new one. From// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list- expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('9be6cc7996a836338e4c6d4aaa075dc40f350dad94c72ef67c0a021870720c49')+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('932705e20a887e12dac75ab29f9d4a79b3f657f33d7c6ff9960948bc65c56443')})test('does not leak European Portuguese UI terms', () => {diff --git a/frontend/src/lib/recovery.js b/frontend/src/lib/recovery.jsindex f6ec2f7e8..035c90d8d 100644--- a/frontend/src/lib/recovery.js+++ b/frontend/src/lib/recovery.js@@ -189,12 +189,9 @@ export function estimateSetRir(set, anchorKg, unit) {// from the 90-day window ending at this session, never from its future.function sessionEffSets(workout, anchors, opts = {}) {const sums = emptyMuscleMap(0)- const score = (row, set, entry, weights, anchorKg, requireDone = true) => {+ const score = (row, set, entry, weights, requireDone = true) => {if (requireDone && row?.done !== true) return- const unit = unitOf(row, set, entry?.target, entry, workout, opts)- const logged = rirOf(row)- const estimated = logged == null ? estimateSetRir(row, anchorKg, unit) : null- const count = rirWeightFor(logged ?? estimated?.rir)+ const count = rirWeightFor(resolveSetRir(row, set, entry, workout, anchors, opts)?.rir)for (const [slug, weight] of Object.entries(weights)) {if (Object.prototype.hasOwnProperty.call(MUSCLES_BY_SLUG, slug)) sums[slug] += count * weight}@@ -202,13 +199,12 @@ function sessionEffSets(workout, anchors, opts = {}) {for (const entry of workout?.entries || []) {const ex = exerciseFor(entry)const weights = musclesOf(ex)- const anchorKg = anchors?.get(entry.id)for (const set of entry.sets || []) {- score(set, set, entry, weights, anchorKg)+ score(set, set, entry, weights)// Drop-set drops carry their own load against the same anchor - extra work at// a discount, never double-counted. Drops carry no done flag of their own;// performed as part of a done set, they count unconditionally.- if (set?.done === true) for (const drop of dropsOf(set)) score(drop, set, entry, weights, anchorKg, false)+ if (set?.done === true) for (const drop of dropsOf(set)) score(drop, set, entry, weights, false)}}for (const slug of MUSCLES) sums[slug] = Math.min(sums[slug], FATIGUE_MAX_SETS_PER_SESSION)@@ -236,6 +232,48 @@ function sessionBests(workout, opts = {}) {return best}+/**+ * Capacity anchors per workout: the 90-day rolling best 1RM estimate per exercise,+ * in kg, keyed by the workout object. One chronological pass - later sessions never+ * leak into earlier anchors. Powers both fatigue scoring and estimated-effort stats;+ * unrated histories without any estimable set simply get empty maps (full credit).+ *+ * @param {Array<object>} workouts Workout history.+ * @param {{unit?: string}} opts Profile unit for unit-stamped loads.+ * @returns {Map<object, Map<string, number>>} Workout -> exercise id -> anchor.+ */+export function anchorsByWorkout(workouts, opts = {}) {+ const ordered = (workouts || [])+ .map((workout, index) => ({ workout, index, timestamp: workoutTimestamp(workout) }))+ .filter(item => Number.isFinite(item.timestamp))+ .sort((a, b) => a.timestamp - b.timestamp || a.index - b.index)+ const bests = ordered.map(item => sessionBests(item.workout, opts))+ const out = new Map()+ ordered.forEach((item, i) => {+ const anchors = new Map()+ for (let j = 0; j <= i; j += 1) {+ if (ordered[j].timestamp <= item.timestamp - FATIGUE_RIR_WINDOW_MS) continue+ for (const [exId, est] of bests[j]) {+ if (!anchors.has(exId) || est > anchors.get(exId)) anchors.set(exId, est)+ }+ }+ out.set(item.workout, anchors)+ })+ return out+}++/**+ * One set's RIR with its provenance: logged effort first, Epley-inverse estimate+ * against the workout's anchors second, null when intensity is unknowable. The same+ * precedence fatigue scoring uses, so stats and the map never disagree about a set.+ */+export function resolveSetRir(row, set, entry, workout, anchors, opts = {}) {+ const logged = rirOf(row)+ if (logged != null) return { rir: logged, source: 'logged' }+ const unit = unitOf(row, set, entry?.target, entry, workout, opts)+ return estimateSetRir(row, anchors?.get(entry?.id), unit)+}+// Build normalised stimuli in workout order. Each session is scored from its own// quality-weighted sets against the fixed full-session unit, multiplied by the// acute:chronic gain left by strictly earlier exposure: a session that doubles the@@ -258,17 +296,8 @@ function fatigueStimuli(workouts, current, opts = {}) {.filter(item => Number.isFinite(item.timestamp) && item.timestamp > poolCutoff).sort((a, b) => a.timestamp - b.timestamp || a.index - b.index)const scored = pool.filter(item => item.timestamp > scanCutoff)- const bests = pool.map(item => sessionBests(item.workout, opts))- const effSets = pool.map((item, i) => {- const anchors = new Map()- for (let j = 0; j <= i; j += 1) {- if (pool[j].timestamp <= item.timestamp - FATIGUE_RIR_WINDOW_MS) continue- for (const [exId, est] of bests[j]) {- if (!anchors.has(exId) || est > anchors.get(exId)) anchors.set(exId, est)- }- }- return sessionEffSets(item.workout, anchors, opts)- })+ const byWorkout = anchorsByWorkout(pool.map(item => item.workout), opts)+ const effSets = pool.map(item => sessionEffSets(item.workout, byWorkout.get(item.workout), opts))const byMuscle = Object.fromEntries(MUSCLES.map(slug => [slug, []]))for (const item of scored) {diff --git a/frontend/src/lib/recovery.test.js b/frontend/src/lib/recovery.test.jsindex cc91ec388..cbf501135 100644--- a/frontend/src/lib/recovery.test.js+++ b/frontend/src/lib/recovery.test.js@@ -14,11 +14,13 @@ import {STRENGTH_FULL_MS,STRENGTH_HALF_LIFE_MS,detrainedMuscles,+ anchorsByWorkout,estimateSetRir,fatiguedMuscles,fatigueHalfLifeOf,fatigueOf,halfLifeDecay,+ resolveSetRir,rirWeightFor,strengthOf,} from './recovery.js'@@ -669,3 +671,32 @@ describe('loads are relative, units are irrelevant', () => {}})})++describe('anchorsByWorkout and resolveSetRir', () => {+ const at = (id, start, sets) => ({+ d: new Date(start).toISOString(), start, entries: [{ id, sets }],+ })++ it('anchors each workout at the 90-day rolling best, never from the future', () => {+ const old = at(SINGLE.id, NOW - 100 * DAY, [{ done: true, w: 120, r: 5 }])+ const mid = at(SINGLE.id, NOW - 10 * DAY, [{ done: true, w: 100, r: 5 }])+ const now = at(SINGLE.id, NOW, [{ done: true, w: 90, r: 5 }])+ const anchors = anchorsByWorkout([old, mid, now])+ // The 100-day-old PR is outside the window; the mid session anchors at its own+ // best, today at the mid session's best.+ expect(anchors.get(old).get(SINGLE.id)).toBeCloseTo(120 * (1 + 5 / 30), 1)+ expect(anchors.get(mid).get(SINGLE.id)).toBeCloseTo(100 * (1 + 5 / 30), 1)+ expect(anchors.get(now).get(SINGLE.id)).toBeCloseTo(100 * (1 + 5 / 30), 1)+ })++ it('resolves logged effort first, estimates second, null when unknowable', () => {+ const anchors = new Map([['e1', 110]])+ const entry = { id: 'e1' }+ const workout = {}+ expect(resolveSetRir({ done: true, w: 40, r: 8, rir: 7 }, null, entry, workout, anchors, {}))+ .toEqual({ rir: 7, source: 'logged' })+ expect(resolveSetRir({ done: true, w: 80, r: 8 }, null, entry, workout, anchors, {}).source).toBe('estimated')+ expect(resolveSetRir({ done: true, w: 80, r: 8 }, null, { id: 'unknown' }, workout, anchors, {}))+ .toBeNull()+ })+})diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.jsindex 07697206c..e57046f3f 100644--- a/frontend/src/locales/ar.js+++ b/frontend/src/locales/ar.js@@ -640,6 +640,8 @@ export default {'average effort': 'متوسط الجهد','at {0} {1} or harder': 'عند {0} {1} أو أعلى','{0} of {1} finished sets rated': '{0} من {1} مجموعات منتهية مُقيّمة',+ 'estimated': 'تقديري',+ '{0} rated · {1} estimated of {2} sets': '{0} مُقيّمة · {1} تقديرية من {2} مجموعات','Effort per set is switched off — turn it on in Settings to keep rating.': 'الجهد لكل مجموعة متوقف — فعّله في الإعدادات لمواصلة التقييم.','Week by week': 'أسبوعًا بأسبوع','Where the sets land': 'أين تقع المجموعات',diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex 663a5a5bb..2e5a753e5 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -819,6 +819,8 @@ export default {'average effort': 'durchschnittliche Anstrengung','at {0} {1} or harder': 'bei {0} {1} oder härter','{0} of {1} finished sets rated': '{0} von {1} erledigten Sätzen bewertet',+ 'estimated': 'geschätzt',+ '{0} rated · {1} estimated of {2} sets': '{0} bewertet · {1} geschätzt von {2} Sätzen','Effort per set is switched off — turn it on in Settings to keep rating.': 'Anstrengung pro Satz ist ausgeschaltet — schalte sie in den Einstellungen ein, um weiter zu bewerten.','Week by week': 'Woche für Woche','Where the sets land': 'Wo die Sätze landen',diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex 8e1d9aa99..cf45b0547 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -800,6 +800,8 @@ export default {'average effort': 'esfuerzo medio','at {0} {1} or harder': 'a {0} {1} o más duro','{0} of {1} finished sets rated': '{0} de {1} series completadas valoradas',+ 'estimated': 'estimado',+ '{0} rated · {1} estimated of {2} sets': '{0} valoradas · {1} estimadas de {2} series','Effort per set is switched off — turn it on in Settings to keep rating.': 'El esfuerzo por serie está desactivado — actívalo en Ajustes para seguir valorando.','Week by week': 'Semana a semana','Where the sets land': 'Dónde caen las series',diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex ee904194c..642b0ed6c 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -800,6 +800,8 @@ export default {'average effort': 'effort moyen','at {0} {1} or harder': 'à {0} {1} ou plus dur','{0} of {1} finished sets rated': '{0} séries notées sur {1} terminées',+ 'estimated': 'estimé',+ '{0} rated · {1} estimated of {2} sets': '{0} notées · {1} estimées sur {2} séries','Effort per set is switched off — turn it on in Settings to keep rating.': 'L’effort par série est désactivé — active-le dans les Réglages pour continuer à noter.','Week by week': 'Semaine par semaine','Where the sets land': 'Où tombent les séries',diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex ccb0ca2aa..e17c7fa5c 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -800,6 +800,8 @@ export default {'average effort': 'औसत मेहनत','at {0} {1} or harder': '{0} {1} या उससे कठिन','{0} of {1} finished sets rated': '{1} पूरे किए सेट में से {0} आँके गए',+ 'estimated': 'अनुमानित',+ '{0} rated · {1} estimated of {2} sets': '{2} सेटों में से {0} रेटेड · {1} अनुमानित','Effort per set is switched off — turn it on in Settings to keep rating.': 'हर सेट की मेहनत बंद है — आँकना जारी रखने के लिए सेटिंग्स में चालू करें।','Week by week': 'हफ़्ते दर हफ़्ते','Where the sets land': 'सेट कहाँ गिरते हैं',diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex 61b151edc..2ac8e5d68 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -773,6 +773,8 @@ export default {'average effort': 'átlagos megerőltetés','at {0} {1} or harder': '{0} {1} vagy nehezebb szinten','{0} of {1} finished sets rated': '{1}-ből {0} befejezett sorozat értékelve',+ 'estimated': 'becsült',+ '{0} rated · {1} estimated of {2} sets': '{2} sorozatból {0} értékelt · {1} becsült','Effort per set is switched off — turn it on in Settings to keep rating.': 'A Megerőltetés sorozatonként ki van kapcsolva — kapcsold be a Beállításokban a további értékeléshez.','Week by week': 'Hétről hétre','Where the sets land': 'Hova esnek a sorozatok',diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 48e5dd34d..3222e6f7e 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -800,6 +800,8 @@ export default {'average effort': 'sforzo medio','at {0} {1} or harder': 'a {0} {1} o più duro','{0} of {1} finished sets rated': '{0} di {1} serie completate valutate',+ 'estimated': 'stimato',+ '{0} rated · {1} estimated of {2} sets': '{0} valutate · {1} stimate su {2} serie','Effort per set is switched off — turn it on in Settings to keep rating.': 'Lo sforzo per serie è disattivato — attivalo nelle Impostazioni per continuare a valutare.','Week by week': 'Settimana per settimana','Where the sets land': 'Dove cadono le serie',diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex 02628fa0a..066e19cd7 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -800,6 +800,8 @@ export default {'average effort': '평균 강도','at {0} {1} or harder': '{0} {1} 이상','{0} of {1} finished sets rated': '완료한 {1}세트 중 {0}세트 평가됨',+ 'estimated': '추정치',+ '{0} rated · {1} estimated of {2} sets': '{2}세트 중 {0} 평가됨 · {1} 추정치','Effort per set is switched off — turn it on in Settings to keep rating.': '세트당 강도가 꺼져 있습니다 — 계속 평가하려면 설정에서 켜세요.','Week by week': '주별 변화','Where the sets land': '세트가 몰리는 곳',diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex f5910a684..3565f3d74 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -800,6 +800,8 @@ export default {'average effort': 'średni wysiłek','at {0} {1} or harder': 'przy {0} {1} lub ciężej','{0} of {1} finished sets rated': 'ocenione serie: {0} z {1} ukończonych',+ 'estimated': 'szacunkowo',+ '{0} rated · {1} estimated of {2} sets': '{0} oceniono · {1} oszacowano z {2} serii','Effort per set is switched off — turn it on in Settings to keep rating.': 'Wysiłek na serię jest wyłączony — włącz go w Ustawieniach, aby dalej oceniać.','Week by week': 'Tydzień po tygodniu','Where the sets land': 'Gdzie lądują serie',diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex 65dd8ff54..7c101c0c4 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -800,6 +800,8 @@ export default {'average effort': 'esforço médio','at {0} {1} or harder': 'a {0} {1} ou mais duro','{0} of {1} finished sets rated': '{0} de {1} séries concluídas avaliadas',+ 'estimated': 'estimado',+ '{0} rated · {1} estimated of {2} sets': '{0} avaliadas · {1} estimadas de {2} séries','Effort per set is switched off — turn it on in Settings to keep rating.': 'O esforço por série está desligado — liga-o nas Definições para continuares a avaliar.','Week by week': 'Semana a semana','Where the sets land': 'Onde caem as séries',diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex 2df1568f7..0088c27bd 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -800,6 +800,8 @@ export default {'average effort': 'среднее усилие','at {0} {1} or harder': 'при {0} {1} или тяжелее','{0} of {1} finished sets rated': 'оценено {0} из {1} выполненных подходов',+ 'estimated': 'оценочно',+ '{0} rated · {1} estimated of {2} sets': '{0} оценено · {1} по расчёту из {2} подходов','Effort per set is switched off — turn it on in Settings to keep rating.': 'Усилие в подходе выключено — включи его в настройках, чтобы продолжать оценивать.','Week by week': 'Неделя за неделей','Where the sets land': 'Куда попадают подходы',diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex 3604d80fa..8d048e0a1 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -773,6 +773,8 @@ export default {'average effort': 'ความหนักเฉลี่ย','at {0} {1} or harder': 'ที่ {0} {1} ขึ้นไป','{0} of {1} finished sets rated': 'ให้คะแนนแล้ว {0} จาก {1} เซ็ตที่ทำเสร็จ',+ 'estimated': 'โดยประมาณ',+ '{0} rated · {1} estimated of {2} sets': 'ให้คะแนนแล้ว {0} · ประมาณ {1} จาก {2} เซ็ต','Effort per set is switched off — turn it on in Settings to keep rating.': 'ปิด “ความหนักต่อเซ็ต” อยู่ — เปิดในตั้งค่าเพื่อให้คะแนนต่อ','Week by week': 'รายสัปดาห์','Where the sets land': 'เซ็ตส่วนใหญ่อยู่ระดับไหน',diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex 1c96ebc30..2814da748 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -800,6 +800,8 @@ export default {'average effort': 'ortalama zorluk','at {0} {1} or harder': '{0} {1} veya daha zor','{0} of {1} finished sets rated': '{1} tamamlanan setin {0} tanesi puanlandı',+ 'estimated': 'tahmini',+ '{0} rated · {1} estimated of {2} sets': '{2} setin {0} tanesi puanlı · {1} tanesi tahmini','Effort per set is switched off — turn it on in Settings to keep rating.': 'Set başına zorluk kapalı — puanlamaya devam etmek için Ayarlar’dan aç.','Week by week': 'Hafta hafta','Where the sets land': 'Setler nereye düşüyor',diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.jsindex ba239e0c8..12dab2f9f 100644--- a/frontend/src/locales/uk.js+++ b/frontend/src/locales/uk.js@@ -609,6 +609,8 @@ export default {'average effort': 'середнє зусилля','at {0} {1} or harder': 'при {0} {1} або важче','{0} of {1} finished sets rated': 'оцінено {0} з {1} виконаних підходів',+ 'estimated': 'орієнтовно',+ '{0} rated · {1} estimated of {2} sets': '{0} оцінено · {1} за розрахунком з {2} підходів','Effort per set is switched off — turn it on in Settings to keep rating.': 'Зусилля в підході вимкнено — увімкни його в налаштуваннях, щоб продовжувати оцінювати.','Week by week': 'Тиждень за тижнем','Where the sets land': 'Куди потрапляють підходи',diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex 84237894a..2a0f00562 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -800,6 +800,8 @@ export default {'average effort': '平均强度','at {0} {1} or harder': '{0} {1} 或更硬','{0} of {1} finished sets rated': '{1} 个已完成组中有 {0} 个已评分',+ 'estimated': '估算',+ '{0} rated · {1} estimated of {2} sets': '已评分 {0} · 估算 {1},共 {2} 组','Effort per set is switched off — turn it on in Settings to keep rating.': '每组强度已关闭——在设置中打开即可继续评分。','Week by week': '逐周变化','Where the sets land': '组都落在哪里',diff --git a/frontend/src/views/Stats.jsx b/frontend/src/views/Stats.jsxindex d96d0ab47..844be3a14 100644--- a/frontend/src/views/Stats.jsx+++ b/frontend/src/views/Stats.jsx@@ -17,9 +17,10 @@ import { strengthExerciseRowsForMuscle } from '../lib/strength-exercises.js'import { fatigueStateOf } from '../lib/recovery-view.js'import { e1rmSeries, best1RM } from '../lib/onerm.js'import {- hasEffort, displayScale, scaleName, toScale, avgRir, effortSummary, effortWeeks,- effortHistogram, isHardSet, HARD_RIR+ hasEffort, hasEstimableEffort, displayScale, scaleName, toScale, avgRir, effortSummary, effortWeeks,+ effortHistogram, isHardSet, HARD_RIR, MIN_RATED} from '../lib/effort.js'+import { anchorsByWorkout, resolveSetRir } from '../lib/recovery.js'import { Button, Segmented, SelectRow } from '../components/ui.jsx'import { tappable } from '../lib/use-sheet-keyboard.js'import { isWarmupRow } from '../lib/workout-model.js'@@ -240,9 +241,21 @@ function EffortCard({ S }) {const [win, setWin] = useState(90)const kind = displayScale(S)const hd = scaleName(kind)- const sum = effortSummary(S, win)- const weeks = effortWeeks(S, win)- const hist = effortHistogram(S, win)+ const logged = effortSummary(S, win)+ // Thin or missing ratings fall back to estimates (same precedence fatigue scoring+ // uses), so imported histories get an effort card too. Well-rated windows keep+ // their logged numbers untouched - estimates never dilute a real average.+ const blend = logged.rated < MIN_RATED+ const anchors = useMemo(+ () => (blend ? anchorsByWorkout(S.workouts, { unit: S.unit }) : new Map()),+ [blend, S.workouts, S.unit],+ )+ const opts = useMemo(() => ({ unit: S.unit }), [S.unit])+ const resolve = (s, w, e) => resolveSetRir(s, s, e, w, anchors.get(w), opts)+ const sum = blend ? effortSummary(S, win, resolve) : logged+ const weeks = blend ? effortWeeks(S, win, resolve) : effortWeeks(S, win)+ const hist = blend ? effortHistogram(S, win, resolve) : effortHistogram(S, win)+ const estimated = blend && sum.est > 0const maxBin = Math.max(1, ...hist.map(b => b.n))// The week's set count rides along in the tooltip, because the pair is the reading:// volume up with effort up is fatigue piling up, volume up with effort flat is adaptation.@@ -251,10 +264,10 @@ function EffortCard({ S }) {const binLabel = b => kind === 'rpe' ? (b.tail ? '≤ 6' : String(10 - b.rir)) : (b.tail ? b.rir + '+' : String(b.rir))return <div className="card">- <h2>{t('Effort')} <span className="dim" style={{ textTransform: 'none', letterSpacing: 0 }}>· {t('how close to failure')}</span></h2>+ <h2>{t('Effort')} <span className="dim" style={{ textTransform: 'none', letterSpacing: 0 }}>· {t('how close to failure')}{estimated ? ' · ' + t('estimated') : ''}</span></h2><Segmented className="seg-range" value={win} onChange={setWin}options={[{ value: 30, label: '30d' }, { value: 90, label: '90d' }, { value: 365, label: '1Y' }, { value: 0, label: t('All') }]} />- {sum.rated === 0 ? <div className="muted small">{t('No rated sets in this period.')}</div> : <>+ {sum.rated === 0 && sum.est === 0 ? <div className="muted small">{t('No rated sets in this period.')}</div> : <><div className="row between" style={{ alignItems: 'flex-end', gap: 12 }}><div><div className="stat-v">{sum.avg == null ? '—' : fmtNum(toScale(kind, sum.avg)) + ' ' + hd}</div>@@ -265,7 +278,9 @@ function EffortCard({ S }) {<div className="small dim">{t('at {0} {1} or harder', hd, fmtNum(toScale(kind, HARD_RIR)))}</div></div></div>- <div className="small dim" style={{ marginTop: 8 }}>{t('{0} of {1} finished sets rated', sum.rated, sum.done)}</div>+ <div className="small dim" style={{ marginTop: 8 }}>{estimated+ ? t('{0} rated · {1} estimated of {2} sets', sum.rated, sum.est, sum.done)+ : t('{0} of {1} finished sets rated', sum.rated, sum.done)}</div>{effortOf(S) === 'none' && <div className="small" style={{ color: 'var(--yellow)', marginTop: 4 }}>{t('Effort per set is switched off — turn it on in Settings to keep rating.')}</div>}@@ -477,7 +492,7 @@ export default function Stats() {<div className="muted small" style={{ marginTop: 4 }}>{t('See which lift is holding back the rest.')}</div></div><Button size="sm" variant="tinted" trailingIcon="chevronRight" style={{ flexShrink: 0 }} onClick={() => nav('/structural-balance')}>{t('Open')}</Button></div>}- {hasEffort(S) && <EffortCard S={S} />}+ {(hasEffort(S) || hasEstimableEffort(S)) && <EffortCard S={S} />}<div className="cols"><div className="card">diff --git a/frontend/src/views/Stats.recovery.test.jsx b/frontend/src/views/Stats.recovery.test.jsxindex ca837dfe8..966b5b2bb 100644--- a/frontend/src/views/Stats.recovery.test.jsx+++ b/frontend/src/views/Stats.recovery.test.jsx@@ -319,6 +319,33 @@ describe('Stats muscle recovery view runtime', () => {})})+describe('Stats estimated effort', () => {+ const effortHead = () => [...container.querySelectorAll('.card h2')]+ .find(h => h.textContent.trim().startsWith('Effort'))++ it('badges estimated numbers on unrated import history', async () => {+ resetFixture([workout('unrated', BASE_NOW, [+ entry('0025', Array.from({ length: 6 }, () => set(true, { w: 80, r: 8 }))),+ ])])+ await mountStats()+ const head = effortHead()+ expect(head, 'expected an Effort card for estimable history').toBeTruthy()+ // Six self-anchored sets estimate RIR 0: a real average with an honest badge.+ expect(head.textContent).toContain('estimated')+ expect(container.textContent).toContain('0 rated')+ })++ it('keeps the logged view badge-free on rated history', async () => {+ resetFixture([workout('rated', BASE_NOW, [+ entry('0025', Array.from({ length: 6 }, () => set(true, { w: 80, r: 8, rir: 2 }))),+ ])])+ await mountStats()+ const head = effortHead()+ expect(head, 'expected an Effort card for rated history').toBeTruthy()+ expect(head.textContent).not.toContain('estimated')+ })+})+describe('Stats strength exercise rows', () => {// The rows under "Exercises · <muscle>" are presented as buttons (role, tabIndex, pointer// cursor) but for a year called a handler that never existed, so every tap threw