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.

A missed planned day can be logged afterwards, and a past workout's sets ticked in one tap (#284)

Duarte Santosd8c4eda89cee
diff --git a/frontend/src/lib/backfill.js b/frontend/src/lib/backfill.js
index be8a6cb1a..8d250004d 100644
--- a/frontend/src/lib/backfill.js
+++ b/frontend/src/lib/backfill.js
@@ -1,6 +1,8 @@
// Logging a workout after the fact. The session itself is the ordinary active workout with a
// `backfill` field on it; these helpers are the parts that differ from a live session, kept
// pure so the date arithmetic and the history surgery can be tested without the UI.
+import { bestWeightForEntry } from './history.js'
+import { isSideSet, syncSideAggregate } from './workout-model.js'
export const workoutsOn = (S, iso) => (S.workouts || []).filter(w => w.d === iso)
@@ -37,3 +39,19 @@ export function completeBackfill(workouts, active, w) {
const kept = replaceId ? workouts.filter(x => x.id !== replaceId) : workouts
return insertChronological(kept, w)
}
+
+// "Mark all sets done" while logging a past workout (#284). A session written down after the
+// fact went as planned more often than not — a routine that is just a run is the case that asked
+// for it — and ticking every box one by one to say so is the chore that leaves it unlogged. Both
+// sides of a unilateral set are ticked, and each exercise gets the top weight that ticking its
+// last set would have stamped. Returns new entries; the caller stores them.
+export function markAllSetsDone(entries) {
+ return (entries || []).map(entry => {
+ const sets = (entry.sets || []).map(s => (isSideSet(s)
+ ? syncSideAggregate({ ...s, sides: { L: { ...s.sides.L, done: true }, R: { ...s.sides.R, done: true } } })
+ : { ...s, done: true }))
+ const next = { ...entry, sets }
+ next.topW = bestWeightForEntry(next) || null
+ return next
+ })
+}
diff --git a/frontend/src/lib/backfill.test.js b/frontend/src/lib/backfill.test.js
index 4d54698e1..78a8372c3 100644
--- a/frontend/src/lib/backfill.test.js
+++ b/frontend/src/lib/backfill.test.js
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
-import { workoutsOn, backfillStart, backfillEnd, insertChronological, completeBackfill } from './backfill.js'
+import { workoutsOn, backfillStart, backfillEnd, insertChronological, completeBackfill, markAllSetsDone } from './backfill.js'
const w = (id, d, start = 0) => ({ id, d, start })
@@ -57,3 +57,28 @@ describe('completeBackfill', () => {
expect(list).toHaveLength(3)
})
})
+
+// #284: a past session that went as planned is logged with one tap instead of one per set.
+describe('markAllSetsDone', () => {
+ it('ticks every row, warm-ups and both sides of a unilateral set included, and stamps the top weight', () => {
+ const side = (w, r) => ({ w, r, done: false })
+ const entries = [
+ { id: 'bench', target: { reps: 5 }, sets: [{ w: 40, r: 8, done: false, phase: 'warmup' }, { w: 60, r: 5, done: false }, { w: 62.5, r: 5, done: true }] },
+ { id: 'curl', target: { reps: 16, side: true }, sets: [{ w: 12, r: 16, done: false, sides: { L: side(12, 8), R: side(10, 8) } }] },
+ { id: 'run', target: { mode: 'cardio' }, sets: [{ min: 30, speed: 10, done: false }] },
+ ]
+ const out = markAllSetsDone(entries)
+ expect(out.every(e => e.sets.every(s => s.done === true))).toBe(true)
+ expect(out[1].sets[0].sides.L.done && out[1].sets[0].sides.R.done).toBe(true)
+ expect(out.map(e => e.topW)).toEqual([62.5, 12, null])
+ // new entries: the ones passed in are left as they were
+ expect(entries[0].sets[1].done).toBe(false)
+ expect(entries[1].sets[0].sides.L.done).toBe(false)
+ })
+
+ it('keeps everything else on the entry, the plan stamps included', () => {
+ const entry = { id: 'bench', rid: 'r1', planned: { sets: 1, reps: 5 }, sg: 'sg1', target: { reps: 5 }, sets: [{ w: 60, r: 5, done: false, rir: 2 }] }
+ expect(markAllSetsDone([entry])[0]).toEqual({ ...entry, sets: [{ w: 60, r: 5, done: true, rir: 2 }], topW: 60 })
+ expect(markAllSetsDone(undefined)).toEqual([])
+ })
+})
diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js
index 3f80bff04..51dbc1a89 100644
--- a/frontend/src/lib/pt-br-locale.test.js
+++ b/frontend/src/lib/pt-br-locale.test.js
@@ -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(679)
- expect(inherited).toHaveLength(677)
+ expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(680)
+ expect(inherited).toHaveLength(678)
// 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('adbf617a0fd3e071a7637df853ed0937d010d1ee9e4bb2cee4286dd4ed88b469')
+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('b3837351e4968a720eae9ce421e45b0aeedb91708ded6745293551f812b88b2a')
})
test('does not leak European Portuguese UI terms', () => {
diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js
index b96973f9d..bd6820713 100644
--- a/frontend/src/locales/de.js
+++ b/frontend/src/locales/de.js
@@ -1324,4 +1324,7 @@ export default {
'Copy as text': 'Als Text kopieren',
'Copied': 'Kopiert',
'Could not copy': 'Kopieren nicht möglich',
+ // --- a missed day logged afterwards (#284) ---
+ 'Log this workout': 'Dieses Training eintragen',
+ 'Mark all sets done': 'Alle Sätze abhaken',
}
diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js
index 36e652f36..722f8ad90 100644
--- a/frontend/src/locales/es.js
+++ b/frontend/src/locales/es.js
@@ -1304,4 +1304,7 @@ export default {
'Copy as text': 'Copiar como texto',
'Copied': 'Copiado',
'Could not copy': 'No se pudo copiar',
+ // --- a missed day logged afterwards (#284) ---
+ 'Log this workout': 'Registrar este entrenamiento',
+ 'Mark all sets done': 'Marcar todas las series como hechas',
}
diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js
index 30cd4b2f4..fd6274537 100644
--- a/frontend/src/locales/fr.js
+++ b/frontend/src/locales/fr.js
@@ -1304,4 +1304,7 @@ export default {
'Copy as text': 'Copier en texte',
'Copied': 'Copié',
'Could not copy': 'Copie impossible',
+ // --- a missed day logged afterwards (#284) ---
+ 'Log this workout': 'Enregistrer cette séance',
+ 'Mark all sets done': 'Cocher toutes les séries',
}
diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js
index 5b286402c..a87d07d6c 100644
--- a/frontend/src/locales/hi.js
+++ b/frontend/src/locales/hi.js
@@ -1304,4 +1304,7 @@ export default {
'Copy as text': 'टेक्स्ट के रूप में कॉपी करें',
'Copied': 'कॉपी हो गया',
'Could not copy': 'कॉपी नहीं हो सका',
+ // --- a missed day logged afterwards (#284) ---
+ 'Log this workout': 'यह वर्कआउट दर्ज करें',
+ 'Mark all sets done': 'सभी सेट पूरे मार्क करें',
}
diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js
index 7f32cff99..743070b9c 100644
--- a/frontend/src/locales/hu.js
+++ b/frontend/src/locales/hu.js
@@ -1307,4 +1307,7 @@ export default {
'Copy as text': 'Másolás szövegként',
'Copied': 'Kimásolva',
'Could not copy': 'Nem sikerült másolni',
+ // --- a missed day logged afterwards (#284) ---
+ 'Log this workout': 'Az edzés rögzítése',
+ 'Mark all sets done': 'Összes sorozat késznek jelölése',
}
diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js
index 8b61b74b3..e82b28677 100644
--- a/frontend/src/locales/it.js
+++ b/frontend/src/locales/it.js
@@ -1304,4 +1304,7 @@ export default {
'Copy as text': 'Copia come testo',
'Copied': 'Copiato',
'Could not copy': 'Impossibile copiare',
+ // --- a missed day logged afterwards (#284) ---
+ 'Log this workout': 'Registra questo allenamento',
+ 'Mark all sets done': 'Segna tutte le serie come fatte',
}
diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js
index 954a8febf..21b15bc95 100644
--- a/frontend/src/locales/ko.js
+++ b/frontend/src/locales/ko.js
@@ -1304,4 +1304,7 @@ export default {
'Copy as text': '텍스트로 복사',
'Copied': '복사됨',
'Could not copy': '복사할 수 없음',
+ // --- a missed day logged afterwards (#284) ---
+ 'Log this workout': '이 운동 기록',
+ 'Mark all sets done': '모든 세트 완료로 표시',
}
diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js
index 610867b49..ccf13408b 100644
--- a/frontend/src/locales/pl.js
+++ b/frontend/src/locales/pl.js
@@ -1304,4 +1304,7 @@ export default {
'Copy as text': 'Kopiuj jako tekst',
'Copied': 'Skopiowano',
'Could not copy': 'Nie udało się skopiować',
+ // --- a missed day logged afterwards (#284) ---
+ 'Log this workout': 'Zapisz ten trening',
+ 'Mark all sets done': 'Oznacz wszystkie serie jako zrobione',
}
diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js
index 54b70d992..f41fb6d45 100644
--- a/frontend/src/locales/pt-BR.js
+++ b/frontend/src/locales/pt-BR.js
@@ -709,6 +709,9 @@ export const PT_BR_OVERRIDES = {
'First time in this routine — starting from its own target.': 'Primeira vez nesta rotina — você começa pela meta dela.',
'No weight logged last time — enter what you lift and progression takes it from there.': 'Nenhum peso registrado na última vez — informe quanto você levanta e a progressão segue a partir daí.',
'reps from your last session': 'reps da sua última sessão',
+ // a missed day logged afterwards (#284) — pt-PT's "Registar" reads as Portugal; "Marcar todas
+ // as séries como feitas" is shared and inherits
+ 'Log this workout': 'Registrar este treino',
}
export default { ...pt, ...PT_BR_OVERRIDES }
diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js
index 9b89e6870..08aa14197 100644
--- a/frontend/src/locales/pt.js
+++ b/frontend/src/locales/pt.js
@@ -1304,4 +1304,7 @@ export default {
'Copy as text': 'Copiar como texto',
'Copied': 'Copiado',
'Could not copy': 'Não foi possível copiar',
+ // --- a missed day logged afterwards (#284) ---
+ 'Log this workout': 'Registar este treino',
+ 'Mark all sets done': 'Marcar todas as séries como feitas',
}
diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js
index 110c32a88..faa95aa72 100644
--- a/frontend/src/locales/ru.js
+++ b/frontend/src/locales/ru.js
@@ -1304,4 +1304,7 @@ export default {
'Copy as text': 'Скопировать как текст',
'Copied': 'Скопировано',
'Could not copy': 'Не удалось скопировать',
+ // --- a missed day logged afterwards (#284) ---
+ 'Log this workout': 'Записать эту тренировку',
+ 'Mark all sets done': 'Отметить все подходы выполненными',
}
diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js
index c2c53f256..94d1cd8d0 100644
--- a/frontend/src/locales/th.js
+++ b/frontend/src/locales/th.js
@@ -1315,4 +1315,7 @@ export default {
'Copy as text': 'คัดลอกเป็นข้อความ',
'Copied': 'คัดลอกแล้ว',
'Could not copy': 'คัดลอกไม่ได้',
+ // --- a missed day logged afterwards (#284) ---
+ 'Log this workout': 'บันทึกการฝึกนี้',
+ 'Mark all sets done': 'ทำเครื่องหมายทุกเซ็ตว่าเสร็จแล้ว',
}
diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js
index 6809101e6..c21d901df 100644
--- a/frontend/src/locales/tr.js
+++ b/frontend/src/locales/tr.js
@@ -1304,4 +1304,7 @@ export default {
'Copy as text': 'Metin olarak kopyala',
'Copied': 'Kopyalandı',
'Could not copy': 'Kopyalanamadı',
+ // --- a missed day logged afterwards (#284) ---
+ 'Log this workout': 'Bu antrenmanı kaydet',
+ 'Mark all sets done': 'Tüm setleri tamamlandı olarak işaretle',
}
diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js
index 80a16a028..5590c06a1 100644
--- a/frontend/src/locales/zh.js
+++ b/frontend/src/locales/zh.js
@@ -1304,4 +1304,7 @@ export default {
'Copy as text': '复制为文本',
'Copied': '已复制',
'Could not copy': '无法复制',
+ // --- a missed day logged afterwards (#284) ---
+ 'Log this workout': '补记这次训练',
+ 'Mark all sets done': '将所有组标为完成',
}
diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx
index a460f7f8d..229841370 100644
--- a/frontend/src/sheets.jsx
+++ b/frontend/src/sheets.jsx
@@ -1604,6 +1604,11 @@ function DayOverride({ iso, close }) {
// one here collapses a combined day to it (docs/COMBINE_ROUTINES.md §8). The check marks
// show everything currently planned for the day.
const effIds = effectiveRoutineIds(st, iso)
+ // A planned day in the past with nothing logged was missed — or trained and never logged,
+ // like a run you forgot to start the app for (#284). Logging it opens "Log a past workout" on
+ // that date with the day's routines picked, where the time and the duration can still change.
+ const missed = iso < todayISO() && effIds.length > 0 && !workoutsOn(st, iso).length
+ const logIt = () => { close(); logPastWorkoutSheet({ iso, routineIds: effIds }) }
const set = v => {
update(s => { if (!v) delete s.dayPlan[iso]; else s.dayPlan[iso] = v })
close()
@@ -1612,6 +1617,7 @@ function DayOverride({ iso, close }) {
return <>
<h3>{fmtDate(iso, true)}</h3>
<div className="muted small" style={{ marginBottom: 12 }}>{t('Weekly plan:')} {weeklyNames.length ? deriveSessionName(weeklyNames) : t('Rest')}{hasOvr && <span style={{ color: 'var(--orange)' }}> · {t('changed for this day')}</span>}<br />{t('Sick, missed a day or want a different session? Pick what to train instead.')}</div>
+ {missed && <div style={{ marginBottom: 14 }}><Button variant="primary" icon="checkCircle" onClick={logIt}>{t('Log this workout')}</Button></div>}
<div className="list">
{st.routines.map(r => <div key={r.id} className="item" {...tappable(() => set(r.id))}>
<span className="lrow-i"><Icon name={glyphOf(r.emoji)} /></span>
@@ -1857,19 +1863,28 @@ export function beginWorkout(routineIds, bw) {
// The same screen as a live session, pointed at another day. `backfill` on the active
// session is what tells the workout screen to drop the clock and the rest timers, and tells
// the finish path to file the workout where its date belongs instead of at the end.
-function LogPastWorkout({ close }) {
+// `initial` is a missed day of the plan (#284): its date, and the routines planned for it. A
+// combined day is offered as the one session it plans, next to each routine on its own.
+const PLANNED_DAY = '__planned-day'
+function LogPastWorkout({ initial, close }) {
const st = useStore(s => s.S)
const yesterday = new Date(); yesterday.setDate(yesterday.getDate() - 1)
- const [date, setDate] = useState(isoOf(yesterday))
+ const planned = [].concat(initial?.routineIds || []).map(id => st.routines.find(r => r.id === id)).filter(Boolean)
+ const [date, setDate] = useState(initial?.iso || isoOf(yesterday))
const [time, setTime] = useState('18:00')
const [dur, setDur] = useState(60)
- const [routineId, setRoutineId] = useState('')
+ const [routineId, setRoutineId] = useState(planned.length > 1 ? PLANNED_DAY : planned[0]?.id || '')
const today = todayISO()
- const options = [{ value: '', label: t('Freestyle') }, ...st.routines.map(r => ({ value: r.id, label: r.name }))]
+ const options = [
+ { value: '', label: t('Freestyle') },
+ ...(planned.length > 1 ? [{ value: PLANNED_DAY, label: deriveSessionName(planned.map(r => r.name)) }] : []),
+ ...st.routines.map(r => ({ value: r.id, label: r.name })),
+ ]
const go = replaceId => {
close()
- beginBackfill({ iso: date, time, durationMin: dur, routineId: routineId || null, replaceId })
+ const routineIds = routineId === PLANNED_DAY ? planned.map(r => r.id) : routineId ? [routineId] : []
+ beginBackfill({ iso: date, time, durationMin: dur, routineIds, replaceId })
}
const submit = () => {
if (!date || date > today) { toast(t('Pick a day up to today')); return }
@@ -1907,15 +1922,18 @@ function SameDayChoice({ iso, existing, onReplace, onAdd, close }) {
<Button variant="ghost" className="dim" onClick={close}>{t('Cancel')}</Button>
</div>
}
-export function logPastWorkoutSheet() {
+// History's button hands this its click event; only a day from the plan counts as `initial`.
+export function logPastWorkoutSheet(initial) {
if (S().active) { toast(t('Finish the current workout first.')); return }
- ui().openSheet(close => <LogPastWorkout close={close} />)
+ const from = typeof initial?.iso === 'string' ? initial : null
+ ui().openSheet(close => <LogPastWorkout initial={from} close={close} />)
}
-// Backfill stays single-routine (the LogPastWorkout UI is one picker), but it emits the new
-// shape: a one-element (or empty) routine list, per-entry rid, no top-level routineId.
-function beginBackfill({ iso, time, durationMin, routineId, replaceId }) {
+// A backfilled session is built the way a live one is (buildCombinedEntries → buildPlannedEntry),
+// so its entries carry the same stamps: the routine list, per-entry rid and the plan, no
+// top-level routineId. One routine from the picker, or every routine of a missed combined day.
+function beginBackfill({ iso, time, durationMin, routineIds, replaceId }) {
const st = S()
- const { entries, routineIds: rids, routines } = buildCombinedEntries(st, routineId ? [routineId] : [])
+ const { entries, routineIds: rids, routines } = buildCombinedEntries(st, routineIds || [])
update(s => {
s.active = {
id: uid(), d: iso, start: backfillStart(iso, time),
diff --git a/frontend/src/sheets.missed-day.test.jsx b/frontend/src/sheets.missed-day.test.jsx
new file mode 100644
index 000000000..92d32478f
--- /dev/null
+++ b/frontend/src/sheets.missed-day.test.jsx
@@ -0,0 +1,136 @@
+// @vitest-environment happy-dom
+// #284: "I forgot to check in, so it appears later in the history as a missed day." A planned day
+// in the past with nothing logged offers to log it, from the week strip and the calendar (both
+// open the day sheet), and what gets logged is built like any session of that plan.
+import React, { act } from 'react'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { createRoot } from 'react-dom/client'
+import { DEF, useStore } from './store/useStore.js'
+import { useUI } from './store/useUI.js'
+import { dayOverrideSheet, logPastWorkoutSheet, finishWorkout } from './sheets.jsx'
+import { markAllSetsDone } from './lib/backfill.js'
+import { EXDB } from './lib/exercises-data.js'
+
+const BENCH = '0025'
+const ROW = EXDB.find(e => e.id !== BENCH && e.bp === 'back' && e.eq === 'barbell').id
+const clone = v => JSON.parse(JSON.stringify(v))
+const S = () => useStore.getState().S
+const mounted = []
+
+function mountTopSheet() {
+ const sheet = useUI.getState().sheets.at(-1)
+ const host = document.createElement('div')
+ document.body.appendChild(host)
+ const root = createRoot(host)
+ mounted.push(root)
+ act(() => root.render(sheet.render(() => useUI.getState().closeSheet(sheet.id))))
+ return host
+}
+const button = (host, text) => [...host.querySelectorAll('button')].find(b => b.textContent.trim() === text)
+// Mounted before the click's own act(): a render nested inside it lands only once it is over.
+function tapInTopSheet(text) {
+ const target = button(mountTopSheet(), text)
+ expect(target, text).toBeTruthy()
+ act(() => { target.click() })
+}
+
+function install(extra = {}) {
+ const st = clone(DEF)
+ Object.assign(st, {
+ routines: [
+ { id: 'A', name: 'Push', emoji: 'dumbbell', ex: [{ id: BENCH, sets: 2, reps: 10, weight: 50, mode: 'reps' }] },
+ { id: 'B', name: 'Pull', emoji: 'dumbbell', ex: [{ id: ROW, sets: 3, reps: 8, weight: 40, mode: 'reps' }] },
+ ],
+ // Monday trains both routines as one session, Friday just the first.
+ week: { 1: ['A', 'B'], 5: ['A'] }, dayPlan: {}, active: null, workouts: [], weighIn: false,
+ }, extra)
+ useStore.setState({ S: st, user: null })
+}
+
+beforeEach(() => {
+ // Wednesday 16 September 2026, midday.
+ vi.useFakeTimers({ toFake: ['Date'] })
+ vi.setSystemTime(new Date('2026-09-16T12:00:00'))
+ globalThis.IS_REACT_ACT_ENVIRONMENT = true
+ localStorage.clear()
+ useUI.setState({ sheets: [], toasts: [] })
+ document.body.innerHTML = ''
+ install()
+})
+afterEach(() => {
+ act(() => { mounted.splice(0).forEach(root => root.unmount()) })
+ vi.useRealTimers()
+})
+
+describe('logging a missed planned day', () => {
+ it('is offered on a past planned day with nothing logged, and nowhere else', () => {
+ const offered = iso => {
+ useUI.setState({ sheets: [] })
+ dayOverrideSheet(iso)
+ return !!button(mountTopSheet(), 'Log this workout')
+ }
+ expect(offered('2026-09-14')).toBe(true) // Monday, missed
+ expect(offered('2026-09-15')).toBe(false) // Tuesday, a rest day
+ expect(offered('2026-09-16')).toBe(false) // today: that is still a Start
+ expect(offered('2026-09-18')).toBe(false) // Friday, still to come
+ install({ workouts: [{ id: 'w', d: '2026-09-11', start: 1, end: 2, name: 'Push', entries: [], prs: [] }] })
+ expect(offered('2026-09-11')).toBe(false) // last Friday, logged
+ install({ dayPlan: { '2026-09-14': 'rest' } })
+ expect(offered('2026-09-14')).toBe(false) // Monday moved to rest
+ })
+
+ it('opens "Log a past workout" on that day with the day\'s routines, as one session', () => {
+ dayOverrideSheet('2026-09-14')
+ tapInTopSheet('Log this workout')
+ // the day sheet made way for the log sheet
+ expect(useUI.getState().sheets).toHaveLength(1)
+ const host = mountTopSheet()
+ expect(host.querySelector('h3').textContent).toBe('Log a past workout')
+ expect(host.querySelector('input[type=date]').value).toBe('2026-09-14')
+ expect(host.textContent).toContain('Push + Pull')
+ act(() => { button(host, 'Continue').click() })
+
+ const A = S().active
+ expect(A).toMatchObject({ d: '2026-09-14', name: 'Push + Pull', routineIds: ['A', 'B'], backfill: { durationMin: 60, replaceId: null } })
+ // built the way a live session of that plan is: each entry stamped with its routine and plan
+ expect(A.entries.map(e => [e.id, e.rid, e.planned?.sets, e.planned?.reps])).toEqual([[BENCH, 'A', 2, 10], [ROW, 'B', 3, 8]])
+ })
+
+ it('offers a single planned routine as the routine itself', () => {
+ dayOverrideSheet('2026-09-11')
+ tapInTopSheet('Log this workout')
+ tapInTopSheet('Continue')
+ expect(S().active).toMatchObject({ d: '2026-09-11', name: 'Push', routineIds: ['A'] })
+ })
+
+ it('files a completed workout on that date once its sets are marked done', () => {
+ dayOverrideSheet('2026-09-14')
+ tapInTopSheet('Log this workout')
+ tapInTopSheet('Continue')
+ act(() => { useStore.getState().update(s => { s.active.entries = markAllSetsDone(s.active.entries) }) })
+ act(() => finishWorkout())
+ expect(S().active).toBeNull()
+ const [w] = S().workouts
+ expect(w).toMatchObject({ d: '2026-09-14', routineIds: ['A', 'B'], prs: [] })
+ expect(new Date(w.start).getHours()).toBe(18)
+ expect(w.entries.map(e => [e.rid, e.sets.every(s => s.done)])).toEqual([['A', true], ['B', true]])
+ expect(w.entries[0].planned).toMatchObject({ sets: 2, reps: 10 })
+ })
+
+ it('still refuses while a workout is running', () => {
+ const toast = vi.fn()
+ useUI.setState({ toast })
+ install({ active: { id: 'live', entries: [] } })
+ dayOverrideSheet('2026-09-14')
+ tapInTopSheet('Log this workout')
+ expect(toast).toHaveBeenCalledWith('Finish the current workout first.')
+ expect(useUI.getState().sheets).toHaveLength(0)
+ })
+
+ it('treats a click event from the History button as no day at all', () => {
+ logPastWorkoutSheet({ type: 'click', target: null })
+ const host = mountTopSheet()
+ expect(host.querySelector('input[type=date]').value).toBe('2026-09-15')
+ expect(host.textContent).toContain('Freestyle')
+ })
+})
diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx
index b8a9c365c..306bcec53 100644
--- a/frontend/src/views/Workout.jsx
+++ b/frontend/src/views/Workout.jsx
@@ -20,6 +20,7 @@ import { defaultIncrement, weightIncrement, stepWeight } from '../lib/progressio
import { progressionGuidance } from '../lib/progression-copy.js'
import { buildPlannedEntry, plannedConfigOf } from '../lib/session-start.js'
import { glyphOf } from '../lib/glyphs.js'
+import { markAllSetsDone } from '../lib/backfill.js'
import { isWarmupRow, isDropSet, isRestPauseSet, dropsOf, clustersOf, addDrop, addCluster, removeDropAt, removeClusterAt, setDropAt, setClusterAt, nextDropWeight, nextBurstReps, isSideSet, makeSideSet, setSideField, toggleSide, addSideDrop, removeSideDropAt, setSideDropAt, addSideCluster, removeSideClusterAt, setSideClusterAt } from '../lib/workout-model.js'
import { canMoveActiveWorkoutUnit, moveActiveWorkoutUnit } from '../lib/active-workout-order.js'
import { MUSCLE_NAME } from '../lib/muscles.js'
@@ -768,10 +769,22 @@ function ActiveWorkout() {
{ icon: 'minimize', label: t('Compact'), on: workoutView === 'compact', onClick: () => setWorkoutView('compact') },
],
})
+ // Logging a past workout (#284): the sets were done days ago, so one tap ticks them all and
+ // offers the finish, the same sheet the last set of a live session opens. What went
+ // differently is still edited on the rows before finishing.
+ const markAllDone = () => {
+ update(s => { if (s.active) s.active.entries = markAllSetsDone(s.active.entries) }, true)
+ const fresh = useStore.getState().S.active
+ // Ticked here rather than row by row: without this, unticking and reticking one of them
+ // would count as new progress and replay the flow a first tick runs.
+ if (fresh) progressHighWater.current = fresh.entries.map(e => e.sets.filter(s => s.done).length)
+ workoutCompleteSheet()
+ }
// The header ⋮: bring another routine into the session, then the layout switch nested a
// level down (it used to be the whole menu).
const openViewMenu = () => menuSheet({
items: [
+ A.backfill && A.entries.length > 0 && { icon: 'checkCircle', label: t('Mark all sets done'), onClick: markAllDone },
{ icon: 'pencil', label: t('Rename workout'), onClick: renameWorkoutSheet },
{ 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 },
diff --git a/frontend/src/views/Workout.test.jsx b/frontend/src/views/Workout.test.jsx
index 55a757a6f..4179b7349 100644
--- a/frontend/src/views/Workout.test.jsx
+++ b/frontend/src/views/Workout.test.jsx
@@ -1705,3 +1705,31 @@ describe('set-row column header', () => {
expect(container.querySelector('.setrow .stp.w').classList.contains('plain')).toBe(true)
})
})
+
+// #284: logging a past workout that went as planned takes one tap, not one per set.
+describe('mark all sets done while logging a past workout', () => {
+ const openMenu = async () => {
+ const btn = container.querySelector('button[aria-label="Workout view"]')
+ await act(async () => { btn.dispatchEvent(new dom.Event('click', { bubbles: true })) })
+ return mocks.menuSheet.mock.calls.at(-1)[0]
+ }
+ const labels = menu => menu.items.filter(Boolean).map(it => it.label)
+
+ it('ticks every set, stamps the top weight and offers the finish', async () => {
+ await mount([
+ exercise('plain-bench', [false, true]),
+ exercise('plain-row', [false], { sets: [{ w: 40, r: 8, done: false, phase: 'warmup' }, { w: 70, r: 8, done: false }] }),
+ ], 0, { active: { backfill: { durationMin: 60, replaceId: null }, routineIds: [] } })
+ const menu = await openMenu()
+ expect(labels(menu)[0]).toBe('Mark all sets done')
+ await act(async () => { menu.items.filter(Boolean)[0].onClick() })
+ expect(mocks.S.active.entries.every(e => e.sets.every(s => s.done))).toBe(true)
+ expect(mocks.S.active.entries.map(e => e.topW)).toEqual([60, 70])
+ expect(mocks.workoutCompleteSheet).toHaveBeenCalledTimes(1)
+ })
+
+ it('is only there for a past workout', async () => {
+ await mount([exercise('plain-bench', [false])], 0, { active: { routineIds: [] } })
+ expect(labels(await openMenu())).not.toContain('Mark all sets done')
+ })
+})