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.

fix(stats): remove duplicate muscle exercise list

Space_Hermes64ea41a5df6a
diff --git a/frontend/src/views/Stats.jsx b/frontend/src/views/Stats.jsx
index c16a41246..3d38e235a 100644
--- a/frontend/src/views/Stats.jsx
+++ b/frontend/src/views/Stats.jsx
@@ -191,7 +191,7 @@ function MuscleBalance({ S }) {
{sel && <>
<h4 className="sec" style={{ marginTop: 14 }}>{t('Exercises')} · {t(MUSCLE_NAME[sel])}</h4>
{muscleExercises.length ? muscleExercises.map(row => (
- <div key={row.id} className="mrow" style={{ minHeight: 48, alignItems: 'stretch' }}>
+ <div key={row.id} className="mrow" style={{ minHeight: 48, alignItems: 'stretch', cursor: 'pointer' }} onClick={() => onExercise && onExercise(row.id)}>
<span className="nm" style={{ whiteSpace: 'normal', lineHeight: 1.35, display: 'flex', flexDirection: 'column', justifyContent: 'center' }}>
<span style={{ display: 'block', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
{row.name}
diff --git a/frontend/src/views/Stats.test.js b/frontend/src/views/Stats.test.js
new file mode 100644
index 000000000..96ab4b553
--- /dev/null
+++ b/frontend/src/views/Stats.test.js
@@ -0,0 +1,30 @@
+import { describe, expect, it } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { bestWeightForEntry, metricModeForEntry, metricRowsForEntry } from '../lib/history.js'
+
+const source = readFileSync(new URL('./Stats.jsx', import.meta.url), 'utf8')
+
+describe('Stats mixed-entry metric contract', () => {
+ it('selects authoritative reps rows before timed rows without stale topW', () => {
+ const entry = { target: { mode: 'time', sec: 60 }, topW: 200, sets: [
+ { phase: 'work', mode: 'reps', w: 100, r: 5, done: true },
+ { phase: 'work', mode: 'time', w: 200, sec: 60, done: true }
+ ] }
+ expect(metricModeForEntry(entry)).toBe('reps')
+ expect(metricRowsForEntry(entry, metricModeForEntry(entry))).toEqual([entry.sets[0]])
+ expect(bestWeightForEntry(entry)).toBe(100)
+ })
+
+ it('renders one clickable muscle exercise list rather than a duplicate non-clickable copy', () => {
+ expect((source.match(/muscleExercises\.length \? muscleExercises\.map\(row =>/g) || []).length).toBe(1)
+ expect(source).toContain('onClick={() => onExercise && onExercise(row.id)}')
+ })
+
+ it('uses the shared metric mode and row helpers rather than entryMode as a chart gate', () => {
+ expect(source).toContain('metricModeForEntry')
+ expect(source).toContain('metricRowsForEntry')
+ expect(source).toContain('bestWeightForEntry')
+ expect(source).not.toContain('const loggedMode = entryMode(en)')
+ expect(source).not.toContain('(en.topW || 0)')
+ })
+})