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.

Workout and History: the last-time or best-set line and a copied workout show cardio in mph like the rows, and a translated exercise name keeps its own casing in the copy and the Replace toast

Duarte Santos7fd9228cd0f9
diff --git a/frontend/src/lib/workout-text.js b/frontend/src/lib/workout-text.js
index d4338187c..dc33c3df1 100644
--- a/frontend/src/lib/workout-text.js
+++ b/frontend/src/lib/workout-text.js
@@ -3,16 +3,18 @@
// same labels the history shows, so a drop-set or a rest-pause set reads the same in both.
// i18n-core rather than i18n, like history.js: nothing here needs the React half.
import { setLabel, supersetUnits, workoutVolume } from './history.js'
+import { EXIDX } from './exercises.js'
import { hasCompletedWork, isWarmupRow } from './workout-model.js'
import { fmtDate, fmtNum, fmtVol, durPart, capWords } from './format.js'
-import { t } from './i18n-core.js'
+import { t, exerciseNameClass } from './i18n-core.js'
/**
- * `unit` is the profile's, `nameOf(entry)` the exercise's display name. Blocks are separated by
- * a blank line: the heading, then each exercise (a superset's under one "Superset" line, its
- * members together), then the session note.
+ * `unit` is the profile's, `nameOf(entry)` the exercise's display name, `speedUnit` the one cardio
+ * is shown in (lib/speed.js; km/h when absent). Blocks are separated by a blank line: the heading,
+ * then each exercise (a superset's under one "Superset" line, its members together), then the
+ * session note.
*/
-export function workoutText(w, { unit, nameOf }) {
+export function workoutText(w, { unit, nameOf, speedUnit }) {
const facts = [
...durPart((w.end || 0) - (w.start || 0)),
fmtVol(w.vol ?? workoutVolume(w), unit),
@@ -25,7 +27,10 @@ export function workoutText(w, { unit, nameOf }) {
const lines = entry => {
const sets = (entry.sets || []).filter(s => hasCompletedWork(s) && !isWarmupRow(s))
if (!sets.length) return null
- return [capWords(nameOf(entry)), sets.map(s => setLabel(entry.id, s, entry.target)).join(', '), ...(entry.note ? [entry.note] : [])]
+ // Title case the way the screen shows it (exerciseNameClass): an English name gets it, a
+ // translated one keeps its own casing, which German's capitalised nouns depend on.
+ const name = nameOf(entry)
+ return [exerciseNameClass(EXIDX[entry.id]) ? capWords(name) : name, sets.map(s => setLabel(entry.id, s, entry.target, speedUnit)).join(', '), ...(entry.note ? [entry.note] : [])]
}
const entries = w.entries || []
for (const group of supersetUnits(entries)) {
diff --git a/frontend/src/lib/workout-text.test.js b/frontend/src/lib/workout-text.test.js
index fbe91afd4..394675ee7 100644
--- a/frontend/src/lib/workout-text.test.js
+++ b/frontend/src/lib/workout-text.test.js
@@ -55,3 +55,15 @@ describe('workoutText', () => {
expect(workoutText(bare, { unit: 'lb', nameOf })).toBe(`Legs — ${fmtDate('2026-09-03', true, true)}\n120 lb\n\nDumbbell Curl\n12×10`)
})
})
+
+// Cardio speed in the profile's unit, as the detail sheet above the button shows it (lib/speed.js).
+describe('workoutText speed unit', () => {
+ it('writes a run in mph when the profile shows mph, and in km/h by default', () => {
+ const w = { d: '2026-09-03', start: 0, end: 0, name: 'Run', entries: [
+ { id: 'run', target: { mode: 'cardio' }, sets: [{ min: 20, speed: 16.09344, done: true }] },
+ ] }
+ const nameOf = () => 'run'
+ expect(workoutText(w, { unit: 'lb', nameOf, speedUnit: 'mph' }).split('\n').at(-1)).toBe('20 min @ 10 mph')
+ expect(workoutText(w, { unit: 'kg', nameOf }).split('\n').at(-1)).toBe('20 min @ 16.1 km/h')
+ })
+})
diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx
index 02cc17ec1..4b31f4faf 100644
--- a/frontend/src/sheets.jsx
+++ b/frontend/src/sheets.jsx
@@ -1888,7 +1888,7 @@ function WorkoutDetail({ w, close }) {
// Copied with the note as it stands in the box, which may not be saved yet.
const copyAsText = async () => {
const rec = { ...(st.workouts.find(x => sameWorkout(x, w)) || w), note: note.trim() }
- toast(await copyText(workoutText(rec, { unit: st.unit, nameOf })) ? t('Copied') : t('Could not copy'))
+ toast(await copyText(workoutText(rec, { unit: st.unit, nameOf, speedUnit: speedUnitOf(st) })) ? t('Copied') : t('Could not copy'))
}
// A combined session's entries carry a `rid`; group them into per-routine sections in merge
// order. A legacy single-routine workout (one routineIds, or no rid anywhere) renders flat.
diff --git a/frontend/src/views/RoutineEdit.jsx b/frontend/src/views/RoutineEdit.jsx
index aa39a7e8a..3a560db1d 100644
--- a/frontend/src/views/RoutineEdit.jsx
+++ b/frontend/src/views/RoutineEdit.jsx
@@ -353,7 +353,7 @@ export default function RoutineEdit() {
picker.close()
let done = false
edit(x => { if (x[i] && x[i].id === openedOn) { x[i] = fn(x[i]); done = true } })
- if (done) toast(t('Replaced with “{0}”', capWords(exerciseNameFor(ex))))
+ if (done) toast(t('Replaced with “{0}”', exerciseNameClass(ex) ? capWords(exerciseNameFor(ex)) : exerciseNameFor(ex)))
}
const picker = exercisePicker((ex, quick) => {
// The slot and the history as they are now, not as this render saw them: a sync can land
diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx
index 7beb6c4ec..eea8e2ba1 100644
--- a/frontend/src/views/Workout.jsx
+++ b/frontend/src/views/Workout.jsx
@@ -196,7 +196,7 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSi
const refLine = ref ? <button type="button" className="refline small dim"
title={refBest ? t('Show last time instead') : t('Show your best set instead')}
onClick={() => update(s => { s.logRef = refBest ? 'last' : 'best' })}>
- <span>{refBest ? t('Best set') : t('Last time')} ({fmtDate(ref.d)}): {(refBest ? [ref.set] : ref.sets).map(s => setLabel(entry.id, s, ref.target)).join(', ')}</span>
+ <span>{refBest ? t('Best set') : t('Last time')} ({fmtDate(ref.d)}): {(refBest ? [ref.set] : ref.sets).map(s => setLabel(entry.id, s, ref.target, speedUnitOf(S))).join(', ')}</span>
<Icon name="shuffle" />
</button> : null
// A bodyweight set has no weight to type, so the column is not there (issue #32) — one
diff --git a/frontend/src/views/Workout.speed.test.jsx b/frontend/src/views/Workout.speed.test.jsx
index 8ab8fb998..74c039ac8 100644
--- a/frontend/src/views/Workout.speed.test.jsx
+++ b/frontend/src/views/Workout.speed.test.jsx
@@ -83,3 +83,18 @@ describe('cardio speed in the set row', () => {
expect(stored()).toBe(10.25)
})
})
+
+// The line under the exercise reads the past in the same unit as the row it sits over, whether
+// it holds the last time or the best set (#173).
+describe('the reference line in mph', () => {
+ const past = { id: 'w0', d: '2026-09-20', start: Date.now() - 3 * 86400000, end: Date.now() - 3 * 86400000 + 1800000, name: 'Cardio',
+ entries: [{ id: BIKE, target: { mode: 'cardio', sets: 1, min: 20, speed: 16.09344 }, sets: [{ min: 20, speed: 16.09344, done: true }] }] }
+ const refText = () => container.querySelector('.refline')?.textContent || ''
+
+ it('shows last time and the best set in mph for a profile in pounds', () => {
+ mount({ unit: 'lb', workouts: [past] })
+ expect(refText()).toContain('20 min @ 10 mph')
+ mount({ unit: 'lb', workouts: [past], logRef: 'best' })
+ expect(refText()).toContain('20 min @ 10 mph')
+ })
+})