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
Merge v1.3.8 main into contribution #203
Space-Hermes2cce6c215a07
diff --cc frontend/src/lib/pt-br-locale.test.jsindex c0b560abc,05eaeab8c..4b6ba7694--- a/frontend/src/lib/pt-br-locale.test.js+++ b/frontend/src/lib/pt-br-locale.test.js@@@ -27,11 -27,11 +27,11 @@@ describe('Brazilian Portuguese locale'.sort(byCodeUnit)const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex')- expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(655)- expect(inherited).toHaveLength(647)- expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(645)++ expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(656)+ expect(inherited).toHaveLength(660)// If this fails, review the changed keys and wording before accepting a new hash. From// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list- expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('185cca3dfbc438a4a2177956d1d18da2bbdc907281c5eb4c858ba34afaf9f38e')+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('a2027d64b3944dcef644b11b4d9688b88fe5cff0693acf04c73f0667e2b86825')})test('does not leak European Portuguese UI terms', () => {diff --cc frontend/src/lib/session-edit.jsindex 4c036b3de,000000000..cf1da0f6fmode 100644,000000..100644--- a/frontend/src/lib/session-edit.js+++ b/frontend/src/lib/session-edit.js@@@ -1,138 -1,0 +1,147 @@@+import { buildCompletedWorkout } from './finish-workout.js'++import { beatsWeight } from './exercises.js'+import { bestWeightForEntry, workoutVolume } from './history.js'+import { hasCompletedWork } from './workout-model.js'++const clone = value => structuredClone(value)+const same = (a, b) => JSON.stringify(a) === JSON.stringify(b)+const byDayStart = (a, b) => a.d === b.d ? (a.start || 0) - (b.start || 0) : a.d < b.d ? -1 : 1++// A saved-workout edit is an ordinary persisted active draft. The history record stays byte for+// byte unchanged until Save, so reload, cancel and an offline spell cannot lose the original.+export function editCompletedSession(state, workoutId) {+ if (state.active) throw new Error('Finish the current workout first.')+ const original = state.workouts.find(workout => workout.id === workoutId)+ if (!original) throw new Error('This workout is no longer available.')+ const active = clone(original)+ active.entries = clone(original.entries)+ active.cur = 0+ active.editingWorkoutId = original.id+ active.editingOriginal = clone(original)+ for (const key of ['vol', 'prs']) delete active[key]+ state.active = active+ return active+}++// Refresh the record-derived caches that can become stale when a correction lowers or removes a+// set. PRs are historical: each workout is compared only with sessions before it.+export function rebuildHistoryDerived(state, exerciseIds) {+ const ids = new Set(exerciseIds)+ const best = new Map()+ for (const workout of [...state.workouts].sort(byDayStart)) {+ const existing = (workout.prs || []).filter(id => !ids.has(id))+ for (const id of ids) {- const weight = Math.max(0, ...workout.entries.filter(entry => entry.id === id).map(bestWeightForEntry))- if (weight > (best.get(id) || 0)) existing.push(id)- if (weight > (best.get(id) || 0)) best.set(id, weight)++ let weight = 0++ for (const entry of workout.entries.filter(entry => entry.id === id)) {++ const entryWeight = bestWeightForEntry(entry)++ if (beatsWeight(id, entryWeight, weight)) weight = entryWeight++ }++ const previous = best.get(id) || 0++ if (beatsWeight(id, weight, previous)) existing.push(id)++ if (beatsWeight(id, weight, previous)) best.set(id, weight)+ }+ workout.prs = [...new Set(existing)]+ }+ for (const id of ids) {+ const candidates = state.workouts.flatMap(workout => workout.entries+ .filter(entry => entry.id === id)+ .map(entry => ({ w: bestWeightForEntry(entry), d: workout.d })))+ .filter(value => value.w > 0)- .sort((a, b) => b.w - a.w)- if (candidates.length) state.exWeights[id] = candidates[0]++ let bestCandidate = null++ for (const candidate of candidates) {++ if (!bestCandidate || beatsWeight(id, candidate.w, bestCandidate.w)) bestCandidate = candidate++ }++ if (bestCandidate) state.exWeights[id] = bestCandidate+ else delete state.exWeights[id]+ }+}++export function saveWorkoutEdit(state) {+ const active = state.active+ const original = active?.editingOriginal+ const index = state.workouts.findIndex(workout => workout.id === active?.editingWorkoutId)+ if (index < 0) throw new Error('This workout was deleted on another device. Your edits are still here.')+ if (!original || !same(state.workouts[index], original)) {+ throw new Error('This workout changed on another device. Your edits are still here.')+ }++ const updated = buildCompletedWorkout(active, {+ end: original.end,+ prs: original.prs || [],+ snapshotFor: entry => entry.muscleSnapshot,+ })+ updated.start = original.start+ updated.d = original.d++ // Carry occurrence metadata opaquely, by order rather than exercise id: the same exercise may+ // appear twice. Canonical completed-entry fields win, while live-only prescription data stays+ // out of history just as it does after an ordinary workout.+ const logged = active.entries.filter(entry => entry.sets.some(hasCompletedWork))+ updated.entries = updated.entries.map((entry, index) => {+ const merged = { ...clone(logged[index]), ...entry }+ delete merged.plan+ for (const key of ['note', 'notePin', 'noProg', 'muscleSnapshot']) if (!(key in entry)) delete merged[key]+ return merged+ })+ const record = { ...original, ...updated, vol: workoutVolume(updated) }+ for (const key of ['note', 'excludeFromProgression']) if (!(key in updated)) delete record[key]+ state.workouts[index] = record+ rebuildHistoryDerived(state, [...original.entries, ...active.entries].map(entry => entry.id))+ state.active = null+ return record+}++// The editor dirties the device state as its draft changes. If another device changes the source+// record meanwhile, make that remote record the visible original before the normal state merge;+// Save will then detect it instead of silently replacing it with the stale copy held at edit start.+export function prepareLocalStateForEditMerge(local, remote, pending = []) {+ const next = clone(local)+ const receipts = Array.isArray(pending) ? pending : (pending?.id ? [pending] : [])+ const active = local?.active+ const activeEdit = active?.editingWorkoutId+ ? { id: active.editingWorkoutId, original: active.editingOriginal, saved: active, activeDraft: true }+ : null+ const edits = [...(activeEdit ? [activeEdit] : []), ...receipts.filter(edit => edit.id !== activeEdit?.id)]+ let blocked = false+ let occupied = !!active+ const affectedExerciseIds = new Set()+ for (const edit of edits) {+ const { id, original } = edit || {}+ if (!id || !original) continue+ const current = next.workouts?.find(workout => workout.id === id)+ const remoteRecord = remote?.workouts?.find(workout => workout.id === id)+ const saved = edit.saved || (!same(current, original) ? current : null)+ if (remoteRecord && same(remoteRecord, original)) continue++ // The server changed or deleted the source record. Its canonical record wins this merge. A+ // saved local correction becomes an editor draft when the active slot is free; otherwise its+ // receipt remains in localStorage and the caller stops before retrying the PUT.+ next.workouts = next.workouts.filter(workout => workout.id !== id)+ if (remoteRecord) next.workouts.push(clone(remoteRecord))+ if (!edit.activeDraft && saved) {+ if (!occupied) {+ next.active = clone(saved)+ next.active.entries = clone(saved.entries)+ next.active.cur = 0+ next.active.editingWorkoutId = id+ next.active.editingOriginal = clone(remoteRecord || original)+ for (const key of ['vol', 'prs']) delete next.active[key]+ occupied = true+ } else blocked = true+ }+ // The saved correction may already have lowered this cache locally. Once it is moved back to+ // a draft (or held in its receipt), the remote document owns derived state again.+ for (const exerciseId of new Set([...(original.entries || []), ...(current?.entries || []), ...(remoteRecord?.entries || [])].map(entry => entry.id))) {+ affectedExerciseIds.add(exerciseId)+ if (remote?.exWeights?.[exerciseId]) next.exWeights[exerciseId] = clone(remote.exWeights[exerciseId])+ else delete next.exWeights[exerciseId]+ }+ }+ return { state: next, blocked, affectedExerciseIds: [...affectedExerciseIds] }+}++export const localStateForEditMerge = (local, remote, pending) => {+ const prepared = prepareLocalStateForEditMerge(local, remote, pending)+ rebuildHistoryDerived(prepared.state, prepared.affectedExerciseIds)+ return prepared.state+}diff --cc frontend/src/lib/session-edit.test.jsindex 798c46612,000000000..16b6ee3edmode 100644,000000..100644--- a/frontend/src/lib/session-edit.test.js+++ b/frontend/src/lib/session-edit.test.js@@@ -1,124 -1,0 +1,138 @@@+import { describe, expect, it } from 'vitest'+import { editCompletedSession, localStateForEditMerge, saveWorkoutEdit } from './session-edit.js'++const entry = (w, id = '0025') => ({ id, sets: [{ w, r: 5, done: true }], target: { mode: 'reps' } })+const fixture = () => ({+ active: null,+ exWeights: {},+ routines: [{ id: 'routine', ex: [] }],+ workouts: [{ id: 'workout', d: '2026-09-01', start: 1000, end: 2000, entries: [entry(40)], note: 'old', prs: ['0025'] }],+})++describe('saved workout editing', () => {+ it('keeps history unchanged until Save, survives reload and preserves its identity, clock and templates', () => {+ const state = fixture(), history = structuredClone(state.workouts), routines = structuredClone(state.routines)+ editCompletedSession(state, 'workout')+ state.active.entries[0].sets[0].w = 80+ state.active.note = ''+ expect(state.workouts).toEqual(history)+ const reloaded = JSON.parse(JSON.stringify(state))+ const saved = saveWorkoutEdit(reloaded)+ expect(saved).toMatchObject({ id: 'workout', d: '2026-09-01', start: 1000, end: 2000, vol: 400 })+ expect(saved).not.toHaveProperty('note')+ expect(saved).not.toHaveProperty('editingWorkoutId')+ expect(reloaded.active).toBeNull()+ expect(reloaded.routines).toEqual(routines)+ })++ it('saves added exercises and sets without persisting a live prescription', () => {+ const state = fixture()+ editCompletedSession(state, 'workout')+ state.active.entries[0].sets.push({ w: 42.5, r: 4, done: true })+ state.active.entries.push({ ...entry(25, 'added'), rid: 'routine', plan: { kind: 'up' } })+ const saved = saveWorkoutEdit(state)+ expect(saved.entries[0].sets).toHaveLength(2)+ expect(saved.entries[1]).toMatchObject({ id: 'added', rid: 'routine' })+ expect(saved.entries[1]).not.toHaveProperty('plan')+ })++ it('rebuilds best weights and historical PR flags after lowering or deleting record work', () => {+ const state = fixture()+ state.workouts.push({ id: 'later', d: '2026-09-02', start: 3000, end: 4000, entries: [entry(30)], prs: [] })+ state.exWeights['0025'] = { w: 40, d: '2026-09-01' }+ editCompletedSession(state, 'workout')+ state.active.entries[0].sets[0].w = 20+ saveWorkoutEdit(state)+ expect(state.exWeights['0025']).toEqual({ w: 30, d: '2026-09-02' })+ expect(state.workouts[0].prs).toEqual(['0025'])+ expect(state.workouts[1].prs).toEqual(['0025'])+ })+++ it('keeps assisted-machine records ordered by less help after an edit', () => {++ const state = fixture()++ state.workouts[0].entries = [entry(30, '0017')]++ state.workouts[0].prs = ['0017']++ state.workouts.push({ id: 'later', d: '2026-09-02', start: 3000, end: 4000, entries: [entry(25, '0017')], prs: [] })++ state.exWeights['0017'] = { w: 30, d: '2026-09-01' }++ editCompletedSession(state, 'workout')++ state.active.entries[0].sets[0].w = 20++ saveWorkoutEdit(state)++ expect(state.exWeights['0017']).toEqual({ w: 20, d: '2026-09-01' })++ expect(state.workouts[0].prs).toEqual(['0017'])++ expect(state.workouts[1].prs).toEqual([])++ })+++ it('preserves repeated occurrences, combined-routine ownership and per-side fields', () => {+ const state = fixture(), workout = state.workouts[0]+ workout.routineIds = ['a', 'b']+ workout.entries = [+ { ...entry(40), rid: 'a', occurrenceId: 'first', opaque: { retained: true } },+ { ...entry(20), rid: 'b', occurrenceId: 'second', sets: [{ w: 20, r: 8, done: true, sides: { L: { w: 12, r: 4, done: true }, R: { w: 8, r: 4, done: true } } }] },+ ]+ editCompletedSession(state, 'workout')+ state.active.entries[1].sets[0].sides.L.w = 14+ const saved = saveWorkoutEdit(state)+ expect(saved.entries.map(item => [item.occurrenceId, item.rid])).toEqual([['first', 'a'], ['second', 'b']])+ expect(saved.entries[0].opaque).toEqual({ retained: true })+ expect(saved.entries[1].sets[0].sides.L.w).toBe(14)+ })++ it('keeps a partially completed per-side occurrence and its opaque ownership', () => {+ const state = fixture()+ state.workouts[0].entries = [{+ ...entry(20), rid: 'routine', occurrenceId: 'partial',+ sets: [{ w: 20, r: 8, done: false, sides: {+ L: { w: 20, r: 4, done: true }, R: { w: 17.5, r: 4, done: false },+ } }],+ }]+ editCompletedSession(state, 'workout')+ const saved = saveWorkoutEdit(state)+ expect(saved.entries[0]).toMatchObject({ rid: 'routine', occurrenceId: 'partial' })+ expect(saved.entries[0].sets[0].sides).toEqual({+ L: { w: 20, r: 4, done: true }, R: { w: 17.5, r: 4, done: false },+ })+ expect(saved.vol).toBe(80)+ })++ it('keeps the draft when the original is missing or changed remotely', () => {+ const deleted = fixture()+ editCompletedSession(deleted, 'workout')+ deleted.workouts = []+ expect(() => saveWorkoutEdit(deleted)).toThrow('deleted on another device')+ expect(deleted.active.editingWorkoutId).toBe('workout')++ const changed = fixture()+ editCompletedSession(changed, 'workout')+ changed.workouts[0].note = 'remote'+ expect(() => saveWorkoutEdit(changed)).toThrow('changed on another device')+ expect(changed.active.editingWorkoutId).toBe('workout')+ })++ it('feeds a remotely changed or deleted original into the current revision merge', () => {+ const local = fixture()+ editCompletedSession(local, 'workout')+ local.active.entries[0].sets[0].w = 50+ const remote = fixture()+ remote.workouts[0].note = 'from phone'+ remote.exWeights['0025'] = { w: 40, d: '2026-09-01' }+ expect(localStateForEditMerge(local, remote).workouts[0].note).toBe('from phone')+ expect(localStateForEditMerge(local, { ...remote, workouts: [] }).workouts).toEqual([])+ expect(local.active.entries[0].sets[0].w).toBe(50)+ })++ it('restores a locally saved correction as a draft when its first push conflicts', () => {+ const local = fixture()+ editCompletedSession(local, 'workout')+ const original = structuredClone(local.active.editingOriginal)+ local.active.entries[0].sets[0].w = 50+ saveWorkoutEdit(local)+ const remote = fixture()+ remote.workouts[0].note = 'from phone'+ remote.exWeights['0025'] = { w: 40, d: '2026-09-01' }+ const merged = localStateForEditMerge(local, remote, { id: 'workout', original })+ expect(merged.workouts[0].note).toBe('from phone')+ expect(merged.active.entries[0].sets[0].w).toBe(50)+ expect(merged.active.editingOriginal).toEqual(remote.workouts[0])+ expect(merged.exWeights['0025'].w).toBe(40)+ })+})diff --cc frontend/src/lib/sync-merge.jsindex 14174c7ba,3f0ca79c1..77e7f9305--- a/frontend/src/lib/sync-merge.js+++ b/frontend/src/lib/sync-merge.js@@@ -14,9 -12,9 +14,10 @@@ import { bestWeightForEntry } from './h* of an id that both have; workouts sorted by day and start like every other writer* - bodyweight: union by day, the later-edited (`t`) entry of a day that both have* - favEx: ordered set union, the newer copy first- * - exWeights: union by exercise, the better `w` for that exercise — larger for an ordinary- * lift, smaller on an assistance machine (a PR logged on the other device must not be- * forgotten, whichever way it runs); exNotes, barWeights: key union+ * - exWeights: union by exercise, normally the larger `w`; when the winning side changed an+ * existing workout, affected exercises are rebuilt from that side and the merged history so- * a deliberate history correction can lower a stale cached best++ * a deliberate history correction can lower a stale cached best. Assistance machines use++ * their smaller-is-better ordering; exNotes and barWeights remain key unions.* - `_ts`: the later of the two; `_rev` dropped (the server sets it); `active` left to the caller** Known limit: with no record of what each side deleted, an entry removed on one device inside@@@ -61,20 -61,17 +64,30 @@@ export function mergeBodyweight(a = []return [...byDay.values()].sort((x, y) => (x.d < y.d ? -1 : 1))}+ // The kept load per exercise. "The larger one wins" held while the app only ever raised it —+ // but an assistance machine progresses downwards, so there the smaller number is the newer,+ // harder setting and taking the larger would hand back the help the other device just dropped+ // (issue #232). `beatsWeight` knows which way round each exercise runs; the date breaks a tie+ // on an exercise where both sides moved in the same direction.-function mergeExWeights(n = {}, o = {}) {+function mergeExWeights(n = {}, o = {}, workouts = [], corrected = new Set()) {const out = { ...(o || {}), ...(n || {}) }for (const k of Object.keys(o || {})) {- if (n && n[k] && o[k] && (o[k].w || 0) > (n[k].w || 0)) out[k] = o[k]+ if (!(n && n[k] && o[k])) continue+ if (beatsWeight(k, o[k].w || 0, n[k].w || 0)) out[k] = o[k]}+ for (const id of corrected) {+ const logged = workouts.flatMap(workout => list(workout.entries)+ .filter(entry => entry?.id === id)+ .map(entry => ({ w: bestWeightForEntry(entry), d: workout.d })))+ .filter(value => value.w > 0)- const candidates = [...logged, ...(n?.[id]?.w > 0 ? [n[id]] : [])].sort((a, b) => b.w - a.w)- if (candidates.length) out[id] = candidates[0]++ const candidates = [...logged, ...(n?.[id]?.w > 0 ? [n[id]] : [])]++ let best = null++ for (const candidate of candidates) {++ if (!best || beatsWeight(id, candidate.w, best.w)) best = candidate++ }++ if (best) out[id] = best+ else delete out[id]+ }return out}diff --cc frontend/src/lib/sync-merge.test.jsindex 76c004c00,62c6a6fbe..53d786a00--- a/frontend/src/lib/sync-merge.test.js+++ b/frontend/src/lib/sync-merge.test.js@@@ -79,13 -79,6 +79,20 @@@ describe('mergeStates', () =>expect(m.exNotes).toEqual({ sq: 'A note', dl: 'B note' })expect(m.barWeights).toEqual({ sq: 20, dl: 15 })})++ it('does not resurrect a cached best lowered by the winning workout correction', () => {+ const set = w => ({ id: 'sq', target: { mode: 'reps' }, sets: [{ w, r: 5, done: true }] })+ const older = base({ _ts: 100, workouts: [{ ...workout('w1'), entries: [set(100)] }], exWeights: { sq: { w: 100, d: '2026-09-01' } } })+ const corrected = base({ _ts: 200, workouts: [{ ...workout('w1'), entries: [set(80)] }], exWeights: { sq: { w: 80, d: '2026-09-01' } } })+ expect(mergeStates(corrected, older).exWeights.sq).toEqual({ w: 80, d: '2026-09-01' })+ })++++ it('keeps assisted-machine correction caches ordered by less help', () => {++ const set = w => ({ id: '0017', target: { mode: 'reps' }, sets: [{ w, r: 5, done: true }] })++ const older = base({ _ts: 100, workouts: [{ ...workout('w1'), entries: [set(30)] }], exWeights: { '0017': { w: 30, d: '2026-09-01' } } })++ const corrected = base({ _ts: 200, workouts: [{ ...workout('w1'), entries: [set(20)] }], exWeights: { '0017': { w: 20, d: '2026-09-01' } } })++ expect(mergeStates(corrected, older).exWeights['0017']).toEqual({ w: 20, d: '2026-09-01' })++ })it('is commutative on the union fields and idempotent', () => {const ab = mergeStates(A(), B()), ba = mergeStates(B(), A())diff --cc frontend/src/views/Workout.jsxindex 31d22511e,bed11c5e8..d13881fc7--- a/frontend/src/views/Workout.jsx+++ b/frontend/src/views/Workout.jsx@@@ -9,10 -9,10 +9,10 @@@ import { effectiveRoutines, effectiveRoimport { fmtNum, capWords, fmtDate, todayISO, exCount, DAYN } from '../lib/format.js'import { beep, vibrate, unlock } from '../lib/sound.js'import { t, exerciseNameFor } from '../lib/i18n.js'- import { api } from '../lib/api.js'+ import { api, appBase } from '../lib/api.js'import { insertionIndexAfterCurrentUnit, nextUnfinishedUnit, setProgressHighWater, supersetFlowStep, restAfterSet, restOnRecheck, restSecFor, warmupRestSecFor } from '../lib/supersetFlow.js'import Media from '../components/Media.jsx'- import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, finishWorkout, exitWorkoutEdit, workoutCompleteSheet, confirmSheet, exerciseNoteSheet, sessionNoteSheet, swapActiveWorkoutExercise, barWeightSheet, menuSheet, effortPickerSheet, exerciseHistorySheet, addRoutineToSessionSheet } from '../sheets.jsx'-import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, finishWorkout, workoutCompleteSheet, confirmSheet, exerciseNoteSheet, sessionNoteSheet, renameWorkoutSheet, swapActiveWorkoutExercise, barWeightSheet, menuSheet, effortPickerSheet, exerciseHistorySheet, addRoutineToSessionSheet } from '../sheets.jsx'++import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, finishWorkout, exitWorkoutEdit, workoutCompleteSheet, confirmSheet, exerciseNoteSheet, sessionNoteSheet, renameWorkoutSheet, swapActiveWorkoutExercise, barWeightSheet, menuSheet, effortPickerSheet, exerciseHistorySheet, addRoutineToSessionSheet } from '../sheets.jsx'import { effortColor } from '../lib/effort.js'import Icon from '../components/Icon.jsx'import { Button, Check, NumberField } from '../components/ui.jsx'@@@ -196,9 -202,9 +202,9 @@@ function ExerciseBlock({ entryIdx, comp// Everything about this exercise that is not a set you are logging right now lives behind one// button. What used to be a row of buttons in the header, a chip under the bar, a strip of// three under the sets and four more below the card is a single list you open once a session.- const barInfo = (!cardio && !(bw && !added) && usesBar(ex)) ? (() => {+ const barInfo = (!editing && !cardio && !(bw && !added) && usesBar(ex)) ? (() => {const bar = barWeightFor(S, entry.id)- if (!(bar > 0)) return null+ if (bar == null || bar < 0) return nullconst nextW = entry.sets.find(s => !s.done)?.wconst refW = nextW > 0 ? nextW : Math.max(0, ...entry.sets.map(s => s.w || 0))const split = plateSplit(refW, bar)@@@ -706,7 -745,8 +750,8 @@@ function ActiveWorkout()// level down (it used to be the whole menu).const openViewMenu = () => menuSheet({items: [+ { icon: 'pencil', label: t('Rename workout'), onClick: renameWorkoutSheet },- { icon: 'plus', label: t('Add routine'), sub: t('Bring another routine into this session'), onClick: addRoutineToSessionSheet },+ !editing && { icon: 'plus', label: t('Add routine'), sub: t('Bring another routine into this session'), onClick: addRoutineToSessionSheet },{ icon: 'list', label: t('Layout'), sub: LAYOUT_LABEL[workoutView] || LAYOUT_LABEL.cards, onClick: openLayoutMenu },],})@@@ -939,13 -977,13 +984,13 @@@{/* In list mode the whole session scrolls under the header, so the header (name, clock,set counter, discard/finish, progress) stays pinned — the one thing you want in viewwhile you are somewhere in the middle of a long stack. Cards mode never scrolls far. */}- <div className={'whdr' + (listMode ? ' stick' : '')}>+ <div className={'whdr' + (listMode ? ' stick' : '')} ref={hdrRef}><div className="hdr">- <button className="iconbtn" aria-label={t('Discard')} onClick={() => confirmSheet({ title: t('Discard workout?'), message: t('The sets you logged in this session will be lost.'), confirmText: t('Discard'), danger: true, onConfirm: () => { update(s => { s.active = null }); stopRest(); stopWork(); nav('/home') } })}><Icon name="xmark" /></button>- <div style={{ textAlign: 'center' }}><div style={{ fontWeight: 600 }}>{A.name}</div><div className="sub">{A.backfill ? fmtDate(A.d, true) : <Elapsed start={A.start} />} · {t('{0} sets', done + '/' + total)}</div></div>+ <button className="iconbtn" aria-label={t(editing ? 'Close editor' : 'Discard')} onClick={() => editing ? exitWorkoutEdit() : confirmSheet({ title: t('Discard workout?'), message: t('The sets you logged in this session will be lost.'), confirmText: t('Discard'), danger: true, onConfirm: () => { update(s => { s.active = null }); stopRest(); stopWork(); nav('/home') } })}><Icon name="xmark" /></button>+ <div style={{ textAlign: 'center' }}><div style={{ fontWeight: 600 }}>{A.name}</div><div className="sub">{(A.backfill || editing) ? fmtDate(A.d, true) : <Elapsed start={A.start} />} · {t('{0} sets', done + '/' + total)}</div></div><div className="row" style={{ gap: 4, flex: 'none' }}><button className="iconbtn" aria-label={t('Workout view')} title={t('Workout view')} onClick={openViewMenu}><Icon name="more" /></button>- <button className="iconbtn" style={{ color: 'var(--acc)' }} aria-label={t('Finish')} onClick={finishWorkout}><Icon name="check" /></button>+ <button className="iconbtn" style={{ color: 'var(--acc)' }} aria-label={t(editing ? 'Save changes' : 'Finish')} onClick={finishWorkout}><Icon name="check" /></button></div></div><div className="wprog"><i style={{ width: (total ? done / total * 100 : 0) + '%' }} /></div>diff --cc frontend/src/views/Workout.test.jsxindex d494a6e94,452fcecf7..bb016c379--- a/frontend/src/views/Workout.test.jsx+++ b/frontend/src/views/Workout.test.jsx@@@ -196,26 -215,9 +216,27 @@@ beforeEach(() =>mocks.timer = nullmocks.work = nullmocks.scrollCalls.length = 0+ mocks.headerHeight = 0})+it('edits a saved set without running live completion, rest or success feedback', async () => {+ await mount([exercise('plain-bench', [false], {+ plan: { policy: 'linear', kind: 'first', why: ['Nothing logged yet — this session sets the baseline.'] },+ })], 0, {+ active: { editingWorkoutId: 'saved', editingOriginal: { id: 'saved' } },+ })+ await toggleSet(0)+ expect(mocks.S.active.entries[0].sets[0].done).toBe(true)+ expect(mocks.startRest).not.toHaveBeenCalled()+ expect(mocks.workoutCompleteSheet).not.toHaveBeenCalled()+ expect(mocks.toast).not.toHaveBeenCalled()+ expect(container.textContent).toContain('Editing a saved workout')+ expect(container.querySelector('.progline')).toBeNull()+ const more = container.querySelector('button[aria-label="More"]')+ await act(async () => { more.dispatchEvent(new dom.Event('click', { bubbles: true })) })+ expect(mocks.menuSheet.mock.calls.at(-1)[0].items.filter(Boolean).map(item => item.label)).not.toContain('Progression settings')+})+afterEach(async () => {await unmount()})