Skip to content

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.

Follow-up to !140: a row that only lacks a weigh-in asks for one

Duarte Santos12180626127a
diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js
index fdc65905b..0a98c2765 100644
--- a/frontend/src/lib/pt-br-locale.test.js
+++ b/frontend/src/lib/pt-br-locale.test.js
@@ -27,7 +27,7 @@ describe('Brazilian Portuguese locale', () => {
.sort(byCodeUnit)
const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex')
- expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(713)
+ expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(714)
expect(inherited).toHaveLength(674)
// If this fails, review the changed keys and wording before accepting a new hash. From
// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list
diff --git a/frontend/src/lib/structuralBalance.js b/frontend/src/lib/structuralBalance.js
index fd687f51d..61a25a98d 100644
--- a/frontend/src/lib/structuralBalance.js
+++ b/frontend/src/lib/structuralBalance.js
@@ -46,6 +46,11 @@ const beltOnLifter = id => {
// body when the entry is flagged bodyweight — would score more help as a stronger lift. A 0
// there is a row with no help entered, not a set done without any (history.js), and help at or
// above body mass moved nothing: both are left unscored.
+const onLifter = entry => {
+ const bodyweight = entry.target?.bodyweight ?? entry.bodyweight
+ return bodyweight == null ? isBw({ id: entry.id }) || beltOnLifter(entry.id) : !!bodyweight
+}
+
function setLoadKg(S, workout, entry, set, bodyweightKg) {
const logged = kgOf(set.w || 0, S.unit)
const stamped = workout?.bw > 0 ? kgOf(workout.bw, S.unit) : null
@@ -54,12 +59,22 @@ function setLoadKg(S, workout, entry, set, bodyweightKg) {
if (!(logged > 0) || !(body > 0)) return null
return body - logged > 0 ? body - logged : null
}
- const bodyweight = entry.target?.bodyweight ?? entry.bodyweight
- const onLifter = bodyweight == null ? isBw({ id: entry.id }) || beltOnLifter(entry.id) : !!bodyweight
- if (!onLifter) return logged
+ if (!onLifter(entry)) return logged
return body > 0 ? body + logged : null
}
+// Whether a role reads "No data" only for want of a weigh-in, with sets logged: a body-weight
+// standard with a lift to hold against it, or a lift on the lifter (a dip, a pull-up, an
+// assistance machine with its help entered) from sessions that carry no weigh-in of their own.
+// The screen says so, rather than a bare "No data" next to sets the user can see they logged.
+function waitsOnBodyweight(S, role, exerciseIds, current, bodyweightKg) {
+ if (bodyweightKg > 0 || role.evaluationMode === EVALUATION_MODES.REP_COUNT) return false
+ if (current) return role.evaluationMode === EVALUATION_MODES.BODYWEIGHT_RATIO
+ return (S.workouts || []).some(workout => !(workout?.bw > 0) && (workout.entries || []).some(entry =>
+ exerciseIds.includes(entry.id) && (isAssistedEntry(entry) || onLifter(entry)) &&
+ (entry.sets || []).some(set => set.done && !isWarmupRow(set) && (!isAssistedEntry(entry) || kgOf(set.w || 0, S.unit) > 0))))
+}
+
// The lifts one logged row stands for, each as the { w, r } it is read from. A unilateral row's
// `r` is the both-sides total and its `w` the heavier side (workout-model.js), so it is read as
// its two sides instead, the better one counting — as bestRepsOf() does below and progression.js
@@ -246,13 +261,14 @@ function evaluateRole(template, role, currentByRoleId, bodyweightKg, S) {
// it to name the role's exercise (and to show an override back to the user who chose it).
const configuredExerciseId = override || role.exerciseIds[0] || null
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 }
+ return { ...base, mappedExerciseId: null, current: null, actualPct: null, status: BALANCE_STATUSES.NO_DATA, needsBodyweight }
}
// An anchor role (no anchorRoleId) is compared against itself — always 100% when it has data.
const anchorCurrent = role.anchorRoleId ? currentByRoleId.get(role.anchorRoleId) : current
const actualPct = ratioFor(role, current, { anchorCurrent, bodyweightKg, targetPct })
- return { ...base, mappedExerciseId: current.exId, current, actualPct, status: classify(actualPct, classifyTarget) }
+ return { ...base, mappedExerciseId: current.exId, current, actualPct, status: classify(actualPct, classifyTarget), needsBodyweight }
}
// Pure ratio-computation engine entry point.
diff --git a/frontend/src/lib/structuralBalance.test.js b/frontend/src/lib/structuralBalance.test.js
index 5294971a7..f16121d2b 100644
--- a/frontend/src/lib/structuralBalance.test.js
+++ b/frontend/src/lib/structuralBalance.test.js
@@ -566,6 +566,44 @@ describe('stored overrides', () => {
})
})
+// Without a weigh-in these rows can only read "No data", next to sets the user can see they
+// logged; the result says when a body weight is all that is missing, so the screen can ask.
+describe('a role waiting on a weigh-in says so', () => {
+ const role = (S, template, roleId) => computeBalance(S, template).find(r => r.roleId === roleId)
+
+ it('flags an ATG load standard with a lift logged and no body weight', () => {
+ const S = { unit: 'kg', workouts: [workoutAt('0085', NOW, [setDone(80, 12)])] }
+ expect(role(S, TEMPLATES.atg, 'romanianDeadlift')).toMatchObject({ status: BALANCE_STATUSES.NO_DATA, needsBodyweight: true })
+ expect(role(S, TEMPLATES.atg, 'goodMorning').needsBodyweight).toBe(false) // nothing logged
+ expect(role({ ...S, bodyweight: [{ d: '2026-01-01', w: 80 }] }, TEMPLATES.atg, 'romanianDeadlift'))
+ .toMatchObject({ status: BALANCE_STATUSES.BALANCED, needsBodyweight: false })
+ })
+
+ it('flags a dip or pull-up on the load table, not a lift that is plain load', () => {
+ const S = { unit: 'kg', workouts: [{ d: '2026-01-10', start: NOW, entries: [
+ { id: '0030', sets: [setDone(100, 1)] }, { id: '0251', sets: [setDone(10, 5)] },
+ { id: '0841', sets: [setDone(20, 5)] }, { id: '0031', sets: [setDone(35, 5)] },
+ ] }] }
+ expect(role(S, TEMPLATES.poliquin, 'dips')).toMatchObject({ status: BALANCE_STATUSES.NO_DATA, needsBodyweight: true })
+ expect(role(S, TEMPLATES.poliquin, 'supinePullups').needsBodyweight).toBe(true)
+ expect(role(S, TEMPLATES.poliquin, 'barbellCurl').needsBodyweight).toBe(false)
+ expect(role(S, TEMPLATES.poliquin, 'deadlift').needsBodyweight).toBe(false)
+ // A session with its own weigh-in scores without the profile's.
+ S.workouts[0].bw = 80
+ expect(role(S, TEMPLATES.poliquin, 'dips')).toMatchObject({ status: BALANCE_STATUSES.WEAK, needsBodyweight: false })
+ })
+
+ it('leaves out rep targets and an assistance machine with no help entered', () => {
+ const S = { unit: 'kg', workouts: [workoutAt('0652', NOW, [setDone(0, 4)])] }
+ expect(role(S, TEMPLATES.atg, 'pullups').needsBodyweight).toBe(false)
+ const poliquin = TEMPLATES.poliquin
+ const key = overrideKey(poliquin, findRole(poliquin, 'supinePullups'))
+ const assisted = w => ({ unit: 'kg', balanceOverrides: { [key]: '0017' }, workouts: [workoutAt('0017', NOW, [setDone(w, 5)])] })
+ expect(role(assisted(0), poliquin, 'supinePullups').needsBodyweight).toBe(false)
+ expect(role(assisted(20), poliquin, 'supinePullups').needsBodyweight).toBe(true)
+ })
+})
+
describe('an override of the role\'s own default exercise', () => {
it('is not custom, and reads the whole whitelist like the default', () => {
const template = TEMPLATES.atg
diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js
index 7d0eeda87..e14f133f9 100644
--- a/frontend/src/locales/de.js
+++ b/frontend/src/locales/de.js
@@ -1355,4 +1355,5 @@ export default {
'Change exercise': 'Übung ändern',
'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.',
}
diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js
index a114b4fcb..54392d494 100644
--- a/frontend/src/locales/es.js
+++ b/frontend/src/locales/es.js
@@ -1335,4 +1335,5 @@ export default {
'Change exercise': 'Cambiar ejercicio',
'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.',
}
diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js
index 6cd9cb6bd..c969a9b06 100644
--- a/frontend/src/locales/fr.js
+++ b/frontend/src/locales/fr.js
@@ -1335,4 +1335,5 @@ export default {
'Change exercise': 'Changer d\'exercice',
'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.',
}
diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js
index a52c4e1cb..8834bdb62 100644
--- a/frontend/src/locales/hi.js
+++ b/frontend/src/locales/hi.js
@@ -1335,4 +1335,5 @@ export default {
'Change exercise': 'व्यायाम बदलें',
'Use default exercise': 'डिफ़ॉल्ट व्यायाम उपयोग करें',
'Custom': 'कस्टम',
+ 'Log your body weight to score this lift.': 'इस व्यायाम का आकलन करने के लिए अपने शरीर का वज़न दर्ज करें।',
}
diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js
index ea45de948..c4999c902 100644
--- a/frontend/src/locales/hu.js
+++ b/frontend/src/locales/hu.js
@@ -1338,4 +1338,5 @@ export default {
'Change exercise': 'Gyakorlat módosítása',
'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.',
}
diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js
index 28ba1b382..017012b5a 100644
--- a/frontend/src/locales/it.js
+++ b/frontend/src/locales/it.js
@@ -1335,4 +1335,5 @@ export default {
'Change exercise': 'Cambia esercizio',
'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.',
}
diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js
index 2b9b4206e..a63c3e7a6 100644
--- a/frontend/src/locales/ko.js
+++ b/frontend/src/locales/ko.js
@@ -1335,4 +1335,5 @@ export default {
'Change exercise': '운동 변경',
'Use default exercise': '기본 운동 사용',
'Custom': '사용자 지정',
+ 'Log your body weight to score this lift.': '이 운동을 평가하려면 체중을 기록하세요.',
}
diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js
index 20064ffba..24619cf3b 100644
--- a/frontend/src/locales/pl.js
+++ b/frontend/src/locales/pl.js
@@ -1335,4 +1335,5 @@ export default {
'Change exercise': 'Zmień ćwiczenie',
'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.',
}
diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js
index 91ffa298a..f0bbddd1a 100644
--- a/frontend/src/locales/pt-BR.js
+++ b/frontend/src/locales/pt-BR.js
@@ -744,6 +744,7 @@ export const PT_BR_OVERRIDES = {
'Change exercise': 'Trocar exercício',
'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.',
}
export default { ...pt, ...PT_BR_OVERRIDES }
diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js
index 22f2925aa..56ef7a009 100644
--- a/frontend/src/locales/pt.js
+++ b/frontend/src/locales/pt.js
@@ -1335,4 +1335,5 @@ export default {
'Change exercise': 'Trocar exercício',
'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.',
}
diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js
index e29bdf451..5bce33ff4 100644
--- a/frontend/src/locales/ru.js
+++ b/frontend/src/locales/ru.js
@@ -1335,4 +1335,5 @@ export default {
'Change exercise': 'Изменить упражнение',
'Use default exercise': 'Использовать упражнение по умолчанию',
'Custom': 'Свой вариант',
+ 'Log your body weight to score this lift.': 'Запишите вес тела, чтобы оценить это упражнение.',
}
diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js
index 28fa275a7..01662646c 100644
--- a/frontend/src/locales/th.js
+++ b/frontend/src/locales/th.js
@@ -1346,4 +1346,5 @@ export default {
'Change exercise': 'เปลี่ยนท่าฝึก',
'Use default exercise': 'ใช้ท่าฝึกเริ่มต้น',
'Custom': 'กำหนดเอง',
+ 'Log your body weight to score this lift.': 'บันทึกน้ำหนักตัวเพื่อประเมินท่านี้',
}
diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js
index b93d517af..94ceb1abc 100644
--- a/frontend/src/locales/tr.js
+++ b/frontend/src/locales/tr.js
@@ -1335,4 +1335,5 @@ export default {
'Change exercise': 'Egzersizi değiştir',
'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.',
}
diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js
index a58c0311d..de31e4380 100644
--- a/frontend/src/locales/zh.js
+++ b/frontend/src/locales/zh.js
@@ -1335,4 +1335,5 @@ export default {
'Change exercise': '更换动作',
'Use default exercise': '使用默认动作',
'Custom': '自定义',
+ 'Log your body weight to score this lift.': '记录你的体重以评估这个动作。',
}
diff --git a/frontend/src/views/StructuralBalance.jsx b/frontend/src/views/StructuralBalance.jsx
index f4a700492..15cd348f3 100644
--- a/frontend/src/views/StructuralBalance.jsx
+++ b/frontend/src/views/StructuralBalance.jsx
@@ -5,7 +5,7 @@ import { exOr } from '../lib/exercises.js'
import { t, exerciseNameFor } from '../lib/i18n.js'
import Icon from '../components/Icon.jsx'
import { Button, Segmented } from '../components/ui.jsx'
-import { exercisePicker } from '../sheets.jsx'
+import { exercisePicker, bwSheet } from '../sheets.jsx'
import { computeBalance, overrideKey, withOverride } from '../lib/structuralBalance.js'
import { balanceStatusView } from '../lib/structuralBalance-view.js'
import { TEMPLATES, TEMPLATE_LIST, DEFAULT_TEMPLATE_ID, EVALUATION_MODES } from '../lib/structuralBalanceTemplates.js'
@@ -70,6 +70,9 @@ export default function StructuralBalance() {
<span className="small dim" style={{ display: 'block' }}>
<span className="capitalize" data-exercise-name>{name}</span>{r.isOverridden ? ` · ${t('Custom')}` : ''}
</span>
+ {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>}
</span>
<span className="v" style={{ textAlign: 'right', flexShrink: 0 }}>
<span style={{ color: STATUS_COLOR[r.status] }}>{t(view.label)}</span>
@@ -77,6 +80,7 @@ export default function StructuralBalance() {
</span>
</div>
<div style={{ display: 'flex', gap: 8 }}>
+ {r.needsBodyweight && <Button size="sm" variant="ghost" icon="plus" onClick={() => bwSheet()}>{t('Log body weight')}</Button>}
<Button size="sm" variant="ghost" icon="pencil" onClick={() => changeExercise(role)}>{t('Change exercise')}</Button>
{r.isOverridden && <Button size="sm" variant="ghost" onClick={() => clearOverride(role)}>{t('Use default exercise')}</Button>}
</div>
diff --git a/frontend/src/views/StructuralBalance.test.jsx b/frontend/src/views/StructuralBalance.test.jsx
index dd1b8d07a..992afac78 100644
--- a/frontend/src/views/StructuralBalance.test.jsx
+++ b/frontend/src/views/StructuralBalance.test.jsx
@@ -120,6 +120,27 @@ describe('StructuralBalance view', () => {
expect([...after.querySelectorAll('button')].some(b => b.textContent.includes('Use default exercise'))).toBe(false)
})
+ it('asks for a weigh-in on a row that only lacks one, with a way to log it', () => {
+ const S = clone(DEF)
+ S.balanceTemplate = 'atg'
+ S.workouts = [workoutAt('0085', Date.now(), [setDoneSet(80, 12)])]
+ useStore.setState({ S, user: null })
+ const host = render()
+ const rdl = host.querySelector('[data-role-id="romanianDeadlift"]')
+ expect(rdl.dataset.status).toBe('no-data')
+ expect(rdl.textContent).toContain('Log your body weight to score this lift.')
+ expect(host.querySelector('[data-role-id="goodMorning"] [data-needs-bodyweight]')).toBe(null)
+ const log = [...rdl.querySelectorAll('button')].find(b => b.textContent.includes('Log body weight'))
+ act(() => log.click())
+ expect(useUI.getState().sheets.length).toBe(1)
+
+ act(() => useStore.getState().update(s => { s.bodyweight.push({ d: '2026-01-01', w: 80, t: 1 }) }))
+ const scored = host.querySelector('[data-role-id="romanianDeadlift"]')
+ expect(scored.dataset.status).toBe('balanced')
+ expect(scored.querySelector('[data-needs-bodyweight]')).toBe(null)
+ expect([...scored.querySelectorAll('button')].some(b => b.textContent.includes('Log body weight'))).toBe(false)
+ })
+
it('the back chevron navigates to /stats', () => {
const host = render()
act(() => host.querySelector('.iconbtn').click())