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.

Muscle balance: an untrained muscle opens its exercises (#553)

Duarte Santosa449893a5cee
diff --git a/frontend/src/components/MuscleExplorer.jsx b/frontend/src/components/MuscleExplorer.jsx
index 410debe64..de6313558 100644
--- a/frontend/src/components/MuscleExplorer.jsx
+++ b/frontend/src/components/MuscleExplorer.jsx
@@ -17,9 +17,9 @@ import { isFav, sortFavouritesFirst } from '../lib/favourites.js'
// One explorer for the Library and every catalogue picker. Supplying `onPick` turns
// a result into a selection; without it the explorer behaves like the normal Library.
-export default function MuscleExplorer({ onPick, onDetail, onPlan, pickIcon = 'plus' }) {
+export default function MuscleExplorer({ onPick, onDetail, onPlan, pickIcon = 'plus', initial = null }) {
const S = useStore(s => s.S)
- const [selected, setSelected] = useState(null)
+ const [selected, setSelected] = useState(initial)
const [q, setQ] = useState('')
const [bp, setBp] = useState('')
const [eq, setEq] = useState('')
diff --git a/frontend/src/components/MuscleExplorer.test.jsx b/frontend/src/components/MuscleExplorer.test.jsx
index 5a6e06617..f4488b269 100644
--- a/frontend/src/components/MuscleExplorer.test.jsx
+++ b/frontend/src/components/MuscleExplorer.test.jsx
@@ -110,3 +110,12 @@ describe('MuscleExplorer search: the × and live count the Library has (#338)',
expect(clear()).toBeNull()
})
})
+
+// #553: Stats' untrained muscles open the explorer on that muscle.
+describe('MuscleExplorer opened on a muscle', () => {
+ it('starts with it chosen and its exercises listed', () => {
+ const host = render({ initial: 'biceps', onDetail: vi.fn() })
+ expect(isOn(muscleChip(host, 'Biceps'))).toBe(true)
+ expect(host.textContent).toContain('Exercises for Biceps')
+ })
+})
diff --git a/frontend/src/index.css b/frontend/src/index.css
index c8656bb1d..3013784e0 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -1707,6 +1707,7 @@ body.no-tabbar #timer.working{box-shadow:inset 0 var(--hair) 0 var(--acc),0 -10p
.mchips{display:flex;flex-wrap:wrap;gap:6px;margin-top:4px}
.mchip{font-size:12px;padding:4px 9px;border-radius:99px;background:var(--surface-2);color:var(--label-2)}
.mchip.miss{background:color-mix(in srgb,var(--orange) 16%,transparent);color:var(--orange)}
+button.mchip{border:none;font:inherit;font-size:12px;cursor:pointer}
/* --- stat tiles --- */
.tiles{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-bottom:12px}
diff --git a/frontend/src/views/Muscles.jsx b/frontend/src/views/Muscles.jsx
index 2e76482a6..9ad62155d 100644
--- a/frontend/src/views/Muscles.jsx
+++ b/frontend/src/views/Muscles.jsx
@@ -1,15 +1,22 @@
-import { useNavigate } from 'react-router-dom'
+import { useNavigate, useLocation, useSearchParams } from 'react-router-dom'
+import { MUSCLES } from '../lib/muscles.js'
import { t } from '../lib/i18n.js'
import MuscleExplorer from '../components/MuscleExplorer.jsx'
import { exerciseDetailSheet, addToRoutineSheet } from '../sheets.jsx'
import Icon from '../components/Icon.jsx'
+// `?m=<muscle>` opens on that muscle (Stats' untrained muscles, #553), and back goes where it came from.
export default function Muscles() {
const nav = useNavigate()
+ const loc = useLocation()
+ const [params] = useSearchParams()
+ const m = params.get('m')
+ const initial = m && MUSCLES.includes(m) ? m : null
+ const back = loc.state?.from === '/stats' ? '/stats' : '/library'
return <>
- <div className="hdr"><button className="iconbtn" data-back="/library" onClick={() => nav('/library')} aria-label={t('Exercises')}><Icon name="chevronLeft" /></button>
+ <div className="hdr"><button className="iconbtn" data-back={back} onClick={() => nav(back)} aria-label={back === '/stats' ? t('Stats') : t('Exercises')}><Icon name="chevronLeft" /></button>
<div style={{ flex: 1, marginInlineStart: 12 }}><h1>{t('Explore muscles')}</h1><div className="sub">{t('Choose a muscle to see exercises that train it.')}</div></div></div>
- <MuscleExplorer onDetail={exerciseDetailSheet} onPlan={addToRoutineSheet} />
+ <MuscleExplorer key={initial || ''} initial={initial} onDetail={exerciseDetailSheet} onPlan={addToRoutineSheet} />
</>
}
diff --git a/frontend/src/views/Stats.jsx b/frontend/src/views/Stats.jsx
index 0decc6ec2..4ffd3a403 100644
--- a/frontend/src/views/Stats.jsx
+++ b/frontend/src/views/Stats.jsx
@@ -125,6 +125,7 @@ function profileBodyweightKg(S) {
}
function MuscleBalance({ S }) {
+ const nav = useNavigate()
const [view, setView] = useState('balance')
const [win, setWin] = useState(7)
const [weekOffset, setWeekOffset] = useState(0)
@@ -194,7 +195,9 @@ function MuscleBalance({ S }) {
const completionSummary = <>
{missed.length > 0 && <>
<h4 className="sec" style={{ marginTop: 12 }}>{on ? t('No hard sets in this period') : t('Not trained in this period')}</h4>
- <div className="mchips">{missed.map(m => <span key={m} className="mchip miss">{t(MUSCLE_NAME[m])}</span>)}</div>
+ {/* A tap opens the exercises for that muscle (#553). */}
+ <div className="mchips">{missed.map(m => <button type="button" key={m} className="mchip miss" data-muscle={m}
+ aria-label={t('Exercises for {0}', t(MUSCLE_NAME[m]))} onClick={() => nav('/muscles?m=' + encodeURIComponent(m), { state: { from: '/stats' } })}>{t(MUSCLE_NAME[m])}</button>)}</div>
</>}
{!missed.length && worked.length > 0 &&
<div className="muted small" style={{ marginTop: 10 }}>{on
diff --git a/frontend/src/views/Stats.weekly-volume.test.jsx b/frontend/src/views/Stats.weekly-volume.test.jsx
index 34f412180..70e030956 100644
--- a/frontend/src/views/Stats.weekly-volume.test.jsx
+++ b/frontend/src/views/Stats.weekly-volume.test.jsx
@@ -7,10 +7,10 @@ import Stats from './Stats.jsx'
const NOW = new Date(2026, 8, 30, 12).getTime()
const press = { id: 'press', n: 'Press', primaries: ['chest'], secondaries: ['triceps'], custom: true }
-const mocks = vi.hoisted(() => ({ S: null, bodyMaps: [] }))
+const mocks = vi.hoisted(() => ({ S: null, bodyMaps: [], nav: null }))
vi.mock('../store/useStore.js', () => ({ useStore: selector => selector({ S: mocks.S }) }))
-vi.mock('react-router-dom', () => ({ useNavigate: () => vi.fn() }))
+vi.mock('react-router-dom', () => ({ useNavigate: () => (...a) => mocks.nav?.(...a) }))
vi.mock('../sheets.jsx', () => ({
bwSheet: vi.fn(), goalSheet: vi.fn(), calendarSheet: vi.fn(), workoutDetailSheet: vi.fn(),
exerciseHistorySheet: vi.fn(), WorkoutRow: () => React.createElement('div'), bwDeltaColor: () => '', weighInsSheet: vi.fn(),
@@ -275,4 +275,19 @@ describe('Stats — weekly planned vs completed volume', () => {
expect(value('triceps').textContent).toBe('0/1 · 0%')
expect(row('biceps')).toBeNull()
})
+
+ // #553: an untrained muscle opens the exercises that train it.
+ it('a tap on an untrained muscle opens its exercises', () => {
+ mocks.nav = vi.fn()
+ mocks.S = state({
+ routines: [{ id: 'push', name: 'Push', ex: [{ id: 'press', sets: 12 }] }],
+ workouts: [completed('2026-09-30', 'chest', 8)],
+ })
+ mount()
+ const chip = comparison().querySelector('.mchip.miss')
+ expect(chip.tagName).toBe('BUTTON')
+ act(() => chip.click())
+ expect(mocks.nav).toHaveBeenCalledWith('/muscles?m=' + chip.dataset.muscle, { state: { from: '/stats' } })
+ expect(MUSCLES).toContain(chip.dataset.muscle)
+ })
})