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.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
Routines: a treadmill's incline is set in its exercise settings, not only during a workout (Discord)
Duarte Santosa22a20ea6de9
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2ab7114de..03f73b30d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -90,6 +90,8 @@ you leave it alone. Handy for deciding whether those legs are really ready (than- Jumping jacks, burpees and the other cardio moves can be counted in sets x reps (or timed):their settings now offer Cardio, Reps and Time, Cardio still the default (#678).- Add exercise → By muscle has the Favourites chip too, for the muscle you picked (#669).+- A treadmill's incline can be set in its settings in the routine, not only mid-workout. The+ session opens at it unless last time had a grade of its own, and it travels in shared plans.- A weight change too small to show (say 0.03 kg) reads 0 instead of a lonely "-0".- Admin → AI Coach: the Remove button for the stored key is red now, like every other buttonthat deletes something for good.diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.jsindex fb275f27a..5a898ad2f 100644--- a/frontend/src/lib/history.js+++ b/frontend/src/lib/history.js@@ -243,7 +243,7 @@ export function exLine(cfg, unit, speedUnit) {const load = !cfg.weight ? '': backoff ? ' · ' + (isBw(cfg) ? '+' : '') + backoffWeights(cfg.weight, n, backoff).map(fmtNum).join(' → ') + ' ' + unit: ' · ' + (isBw(cfg) ? '+' : '') + fmtNum(cfg.weight) + ' ' + unit- if (mode === 'cardio') return `${n} × ${cfg.min || 20} min @ ${fmtSpeed(cfg.speed || 8, speedUnit)}`+ if (mode === 'cardio') return `${n} × ${cfg.min || 20} min @ ${fmtSpeed(cfg.speed || 8, speedUnit)}` + (hasIncline(cfg) ? ' · ' + t('{0}% incline', fmtNum(Number(cfg.incline))) : '')// A timed hold has no rep count to spell a split out of ("8/side" below) — "per side" says it// happens twice, once each side (buildWorkSets), rather than trying to divide a duration.if (mode === 'time') return `${setsRepsOf(cfg)}${load}${isPerSide(cfg) ? ' · ' + t('per side') : ''}`@@ -574,7 +574,9 @@ function buildWorkSets(S, cfg, options = {}) {if (mode === 'cardio') {for (let i = 0; i < n; i++) {const prev = prevAt(i)- sets.push({ min: prev ? prev.min : (cfg.min || 20), speed: prev ? prev.speed : (cfg.speed || 8), ...inclineFrom(prev), done: false })+ // The grade is last time's when it had one, else the routine's own (set in the exercise's+ // settings, Discord "can not set incline"): a flat walk last time never hides it.+ sets.push({ min: prev ? prev.min : (cfg.min || 20), speed: prev ? prev.speed : (cfg.speed || 8), ...inclineFrom(hasIncline(prev) ? prev : cfg), done: false })}return sets}diff --git a/frontend/src/lib/incline.test.js b/frontend/src/lib/incline.test.jsindex 1843c05de..375373f71 100644--- a/frontend/src/lib/incline.test.js+++ b/frontend/src/lib/incline.test.js@@ -3,7 +3,8 @@import { describe, it, expect } from 'vitest'import { INCLINE_MAX, clampIncline, inclineFits, hasIncline, inclineFrom } from './incline.js'import { EXIDX } from './exercises.js'-import { setLabel, buildSets, insertWarmupRow, copyRowAt } from './history.js'+import { setLabel, buildSets, insertWarmupRow, copyRowAt, exLine } from './history.js'+import { buildPlanBundle, parsePlan } from './plan-share.js'import { workoutText } from './workout-text.js'import { finishCardio } from './finish-compare.js'import { parseWorkoutCSV } from './import-csv.js'@@ -90,6 +91,26 @@ describe('a set with an incline', () => {])})+ it('opens at the routine\'s own incline when last time had none, and last time\'s grade wins (Discord)', () => {+ const cfg = { id: TREADMILL, sets: 1, min: 20, speed: 8, incline: 6 }+ const last = sets => ({ exWeights: {}, workouts: [{ id: 'w1', d: '2026-10-01', start: 0, end: 1, entries: [{ id: TREADMILL, target: { sets: 1, min: 20, speed: 8 }, sets }] }] })+ expect(buildSets({ exWeights: {}, workouts: [] }, cfg)).toEqual([{ min: 20, speed: 8, incline: 6, done: false }])+ expect(buildSets(last([{ min: 25, speed: 5, done: true }]), cfg)).toEqual([{ min: 25, speed: 5, incline: 6, done: false }])+ expect(buildSets(last([{ min: 25, speed: 5, incline: 10, done: true }]), cfg)).toEqual([{ min: 25, speed: 5, incline: 10, done: false }])+ })++ it('reads in the routine\'s line and travels in a shared plan, clamped', () => {+ expect(exLine({ id: TREADMILL, sets: 1, min: 30, speed: 5, incline: 12 }, 'kg')).toBe('1 × 30 min @ 5 km/h · 12% incline')+ expect(exLine({ id: TREADMILL, sets: 1, min: 30, speed: 5 }, 'kg')).toBe('1 × 30 min @ 5 km/h')+ const S = { unit: 'kg', customEx: [], routines: [{ id: 'r1', name: 'Walk', ex: [{ id: TREADMILL, sets: 1, min: 30, speed: 5, incline: 12 }] }] }+ const file = buildPlanBundle(S, 'Walk')+ expect(file.routines[0].ex[0].incline).toBe(12)+ file.routines[0].ex[0].incline = 90+ expect(parsePlan(file, 'kg').routines[0].ex[0].incline).toBe(INCLINE_MAX)+ delete file.routines[0].ex[0].incline+ expect(parsePlan(file, 'kg').routines[0].ex[0]).not.toHaveProperty('incline')+ })+it('comes along on a warm-up added in front of it and on a copied row', () => {const rows = insertWarmupRow([{ min: 20, speed: 5, incline: 8, done: false }], 'cardio', { min: 20, speed: 5 })expect(rows[0]).toMatchObject({ min: 20, speed: 5, incline: 8, phase: 'warmup' })diff --git a/frontend/src/lib/plan-share.js b/frontend/src/lib/plan-share.jsindex 93a0cddc3..463086e81 100644--- a/frontend/src/lib/plan-share.js+++ b/frontend/src/lib/plan-share.js@@ -21,6 +21,7 @@ import { uid, todayISO, DAYN, weekOrder, weekStartOf, exCount, routineCount } frimport { t, exerciseNameFor, exerciseNameClass } from './i18n-core.js'import { convertWeight } from './units.js'import { fmtSpeed, speedUnitOf } from './speed.js'+import { clampIncline, hasIncline } from './incline.js'import { MUSCLES, inMuscleOrder } from './muscles.js'import { SG_NAME_MAX } from './superset-meta.js'import { esc, printShell, printDocument, probeMarks } from './print-doc.js'@@ -79,6 +80,7 @@ function cleanEx(e) {o.mode = 'cardio'if (e.min != null) o.min = e.minif (e.speed != null) o.speed = e.speed+ if (hasIncline(e)) o.incline = clampIncline(e.incline)} else if (mode === 'time') {// Written out even though 'reps' is the fallback for a non-cardio id: a plan file that// dropped the mode would turn a 45-second plank into a 45-rep one at the other end.@@ -273,6 +275,7 @@ export function parsePlan(raw, destinationUnit = 'kg') {const warmRest = cleanRestSec(e.warmupRestSec)const warmOff = e.warmupRestOff === trueconst sideRest = cleanRestSec(e.sideRestSec)+ const incline = clampIncline(e.incline)// Planned substitutes: the catalogue's only, as they are exported.const subs = cleanBackups(Array.isArray(e.subs) ? e.subs.map(x => (typeof x === 'string' ? canonicalExId(x) : x)) : [], known.has(e.id) ? e.id : canonicalExId(e.id), x => !known.has(x) && !!EXIDX[x] && !isCustomEx(EXIDX[x]))// Superset meta only means something on a member of a superset; on a lone exercise it is dropped.@@ -281,9 +284,9 @@ export function parsePlan(raw, destinationUnit = 'kg') {const pyramid = normalizePyramid(e.pyramid)const pyramidRest = pyramid.length ? normalizePyramidRest(e.pyramidRest, pyramid.length) : []const pyramidWeight = pyramid.length ? normalizePyramidWeight(e.pyramidWeight, pyramid.length) : []- const { warmupSets, intensifier, restSec, warmupRestSec, warmupRestOff: _warmOff, sideRestSec: _sideRest, subs: _subs, pyramid: _pyramid, pyramidRest: _pyramidRest, pyramidWeight: _pyramidWeight, sgName: _sgName, sgRest: _sgRest, ...passthrough } = e+ const { warmupSets, intensifier, restSec, warmupRestSec, warmupRestOff: _warmOff, sideRestSec: _sideRest, subs: _subs, pyramid: _pyramid, pyramidRest: _pyramidRest, pyramidWeight: _pyramidWeight, sgName: _sgName, sgRest: _sgRest, incline: _incline, ...passthrough } = eif (!known.has(passthrough.id)) passthrough.id = canonicalExId(passthrough.id)- return convertedExercise({ ...passthrough, ...(pyramid.length ? { pyramid } : {}), ...(pyramidRest.length ? { pyramidRest } : {}), ...(pyramidWeight.length ? { pyramidWeight } : {}), ...(warm ? { warmupSets: warm } : {}), ...(intens ? { intensifier: intens } : {}), ...(rest ? { restSec: rest } : {}), ...(warmOff ? { warmupRestOff: true } : warmRest ? { warmupRestSec: warmRest } : {}), ...(sideRest ? { sideRestSec: sideRest } : {}), ...(subs.length ? { subs } : {}), ...(sgName ? { sgName } : {}), ...(sgRest ? { sgRest } : {}) }, sourceUnit || destination, destination)+ return convertedExercise({ ...passthrough, ...(pyramid.length ? { pyramid } : {}), ...(pyramidRest.length ? { pyramidRest } : {}), ...(pyramidWeight.length ? { pyramidWeight } : {}), ...(warm ? { warmupSets: warm } : {}), ...(intens ? { intensifier: intens } : {}), ...(rest ? { restSec: rest } : {}), ...(warmOff ? { warmupRestOff: true } : warmRest ? { warmupRestSec: warmRest } : {}), ...(sideRest ? { sideRestSec: sideRest } : {}), ...(subs.length ? { subs } : {}), ...(sgName ? { sgName } : {}), ...(sgRest ? { sgRest } : {}), ...(incline > 0 ? { incline } : {}) }, sourceUnit || destination, destination)})}))return {diff --git a/frontend/src/sheets.config-incline.test.jsx b/frontend/src/sheets.config-incline.test.jsxnew file mode 100644index 000000000..849cd5c87--- /dev/null+++ b/frontend/src/sheets.config-incline.test.jsx@@ -0,0 +1,66 @@+// @vitest-environment happy-dom+// Discord: "the incline can only be modified while a workout is actively in progress". A+// treadmill's settings (the routine editor's exercise sheet) take an incline next to its minutes+// and speed, the same Stepper the workout rows use, and save it on the slot.+import React, { act } from 'react'+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { createRoot } from 'react-dom/client'+import { EXIDX } from './lib/exercises.js'+import { DEF, useStore } from './store/useStore.js'+import { useUI } from './store/useUI.js'+import { exConfigSheet } from './sheets.jsx'++const TREADMILL = '2259' // walking on treadmill+const BIKE = '2138' // stationary bike run v. 3+const mounted = []+function open(ex, existing) {+ useStore.setState({ S: structuredClone(DEF), user: null })+ const onSave = vi.fn()+ exConfigSheet(ex, existing, onSave, null, null)+ const sheet = useUI.getState().sheets.at(-1)+ const host = document.createElement('div')+ document.body.appendChild(host)+ const root = createRoot(host)+ mounted.push(root)+ act(() => root.render(sheet.render(() => useUI.getState().closeSheet(sheet.id))))+ const labels = () => [...host.querySelectorAll('.stp-l')].map(l => l.textContent.trim())+ const field = label => [...host.querySelectorAll('.stp-w')].find(w => w.querySelector('.stp-l')?.textContent === label)?.querySelector('input.num')+ const type = (el, value) => act(() => {+ Object.getOwnPropertyDescriptor(el.constructor.prototype, 'value').set.call(el, value)+ el.dispatchEvent(new Event('input', { bubbles: true }))+ })+ const save = () => act(() => [...host.querySelectorAll('button')].find(b => b.textContent.trim() === 'Save').click())+ return { labels, field, type, save, onSave }+}++beforeEach(() => {+ globalThis.IS_REACT_ACT_ENVIRONMENT = true+ useUI.setState({ sheets: [] })+ document.body.innerHTML = ''+})+afterEach(() => { act(() => { mounted.splice(0).forEach(root => root.unmount()) }) })++describe('incline in a treadmill\'s settings (Discord)', () => {+ it('offers Incline next to Minutes and Speed and saves it on the slot', () => {+ const v = open(EXIDX[TREADMILL], { sets: 1, min: 30, speed: 5 })+ expect(v.labels()).toEqual(expect.arrayContaining(['Minutes', 'Incline (%)']))+ v.type(v.field('Incline (%)'), '7.3')+ v.save()+ expect(v.onSave.mock.calls[0][0]).toMatchObject({ sets: 1, min: 30, speed: 5, incline: 7.5 })+ })++ it('reopens with the saved incline, and a flat one leaves the key out', () => {+ const v = open(EXIDX[TREADMILL], { sets: 1, min: 30, speed: 5, incline: 6 })+ expect(v.field('Incline (%)').value).toBe('6')+ v.type(v.field('Incline (%)'), '0')+ v.save()+ expect(v.onSave.mock.calls[0][0]).not.toHaveProperty('incline')+ })++ it('a bike has no incline to set', () => {+ const v = open(EXIDX[BIKE], { sets: 1, min: 30, speed: 20 })+ expect(v.labels()).not.toContain('Incline (%)')+ v.save()+ expect(v.onSave.mock.calls[0][0]).not.toHaveProperty('incline')+ })+})diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsxindex a4c18934e..7bab9b31a 100644--- a/frontend/src/sheets.jsx+++ b/frontend/src/sheets.jsx@@ -45,6 +45,7 @@ import { isBackoff, backoffWeights } from './lib/backoff.js'import { isPyramid, normalizePyramid, normalizePyramidRest, normalizePyramidWeight, pyramidFromFlat, flatFromPyramid, pyramidLabel, PYRAMID_MAX, MAX_PYRAMID_SETS, PYRAMID_PRESETS } from './lib/pyramid.js'import { MOBILE, shareExport, shareExportBlob, printHtml } from './lib/mobile.js'import { speedUnitOf, toSpeed, fromSpeed } from './lib/speed.js'+import { clampIncline, inclineFits, INCLINE_MAX, INCLINE_STEP } from './lib/incline.js'import { buildCompletedWorkout, sessionEnd } from './lib/finish-workout.js'import { refillAfter } from './lib/rotation.js'import { isWarmupRow, hasCompletedWork } from './lib/workout-model.js'@@ -1849,7 +1850,9 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, i...(c.warmupRestOff === true ? { warmupRestOff: true } : c.warmupRestSec > 0 ? { warmupRestSec: Math.round(c.warmupRestSec) } : {}),...(perSide && c.sideRestSec > 0 ? { sideRestSec: Math.round(c.sideRestSec) } : {}),}- if (cardio) onSave({ sets, min: Math.max(1, Math.round(c.min) || 20), speed: Math.max(0, c.speed || 8), ...withNote, ...withRest, ...withSubs })+ // The treadmill's grade, only when it has one, so a flat slot keeps the shape it had.+ const incline = clampIncline(c.incline)+ if (cardio) onSave({ sets, min: Math.max(1, Math.round(c.min) || 20), speed: Math.max(0, c.speed || 8), ...(incline > 0 ? { incline } : {}), ...withNote, ...withRest, ...withSubs })else if (mode === 'time') onSave({ sets, mode: 'time', sec: Math.max(1, Math.round(c.sec) || 45), weight: Math.max(0, c.weight || 0), ...flags, ...(perSide ? { side: true } : {}), ...prog, ...withNote, ...withWarmups, ...withRest, ...withSetRests, ...withMeant, ...withFailure, ...withSubs })else {// A unilateral target is stored even: the split has to divide, and a typed 15 would@@ -1913,6 +1916,10 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, i{/* Typed and stepped in the profile's unit, kept in km/h (lib/speed.js). */}<Stepper label={speedUnit === 'mph' ? t('Speed (mph)') : t('Speed (km/h)')} value={toSpeed(c.speed, speedUnit)} step={0.5}onChange={v => setC(x => ({ ...x, speed: fromSpeed(v, speedUnit) }))} />+ {/* The grade it starts at, where the exercise has one (lib/incline.js); the workout rows+ take it from here when last time had none. */}+ {(inclineFits(ex) || c.incline > 0) && <Stepper label={t('Incline (%)')} value={c.incline || 0} step={INCLINE_STEP} max={INCLINE_MAX}+ onChange={v => setC(x => ({ ...x, incline: clampIncline(v) }))} />}</> : mode === 'time' ? <><Stepper label={t('Sets')} value={c.sets} step={1} decimal={false} onChange={v => setC(x => ({ ...x, sets: v }))} /><Stepper label={t('Seconds')} value={c.sec} step={5} decimal={false} onChange={v => setC(x => ({ ...x, sec: v }))} />diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsxindex 58275eeb3..5de8da424 100644--- a/frontend/src/views/Workout.jsx+++ b/frontend/src/views/Workout.jsx@@ -1234,7 +1234,7 @@ function ActiveWorkout() {const addSet = idx => mutEntry(idx, e => {const l = e.sets[e.sets.length - 1]const m = modeOf({ ...(e.target || {}), id: e.id })- if (m === 'cardio') e.sets.push({ min: l ? l.min : (e.target.min || 20), speed: l ? l.speed : (e.target.speed || 8), ...inclineFrom(l), done: false })+ if (m === 'cardio') e.sets.push({ min: l ? l.min : (e.target.min || 20), speed: l ? l.speed : (e.target.speed || 8), ...inclineFrom(l || e.target), done: false })else if (m === 'time') {const sec = l ? l.sec : (e.target.sec || 45)const w = l ? (l.w || 0) : (e.target.weight || 0)