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
feat(cardio): treadmill incline per cardio set, prefilled from last time, in the text, the finish summary and the gravl import
Duarte Santos49ef26b49929
diff --git a/frontend/src/lib/finish-compare.js b/frontend/src/lib/finish-compare.jsindex e71c835c2..0ee4d7336 100644--- a/frontend/src/lib/finish-compare.js+++ b/frontend/src/lib/finish-compare.js@@ -60,3 +60,18 @@ export function finishCompare(st, w) {}return rows}++/**+ * The cardio of `w` for the finish summary, which the rows above leave out: one row per cardio+ * exercise with the sets that were done, warm-ups included (a walk to warm up is still a walk).+ * The summary prints them with setLabel, so a treadmill's speed and incline read as logged.+ */+export function finishCardio(w) {+ const rows = []+ for (const entry of w?.entries || []) {+ if (!entry?.id || modeOf({ ...(entry.target || {}), id: entry.id }) !== 'cardio') continue+ const sets = (Array.isArray(entry.sets) ? entry.sets : []).filter(s => s && s.done && (Number(s.min) > 0 || Number(s.speed) > 0))+ if (sets.length) rows.push({ id: entry.id, target: entry.target, sets })+ }+ return rows+}diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.jsindex 5f0290b6e..1b0f1d703 100644--- a/frontend/src/lib/history.js+++ b/frontend/src/lib/history.js@@ -2,6 +2,7 @@import { syncSupersetMeta } from './superset-meta.js'import { todayISO, isoOf, weekKey, weekStartOf, fmtNum } from './format.js'import { fmtSpeed } from './speed.js'+import { hasIncline, inclineFrom } from './incline.js'import { isCardio, isBodyweightEq, isAssisted, betterWeight } from './exercises.js'import { barWeightFor } from './bar.js'import { phaseForSet, modeForSet, modeForEntry, isWarmupRow, isDropSet, isRestPauseSet, normalizeMode, completedVolumeOf, hasCompletedWork, nextDropWeight, splitBurstReps, makeSideSet, isSideSet, syncSideAggregate, WEIGHT_ORIGIN_MANUAL, dropsOf, clustersOf } from './workout-model.js'@@ -148,7 +149,8 @@ export function setLabel(id, s, cfg, speedUnit) {// custom one moved to Cardio after months of rep sets read them all as "0 min @ 0 km/h", next// to the volume those same sets still count. A set with reps and nothing cardio was a rep set.if (!EXPLICIT_MODES.has(cfg?.mode) && mode !== 'reps' && s.r > 0 && !(s.min > 0 || s.speed > 0 || s.sec > 0)) mode = 'reps'- if (mode === 'cardio') return `${s.min || 0} min @ ${fmtSpeed(s.speed || 0, speedUnit)}`+ // A treadmill grade rides along when the set has one (lib/incline.js); a flat set reads as it did.+ if (mode === 'cardio') return `${s.min || 0} min @ ${fmtSpeed(s.speed || 0, speedUnit)}` + (hasIncline(s) ? ' · ' + t('{0}% incline', fmtNum(Number(s.incline))) : '')if (mode === 'time') return fmtSec(s.sec) + (s.w > 0 ? ` · ${fmtNum(s.w)}` : '')const bw = isBw(c)const load = (w, reps) => (bw ? (w > 0 ? `+${fmtNum(w)} × ` : '') + reps : `${fmtNum(w || 0)}×${reps}`)@@ -551,7 +553,7 @@ 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), done: false })+ sets.push({ min: prev ? prev.min : (cfg.min || 20), speed: prev ? prev.speed : (cfg.speed || 8), ...inclineFrom(prev), done: false })}return sets}@@ -970,6 +972,7 @@ export function insertWarmupRow(rows, mode, target, step = 2.5, floor = 0) {? {min: prev ? prev.min : (work ? work.min : (target.min || 20)),speed: prev ? prev.speed : (work ? work.speed : (target.speed || 8)),+ ...inclineFrom(prev || work),done: false, phase: 'warmup', warmup: true,}: mode === 'time'diff --git a/frontend/src/lib/import-csv.js b/frontend/src/lib/import-csv.jsindex 0246b7ac7..d4c81ade0 100644--- a/frontend/src/lib/import-csv.js+++ b/frontend/src/lib/import-csv.js@@ -22,6 +22,7 @@ import { EXDB, EXIDX, canonicalExId, isCardio as isCardioEx } from './exercises.import { uid } from './format.js'import { isWarmupRow } from './workout-model.js'import { HEVY_TITLE_MAP } from './hevy-id-map.js'+import { clampIncline, inclineFrom } from './incline.js'/* ----------------------------------------------------------------- CSV ---- */@@ -89,6 +90,8 @@ const COLUMNS = [['distanceM', ['distance meters', 'distance m', 'distance metres']],['distance', ['distance']],['distanceUnit', ['distance unit']],+ // gravl writes a treadmill's grade per set; "Incline (%)" normalises to the same name.+ ['incline', ['incline', 'incline percent']],['seconds', ['seconds', 'duration seconds', 'set duration sec']],['time', ['time', 'duration']],// Strong's current export: the whole workout's length, in seconds, on every row.@@ -577,7 +580,7 @@ export function parseWorkoutCSV(text, { unit = 'kg', customEx = [] } = {}) {const set = timed? { sec: Math.round(secs), w, done: true, u: rowUnit, ...(warmup ? { phase: 'warmup' } : {}) }: isCardio- ? { min: mins || 0, speed: mins > 0 ? Math.round(km / (mins / 60) * 10) / 10 : 0, done: true, ...(warmup ? { phase: 'warmup' } : {}) }+ ? { min: mins || 0, speed: mins > 0 ? Math.round(km / (mins / 60) * 10) / 10 : 0, ...inclineFrom({ incline: clampIncline(num(cell(r, 'incline'))) }), done: true, ...(warmup ? { phase: 'warmup' } : {}) }: { w, r: reps || 0, done: true, u: rowUnit, ...(warmup ? { phase: 'warmup' } : {}) }// Effort rides along only where the app can show it again: a weighted rep set. A treadmill// row with an RPE would have nowhere to put it. A set is kept on one scale, so a filediff --git a/frontend/src/lib/incline.js b/frontend/src/lib/incline.jsnew file mode 100644index 000000000..f56193c3b--- /dev/null+++ b/frontend/src/lib/incline.js@@ -0,0 +1,51 @@+// Treadmill incline per cardio set (Discord "Add incline level for treadmill").+//+// A cardio set is minutes at a speed; `incline` is the grade on top of it, in percent, on the+// set itself: { min: 30, speed: 5.5, incline: 12, done: true }. It is optional everywhere. A set+// without it is a flat one, exactly what every set logged before this was, so nothing stored is+// ever rewritten and an older app that does not know the key leaves it alone (the server puts a+// key it never knew back from the stored copy, api/sync-stamps.js keepKeys).+import { isCustomEx } from './exercises.js'++// Treadmills top out around 15 %, incline trainers at 40 %. Half a percent is the finest step+// any of them shows.+export const INCLINE_MAX = 40+export const INCLINE_STEP = 0.5++/**+ * A typed or stepped incline as it is stored: on the half percent, between 0 and 40. Nothing+ * (a cleared field) stays nothing, so the key goes rather than holding a 0 nobody typed.+ */+export function clampIncline(v) {+ if (v == null || v === '') return null+ const n = Number(v)+ if (!Number.isFinite(n)) return null+ return Math.min(INCLINE_MAX, Math.max(0, Math.round(n / INCLINE_STEP) * INCLINE_STEP))+}++// Where a grade means something: on the machines that have one, and on foot, where a hill is the+// same thing outdoors. Read off the catalogue's English name and equipment. A bike, a rower, a+// rope or a jumping jack has no incline to set, whatever else its name says.+const HILLY = /treadmill|\bwalk|\brun\b|running|\bjog|sprint|stepmill|stair|stepper|elliptical|cross ?trainer|\bhik(e|ing)|incline|trot|march/i+const FLAT = /bike|bicycl|cycl|row(ing|er)?\b|rope|skat|swim|\bski\b|erg\b|jack|burpee|punch|shuffle|hop|jump|climber|crawl/i+const HILLY_EQ = new Set(['elliptical machine', 'stepmill machine'])++/**+ * Whether a cardio exercise offers the incline column. A catalogue exercise does when its name+ * or equipment says treadmill, walking, running, stairs or elliptical. Your own exercise does+ * unless its name says it is a bike, a rower and the like: its name can be in any language, and+ * an optional field you never fill costs nothing.+ */+export function inclineFits(ex) {+ if (!ex || typeof ex !== 'object') return false+ const name = String(ex.n || '')+ if (FLAT.test(name)) return false+ if (HILLY.test(name) || HILLY_EQ.has(String(ex.eq || '').toLowerCase())) return true+ return isCustomEx(ex)+}++/** Whether a set carries a grade worth showing: anything above flat. */+export const hasIncline = s => Number(s?.incline) > 0++/** What a new row takes over from the set it follows: its incline, when it had one. */+export const inclineFrom = s => (hasIncline(s) ? { incline: Number(s.incline) } : {})diff --git a/frontend/src/lib/incline.test.js b/frontend/src/lib/incline.test.jsnew file mode 100644index 000000000..1843c05de--- /dev/null+++ b/frontend/src/lib/incline.test.js@@ -0,0 +1,140 @@+// Treadmill incline per cardio set (Discord "Add incline level for treadmill"): optional on the+// set, offered where a grade means something, and carried everywhere a cardio set is read back.+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 { workoutText } from './workout-text.js'+import { finishCardio } from './finish-compare.js'+import { parseWorkoutCSV } from './import-csv.js'++const TREADMILL = '2259' // walking on treadmill+const INCLINE_WALK = '3666' // walking on incline treadmill+const ELLIPTICAL = '2192' // elliptical machine walk+const STEPMILL = '2311' // walking on stepmill+const RUN = '0685' // run+const BIKE = '2138' // stationary bike run v. 3+const ROWER = '1161' // rowing (with rowing machine)+const ROPE = '2612' // jump rope+const JACKS = '3094' // jumping jack++describe('clampIncline', () => {+ it('keeps a grade on the half percent between 0 and 40', () => {+ expect(clampIncline(5)).toBe(5)+ expect(clampIncline(7.3)).toBe(7.5)+ expect(clampIncline(7.2)).toBe(7)+ expect(clampIncline('12.5')).toBe(12.5)+ expect(clampIncline(55)).toBe(INCLINE_MAX)+ expect(clampIncline(-3)).toBe(0)+ expect(clampIncline(0)).toBe(0)+ })+ it('leaves nothing as nothing, so a cleared field drops the key', () => {+ expect(clampIncline(null)).toBe(null)+ expect(clampIncline(undefined)).toBe(null)+ expect(clampIncline('')).toBe(null)+ expect(clampIncline('steep')).toBe(null)+ expect(clampIncline(NaN)).toBe(null)+ })+})++describe('inclineFits', () => {+ it('offers the incline on treadmills, walking, running, stairs and ellipticals', () => {+ for (const id of [TREADMILL, INCLINE_WALK, ELLIPTICAL, STEPMILL, RUN]) expect(inclineFits(EXIDX[id]), EXIDX[id].n).toBe(true)+ })+ it('not on a bike, a rower, a rope or jumping jacks', () => {+ for (const id of [BIKE, ROWER, ROPE, JACKS]) expect(inclineFits(EXIDX[id]), EXIDX[id].n).toBe(false)+ })+ it('on your own cardio exercise unless its name says it has no grade', () => {+ expect(inclineFits({ id: 'c1', n: 'Laufband', bp: 'cardio', custom: true })).toBe(true)+ expect(inclineFits({ id: 'c2', n: 'Hill walk', bp: 'cardio', custom: true })).toBe(true)+ expect(inclineFits({ id: 'c3', n: 'Spin bike', bp: 'cardio', custom: true })).toBe(false)+ expect(inclineFits({ id: 'c4', n: 'Concept2 rower', bp: 'cardio', custom: true })).toBe(false)+ expect(inclineFits(null)).toBe(false)+ })+})++describe('a set with an incline', () => {+ it('reads with its grade, and a flat or older set reads exactly as before', () => {+ expect(setLabel(TREADMILL, { min: 30, speed: 5.5, incline: 12, done: true })).toBe('30 min @ 5.5 km/h · 12% incline')+ expect(setLabel(TREADMILL, { min: 30, speed: 5.5, incline: 7.5 })).toBe('30 min @ 5.5 km/h · 7.5% incline')+ expect(setLabel(TREADMILL, { min: 30, speed: 5.5, incline: 0 })).toBe('30 min @ 5.5 km/h')+ expect(setLabel(TREADMILL, { min: 30, speed: 5.5 })).toBe('30 min @ 5.5 km/h')+ // In mph too: the grade is a percentage either way.+ expect(setLabel(TREADMILL, { min: 30, speed: 16.09344, incline: 4 }, null, 'mph')).toBe('30 min @ 10 mph · 4% incline')+ })++ it('knows which sets carry one and what a new row takes over', () => {+ expect(hasIncline({ incline: 3 })).toBe(true)+ expect(hasIncline({ incline: 0 })).toBe(false)+ expect(hasIncline({})).toBe(false)+ expect(hasIncline(null)).toBe(false)+ expect(inclineFrom({ incline: 6 })).toEqual({ incline: 6 })+ expect(inclineFrom({ incline: 0 })).toEqual({})+ expect(inclineFrom(null)).toEqual({})+ })++ it('is prefilled from last time, and a session with no grade last time opens flat', () => {+ const cfg = { id: TREADMILL, sets: 2, min: 20, speed: 8 }+ const last = sets => ({ exWeights: {}, workouts: [{ id: 'w1', d: '2026-10-01', start: 0, end: 1, entries: [{ id: TREADMILL, target: { sets: 2, min: 20, speed: 8 }, sets }] }] })+ expect(buildSets(last([{ min: 25, speed: 5, incline: 10, done: true }, { min: 10, speed: 6, done: true }]), cfg)).toEqual([+ { min: 25, speed: 5, incline: 10, done: false },+ { min: 10, speed: 6, done: false },+ ])+ expect(buildSets(last([{ min: 25, speed: 5, done: true }]), cfg)).toEqual([+ { min: 25, speed: 5, done: false },+ { min: 25, speed: 5, done: false },+ ])+ expect(buildSets({ exWeights: {}, workouts: [] }, cfg)).toEqual([+ { min: 20, speed: 8, done: false },+ { min: 20, speed: 8, done: false },+ ])+ })++ 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' })+ expect(copyRowAt([{ min: 20, speed: 5, incline: 8, done: true }], 0)[1]).toEqual({ min: 20, speed: 5, incline: 8, done: false })+ })++ it('is in the workout copied as text', () => {+ const w = { id: 'w', d: '2026-10-01', start: 0, end: 30 * 60000, name: 'Walk', vol: 0,+ entries: [{ id: TREADMILL, target: { mode: 'cardio' }, sets: [{ min: 30, speed: 5.5, incline: 12, done: true }] }] }+ expect(workoutText(w, { unit: 'kg', nameOf: () => 'treadmill' })).toContain('30 min @ 5.5 km/h · 12% incline')+ })++ it('is in the finish summary, which lists the cardio the lift rows leave out', () => {+ const w = { entries: [+ { id: '0025', target: { mode: 'reps' }, sets: [{ w: 60, r: 5, done: true }] },+ { id: TREADMILL, target: { sets: 2, min: 20, speed: 8 }, sets: [{ min: 20, speed: 5, incline: 9, done: true }, { min: 20, speed: 5, done: false }] },+ { id: BIKE, target: { mode: 'cardio' }, sets: [{ min: 20, speed: 25, done: false }] },+ ] }+ const rows = finishCardio(w)+ expect(rows).toHaveLength(1)+ expect(rows[0].id).toBe(TREADMILL)+ expect(rows[0].sets).toEqual([{ min: 20, speed: 5, incline: 9, done: true }])+ expect(setLabel(rows[0].id, rows[0].sets[0], rows[0].target)).toBe('20 min @ 5 km/h · 9% incline')+ expect(finishCardio({})).toEqual([])+ })+})++describe('importing an incline', () => {+ // gravl writes the grade per set in an "Incline" column.+ const head = 'Date,Start Date,Workout,Source,Workout Duration (min),Energy,Exercise,Superset,Set,Set Type,Reps,Weight (kg),Distance (km),Set Duration (sec),Incline,Steps,Effort,Workout Notes'+ it('reads the column onto a cardio set, clamped, and leaves an empty one out', () => {+ const csv = [head,+ '2026/01/22,2:22 PM,Walk,,30,0,Walking,No,0,Normal,0,0,3,1800,12,,,',+ '2026/01/23,2:22 PM,Walk,,30,0,Walking,No,0,Normal,0,0,3,1800,"8,5",,,',+ '2026/01/24,2:22 PM,Walk,,30,0,Walking,No,0,Normal,0,0,3,1800,90,,,',+ '2026/01/25,2:22 PM,Walk,,30,0,Walking,No,0,Normal,0,0,3,1800,,,,',+ ].join('\n')+ const sets = parseWorkoutCSV(csv, { unit: 'kg' }).workouts.map(w => w.entries[0].sets[0])+ expect(sets[0]).toEqual({ min: 30, speed: 6, incline: 12, done: true })+ expect(sets[1].incline).toBe(8.5)+ expect(sets[2].incline).toBe(INCLINE_MAX)+ expect(sets[3]).toEqual({ min: 30, speed: 6, done: true })+ })+ it('never puts a grade on a lifting set', () => {+ const csv = [head, '2026/01/01,1:11 PM,Push Day,,11,11,Chin Up,No,1,Normal,11,11,0,,5,,,'].join('\n')+ expect(parseWorkoutCSV(csv, { unit: 'kg' }).workouts[0].entries[0].sets[0]).toEqual({ w: 11, r: 11, done: true })+ })+})diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.jsindex 7b002676a..897855a65 100644--- a/frontend/src/locales/ar.js+++ b/frontend/src/locales/ar.js@@ -2213,4 +2213,7 @@ export default {// --- search: similar exercises ---'Similar exercises': 'تمارين مشابهة','No exact match. These come close:': 'لا تطابق تام. هذه قريبة:',+ // --- cardio: treadmill incline ---+ 'Incline (%)': 'الميل (%)',+ '{0}% incline': 'ميل {0}%',}diff --git a/frontend/src/locales/bn.js b/frontend/src/locales/bn.jsindex 39745f383..a39939b97 100644--- a/frontend/src/locales/bn.js+++ b/frontend/src/locales/bn.js@@ -2237,4 +2237,7 @@ export default {// --- search: similar exercises ---'Similar exercises': 'একই ধরনের ব্যায়াম','No exact match. These come close:': 'হুবহু মিল নেই। এগুলো কাছাকাছি:',+ // --- cardio: treadmill incline ---+ 'Incline (%)': 'ঢাল (%)',+ '{0}% incline': '{0}% ঢাল',}diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex a54996bf8..514e64bbd 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -2178,4 +2178,7 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Ähnliche Übungen','No exact match. These come close:': 'Kein genauer Treffer. Die hier kommen nah ran:',+ // --- cardio: treadmill incline ---+ 'Incline (%)': 'Steigung (%)',+ '{0}% incline': '{0} % Steigung',}diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex fbfa422c9..f0455aefe 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -2158,4 +2158,7 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Ejercicios parecidos','No exact match. These come close:': 'Nada exacto. Estos se acercan:',+ // --- cardio: treadmill incline ---+ 'Incline (%)': 'Inclinación (%)',+ '{0}% incline': '{0} % de inclinación',}diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex 6dd9b5430..8ee3987b4 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -2158,4 +2158,7 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Exercices similaires','No exact match. These come close:': 'Rien d’exact. Ceux-ci s’en approchent :',+ // --- cardio: treadmill incline ---+ 'Incline (%)': 'Inclinaison (%)',+ '{0}% incline': '{0} % d’inclinaison',}diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex 57b07f370..58f1065b7 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -2158,4 +2158,7 @@ export default {// --- search: similar exercises ---'Similar exercises': 'मिलते-जुलते व्यायाम','No exact match. These come close:': 'सटीक मेल नहीं मिला। ये करीब हैं:',+ // --- cardio: treadmill incline ---+ 'Incline (%)': 'ढलान (%)',+ '{0}% incline': '{0}% ढलान',}diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex a496dfb81..3a565e2a2 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -2161,4 +2161,7 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Hasonló gyakorlatok','No exact match. These come close:': 'Nincs pontos találat. Ezek közel állnak:',+ // --- cardio: treadmill incline ---+ 'Incline (%)': 'Emelkedő (%)',+ '{0}% incline': '{0}% emelkedő',}diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 8c3d96f6f..308ea5bd6 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -2158,4 +2158,7 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Esercizi simili','No exact match. These come close:': 'Niente di esatto. Questi ci vanno vicino:',+ // --- cardio: treadmill incline ---+ 'Incline (%)': 'Pendenza (%)',+ '{0}% incline': 'pendenza {0}%',}diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex c906b2b53..7e3478400 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -2158,4 +2158,7 @@ export default {// --- search: similar exercises ---'Similar exercises': '비슷한 운동','No exact match. These come close:': '정확히 일치하는 항목이 없어요. 이건 비슷해요:',+ // --- cardio: treadmill incline ---+ 'Incline (%)': '경사 (%)',+ '{0}% incline': '경사 {0}%',}diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex 0525f3041..3d4b37b51 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -2158,4 +2158,7 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Podobne ćwiczenia','No exact match. These come close:': 'Brak dokładnego dopasowania. Te są blisko:',+ // --- cardio: treadmill incline ---+ 'Incline (%)': 'Nachylenie (%)',+ '{0}% incline': 'nachylenie {0}%',}diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.jsindex 9f283b0d1..08dc91cf4 100644--- a/frontend/src/locales/pt-BR.js+++ b/frontend/src/locales/pt-BR.js@@ -1331,6 +1331,9 @@ export const PT_BR_OVERRIDES = {'Where an exercise is drawn on both figures. Your workouts stay exactly as they are.': 'Que figura mostra um exercício quando está desenhado nas duas. Seus treinos ficam exatamente como estão.','Enter the address of the server this token is for': 'Informe o endereço do servidor a que este token pertence','No exact match. These come close:': 'Nada exato. Estes chegam perto:',+ // --- cardio: treadmill incline ---+ 'Incline (%)': 'Inclinação (%)',+ '{0}% incline': '{0}% de inclinação',}export default { ...pt, ...PT_BR_OVERRIDES }diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex 31486ba97..987c704f6 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -2158,4 +2158,7 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Exercícios semelhantes','No exact match. These come close:': 'Nada exato. Estes andam perto:',+ // --- cardio: treadmill incline ---+ 'Incline (%)': 'Inclinação (%)',+ '{0}% incline': '{0}% de inclinação',}diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex 9bbf9caa1..54b53bd36 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -2162,4 +2162,7 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Похожие упражнения','No exact match. These come close:': 'Точного совпадения нет. Вот что близко:',+ // --- cardio: treadmill incline ---+ 'Incline (%)': 'Наклон (%)',+ '{0}% incline': 'наклон {0}%',}diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex 475397099..ddbe9a01f 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -2169,4 +2169,7 @@ export default {// --- search: similar exercises ---'Similar exercises': 'ท่าที่คล้ายกัน','No exact match. These come close:': 'ไม่พบที่ตรงทั้งหมด ท่าเหล่านี้ใกล้เคียง:',+ // --- cardio: treadmill incline ---+ 'Incline (%)': 'ความชัน (%)',+ '{0}% incline': 'ความชัน {0}%',}diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex edf569226..cc6e3ec92 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -2158,4 +2158,7 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Benzer egzersizler','No exact match. These come close:': 'Tam eşleşme yok. Bunlar yakın:',+ // --- cardio: treadmill incline ---+ 'Incline (%)': 'Eğim (%)',+ '{0}% incline': '%{0} eğim',}diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.jsindex fad71d4f9..22cfc0027 100644--- a/frontend/src/locales/uk.js+++ b/frontend/src/locales/uk.js@@ -2155,4 +2155,7 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Схожі вправи','No exact match. These come close:': 'Точного збігу немає. Ось що близько:',+ // --- cardio: treadmill incline ---+ 'Incline (%)': 'Нахил (%)',+ '{0}% incline': 'нахил {0}%',}diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.jsindex ad7411e1d..756748092 100644--- a/frontend/src/locales/zh-TW.js+++ b/frontend/src/locales/zh-TW.js@@ -2151,4 +2151,7 @@ export default {// --- search: similar exercises ---'Similar exercises': '相似動作','No exact match. These come close:': '沒有完全符合,這些比較接近:',+ // --- cardio: treadmill incline ---+ 'Incline (%)': '坡度 (%)',+ '{0}% incline': '坡度 {0}%',}diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex c7b7277d9..c01783382 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -2158,4 +2158,7 @@ export default {// --- search: similar exercises ---'Similar exercises': '相似动作','No exact match. These come close:': '没有完全匹配,这些比较接近:',+ // --- cardio: treadmill incline ---+ 'Incline (%)': '坡度 (%)',+ '{0}% incline': '坡度 {0}%',}diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsxindex 7c6846f22..9c9f7e73b 100644--- a/frontend/src/sheets.jsx+++ b/frontend/src/sheets.jsx@@ -51,7 +51,7 @@ import { useSheetKeyboard, useRevealActiveChip, tappable } from './lib/use-sheetimport { useAutoMore } from './lib/use-auto-more.js'import { isFav, toggleFav, sortFavouritesFirst } from './lib/favourites.js'import { buildSessionEntries, buildPlannedEntry, builtOutOfProgression } from './lib/session-start.js'-import { finishCompare } from './lib/finish-compare.js'+import { finishCompare, finishCardio } from './lib/finish-compare.js'import { joinSessionNoProg } from './lib/session-noprog.js'import { buildCombinedEntries, deriveSessionName } from './lib/session-merge.js'import { workoutsOn, backfillStart, backfillEnd, completeBackfill, historyAsOf, sessionHistory } from './lib/backfill.js'@@ -3072,6 +3072,23 @@ function LastAndNext({ st, w }) {</div>}+// The cardio of the session, which "Last time and next time" leaves out: minutes, speed and the+// treadmill's incline as they were logged.+function CardioDone({ st, w }) {+ const rows = finishCardio(w)+ if (!rows.length) return null+ return <div style={{ textAlign: 'start', marginBottom: 14 }}>+ <h4 className="sec">{t('Cardio')}</h4>+ <div className="list">{rows.map((row, i) => {+ const ex = EXIDX[row.id]+ return <div key={i} className="item" style={{ display: 'block' }}>+ <span className={'tt ' + exerciseNameClass(ex)} style={{ fontWeight: 600 }}>{ex ? exerciseNameFor(ex) : row.id}</span>+ <div className="small">{row.sets.map(x => setLabel(row.id, x, row.target, speedUnitOf(st))).join(' · ')}</div>+ </div>+ })}</div>+ </div>+}+function FinishSummary({ w, prs, e1prs = [], close }) {const st = useStore(s => s.S)return <div style={{ textAlign: 'center', padding: '8px 0' }}>@@ -3091,6 +3108,7 @@ function FinishSummary({ w, prs, e1prs = [], close }) {<BodyMap load={loadOfWorkouts([w])} body={st.body} /><div style={{ height: 14 }} /><LastAndNext st={st} w={w} />+ <CardioDone st={st} w={w} />{/* The moment for a progress photo or the clip of a set: the workout is already saved, sowhat is added here goes straight onto its record. */}<div style={{ textAlign: 'start' }}><WorkoutMediaSection w={w} hint /></div>diff --git a/frontend/src/views/FocusView.jsx b/frontend/src/views/FocusView.jsxindex 9239056c7..798c0a890 100644--- a/frontend/src/views/FocusView.jsx+++ b/frontend/src/views/FocusView.jsx@@ -1,6 +1,7 @@import { useState } from 'react'import { useStore } from '../store/useStore.js'import { exOr } from '../lib/exercises.js'+import { clampIncline, hasIncline, inclineFits, INCLINE_MAX, INCLINE_STEP } from '../lib/incline.js'import { exerciseNameFor, t } from '../lib/i18n.js'import { fmtDate, fmtNum, fmtPlate } from '../lib/format.js'import { EFFORT, effortOf, modeOf } from '../lib/history.js'@@ -279,6 +280,9 @@ export default function FocusView({onChange={value => onField(setIdx, 'min', value)} /><Stepper label={t('Speed (km/h)')} ariaLabel="speed" value={set.speed || 0} step={0.5} disabled={readOnly}onChange={value => onField(setIdx, 'speed', value)} />+ {/* The treadmill's grade, where the exercise has one (lib/incline.js). */}+ {(inclineFits(ex) || entry.sets.some(hasIncline)) && <Stepper label={t('Incline (%)')} ariaLabel="incline" value={set.incline || 0} step={INCLINE_STEP} max={INCLINE_MAX} disabled={readOnly}+ onChange={value => onField(setIdx, 'incline', clampIncline(value))} />}</> : <><Stepper label={t('Load ({0})', S.unit)} ariaLabel="load" value={set.w || 0} step={loadStep} onStep={stepWeight} disabled={readOnly}onChange={value => onField(setIdx, 'w', value)} />diff --git a/frontend/src/views/Workout.incline.test.jsx b/frontend/src/views/Workout.incline.test.jsxnew file mode 100644index 000000000..4e5b7b299--- /dev/null+++ b/frontend/src/views/Workout.incline.test.jsx@@ -0,0 +1,96 @@+// @vitest-environment happy-dom+// Treadmill incline (Discord "Add incline level for treadmill"): a third column on the cardio+// rows that have a grade, stepped and typed in half percents up to 40, and stored on the set.+import React, { act } from 'react'+import { createRoot } from 'react-dom/client'+import { MemoryRouter } from 'react-router-dom'+import { afterEach, describe, expect, it, vi } from 'vitest'+import Workout from './Workout.jsx'+import { DEF, useStore } from '../store/useStore.js'++vi.mock('../lib/sound.js', () => ({ beep: vi.fn(), vibrate: vi.fn(), alertBuzz: vi.fn(), unlock: vi.fn() }))+vi.mock('../lib/api.js', () => ({ api: vi.fn(() => Promise.resolve({})) }))++globalThis.IS_REACT_ACT_ENVIRONMENT = true+const TREADMILL = '2259' // walking on treadmill+const BIKE = '2138' // stationary bike, cardio+let root, container++function mount(id, sets, more = {}) {+ if (root) unmount()+ const S = JSON.parse(JSON.stringify(DEF))+ S.active = {+ id: 'incline-test', d: '2026-10-09', start: Date.now(), routineId: null, name: 'Cardio', bw: null, cur: 0, ...more,+ entries: [{ id, target: { sets: 1, min: 20, speed: 5 }, sets }],+ }+ useStore.setState({ S, user: null })+ container = document.createElement('div')+ document.body.appendChild(container)+ root = createRoot(container)+ act(() => root.render(<MemoryRouter><Workout /></MemoryRouter>))+}+function unmount() {+ act(() => root.unmount())+ container.remove()+ root = null+}+afterEach(() => { if (root) unmount() })++const cells = () => container.querySelector('.setrow').querySelectorAll('.stp')+const inclineCell = () => container.querySelector('.setrow .stp.inc')+const stored = () => useStore.getState().S.active.entries[0].sets[0]+const heads = () => [...container.querySelectorAll('.sethead span')].map(s => s.textContent).filter(Boolean)+function type(input, value) {+ act(() => {+ Object.getOwnPropertyDescriptor(input.constructor.prototype, 'value').set.call(input, value)+ input.dispatchEvent(new Event('input', { bubbles: true }))+ })+}++describe('the incline column', () => {+ it('sits after the speed on a treadmill, steps in half percents and stores on the set', () => {+ mount(TREADMILL, [{ min: 20, speed: 5, done: false }])+ expect(cells()).toHaveLength(3)+ expect(heads()).toEqual(['Duration (min)', 'Speed (km/h)', 'Incline (%)'])+ // No grade logged yet: the field is empty, not a 0 nobody typed.+ expect(inclineCell().querySelector('input').value).toBe('')+ expect('incline' in stored()).toBe(false)+ act(() => inclineCell().querySelector('button[aria-label="Increase"]').click())+ expect(stored().incline).toBe(0.5)+ type(inclineCell().querySelector('input'), '12')+ expect(stored().incline).toBe(12)+ // A typo past what any treadmill does lands on the top, never on a grade nobody can walk.+ type(inclineCell().querySelector('input'), '60')+ expect(stored().incline).toBe(40)+ act(() => inclineCell().querySelector('button[aria-label="Increase"]').click())+ expect(stored().incline).toBe(40)+ // Cleared, the key goes, and the set is a flat one again.+ type(inclineCell().querySelector('input'), '')+ expect('incline' in stored()).toBe(false)+ })++ it('is not offered on a bike, unless its rows already carry a grade', () => {+ mount(BIKE, [{ min: 20, speed: 25, done: false }])+ expect(cells()).toHaveLength(2)+ expect(inclineCell()).toBe(null)+ mount(BIKE, [{ min: 20, speed: 25, incline: 3, done: false }])+ expect(inclineCell().querySelector('input').value).toBe('3')+ })++ it('copies the grade onto a set added below', () => {+ mount(TREADMILL, [{ min: 20, speed: 5, incline: 8, done: true }])+ const add = [...container.querySelectorAll('button')].find(b => /Add set/.test(b.textContent))+ act(() => add.click())+ expect(useStore.getState().S.active.entries[0].sets[1]).toMatchObject({ min: 20, speed: 5, incline: 8, done: false })+ })++ it('has its own stepper in the focus view', () => {+ mount(TREADMILL, [{ min: 20, speed: 5, incline: 4, done: false }], { workoutView: 'focus' })+ const inc = container.querySelector('button[aria-label="Increase incline"]')+ expect(inc).not.toBe(null)+ act(() => inc.click())+ expect(stored().incline).toBe(4.5)+ mount(BIKE, [{ min: 20, speed: 25, done: false }], { workoutView: 'focus' })+ expect(container.querySelector('button[aria-label="Increase incline"]')).toBe(null)+ })+})diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsxindex 2843f697f..f1737206b 100644--- a/frontend/src/views/Workout.jsx+++ b/frontend/src/views/Workout.jsx@@ -11,6 +11,7 @@ import { loadKindFor, baseWeightFor, inventoryFor, rowLoad, sameLoad, plateDeltaimport { effectiveRoutines, effectiveRoutineIds, lastEntryFor, bestWeightFor, bestWeightForEntry, buildSets, freestyleConfig, defaultConfig, setsDoneActive, setUnitsTotal, supersetUnits, unitOf, setLabel, modeOf, isBw, isPerSide, repStep, EFFORT, effortOf, stepEffort, capEffort, cascadeWeight, insertWarmupRow, barFloor, makeWarmupAt, canBeWarmup, makeWorkAt, removeRowAt, removeLastSet, setSpanAt, copyRowAt, copySpanAt, insertRowAt, pairAdjacent, unpairSuperset, cleanupSg, applyIntensifierPlan, pinnedNoteFor, exNoteFor, setsRepsOf } from '../lib/history.js'import { fmtNum, fmtPlate, exerciseNameText, fmtDate, fmtDaysAgo, todayISO, exCount, DAYN } from '../lib/format.js'import { speedUnitOf, toSpeed, fromSpeed } from '../lib/speed.js'+import { clampIncline, hasIncline, inclineFits, inclineFrom, INCLINE_STEP } from '../lib/incline.js'import { beep, vibrate, unlock } from '../lib/sound.js'import { pinState } from '../lib/queue.js'import { t, tn, exerciseNameFor, exerciseNameClass } from '../lib/i18n.js'@@ -275,7 +276,12 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSiconst eff = EFFORT[kind]// The effort column carries the scale key (`eff`) and its field name; unlike weight/reps it// is not a stepper — it opens a colour-coded picker (see effortCell). `f` is s.rir or s.rpe.- const col3 = mode === 'reps' && eff ? { f: eff.f, eff: kind, hd: t(eff.hd) } : null+ // Cardio's third column is the treadmill's incline (lib/incline.js), on the exercises that have+ // one and on any whose rows already carry a grade. `opt` again: a cleared field is no incline,+ // and `store` keeps whatever is typed on the half percent between 0 and 40.+ const inclineCol = cardio && (inclineFits(ex) || entry.sets.some(hasIncline))+ ? { f: 'incline', step: INCLINE_STEP, dec: true, opt: true, hd: t('Incline (%)'), store: clampIncline } : null+ const col3 = cardio ? inclineCol : mode === 'reps' && eff ? { f: eff.f, eff: kind, hd: t(eff.hd) } : null// The effort column walks its own scale — see stepEffort. Weight and reps step up from 0// with no ceiling, as they always did.const bump = (s, i, col, dir) => {@@ -563,7 +569,7 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSi{sideTagOf(s) && <span className="tag acc nocap sidepill" data-l={t('Left')} data-r={t('Right')}><span>{sideTagOf(s)}</span></span>}{cell(s, i, col1, 'w')}{col2 && cell(s, i, col2, 'r')}- {col3 && effortCell(s, i, col3)}+ {col3 && (col3.eff ? effortCell(s, i, col3) : cell(s, i, col3, 'r inc'))}{/* A timed set is started, not typed: the timer counts the hold down and checks theset off itself. The checkbox stays for anyone who timed it on their own watch. */}{timed && !editing && <button className="setgo" aria-label={t('Start set')} disabled={s.done || !!working}@@ -655,7 +661,7 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSi<div className="card" style={{ marginTop: 10, marginBottom: 0 }}>{/* the header carries the same eff3/timed sizing as the rows, or the labels drift off theircolumns; over L/R rows it also has to skip the side badge that sits in front of the weight cell */}- <div className={'sethead' + (col3 ? ' eff3' : '') + (timed ? ' timed' : '') + (perSide ? ' per-side' : '') + (wc.steppers ? '' : ' plain')}><span className="n-sp" /><span className="w-sp">{col1.hd}</span>{col2 && <span className="r-sp">{col2.hd}</span>}{col3 && <span className="eff-sp">{col3.hd}</span>}{timed && <span className="ck-sp" />}<span className="ck-sp" /></div>+ <div className={'sethead' + (col3 ? ' eff3' : '') + (timed ? ' timed' : '') + (perSide ? ' per-side' : '') + (wc.steppers ? '' : ' plain')}><span className="n-sp" /><span className="w-sp">{col1.hd}</span>{col2 && <span className="r-sp">{col2.hd}</span>}{col3 && <span className={col3.eff ? 'eff-sp' : 'r-sp'}>{col3.hd}</span>}{timed && <span className="ck-sp" />}<span className="ck-sp" /></div><span id={optsId} className="vh">{t('Options: copy, remove')}</span>{entry.sets.map((s, i) => {const warm = isWarmupRow(s)@@ -1107,7 +1113,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), 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), 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)