MCP: fixes from review (cardio mode, dead code, Stryker drop, docs)
· entryView was passing `e.target || { id: e.id }` to modeOf, which
doesn't put id on the target when target exists — so a cardio config
saved as {sets, min, speed} (no mode, no id) fell through to 'reps'
and the label came back as "0×0". Now uses the same pattern every
app call site uses (Workout.jsx, Stats.jsx, progression.js):
modeOf({ ...(e.target || {}), id: e.id }). Same fix applied to the
setLabel call right below. Added a regression test using a real
cardio exercise id with a target that has no mode key — would have
caught the original bug.
· requireIso/ISO/fmt/friendlyDate/MUSCLES were unused (zod regexes
cover ISO validation at the SDK layer). Removed, along with the
misplaced comment that described requireIso but sat above entryView.
· estimate_1rm's exercise_id schema description referenced
search_exercises (v1.5) which doesn't exist yet — an LLM reading
the schema would try to call it. Dropped the reference; the
Roadmap section in mcp/README.md drops the same mention.
· resolveUid threw "set OPENGYM_UID to one of: " (empty list) when
there were zero state files but multiple users in db.json — the
files array was empty so files.join(', ') rendered nothing. Now
falls back to the db.json user ids in that branch.
· Dropped Stryker entirely. The MCP SDK's 93 transitive runtime
packages are tolerable since mcp/ is opt-in and never enters
Docker, but a second test toolchain for a 39% mutation score
wasn't carrying its weight next to the plain vitest suite.
Removed .stryker.conf.json, the two Stryker devDeps, the
mutation:test script, the .gitignore entries, and the README
section. mcp/ now has a single devDep (vitest); 0 vulnerabilities
(was 2 moderate).
· CONTRIBUTING.md layout block + a one-line cross-reference in
README.md's Tech section pointing at mcp/README.md, so people can
actually find it.
92 frontend + 33 MCP tests pass.
This commit is contained in:
1 parent
6aaf2a3eea
commit
09949686c2
10 files changed
+173
-2029
No files matched your search
@@ -4,6 +4,7 @@
|
||||
// (rest-day override, missing routine, zero-workout history, no synced state, superset links).
|
||||
import { describe, beforeAll, afterAll, beforeEach, test, expect, vi } from 'vitest'
|
||||
import { buildDemoState } from '../../frontend/src/lib/demoSeed.js'
|
||||
import { EXDB } from '../../frontend/src/lib/exercises.js'
|
||||
import { _seedStateForTests } from '../src/state.js'
|
||||
import { TOOLS } from '../src/tools.js'
|
||||
|
||||
@@ -281,6 +282,23 @@ describe('get_workout', () => {
|
||||
expect(w.entries[2].sets[0].label).toBe('1:30 · 20') // weighted plank
|
||||
expect(w.entries[3].sets[0].label).toBe('20 min @ 8 km/h') // cardio
|
||||
})
|
||||
|
||||
test('infers cardio mode from the exercise id when the target has no mode key', () => {
|
||||
// Reproduces the review bug: the sheet saves a cardio target as {sets, min, speed} with
|
||||
// no mode and no id. modeOf must fall through to isCardio(id), which needs the id on the
|
||||
// cfg — entryView has to spread id into the cfg the way every app call site does.
|
||||
const CARDIO_ID = EXDB.find(e => e.bp === 'cardio').id
|
||||
S.workouts = [{
|
||||
id: 'synth-cardio', d: '2026-07-25', start: 0, end: 1800000, routineId: 'x', name: 'Synth',
|
||||
bw: 78, vol: 0, prs: [],
|
||||
entries: [
|
||||
{ id: CARDIO_ID, target: { sets: 1, min: 20, speed: 8 }, sets: [{ min: 20, speed: 8, done: true }] }
|
||||
]
|
||||
}]
|
||||
const w = call('get_workout', { date: '2026-07-25' })
|
||||
expect(w.entries[0].mode).toBe('cardio')
|
||||
expect(w.entries[0].sets[0].label).toBe('20 min @ 8 km/h')
|
||||
})
|
||||
})
|
||||
|
||||
/* ---------- get_bodyweight ---------- */
|
||||
|
||||
Reference in new issue
Block a user