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: the Finish pill opens a sheet with Finish and save and Discard workout

Duarte Santos1f191168db6f
diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js
index eb2e78468..19ef73e6d 100644
--- a/frontend/src/lib/pt-br-locale.test.js
+++ b/frontend/src/lib/pt-br-locale.test.js
@@ -41,7 +41,7 @@ describe('Brazilian Portuguese locale', () => {
// has to be taught is a number nobody reads. What the numbers stood for is asserted above.
// If the hash fails, review the changed keys and wording before accepting a new one. From
// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list
- expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('4da56efa8354bfc0964ccfaeb7f69d760b00f83ce86853545e8b6b6a90b18b63')
+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('367ca8081ab9ad74d99b272118b21ac0f7ccb3398d01f647a071506f156894aa')
})
test('does not leak European Portuguese UI terms', () => {
diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.js
index 1d0a9eeb8..c8c4e8fe8 100644
--- a/frontend/src/locales/ar.js
+++ b/frontend/src/locales/ar.js
@@ -1937,4 +1937,6 @@ export default {
'Move {0}': 'نقل {0}',
'Build your loop in Plan': 'أنشئ دورتك في الخطة',
'week start': 'بداية الأسبوع',
+ 'Finish workout?': 'إنهاء التمرين؟',
+ 'Finish and save': 'إنهاء وحفظ',
}
diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js
index 08afb1979..816736c16 100644
--- a/frontend/src/locales/de.js
+++ b/frontend/src/locales/de.js
@@ -1904,4 +1904,6 @@ export default {
'Move {0}': '{0} verschieben',
'Build your loop in Plan': 'Kreislauf im Plan erstellen',
'week start': 'Wochenstart',
+ 'Finish workout?': 'Training beenden?',
+ 'Finish and save': 'Beenden und speichern',
}
diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js
index 63c4b6840..1a2c25eb6 100644
--- a/frontend/src/locales/es.js
+++ b/frontend/src/locales/es.js
@@ -1884,4 +1884,6 @@ export default {
'Move {0}': 'Mover {0}',
'Build your loop in Plan': 'Crea tu bucle en Plan',
'week start': 'inicio de semana',
+ 'Finish workout?': '¿Terminar entrenamiento?',
+ 'Finish and save': 'Terminar y guardar',
}
diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js
index bd33dfc0d..d9fb384ea 100644
--- a/frontend/src/locales/fr.js
+++ b/frontend/src/locales/fr.js
@@ -1884,4 +1884,6 @@ export default {
'Move {0}': 'Déplacer {0}',
'Build your loop in Plan': 'Crée ta boucle dans Plan',
'week start': 'début de semaine',
+ 'Finish workout?': 'Terminer la séance ?',
+ 'Finish and save': 'Terminer et enregistrer',
}
diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js
index c02440d85..fcdcfbe09 100644
--- a/frontend/src/locales/hi.js
+++ b/frontend/src/locales/hi.js
@@ -1884,4 +1884,6 @@ export default {
'Move {0}': '{0} खिसकाएँ',
'Build your loop in Plan': 'योजना में अपना चक्र बनाएं',
'week start': 'सप्ताह की शुरुआत',
+ 'Finish workout?': 'वर्कआउट समाप्त करें?',
+ 'Finish and save': 'समाप्त करें और सहेजें',
}
diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js
index 43e73aee2..88aa185f5 100644
--- a/frontend/src/locales/hu.js
+++ b/frontend/src/locales/hu.js
@@ -1887,4 +1887,6 @@ export default {
'Move {0}': '{0} áthelyezése',
'Build your loop in Plan': 'Állítsd össze a köröd a Tervben',
'week start': 'hét kezdete',
+ 'Finish workout?': 'Befejezed az edzést?',
+ 'Finish and save': 'Befejezés és mentés',
}
diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js
index 167cd3c47..ba9ee861a 100644
--- a/frontend/src/locales/it.js
+++ b/frontend/src/locales/it.js
@@ -1884,4 +1884,6 @@ export default {
'Move {0}': 'Sposta {0}',
'Build your loop in Plan': 'Crea il tuo ciclo in Piano',
'week start': 'inizio settimana',
+ 'Finish workout?': 'Terminare l’allenamento?',
+ 'Finish and save': 'Termina e salva',
}
diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js
index d14b447e8..98d34ef02 100644
--- a/frontend/src/locales/ko.js
+++ b/frontend/src/locales/ko.js
@@ -1884,4 +1884,6 @@ export default {
'Move {0}': '{0} 이동',
'Build your loop in Plan': '계획에서 순환 만들기',
'week start': '주 시작',
+ 'Finish workout?': '운동을 마칠까요?',
+ 'Finish and save': '마치고 저장',
}
diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js
index 38beb0f0e..b8605de98 100644
--- a/frontend/src/locales/pl.js
+++ b/frontend/src/locales/pl.js
@@ -1884,4 +1884,6 @@ export default {
'Move {0}': 'Przenieś {0}',
'Build your loop in Plan': 'Zbuduj pętlę w Planie',
'week start': 'początek tygodnia',
+ 'Finish workout?': 'Zakończyć trening?',
+ 'Finish and save': 'Zakończ i zapisz',
}
diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js
index 603b6944f..55adae69d 100644
--- a/frontend/src/locales/pt-BR.js
+++ b/frontend/src/locales/pt-BR.js
@@ -1167,6 +1167,7 @@ export const PT_BR_OVERRIDES = {
'Turn on push notifications first.': 'Ative primeiro as notificações push.',
'Delete {0}': 'Excluir {0}',
'Build your loop in Plan': 'Monte seu ciclo no Plano',
+ 'Finish and save': 'Terminar e salvar',
}
export default { ...pt, ...PT_BR_OVERRIDES }
diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js
index 541d49e3d..56134a439 100644
--- a/frontend/src/locales/pt.js
+++ b/frontend/src/locales/pt.js
@@ -1884,4 +1884,6 @@ export default {
'Move {0}': 'Mover {0}',
'Build your loop in Plan': 'Crie o seu ciclo no Plano',
'week start': 'início da semana',
+ 'Finish workout?': 'Terminar o treino?',
+ 'Finish and save': 'Terminar e guardar',
}
diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js
index 742fd8370..093ddd94b 100644
--- a/frontend/src/locales/ru.js
+++ b/frontend/src/locales/ru.js
@@ -1888,4 +1888,6 @@ export default {
'Move {0}': 'Переместить {0}',
'Build your loop in Plan': 'Собери круг в Плане',
'week start': 'начало недели',
+ 'Finish workout?': 'Завершить тренировку?',
+ 'Finish and save': 'Завершить и сохранить',
}
diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js
index 8ccff505a..7f9586fa1 100644
--- a/frontend/src/locales/th.js
+++ b/frontend/src/locales/th.js
@@ -1895,4 +1895,6 @@ export default {
'Move {0}': 'ย้าย {0}',
'Build your loop in Plan': 'สร้างการวนรอบในแผน',
'week start': 'วันเริ่มสัปดาห์',
+ 'Finish workout?': 'จบการออกกำลังกายไหม?',
+ 'Finish and save': 'จบและบันทึก',
}
diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js
index 3fabcb317..882991023 100644
--- a/frontend/src/locales/tr.js
+++ b/frontend/src/locales/tr.js
@@ -1884,4 +1884,6 @@ export default {
'Move {0}': '{0} taşı',
'Build your loop in Plan': 'Döngünü Plan\'da oluştur',
'week start': 'hafta başlangıcı',
+ 'Finish workout?': 'Antrenman bitirilsin mi?',
+ 'Finish and save': 'Bitir ve kaydet',
}
diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.js
index 510aea9d5..4cb74f562 100644
--- a/frontend/src/locales/uk.js
+++ b/frontend/src/locales/uk.js
@@ -1881,4 +1881,6 @@ export default {
'Move {0}': 'Перемістити {0}',
'Build your loop in Plan': 'Збери коло в Плані',
'week start': 'початок тижня',
+ 'Finish workout?': 'Завершити тренування?',
+ 'Finish and save': 'Завершити й зберегти',
}
diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.js
index b5e621879..833c6e7fd 100644
--- a/frontend/src/locales/zh-TW.js
+++ b/frontend/src/locales/zh-TW.js
@@ -1877,4 +1877,6 @@ export default {
'Move {0}': '移動 {0}',
'Build your loop in Plan': '在計畫中建立循環',
'week start': '每週開始',
+ 'Finish workout?': '結束訓練?',
+ 'Finish and save': '結束並儲存',
}
diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js
index 7503b45e1..e4f789a5b 100644
--- a/frontend/src/locales/zh.js
+++ b/frontend/src/locales/zh.js
@@ -1884,4 +1884,6 @@ export default {
'Move {0}': '移动 {0}',
'Build your loop in Plan': '在计划中创建循环',
'week start': '每周开始',
+ 'Finish workout?': '结束训练?',
+ 'Finish and save': '结束并保存',
}
diff --git a/frontend/src/sheets.finish-hold.test.jsx b/frontend/src/sheets.finish-hold.test.jsx
index 43d984e61..01b060e2b 100644
--- a/frontend/src/sheets.finish-hold.test.jsx
+++ b/frontend/src/sheets.finish-hold.test.jsx
@@ -7,7 +7,7 @@ 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 { finishWorkout } from './sheets.jsx'
+import { finishWorkout, finishWorkoutSheet } from './sheets.jsx'
import { EXDB } from './lib/exercises-data.js'
const clone = v => JSON.parse(JSON.stringify(v))
@@ -82,3 +82,50 @@ describe('finishing while a timed hold runs', () => {
expect(held).not.toHaveBeenCalled()
})
})
+
+// The header's Finish pill (v1.3.11): a sheet with Finish and save and Discard workout, the
+// unchecked-sets warning as its subtitle, and no second question after Finish and save.
+describe('the Finish sheet', () => {
+ const sheetText = () => {
+ 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 tapItem = (host, text) => act(() => { [...host.querySelectorAll('.menu-item')].find(el => el.textContent.includes(text)).click() })
+
+ it('all sets done: Finish workout? and a save that needs no confirm', () => {
+ install([{ w: 40, r: 5, done: true }])
+ act(() => finishWorkoutSheet({ onDiscard: vi.fn() }))
+ const host = sheetText()
+ expect(host.querySelector('h3').textContent).toBe('Finish workout?')
+ expect([...host.querySelectorAll('.menu-item .tt')].map(e => e.textContent)).toEqual(['Finish and save', 'Discard workout'])
+ expect(host.querySelector('.menu-item.danger').textContent).toContain('Discard workout')
+ tapItem(host, 'Finish and save')
+ expect(S().active).toBeNull()
+ expect(S().workouts).toHaveLength(1)
+ })
+
+ it('keeps the early-finish wording as its message, and Discard calls the screen\'s own discard', () => {
+ install([{ w: 40, r: 5, done: true }, { w: 40, r: 5 }, { w: 40, r: 5 }])
+ const onDiscard = vi.fn()
+ act(() => finishWorkoutSheet({ onDiscard }))
+ const host = sheetText()
+ expect(host.querySelector('h3').textContent).toBe('Finish early?')
+ expect(host.textContent).toContain('2 sets still unchecked. Finish the workout now?')
+ tapItem(host, 'Discard workout')
+ expect(onDiscard).toHaveBeenCalledOnce()
+ expect(S().active).not.toBeNull()
+ })
+
+ it('nothing checked: says so', () => {
+ install([{ w: 40, r: 5 }])
+ act(() => finishWorkoutSheet({ onDiscard: vi.fn() }))
+ const host = sheetText()
+ expect(host.querySelector('h3').textContent).toBe('Nothing logged yet')
+ expect(host.textContent).toContain('You haven’t checked off any sets.')
+ })
+})
diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx
index a89837ba2..cce7ebf8f 100644
--- a/frontend/src/sheets.jsx
+++ b/frontend/src/sheets.jsx
@@ -2739,6 +2739,26 @@ export function finishWorkout() {
if (done < total) { confirmSheet({ title: t('Finish early?'), message: tn('{0} set still unchecked. Finish the workout now?', '{0} sets still unchecked. Finish the workout now?', total - done), confirmText: t('Finish workout'), onConfirm: doFinishWorkout }); return }
doFinishWorkout()
}
+// The workout screen's Finish pill (v1.3.11): one sheet with both ways out, Finish and save or
+// Discard. It says what finishWorkout's confirm would have said about sets still unchecked, so
+// the save needs no second question. `onDiscard` is the screen's own discard, with its confirm.
+// The editor of a saved workout still saves at once.
+export function finishWorkoutSheet({ onDiscard } = {}) {
+ if (S().active?.editingWorkoutId) { saveWorkoutEdits(); return }
+ const A = S().active
+ if (!A) return
+ const done = setsDoneActive(A)
+ const total = setUnitsTotal(A.entries)
+ menuSheet({
+ title: !done ? t('Nothing logged yet') : done < total ? t('Finish early?') : t('Finish workout?'),
+ subtitle: !done ? t('You haven’t checked off any sets. Finish the workout anyway?')
+ : done < total ? tn('{0} set still unchecked. Finish the workout now?', '{0} sets still unchecked. Finish the workout now?', total - done) : null,
+ sections: [
+ { items: [{ icon: 'flag', accent: true, label: t('Finish and save'), onClick: doFinishWorkout }] },
+ { items: [onDiscard && { icon: 'trash', danger: true, label: t('Discard workout'), onClick: onDiscard }] },
+ ],
+ })
+}
function doFinishWorkout() {
const st = S()
const A = st.active
diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx
index dff5d4bbb..b0491a1f6 100644
--- a/frontend/src/views/Workout.jsx
+++ b/frontend/src/views/Workout.jsx
@@ -21,7 +21,7 @@ import WorkoutThumb, { hasWorkoutMedia } from '../components/WorkoutThumb.jsx'
import { workoutSettingsSheet } from '../components/WorkoutSettingsSheet.jsx'
import { durationSheet } from '../components/DurationWheel.jsx'
import { REST_MAX, fmtRest } from '../lib/duration.js'
-import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, finishWorkout, exitWorkoutEdit, 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, finishWorkoutSheet } from '../sheets.jsx'
import { afterScrollRestore, scrollRestorePending } from '../components/Modals.jsx'
import { effortColor } from '../lib/effort.js'
import Elapsed from '../components/Elapsed.jsx'
@@ -1525,14 +1525,16 @@ function ActiveWorkout() {
<div className={'whdr' + (listMode ? ' stick' : '')} ref={hdrRef}>
{/* ⌄ leaves the screen and keeps the session running (the tab bar's Resume brings it back);
in the editor of a saved workout it is the ✕ that closes the editor. Discard is in the ⋯
- menu now, and Finish is a labelled pill rather than a check that looked like a set tick. */}
+ menu now, and Finish is a labelled pill rather than a check that looked like a set tick: it
+ opens the Finish sheet (Finish and save, Discard), the editor's Save saves at once. */}
<div className="hdr whdr-bar">
{editing
? <button className="iconbtn" aria-label={t('Close editor')} title={t('Close editor')} onClick={() => exitWorkoutEdit()}><Icon name="xmark" /></button>
: <button className="iconbtn" aria-label={t('Minimize')} title={t('Minimize')} onClick={() => nav('/home')}><Icon name="chevronDown" /></button>}
<div className="whdr-mid"><div className="whdr-name">{A.name}</div><div className="sub">{(A.backfill || editing) ? fmtDate(A.d, true) : <Elapsed start={A.start} />} · {t('{0} sets', done + '/' + total)}</div></div>
<button className="iconbtn" aria-label={t('Workout options')} title={t('Workout options')} onClick={openViewMenu}><Icon name="more" /></button>
- <button className="btn primary pill whdr-finish" aria-label={editing ? t('Save changes') : undefined} onClick={finishWorkout}>{editing ? t('Save') : t('Finish')}</button>
+ <button className="btn primary pill whdr-finish" aria-label={editing ? t('Save changes') : undefined}
+ onClick={() => (editing ? finishWorkout() : finishWorkoutSheet({ onDiscard: discardWorkout }))}>{editing ? t('Save') : t('Finish')}</button>
</div>
<div className="wprog"><i style={{ width: (total ? done / total * 100 : 0) + '%' }} /></div>
</div>
diff --git a/frontend/src/views/Workout.stepper.test.jsx b/frontend/src/views/Workout.stepper.test.jsx
index ad5b6b64a..f726962a0 100644
--- a/frontend/src/views/Workout.stepper.test.jsx
+++ b/frontend/src/views/Workout.stepper.test.jsx
@@ -58,6 +58,7 @@ vi.mock('../sheets.jsx', () => ({
exConfigSheet: vi.fn(),
exerciseDetailSheet: vi.fn(),
finishWorkout: vi.fn(),
+ finishWorkoutSheet: vi.fn(),
workoutCompleteSheet: vi.fn(),
confirmSheet: vi.fn(),
swapActiveWorkoutExercise: vi.fn(),
diff --git a/frontend/src/views/Workout.superset-scroll.test.jsx b/frontend/src/views/Workout.superset-scroll.test.jsx
index df620aa01..432ada107 100644
--- a/frontend/src/views/Workout.superset-scroll.test.jsx
+++ b/frontend/src/views/Workout.superset-scroll.test.jsx
@@ -51,7 +51,7 @@ vi.mock('../store/useUI.js', () => {
vi.mock('react-router-dom', () => ({ useNavigate: () => () => {} }))
vi.mock('../sheets.jsx', () => ({
startFlow: vi.fn(), exercisePicker: vi.fn(), exConfigSheet: vi.fn(), exerciseDetailSheet: vi.fn(),
- finishWorkout: vi.fn(), exitWorkoutEdit: vi.fn(), workoutCompleteSheet: vi.fn(), confirmSheet: vi.fn(),
+ finishWorkout: vi.fn(), finishWorkoutSheet: vi.fn(), exitWorkoutEdit: vi.fn(), workoutCompleteSheet: vi.fn(), confirmSheet: vi.fn(),
swapActiveWorkoutExercise: vi.fn(), menuSheet: mocks.menuSheet, barWeightSheet: vi.fn(),
exerciseNoteSheet: vi.fn(), sessionNoteSheet: vi.fn(), renameWorkoutSheet: vi.fn(),
effortPickerSheet: vi.fn(), exerciseHistorySheet: vi.fn(), addRoutineToSessionSheet: vi.fn(),
diff --git a/frontend/src/views/Workout.test.jsx b/frontend/src/views/Workout.test.jsx
index 7eff8d1cb..f7d0c26d2 100644
--- a/frontend/src/views/Workout.test.jsx
+++ b/frontend/src/views/Workout.test.jsx
@@ -7,6 +7,7 @@ import { nextPrescription } from '../lib/progression.js'
import { buildCombinedEntries } from '../lib/session-merge.js'
import { buildCompletedWorkout } from '../lib/finish-workout.js'
import { isWarmupRow } from '../lib/workout-model.js'
+import { finishWorkout, finishWorkoutSheet } from '../sheets.jsx'
// A menu's actions in order, whether it came as one list or in groups (menuSheet `sections`).
const menuItemsOf = menu => (menu.sections ? menu.sections.flatMap(g => g.items || []) : menu.items || []).filter(Boolean)
@@ -77,6 +78,7 @@ vi.mock('../sheets.jsx', () => ({
exConfigSheet: mocks.exConfigSheet,
exerciseDetailSheet: vi.fn(),
finishWorkout: vi.fn(),
+ finishWorkoutSheet: vi.fn(),
exitWorkoutEdit: vi.fn(),
workoutCompleteSheet: mocks.workoutCompleteSheet,
confirmSheet: mocks.confirmSheet,
@@ -2192,6 +2194,12 @@ describe('the workout screen chrome (v1.3.11)', () => {
const pill = container.querySelector('.whdr-finish')
expect(pill.textContent).toBe('Finish')
expect(container.querySelector('button[aria-label="Discard"]')).toBeNull()
+ // the pill opens the Finish sheet, whose Discard is the screen's own (with its confirm)
+ finishWorkoutSheet.mockClear()
+ await click(pill)
+ expect(finishWorkoutSheet).toHaveBeenCalledOnce()
+ finishWorkoutSheet.mock.calls[0][0].onDiscard()
+ expect(mocks.confirmSheet.mock.calls.at(-1)[0].title).toBe('Discard workout?')
await click(container.querySelector('button[aria-label="Minimize"]'))
expect(mocks.nav).toHaveBeenCalledWith('/home')
expect(mocks.S.active).not.toBeNull()
@@ -2202,6 +2210,10 @@ describe('the workout screen chrome (v1.3.11)', () => {
const pill = container.querySelector('.whdr-finish')
expect(pill.textContent).toBe('Save')
expect(pill.getAttribute('aria-label')).toBe('Save changes')
+ finishWorkoutSheet.mockClear(); finishWorkout.mockClear()
+ await click(pill)
+ expect(finishWorkout).toHaveBeenCalledOnce() // the editor saves at once
+ expect(finishWorkoutSheet).not.toHaveBeenCalled()
expect(container.querySelector('button[aria-label="Close editor"]')).toBeTruthy()
expect(container.querySelector('button[aria-label="Minimize"]')).toBeNull()
})