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.

MCP: warm-ups do not become personal records

TheophileDiot19a8be2c38f8
diff --git a/mcp/src/tools.js b/mcp/src/tools.js
index 513fd0a60..07db2f530 100644
--- a/mcp/src/tools.js
+++ b/mcp/src/tools.js
@@ -10,6 +10,7 @@ import {
modeOf, workoutVolume, setsDone, effectiveRoutine, effectiveRoutineId
} from '../../frontend/src/lib/history.js'
import { exOr } from '../../frontend/src/lib/exercises.js'
+import { isWarmupRow } from '../../frontend/src/lib/workout-model.js'
import {
estimate1RM, best1RM, e1rmSeries, DEFAULT_FORMULA, REP_CAP
} from '../../frontend/src/lib/onerm.js'
@@ -53,13 +54,15 @@ function entryView(e, S) {
}
// Best estimate per exercise, mirroring the UI's PR table: every eligible set across history, biggest wins.
+// Warm-ups are skipped for the same reason bestSetOf() skips them (onerm.js): a heavy ramp row is not a
+// record. Without this the coach's PR and the athlete's PR silently disagree for the same exercise.
function prTable(S, formula) {
const byId = new Map()
for (const w of (S.workouts || [])) {
for (const e of (w.entries || [])) {
const ex = exerciseOf(e.id, S)
for (const s of (e.sets || [])) {
- if (!s.done) continue
+ if (!s.done || isWarmupRow(s)) continue
const est = estimate1RM(s.w, s.r, formula)
if (est == null) continue
const prev = byId.get(e.id)
diff --git a/mcp/test/tools.test.js b/mcp/test/tools.test.js
index 9a7961847..b5c3cf061 100644
--- a/mcp/test/tools.test.js
+++ b/mcp/test/tools.test.js
@@ -7,6 +7,7 @@ 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'
+import { bestSetOf } from '../../frontend/src/lib/onerm.js'
// Re-stated here so the assertions stand alone without reaching into lib internals to learn
// the demo state's exact values.
@@ -475,6 +476,35 @@ describe('estimate_1rm', () => {
expect(table).toEqual([])
})
+ test('a heavy warm-up is never a PR — the table matches the app, which excludes warm-ups', () => {
+ // The app scans with bestSetOf(), which skips warm-ups (onerm.js). prTable used to gate on
+ // s.done alone, so a ramp row heavier than the work set became a record the coach reported
+ // and the athlete never saw — for the same exercise, from the same state.
+ S.workouts = [{
+ id: 'w-ramp', d: '2026-07-26', name: 'Legs', start: 1000, end: 1000 + 30 * 60000,
+ vol: 0, prs: [],
+ entries: [{
+ id: LEG_PRESS_ID, target: { sets: 2, reps: 5, mode: 'reps' },
+ sets: [
+ { w: 200, r: 5, done: true, phase: 'warmup' }, // mistyped/greedy ramp row
+ { w: 100, r: 5, done: true } // the only real work set
+ ]
+ }]
+ }]
+ _seedStateForTests(S)
+
+ const app = bestSetOf(S.workouts[0].entries[0])
+ expect(app.w).toBe(100) // the app ignores the 200 kg warm-up
+
+ const best = call('estimate_1rm', { exercise_id: LEG_PRESS_ID }).best
+ expect(best.w).toBe(100)
+ expect(best.est).toBeCloseTo(app.est, 1)
+
+ const row = call('estimate_1rm', {}).pr_table.find(p => p.exId === LEG_PRESS_ID)
+ expect(row.w).toBe(100)
+ expect(row.est).toBeCloseTo(app.est, 1)
+ })
+
test('a null estimate says which kind of null it is', () => {
// "Never trained" and "trained, but always above the rep cap" are opposite facts that both
// arrive as best: null. Undistinguished, the second one reads as the first and an assistant