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
Heart rate per set: optional hr and restHr, safe for every reader
Duarte Santosdf3acc5520a0
diff --git a/api/test/sync-hr.test.js b/api/test/sync-hr.test.jsnew file mode 100644index 000000000..14573ff5e--- /dev/null+++ b/api/test/sync-hr.test.js@@ -0,0 +1,37 @@+// Heart rate per set from the Apple Watch (frontend lib/heart-rate.js): optional `hr` / `restHr` on+// a logged set. The server's PUT /api/data merge (sync-stamps.js stampPut) must carry them along+// for every kind of writer: the app that wrote them, an older app that read them and sends the+// document back without knowing them, an API client. And a document without them is unchanged.+import test from 'node:test';+import assert from 'node:assert/strict';+import { stampPut } from '../sync-stamps.js';++const clone = v => JSON.parse(JSON.stringify(v));+const doc = sets => ({ _ts: 10, unit: 'kg', workouts: [{ id: 'w1', d: '2026-10-10', _ts: 5, entries: [{ id: '0025', sets }] }], routines: [] });+const hrSets = [{ w: 60, r: 8, done: true, hr: { avg: 128, max: 149 }, restHr: { avg: 110, max: 131 } }];+const plainSets = [{ w: 60, r: 8, done: true }];++test('the fields stay through a PUT from the app that wrote them and from an older app', () => {+ const cur = doc(hrSets);+ for (const stamped of [true, false]) {+ const out = stampPut(clone(cur), clone(cur), { stamped, overRead: false, now: 20 });+ assert.deepEqual(out.workouts[0].entries[0].sets, hrSets);+ }+});++test('a document without them comes out without them', () => {+ const cur = doc(plainSets);+ for (const stamped of [true, false]) {+ const out = stampPut(clone(cur), clone(cur), { stamped, overRead: false, now: 20 });+ assert.deepEqual(out.workouts[0].entries[0].sets, plainSets);+ assert.ok(!/"hr"|restHr/.test(JSON.stringify(out)));+ }+});++test('an older app editing another workout leaves these alone', () => {+ const cur = doc(hrSets);+ const next = clone(cur);+ next.workouts.push({ id: 'w2', d: '2026-10-11', entries: [{ id: '0001', sets: plainSets }] });+ const out = stampPut(clone(cur), next, { stamped: false, overRead: false, now: 20 });+ assert.deepEqual(out.workouts.find(w => w.id === 'w1').entries[0].sets, hrSets);+});diff --git a/frontend/src/App.jsx b/frontend/src/App.jsxindex ccbc91fee..e7247667e 100644--- a/frontend/src/App.jsx+++ b/frontend/src/App.jsx@@ -13,7 +13,8 @@ import { setNav, notePath, keyBefore } from './lib/nav.js'import { setSystemBarsLight } from './lib/system-bars.js'import { initBackButton } from './lib/back.js'import { installEdgeSwipeBack, BACK_PREVIEW_EVENT } from './lib/edge-swipe-back.js'-import { startWatchSync, bindWatchAppActions } from './lib/watch-sync.js'+import { startWatchSync, bindWatchAppActions, patchSetIn } from './lib/watch-sync.js'+import { stampWorkout } from './lib/sync-merge.js'import { useWakeLock } from './lib/wakelock.js'import { installViewportGuard } from './lib/viewport-guard.js'import { installChipDrag } from './lib/hchips.js'@@ -330,7 +331,10 @@ export default function App() {startWatchSync({ useStore, useUI }).then(fn => { if (gone) fn(); else stop = fn })// A session started on the watch starts here as the phone's Start does, with the watch's id// and start time, and no weigh-in question (the lifter is at the watch, not here).- const unbind = bindWatchAppActions({ start: (ids, opts) => beginWorkout(ids, null, opts) })+ const unbind = bindWatchAppActions({+ start: (ids, opts) => beginWorkout(ids, null, opts),+ patchSet: (where, fields) => useStore.getState().update(s => { patchSetIn(s, where, fields, stampWorkout) }),+ })return () => { gone = true; stop?.(); unbind() }}, [])return <HashRouter><Shell /></HashRouter>diff --git a/frontend/src/lib/heart-rate.js b/frontend/src/lib/heart-rate.jsnew file mode 100644index 000000000..394c5ac1c--- /dev/null+++ b/frontend/src/lib/heart-rate.js@@ -0,0 +1,26 @@+// Heart rate per set, from the Apple Watch (lib/watch-sync.js, ios/App/Watch). Two optional+// fields on a logged set, written only when the watch measured something:+//+// hr { avg, max } beats per minute while the set was done (from its start to its tick)+// restHr { avg, max } during the rest after it+//+// Nothing else changes: a set without them is exactly the set it always was, and every reader+// that does not know them (older apps, the server, the exports) carries them along untouched.++const BPM_MIN = 25+const BPM_MAX = 250++/** { avg, max } as whole beats per minute, or null for anything that is not a plausible reading. */+export function sanitizeHr(v) {+ if (!v || typeof v !== 'object') return null+ const avg = Math.round(Number(v.avg)), max = Math.round(Number(v.max))+ if (!Number.isFinite(avg) || !Number.isFinite(max)) return null+ if (avg < BPM_MIN || avg > BPM_MAX || max < BPM_MIN || max > BPM_MAX || max < avg) return null+ return { avg, max }+}++/** " ♥ 132/151" after a set's label, or '' for a set without a reading. */+export function hrLabel(set) {+ const hr = sanitizeHr(set && set.hr)+ return hr ? ` ♥ ${hr.avg}/${hr.max}` : ''+}diff --git a/frontend/src/lib/heart-rate.test.js b/frontend/src/lib/heart-rate.test.jsnew file mode 100644index 000000000..af90b692d--- /dev/null+++ b/frontend/src/lib/heart-rate.test.js@@ -0,0 +1,114 @@+// @vitest-environment happy-dom+// Heart rate per set from the Apple Watch: two OPTIONAL fields on a logged set (hr, restHr), and+// nothing else. These pin that the data is safe: a profile without them is byte for byte what it+// was after loading, saving, finishing, merging and a backup; with them, every one of those keeps+// them; a reading that does not hold up is never written; a saved workout patched later is stamped+// so a sync keeps the change.+import { beforeEach, describe, expect, it, vi } from 'vitest'+import { sanitizeHr, hrLabel } from './heart-rate.js'+import { buildCompletedWorkout } from './finish-workout.js'+import { mergeStates } from './sync-merge.js'+import { patchSetIn } from './watch-sync.js'++const workout = (id, sets, extra = {}) => ({ id, d: '2026-10-10', name: 'Push', start: 1000, end: 4000, entries: [{ id: '0025', target: { sets: sets.length, reps: 8 }, sets }], ...extra })+const plainSets = () => [{ w: 60, r: 8, done: true, at: 2000 }, { w: 60, r: 7, done: true, at: 3000 }]+const hrSets = () => [{ w: 60, r: 8, done: true, at: 2000, hr: { avg: 128, max: 149 }, restHr: { avg: 110, max: 131 } }, { w: 60, r: 7, done: true, at: 3000, hr: { avg: 135, max: 156 } }]++describe('the reading', () => {+ it('is whole beats per minute in a plausible range, or nothing', () => {+ expect(sanitizeHr({ avg: 128.4, max: 149.6 })).toEqual({ avg: 128, max: 150 })+ for (const bad of [null, {}, { avg: 'x', max: 1 }, { avg: 10, max: 20 }, { avg: 140, max: 120 }, { avg: 120, max: 300 }, 'hr']) expect(sanitizeHr(bad)).toBeNull()+ })+ it('shows only where there is one', () => {+ expect(hrLabel({ w: 60, r: 8 })).toBe('')+ expect(hrLabel({ hr: { avg: 128, max: 149 } })).toBe(' ♥ 128/149')+ })+})++describe('a profile without the fields', () => {+ it('finishes a session byte for byte as before: no hr, no restHr, nothing renamed', () => {+ const active = { id: 'a1', d: '2026-10-10', start: 1000, entries: [{ id: '0025', target: { sets: 2, reps: 8 }, sets: plainSets() }] }+ const w = buildCompletedWorkout(active, { end: 4000 })+ expect(JSON.stringify(w.entries[0].sets)).toBe(JSON.stringify(plainSets()))+ expect(JSON.stringify(w)).not.toMatch(/"hr"|restHr/)+ })++ it('merges byte for byte as before', () => {+ const a = { workouts: [workout('w1', plainSets(), { _ts: 5 })] }+ const b = { workouts: [workout('w1', plainSets(), { _ts: 4 }), workout('w2', plainSets())] }+ const m = mergeStates(a, b)+ expect(JSON.stringify(m.workouts.find(w => w.id === 'w1'))).toBe(JSON.stringify(a.workouts[0]))+ expect(JSON.stringify(m)).not.toMatch(/"hr"|restHr/)+ })+})++describe('a profile with them', () => {+ it('keeps them when the session is finished', () => {+ const active = { id: 'a1', d: '2026-10-10', start: 1000, entries: [{ id: '0025', target: { sets: 2, reps: 8 }, sets: hrSets() }] }+ expect(buildCompletedWorkout(active, { end: 4000 }).entries[0].sets).toEqual(hrSets())+ })++ it('keeps them through a merge, whichever copy was edited last', () => {+ const withHr = workout('w1', hrSets(), { _ts: 5 })+ // another device's copy, edited after it read this one (it carries the fields along, untouched)+ const otherNewer = { ...workout('w1', hrSets().map(s => ({ ...s, r: s.r + 1 })), { _ts: 9 }) }+ expect(mergeStates({ workouts: [withHr] }, { workouts: [] }).workouts[0].entries[0].sets).toEqual(hrSets())+ const m = mergeStates({ workouts: [withHr] }, { workouts: [otherNewer] })+ expect(m.workouts[0].entries[0].sets.map(s => s.hr)).toEqual(hrSets().map(s => s.hr))+ expect(m.workouts[0].entries[0].sets[0].restHr).toEqual({ avg: 110, max: 131 })+ })++ it('survives a JSON round trip the way an older app stores and sends the profile', () => {+ const S = { workouts: [workout('w1', hrSets())] }+ expect(JSON.parse(JSON.stringify(S))).toEqual(S)+ })+})++describe('a set patched after the workout was saved (the rest\'s reading comes late)', () => {+ it('gets the fields, and the workout is stamped as edited so the sync keeps it', () => {+ const s = { active: null, workouts: [workout('w1', plainSets())] }+ const stamp = vi.fn(w => { w._ts = 99 })+ expect(patchSetIn(s, { wid: 'w1', exId: '0025', entryIdx: 0, setIdx: 0 }, { restHr: { avg: 110, max: 131 } }, stamp)).toBe(true)+ expect(s.workouts[0].entries[0].sets[0]).toEqual({ ...plainSets()[0], restHr: { avg: 110, max: 131 } })+ expect(s.workouts[0].entries[0].sets[1]).toEqual(plainSets()[1])+ expect(stamp).toHaveBeenCalledTimes(1)+ expect(s.workouts[0]._ts).toBe(99)+ })++ it('in the running session, without a stamp; a set that is not there changes nothing', () => {+ const s = { active: { id: 'a1', entries: [{ id: '0025', sets: plainSets() }] }, workouts: [] }+ const stamp = vi.fn()+ expect(patchSetIn(s, { wid: 'a1', exId: '0025', entryIdx: 0, setIdx: 1 }, { hr: { avg: 130, max: 150 } }, stamp)).toBe(true)+ expect(s.active.entries[0].sets[1].hr).toEqual({ avg: 130, max: 150 })+ expect(stamp).not.toHaveBeenCalled()+ const before = JSON.stringify(s)+ expect(patchSetIn(s, { wid: 'a1', exId: '9999', entryIdx: 4, setIdx: 0 }, { hr: { avg: 130, max: 150 } }, stamp)).toBe(false)+ expect(patchSetIn(s, { wid: 'gone', exId: '0025', entryIdx: 0, setIdx: 0 }, { hr: { avg: 130, max: 150 } }, stamp)).toBe(false)+ expect(JSON.stringify(s)).toBe(before)+ })+})++describe('the store: load, save, backup', () => {+ beforeEach(() => { localStorage.clear(); vi.resetModules() })+ const fixture = sets => ({ unit: 'kg', restSec: 90, routines: [], workouts: [workout('w1', sets)], bodyweight: [] })++ it('a profile without the fields loads and saves byte for byte', async () => {+ localStorage.setItem('gym_state_v1', JSON.stringify(fixture(plainSets())))+ const { useStore } = await import('../store/useStore.js')+ useStore.getState().update(() => {})+ const saved = JSON.parse(localStorage.getItem('gym_state_v1'))+ expect(JSON.stringify(saved.workouts)).toBe(JSON.stringify(fixture(plainSets()).workouts))+ })++ it('a profile with them loads, saves, exports and imports with them', async () => {+ localStorage.setItem('gym_state_v1', JSON.stringify(fixture(hrSets())))+ const { useStore } = await import('../store/useStore.js')+ useStore.getState().update(() => {})+ expect(JSON.parse(localStorage.getItem('gym_state_v1')).workouts[0].entries[0].sets).toEqual(hrSets())+ // Settings → Export is JSON.stringify(S); Import is importBackup of it+ const backup = JSON.parse(JSON.stringify(useStore.getState().S, null, 2))+ useStore.getState().update(s => { s.workouts = [] })+ useStore.getState().importBackup(backup)+ expect(useStore.getState().S.workouts[0].entries[0].sets).toEqual(hrSets())+ })+})diff --git a/frontend/src/lib/watch-sync.js b/frontend/src/lib/watch-sync.jsindex 786492d98..eadd75d10 100644--- a/frontend/src/lib/watch-sync.js+++ b/frontend/src/lib/watch-sync.js@@ -22,6 +22,7 @@ import { isWarmupRow } from './workout-model.js'import { sessionHistory } from './backfill.js'import { buildCombinedEntries, deriveSessionName } from './session-merge.js'import { todayISO } from './format.js'+import { sanitizeHr } from './heart-rate.js'export const SNAPSHOT_VERSION = 1const APPLIED_KEY = 'gym_watch_applied'@@ -124,6 +125,7 @@ function entryIndexOf (A, ev) {* start { routineIds, wid, at } the app starts that session with the watch's id and start* setDone { wid, exId, entryIdx, setIdx, w, r, at } the workout screen's own tick* finish { wid, at } the workout screen's own Finish and save+ * setHr { wid, exId, entryIdx, setIdx, hr?, restHr? } heart rate on a set (lib/heart-rate.js)*/export function applyEvents (events, getState) {if (!Array.isArray(events)) return []@@ -144,7 +146,18 @@ export function applyEvents (events, getState) {if (!handlers) breakconst idx = entryIndexOf(A, ev)const set = idx >= 0 ? A.entries[idx].sets?.[ev.setIdx] : null- if (set) handlers.setDone(idx, ev.setIdx, { w: num(ev.w), r: num(ev.r), at: num(ev.at) })+ if (set) handlers.setDone(idx, ev.setIdx, { w: num(ev.w), r: num(ev.r), at: num(ev.at), hr: sanitizeHr(ev.hr) })+ } else if (ev.type === 'setHr') {+ // The rest's heart rate comes once the rest is over, maybe after the workout was saved:+ // a field on that set, wherever the set is now. Nothing for a reading that does not hold up.+ const fields = {}+ const hr = sanitizeHr(ev.hr), restHr = sanitizeHr(ev.restHr)+ if (hr) fields.hr = hr+ if (restHr) fields.restHr = restHr+ if (Object.keys(fields).length) {+ if (!appHandlers) break+ appHandlers.patchSet({ wid: ev.wid, exId: ev.exId, entryIdx: ev.entryIdx, setIdx: ev.setIdx }, fields)+ }} else if (ev.type === 'finish' && ours) {if (!handlers) breakhandlers.finish()@@ -157,7 +170,7 @@ export function applyEvents (events, getState) {return done}-/** The app's own actions, for what needs no screen (starting a session). Returns the unbind. */+/** The app's own actions, for what needs no screen (starting a session, a set's heart rate). */export function bindWatchAppActions (h) {appHandlers = hdrainWatchEvents()@@ -246,3 +259,28 @@ export async function startWatchSync ({ useStore, useUI }) {// Test seams.export function _setWatchPluginForTest (plugin, getState) { pluginP = Promise.resolve(plugin ? { WatchBridge: plugin } : null); getStateRef = getState || null }export function _resetWatchSync () { handlers = null; appHandlers = null; pluginP = null; getStateRef = null; draining = null }++/**+ * Writes `fields` (heart rate) onto one set: in the running session when it is that workout, else in+ * the saved workout of that id, which is then stamped as edited so the next sync keeps the change+ * (lib/sync-merge.js: of two copies of a workout the one edited last wins). Only these optional+ * fields are ever added; nothing is removed or renamed.+ */+export function patchSetIn (s, { wid, exId, entryIdx, setIdx }, fields, stamp) {+ const find = w => {+ if (!w || !Array.isArray(w.entries)) return null+ const i = w.entries[entryIdx] && w.entries[entryIdx].id === exId ? entryIdx : w.entries.findIndex(e => e && e.id === exId)+ return i >= 0 ? w.entries[i].sets?.[setIdx] || null : null+ }+ if (s.active && s.active.id === wid) {+ const set = find(s.active)+ if (set) Object.assign(set, fields)+ return !!set+ }+ const w = (s.workouts || []).find(x => x && x.id === wid)+ const set = find(w)+ if (!set) return false+ Object.assign(set, fields)+ if (stamp) stamp(w)+ return true+}diff --git a/frontend/src/lib/watch-sync.test.js b/frontend/src/lib/watch-sync.test.jsindex 311a4e00f..ad4c1f234 100644--- a/frontend/src/lib/watch-sync.test.js+++ b/frontend/src/lib/watch-sync.test.js@@ -59,7 +59,7 @@ describe('the events from the watch', () => {bindWatchActions({ setDone })expect(applyEvents([ev('a'), ev('a')], () => ({ S }))).toEqual(['a', 'a'])expect(setDone).toHaveBeenCalledTimes(1)- expect(setDone).toHaveBeenCalledWith(0, 1, { w: 62.5, r: 7, at: 1 })+ expect(setDone).toHaveBeenCalledWith(0, 1, { w: 62.5, r: 7, at: 1, hr: null })// …and again later (a second drain, a restart of the page): still onceexpect(applyEvents([ev('a')], () => ({ S }))).toEqual(['a'])expect(setDone).toHaveBeenCalledTimes(1)@@ -72,7 +72,7 @@ describe('the events from the watch', () => {bindWatchActions({ setDone })expect(applyEvents([ev('moved'), ev('gone', { exId: '9999', entryIdx: 5 }), ev('other', { wid: 'w-2' })], () => ({ S }))).toEqual(['moved', 'gone', 'other'])expect(setDone).toHaveBeenCalledTimes(1)- expect(setDone).toHaveBeenCalledWith(1, 1, { w: 62.5, r: 7, at: 1 })+ expect(setDone).toHaveBeenCalledWith(1, 1, { w: 62.5, r: 7, at: 1, hr: null })})it('wait in the queue while the workout screen is not there', () => {@@ -90,7 +90,7 @@ describe('the native queue', () => {const setDone = vi.fn()bindWatchActions({ setDone })await drainWatchEvents()- expect(setDone).toHaveBeenCalledWith(0, 1, { w: 60, r: 8, at: null })+ expect(setDone).toHaveBeenCalledWith(0, 1, { w: 60, r: 8, at: null, hr: null })expect(p.ack).toHaveBeenCalledWith({ ids: ['x1'] })})@@ -139,7 +139,7 @@ describe('starting and finishing on the watch', () => {bindWatchActions({ setDone, finish })expect(applyEvents([...events, { id: 'f1', type: 'finish', wid: 'watch-1', at: 1700000200000 }], () => ({ S }))).toEqual(['s1', 'd1', 'f1'])expect(start).toHaveBeenCalledTimes(1)- expect(setDone).toHaveBeenCalledWith(0, 0, { w: 60, r: 8, at: 1700000100000 })+ expect(setDone).toHaveBeenCalledWith(0, 0, { w: 60, r: 8, at: 1700000100000, hr: null })expect(finish).toHaveBeenCalledTimes(1)})@@ -151,3 +151,20 @@ describe('starting and finishing on the watch', () => {expect(start).not.toHaveBeenCalled()})})++describe('heart rate from the watch', () => {+ it('rides on the tick when the reading holds up, and comes late for the rest through the app', () => {+ const S = state()+ const setDone = vi.fn(), patchSet = vi.fn()+ bindWatchActions({ setDone, finish: vi.fn() })+ bindWatchAppActions({ start: vi.fn(), patchSet })+ applyEvents([+ { id: 'h1', type: 'setDone', wid: 'w-1', exId: '0025', entryIdx: 0, setIdx: 1, w: 60, r: 8, at: 5, hr: { avg: 131.2, max: 150 } },+ { id: 'h2', type: 'setHr', wid: 'w-1', exId: '0025', entryIdx: 0, setIdx: 1, restHr: { avg: 112, max: 128 } },+ { id: 'h3', type: 'setHr', wid: 'w-1', exId: '0025', entryIdx: 0, setIdx: 1, restHr: { avg: 9000, max: 1 } },+ ], () => ({ S }))+ expect(setDone).toHaveBeenCalledWith(0, 1, { w: 60, r: 8, at: 5, hr: { avg: 131, max: 150 } })+ expect(patchSet).toHaveBeenCalledTimes(1)+ expect(patchSet).toHaveBeenCalledWith({ wid: 'w-1', exId: '0025', entryIdx: 0, setIdx: 1 }, { restHr: { avg: 112, max: 128 } })+ })+})diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsxindex d7e31b863..26088ebd1 100644--- a/frontend/src/sheets.jsx+++ b/frontend/src/sheets.jsx@@ -60,6 +60,7 @@ import { workoutsOn, backfillStart, backfillEnd, completeBackfill, historyAsOf,import { moveWorkout, sameWorkout, startTimeOf, durationMinOf, setWorkoutDuration, rebuildPrHistory, MAX_DURATION_MIN, endsInFuture } from './lib/workout-date.js'import { editCompletedSession, editLeftEmpty, editedRecord, editChangesNothing } from './lib/session-edit.js'import { stampWorkout } from './lib/sync-merge.js'+import { hrLabel } from './lib/heart-rate.js'import { weeklyWeights } from './lib/bodyweight.js'import { workoutText } from './lib/workout-text.js'import { workoutCardModel, layoutWorkoutCard, drawWorkoutCard, viewAspect, CARD_FONT } from './lib/workout-card.js'@@ -2488,7 +2489,7 @@ function WorkoutDetail({ w, close }) {return <div key={i} className="row wd-ex" style={{ alignItems: 'flex-start' }} {...tappable(() => exerciseHistorySheet(e.id))}>{ex && <Thumb ex={ex} />}<div className="grow"><div className={`tt ${exerciseNameClass(ex)}`} style={{ fontWeight: 600 }}>{nameOf(e)} {w.prs && w.prs.includes(e.id) && <span className="pr"><Icon name="trophy" />PR</span>}</div>- <div className="ss">{e.sets.filter(hasCompletedWork).map(s => setLabel(e.id, s, e.target, speedUnitOf(st))).join(' · ') || t('no sets')}</div>+ <div className="ss">{e.sets.filter(hasCompletedWork).map(s => setLabel(e.id, s, e.target, speedUnitOf(st)) + hrLabel(s)).join(' · ') || t('no sets')}</div>{e.note && <div className="small dim" style={{ marginTop: 3 }}>{e.notePin && <Icon name="pin" style={{ fontSize: 12, marginInlineEnd: 4, verticalAlign: '-1px', color: 'var(--yellow)' }} />}{e.note}</div>}</div>@@ -3316,7 +3317,7 @@ function CardioDone({ st, w }) {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 className="small">{row.sets.map(x => setLabel(row.id, x, row.target, speedUnitOf(st)) + hrLabel(x)).join(' · ')}</div></div>})}</div></div>diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsxindex c30d72fdb..ea55e4317 100644--- a/frontend/src/views/Workout.jsx+++ b/frontend/src/views/Workout.jsx@@ -1761,11 +1761,11 @@ function ActiveWorkout() {// The time is the watch's: the phone may hear of the set much later (lib/finish-workout.js// sessionEnd reads the sets' times). The watch's Finish runs the phone's Finish and save.useEffect(() => bindWatchActions({- setDone: (idx, i, { w, r, at }) => {+ setDone: (idx, i, { w, r, at, hr }) => {if (useStore.getState().S.active?.editingWorkoutId) return // a saved workout being edited is not the sessionmutEntry(idx, en => { const set = en.sets[i]; if (!set) return; if (w != null) set.w = w; if (r != null) set.r = r })if (!useStore.getState().S.active?.entries?.[idx]?.sets?.[i]?.done) toggleRef.current(idx, i)- if (at) mutEntry(idx, en => { const set = en.sets[i]; if (set?.done) set.at = at })+ if (at || hr) mutEntry(idx, en => { const set = en.sets[i]; if (!set?.done) return; if (at) set.at = at; if (hr) set.hr = hr })},finish: () => { if (!useStore.getState().S.active?.editingWorkoutId) finishWorkoutNow() },}), [])