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
Structural balance: a logged lift whose anchor lift was never logged reads Not scored and asks for the anchor lift, instead of No data (!140)
Duarte Santos86e806f3c69d
diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.jsindex 3a4c5e5d1..3d7b9cf0f 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('0371d550d1b87e35334f3e18933f91b64621268c5c3075f41ec3cd732aaa0dd1')+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('1a6ecca227bbbead13b5be3e4e410f1e1c9ac36bd32d31199bfd1581d792f4ef')})test('does not leak European Portuguese UI terms', () => {diff --git a/frontend/src/lib/structuralBalance-view.js b/frontend/src/lib/structuralBalance-view.jsindex 9404753a3..e6325681d 100644--- a/frontend/src/lib/structuralBalance-view.js+++ b/frontend/src/lib/structuralBalance-view.js@@ -3,7 +3,10 @@ import { BALANCE_STATUSES } from './structuralBalanceTemplates.js'// Status -> UI label/severity (0 = best). Kept as a tiny boundary selector so the view and its// tests can't drift from the engine's status values, same rationale as fatigueStateOf() in// recovery-view.js.-export function balanceStatusView(status) {+// `needsAnchor` (computeBalance): a lift that is logged but has no anchor lift to be held+// against is not scored, which is not the same as having no data.+export function balanceStatusView(status, needsAnchor = false) {+ if (needsAnchor && status === BALANCE_STATUSES.NO_DATA) return { label: 'Not scored', severity: 3 }switch (status) {case BALANCE_STATUSES.BALANCED: return { label: 'Balanced', severity: 0 }case BALANCE_STATUSES.BORDERLINE: return { label: 'Borderline', severity: 1 }diff --git a/frontend/src/lib/structuralBalance-view.test.js b/frontend/src/lib/structuralBalance-view.test.jsindex c56cfcf86..8c2a87d22 100644--- a/frontend/src/lib/structuralBalance-view.test.js+++ b/frontend/src/lib/structuralBalance-view.test.js@@ -12,4 +12,9 @@ describe('balanceStatusView', () => {it('falls back to no-data for an unknown status', () => {expect(balanceStatusView('bogus')).toEqual({ label: 'No data', severity: 3 })})++ it('reads a logged lift with no anchor to hold it against as not scored, not as no data', () => {+ expect(balanceStatusView('no-data', true)).toEqual({ label: 'Not scored', severity: 3 })+ expect(balanceStatusView('no-data', false)).toEqual({ label: 'No data', severity: 3 })+ })})diff --git a/frontend/src/lib/structuralBalance.js b/frontend/src/lib/structuralBalance.jsindex e4de854d0..314a7b88c 100644--- a/frontend/src/lib/structuralBalance.js+++ b/frontend/src/lib/structuralBalance.js@@ -266,12 +266,15 @@ function evaluateRole(template, role, currentByRoleId, bodyweightKg, S) {const base = { roleId: role.id, configuredExerciseId, targetPct, isOverridden: Boolean(override) }const needsBodyweight = waitsOnBodyweight(S, role, exerciseIdsFor(S, template, role), current, bodyweightKg)if (!current) {- return { ...base, mappedExerciseId: null, current: null, actualPct: null, status: BALANCE_STATUSES.NO_DATA, needsBodyweight }+ return { ...base, mappedExerciseId: null, current: null, actualPct: null, status: BALANCE_STATUSES.NO_DATA, needsBodyweight, needsAnchor: false }}// An anchor role (no anchorRoleId) is compared against itself — always 100% when it has data.const anchorCurrent = role.anchorRoleId ? currentByRoleId.get(role.anchorRoleId) : currentconst actualPct = ratioFor(role, current, { anchorCurrent, bodyweightKg, targetPct })- return { ...base, mappedExerciseId: current.exId, current, actualPct, status: classify(actualPct, classifyTarget), needsBodyweight }+ // Logged, but nothing to hold it against: the anchor never was. Still no score, but the view+ // must not say there is no data for a lift with months of sets — it says what is missing.+ const needsAnchor = !!role.anchorRoleId && role.evaluationMode === EVALUATION_MODES.LOAD_RATIO && !(anchorCurrent?.estKg > 0)+ return { ...base, mappedExerciseId: current.exId, current, actualPct, status: classify(actualPct, classifyTarget), needsBodyweight, needsAnchor }}// Pure ratio-computation engine entry point.diff --git a/frontend/src/lib/structuralBalance.test.js b/frontend/src/lib/structuralBalance.test.jsindex c72314be0..33e179511 100644--- a/frontend/src/lib/structuralBalance.test.js+++ b/frontend/src/lib/structuralBalance.test.js@@ -694,3 +694,24 @@ describe('ratioFor', () => {expect(ratioFor(role, { estKg: 80 }, { bodyweightKg: null })).toBe(null)})})++// A lift logged for months next to an anchor never logged read "No data", with nothing saying the+// anchor was the reason. The result says so, like a missing weigh-in.+describe('a role waiting on its anchor says so', () => {+ const role = (S, template, roleId) => computeBalance(S, template).find(r => r.roleId === roleId)+ const logged = { unit: 'kg', workouts: [workoutAt('0047', NOW - 1000, [setDone(57.5, 10)]), workoutAt('0031', NOW, [setDone(35, 8)])] }++ it('flags a logged load-ratio lift whose anchor has no reading, and nothing else', () => {+ expect(role(logged, TEMPLATES.poliquin, 'inclineBench')).toMatchObject({ status: BALANCE_STATUSES.NO_DATA, needsAnchor: true, mappedExerciseId: '0047' })+ expect(role(logged, TEMPLATES.poliquin, 'barbellCurl')).toMatchObject({ status: BALANCE_STATUSES.NO_DATA, needsAnchor: true })+ expect(role(logged, TEMPLATES.poliquin, 'frontSquat').needsAnchor).toBe(false) // not logged: plain no data+ expect(role(logged, TEMPLATES.poliquin, 'narrowBench').needsAnchor).toBe(false) // the anchor itself+ })++ it('stops once the anchor is logged', () => {+ const S = { ...logged, workouts: [...logged.workouts, workoutAt('0030', NOW, [setDone(100, 1)])] }+ const incline = role(S, TEMPLATES.poliquin, 'inclineBench')+ expect(incline.needsAnchor).toBe(false)+ expect(incline.status).not.toBe(BALANCE_STATUSES.NO_DATA)+ })+})diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.jsindex a693ea8fb..dac9b3762 100644--- a/frontend/src/locales/ar.js+++ b/frontend/src/locales/ar.js@@ -1506,6 +1506,8 @@ export default {'Use default exercise': 'استخدام التمرين الافتراضي','Custom': 'مخصص','Log your body weight to score this lift.': 'سجّل وزن جسمك لتقييم هذه الرفعة.',+ 'Log the anchor lift to score this one.': 'سجّل الرفعة المرجعية لتقييم هذه الرفعة.',+ 'Not scored': 'لم يُقيَّم',// --- v1.3.9: password sign-in next to passkeys, admin reset codes (#118) ---'Sign in with password': 'تسجيل الدخول بكلمة المرور','Password': 'كلمة المرور',diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex db7e419cd..4a908b80a 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -1562,4 +1562,6 @@ export default {'Use default exercise': 'Standardübung verwenden','Custom': 'Angepasst','Log your body weight to score this lift.': 'Trag dein Körpergewicht ein, damit diese Übung bewertet werden kann.',+ 'Log the anchor lift to score this one.': 'Trag die Anker-Übung ein, damit diese bewertet werden kann.',+ 'Not scored': 'Nicht bewertet',}diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex ee434cc4a..1950c5525 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -1542,4 +1542,6 @@ export default {'Use default exercise': 'Usar ejercicio por defecto','Custom': 'Personalizado','Log your body weight to score this lift.': 'Registra tu peso corporal para evaluar este ejercicio.',+ 'Log the anchor lift to score this one.': 'Registra el ejercicio ancla para evaluar este.',+ 'Not scored': 'Sin evaluar',}diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex 10d5e57bf..378e8580d 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -1542,4 +1542,6 @@ export default {'Use default exercise': 'Utiliser l\'exercice par défaut','Custom': 'Personnalisé','Log your body weight to score this lift.': 'Note ton poids corporel pour évaluer cet exercice.',+ 'Log the anchor lift to score this one.': 'Note l’exercice de référence pour évaluer celui-ci.',+ 'Not scored': 'Non évalué',}diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex f09d89b7f..b5da08470 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -1542,4 +1542,6 @@ export default {'Use default exercise': 'डिफ़ॉल्ट व्यायाम उपयोग करें','Custom': 'कस्टम','Log your body weight to score this lift.': 'इस व्यायाम का आकलन करने के लिए अपने शरीर का वज़न दर्ज करें।',+ 'Log the anchor lift to score this one.': 'इसका आकलन करने के लिए आधार व्यायाम दर्ज करें।',+ 'Not scored': 'आकलन नहीं हुआ',}diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex 9a7ea174a..73f877747 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -1545,4 +1545,6 @@ export default {'Use default exercise': 'Alapértelmezett gyakorlat használata','Custom': 'Egyéni','Log your body weight to score this lift.': 'Rögzítsd a testsúlyodat, hogy ez a gyakorlat értékelhető legyen.',+ 'Log the anchor lift to score this one.': 'Rögzítsd a viszonyítási alapul szolgáló gyakorlatot, hogy ez is értékelhető legyen.',+ 'Not scored': 'Nincs értékelve',}diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 08b16d8d8..a5c176744 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -1542,4 +1542,6 @@ export default {'Use default exercise': 'Usa esercizio predefinito','Custom': 'Personalizzato','Log your body weight to score this lift.': 'Registra il tuo peso corporeo per valutare questo esercizio.',+ 'Log the anchor lift to score this one.': 'Registra l’esercizio di riferimento per valutare questo.',+ 'Not scored': 'Non valutato',}diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex 0b61e317c..52c622640 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -1542,4 +1542,6 @@ export default {'Use default exercise': '기본 운동 사용','Custom': '사용자 지정','Log your body weight to score this lift.': '이 운동을 평가하려면 체중을 기록하세요.',+ 'Log the anchor lift to score this one.': '이 운동을 평가하려면 기준 운동을 기록하세요.',+ 'Not scored': '평가 안 됨',}diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex be092f505..e32cdcb6d 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -1542,4 +1542,6 @@ export default {'Use default exercise': 'Użyj domyślnego ćwiczenia','Custom': 'Niestandardowe','Log your body weight to score this lift.': 'Zapisz swoją masę ciała, aby ocenić to ćwiczenie.',+ 'Log the anchor lift to score this one.': 'Zapisz ćwiczenie będące punktem odniesienia, aby ocenić to ćwiczenie.',+ 'Not scored': 'Bez oceny',}diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.jsindex 0c0ab256c..87ff1a4b3 100644--- a/frontend/src/locales/pt-BR.js+++ b/frontend/src/locales/pt-BR.js@@ -902,6 +902,7 @@ export const PT_BR_OVERRIDES = {'Use default exercise': 'Usar exercício padrão','Custom': 'Personalizado','Log your body weight to score this lift.': 'Registre seu peso corporal para avaliar este exercício.',+ 'Log the anchor lift to score this one.': 'Registre o exercício de referência para avaliar este.',}export default { ...pt, ...PT_BR_OVERRIDES }diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex 06bc04e4f..a24c3d453 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -1542,4 +1542,6 @@ export default {'Use default exercise': 'Usar exercício predefinido','Custom': 'Personalizado','Log your body weight to score this lift.': 'Regista o teu peso corporal para avaliar este exercício.',+ 'Log the anchor lift to score this one.': 'Regista o exercício de referência para avaliar este.',+ 'Not scored': 'Sem avaliação',}diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex dd3a3798f..8509c6f6c 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -1542,4 +1542,6 @@ export default {'Use default exercise': 'Использовать упражнение по умолчанию','Custom': 'Свой вариант','Log your body weight to score this lift.': 'Запишите вес тела, чтобы оценить это упражнение.',+ 'Log the anchor lift to score this one.': 'Запишите опорное упражнение, чтобы оценить это.',+ 'Not scored': 'Не оценено',}diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex 3760b7bb4..113bc6195 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -1553,4 +1553,6 @@ export default {'Use default exercise': 'ใช้ท่าฝึกเริ่มต้น','Custom': 'กำหนดเอง','Log your body weight to score this lift.': 'บันทึกน้ำหนักตัวเพื่อประเมินท่านี้',+ 'Log the anchor lift to score this one.': 'บันทึกท่าอ้างอิงเพื่อประเมินท่านี้',+ 'Not scored': 'ยังไม่ได้ประเมิน',}diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex 1141f249f..3551af1cb 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -1542,4 +1542,6 @@ export default {'Use default exercise': 'Varsayılan egzersizi kullan','Custom': 'Özel','Log your body weight to score this lift.': 'Bu hareketin değerlendirilmesi için vücut ağırlığını kaydet.',+ 'Log the anchor lift to score this one.': 'Bunu değerlendirmek için referans hareketi kaydet.',+ 'Not scored': 'Değerlendirilmedi',}diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.jsindex 7302f0a16..2b7ae36d2 100644--- a/frontend/src/locales/uk.js+++ b/frontend/src/locales/uk.js@@ -1450,6 +1450,8 @@ export default {'Use default exercise': 'Використати вправу за замовчуванням','Custom': 'Власний вибір','Log your body weight to score this lift.': 'Запиши вагу тіла, щоб оцінити цю вправу.',+ 'Log the anchor lift to score this one.': 'Запиши опорну вправу, щоб оцінити цю.',+ 'Not scored': 'Не оцінено',// --- v1.3.9: password sign-in next to passkeys, admin reset codes (#118) ---'Sign in with password': 'Увійти з паролем','Password': 'Пароль',diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex 4d8dac2dd..e3e097d6d 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -1542,4 +1542,6 @@ export default {'Use default exercise': '使用默认动作','Custom': '自定义','Log your body weight to score this lift.': '记录你的体重以评估这个动作。',+ 'Log the anchor lift to score this one.': '记录锚点动作以评估这个动作。',+ 'Not scored': '未评估',}diff --git a/frontend/src/views/StructuralBalance.jsx b/frontend/src/views/StructuralBalance.jsxindex cec397e20..5a2b6f287 100644--- a/frontend/src/views/StructuralBalance.jsx+++ b/frontend/src/views/StructuralBalance.jsx@@ -53,7 +53,7 @@ export default function StructuralBalance() {<div className="card">{results.map(r => {const role = template.roles.find(role => role.id === r.roleId)- const view = balanceStatusView(r.status)+ const view = balanceStatusView(r.status, r.needsAnchor)// The exercise the number came from when there is one, otherwise the one this role is// set to — a role you just pointed at an exercise should name it, logged or not.const exId = r.mappedExerciseId || r.configuredExerciseId@@ -76,6 +76,9 @@ export default function StructuralBalance() {{r.needsBodyweight && <span className="small" data-needs-bodyweight style={{ display: 'block', color: 'var(--label-2)' }}>{t('Log your body weight to score this lift.')}</span>}+ {r.needsAnchor && <span className="small" data-needs-anchor style={{ display: 'block', color: 'var(--label-2)' }}>+ {t('Log the anchor lift to score this one.')}+ </span>}</span><span className="v" style={{ textAlign: 'end', flexShrink: 0 }}><span style={{ color: STATUS_COLOR[r.status] }}>{t(view.label)}</span>diff --git a/frontend/src/views/StructuralBalance.test.jsx b/frontend/src/views/StructuralBalance.test.jsxindex ed0b87e63..7a7303a8e 100644--- a/frontend/src/views/StructuralBalance.test.jsx+++ b/frontend/src/views/StructuralBalance.test.jsx@@ -145,6 +145,22 @@ describe('StructuralBalance view', () => {expect([...scored.querySelectorAll('button')].some(b => b.textContent.includes('Log body weight'))).toBe(false)})+ it('says why a logged lift is not scored when its anchor never was', () => {+ const S = clone(DEF)+ S.workouts = [workoutAt('0047', Date.now(), [setDoneSet(57.5, 10)])] // incline bench, no close-grip bench+ useStore.setState({ S, user: null })+ const host = render()+ const incline = host.querySelector('[data-role-id="inclineBench"]')+ expect(incline.dataset.status).toBe('no-data')+ expect(incline.textContent).toContain('Not scored')+ expect(incline.textContent).not.toContain('No data')+ expect(incline.querySelector('[data-needs-anchor]').textContent).toBe('Log the anchor lift to score this one.')+ const anchor = host.querySelector('[data-role-id="narrowBench"]')+ expect(anchor.textContent).toContain('No data')+ expect(anchor.querySelector('[data-needs-anchor]')).toBe(null)+ expect(host.querySelector('[data-role-id="frontSquat"] [data-needs-anchor]')).toBe(null) // not logged either+ })+it('the back chevron navigates to /stats', () => {const host = render()act(() => host.querySelector('.iconbtn').click())