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
feat: keep timers ready and allow optional overtime
Space-Hermes0783e2ef752d
diff --git a/frontend/src/components/RestTimer.jsx b/frontend/src/components/RestTimer.jsxindex 9599f61a3..75fd09154 100644--- a/frontend/src/components/RestTimer.jsx+++ b/frontend/src/components/RestTimer.jsx@@ -21,11 +21,11 @@ export default function RestTimer() {return () => document.body.classList.remove('resting')}, [!!on])if (!on) return null- const pct = (on.left / on.total) * 100+ const pct = Math.max(0, Math.min(100, (on.left / on.total) * 100))if (work) return (<div id="timer" className="working">- <div className="t">{clock(work.left)}</div>+ <div className="t">{work.left <= 0 && work.overtime ? '+' + clock(-work.left) : clock(work.left)}</div><div className="grow">{work.label && <div className="lbl">{work.label}</div>}<div className="bar"><i style={{ width: pct + '%' }} /></div>@@ -41,13 +41,13 @@ export default function RestTimer() {return (<div id="timer" className="rest"><div className="head">- <div className="t">{clock(timer.left)}</div>+ <div className="t" role={timer.ready ? 'status' : undefined}>{timer.ready ? t('Ready') : clock(timer.left)}</div><div className="bar"><i style={{ width: pct + '%' }} /></div></div><div className="acts"><Button size="sm" icon="minus" onClick={() => addRest(-15)}>15s</Button><Button size="sm" icon="plus" onClick={() => addRest(15)}>15s</Button>- <Button size="sm" variant="primary" className="skip" onClick={stopRest}>{t('Skip')}</Button>+ <Button size="sm" variant="primary" className="skip" onClick={stopRest}>{t(timer.ready ? 'Dismiss' : 'Skip')}</Button></div></div>)diff --git a/frontend/src/components/RestTimer.ready.test.jsx b/frontend/src/components/RestTimer.ready.test.jsxnew file mode 100644index 000000000..5e45f9a6f--- /dev/null+++ b/frontend/src/components/RestTimer.ready.test.jsx@@ -0,0 +1,63 @@+// @vitest-environment happy-dom+import React, { act } from 'react'+import { createRoot } from 'react-dom/client'+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import RestTimer from './RestTimer.jsx'+import { useUI } from '../store/useUI.js'+import { useStore } from '../store/useStore.js'++globalThis.IS_REACT_ACT_ENVIRONMENT = true++vi.mock('../lib/sound.js', () => ({ beep: vi.fn(), vibrate: vi.fn() }))++let host, root, originalS++beforeEach(() => {+ vi.useFakeTimers()+ originalS = useStore.getState().S+ useStore.setState({ S: { ...originalS, sound: false, timedSetOvertime: true } })+ useUI.setState({ timer: null, work: null, timerFlashId: 0 })+ host = document.createElement('div')+ document.body.appendChild(host)+ root = createRoot(host)+})++afterEach(() => {+ act(() => root.render(null))+ useUI.getState().stopRest()+ useUI.getState().stopWork()+ useStore.setState({ S: originalS })+ host.remove()+ vi.useRealTimers()+})++const mount = () => act(() => root.render(<RestTimer />))++describe('RestTimer Ready and overtime display', () => {+ it('keeps Ready and its Dismiss action across a remount', () => {+ act(() => useUI.getState().startRest(1, 4))+ act(() => vi.advanceTimersByTime(1000))+ mount()++ expect(host.querySelector('#timer .t').textContent).toBe('Ready')+ expect(host.querySelector('#timer .t').getAttribute('role')).toBe('status')+ expect(host.querySelector('#timer .skip').textContent).toBe('Dismiss')+ expect(useUI.getState().timer.forIdx).toBe(4)++ act(() => root.render(null))+ expect(host.querySelector('#timer')).toBeNull()+ mount()+ expect(host.querySelector('#timer .t').textContent).toBe('Ready')+ act(() => host.querySelector('#timer .skip').click())+ expect(useUI.getState().timer).toBeNull()+ })++ it('shows a plus clock and an empty bar during opted-in overtime', () => {+ act(() => useUI.getState().startWork(2, 'Hold', vi.fn()))+ mount()+ act(() => vi.advanceTimersByTime(5000))++ expect(host.querySelector('#timer .t').textContent).toBe('+0:03')+ expect(host.querySelector('#timer .bar i').style.width).toBe('0%')+ })+})diff --git a/frontend/src/components/ui.jsx b/frontend/src/components/ui.jsxindex 66fdc18ac..d8395a9d3 100644--- a/frontend/src/components/ui.jsx+++ b/frontend/src/components/ui.jsx@@ -76,9 +76,10 @@ export const SearchField = forwardRef(function SearchField({ value, onChange, on/* ============================ switch ============================ */-export function Switch({ checked, onChange, disabled }) {+export function Switch({ checked, onChange, disabled, ...accessibility }) {return (<button+ {...accessibility}role="switch"aria-checked={!!checked}disabled={disabled}diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.jsindex f692c6095..b0dfc831b 100644--- a/frontend/src/lib/pt-br-locale.test.js+++ b/frontend/src/lib/pt-br-locale.test.js@@ -27,7 +27,7 @@ describe('Brazilian Portuguese locale', () => {.sort(byCodeUnit)const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex')- expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(644)+ expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(646)expect(inherited).toHaveLength(647)// If this fails, review the changed keys and wording before accepting a new hash. From// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --listdiff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex fad9cba71..2366fd7d9 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -1256,4 +1256,6 @@ export default {'already added': 'schon drin','no exercises': 'keine Übungen','Pick equipment': 'Gerät wählen',+ 'Keep timing after target': 'Nach dem Ziel weiterzählen',+ 'Timed sets continue up to 15 extra minutes. Tap Done to log the actual duration.': 'Zeitbasierte Sätze laufen bis zu 15 zusätzliche Minuten weiter. Tippe auf „Fertig“, um die tatsächliche Dauer zu speichern.',}diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex 68e2144a4..c22a46231 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -1236,4 +1236,6 @@ export default {'already added': 'ya añadido','no exercises': 'sin ejercicios','Pick equipment': 'Elegir equipamiento',+ 'Keep timing after target': 'Seguir contando después del objetivo',+ 'Timed sets continue up to 15 extra minutes. Tap Done to log the actual duration.': 'Las series cronometradas continúan hasta 15 minutos extra. Toca «Listo» para registrar la duración real.',}diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex ff4b17cfd..2fae1cef8 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -1236,4 +1236,6 @@ export default {'already added': 'déjà ajouté','no exercises': 'aucun exercice','Pick equipment': 'Choisir l’équipement',+ 'Keep timing after target': 'Continuer après l’objectif',+ 'Timed sets continue up to 15 extra minutes. Tap Done to log the actual duration.': 'Les séries chronométrées continuent jusqu’à 15 minutes supplémentaires. Touchez « Terminé » pour enregistrer la durée réelle.',}diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex da466b3f2..7bc510158 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -1236,4 +1236,6 @@ export default {'already added': 'पहले से जोड़ा हुआ','no exercises': 'कोई व्यायाम नहीं','Pick equipment': 'उपकरण चुनें',+ 'Keep timing after target': 'लक्ष्य के बाद भी समय जारी रखें',+ 'Timed sets continue up to 15 extra minutes. Tap Done to log the actual duration.': 'समयबद्ध सेट 15 अतिरिक्त मिनट तक जारी रहेंगे। वास्तविक अवधि दर्ज करने के लिए “पूरा” दबाएँ।',}diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex f99fa4ff9..522d44182 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -1239,4 +1239,6 @@ export default {'already added': 'már hozzáadva','no exercises': 'nincs gyakorlat','Pick equipment': 'Eszköz kiválasztása',+ 'Keep timing after target': 'Időzítés folytatása a cél után',+ 'Timed sets continue up to 15 extra minutes. Tap Done to log the actual duration.': 'Az időzített sorozatok legfeljebb 15 extra percig folytatódnak. A tényleges idő rögzítéséhez koppints a Kész gombra.',}diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 3c8c8415f..b3e947ac4 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -1236,4 +1236,6 @@ export default {'already added': 'già aggiunto','no exercises': 'nessun esercizio','Pick equipment': 'Scegli l’attrezzatura',+ 'Keep timing after target': 'Continua a cronometrare dopo l’obiettivo',+ 'Timed sets continue up to 15 extra minutes. Tap Done to log the actual duration.': 'Le serie a tempo continuano fino a 15 minuti extra. Tocca Fine per registrare la durata effettiva.',}diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex 48ea492ff..e0af4264a 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -1236,4 +1236,6 @@ export default {'already added': '이미 추가됨','no exercises': '운동 없음','Pick equipment': '기구 선택',+ 'Keep timing after target': '목표 시간 후에도 계속 측정',+ 'Timed sets continue up to 15 extra minutes. Tap Done to log the actual duration.': '시간 제한 세트는 최대 15분 추가로 계속됩니다. 실제 시간을 기록하려면 완료를 누르세요.',}diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex 213baab72..5c8e35494 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -1236,4 +1236,6 @@ export default {'already added': 'już dodano','no exercises': 'brak ćwiczeń','Pick equipment': 'Wybierz sprzęt',+ 'Keep timing after target': 'Kontynuuj pomiar po czasie docelowym',+ 'Timed sets continue up to 15 extra minutes. Tap Done to log the actual duration.': 'Serie na czas trwają do 15 dodatkowych minut. Stuknij Gotowe, aby zapisać rzeczywisty czas.',}diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.jsindex 324b0f2ae..6aa78992f 100644--- a/frontend/src/locales/pt-BR.js+++ b/frontend/src/locales/pt-BR.js@@ -671,6 +671,8 @@ export const PT_BR_OVERRIDES = {'Download & Install': 'Baixar e instalar','Starting download…': 'Iniciando download…','Downloading update…': 'Baixando atualização…',+ 'Keep timing after target': 'Continuar contando após o objetivo',+ 'Timed sets continue up to 15 extra minutes. Tap Done to log the actual duration.': 'As séries cronometradas continuam por até 15 minutos extras. Toque em Concluído para registrar a duração real.',}export default { ...pt, ...PT_BR_OVERRIDES }diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex ea44d465c..b009cddad 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -1236,4 +1236,6 @@ export default {'already added': 'já adicionado','no exercises': 'sem exercícios','Pick equipment': 'Escolher equipamento',+ 'Keep timing after target': 'Continuar a contar após o objetivo',+ 'Timed sets continue up to 15 extra minutes. Tap Done to log the actual duration.': 'As séries cronometradas continuam até mais 15 minutos. Toca em Concluído para registar a duração real.',}diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex 46ce8efb2..f094d8113 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -1236,4 +1236,6 @@ export default {'already added': 'уже добавлено','no exercises': 'нет упражнений','Pick equipment': 'Выбрать оборудование',+ 'Keep timing after target': 'Продолжать отсчёт после цели',+ 'Timed sets continue up to 15 extra minutes. Tap Done to log the actual duration.': 'Подходы на время продолжаются ещё до 15 минут. Нажмите «Готово», чтобы записать фактическую длительность.',}diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex f2b372dbd..15b0cb89d 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -1247,4 +1247,6 @@ export default {'already added': 'เพิ่มแล้ว','no exercises': 'ไม่มีท่าออกกำลังกาย','Pick equipment': 'เลือกอุปกรณ์',+ 'Keep timing after target': 'จับเวลาต่อหลังถึงเป้าหมาย',+ 'Timed sets continue up to 15 extra minutes. Tap Done to log the actual duration.': 'เซ็ตแบบจับเวลาจะทำต่อได้อีกสูงสุด 15 นาที แตะ “เสร็จแล้ว” เพื่อบันทึกระยะเวลาจริง',}diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex 95720d15e..870b7c45d 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -1236,4 +1236,6 @@ export default {'already added': 'zaten ekli','no exercises': 'egzersiz yok','Pick equipment': 'Ekipman seç',+ 'Keep timing after target': 'Hedeften sonra zamanlamayı sürdür',+ 'Timed sets continue up to 15 extra minutes. Tap Done to log the actual duration.': 'Süreli setler en fazla 15 dakika daha devam eder. Gerçek süreyi kaydetmek için Bitti’ye dokunun.',}diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex f45110eec..36cf6c1b7 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -1236,4 +1236,6 @@ export default {'already added': '已添加','no exercises': '没有动作','Pick equipment': '选择器械',+ 'Keep timing after target': '达到目标后继续计时',+ 'Timed sets continue up to 15 extra minutes. Tap Done to log the actual duration.': '计时组最多继续 15 分钟。点击“完成”记录实际时长。',}diff --git a/frontend/src/store/useStore.js b/frontend/src/store/useStore.jsindex 79451dfd8..91d48699d 100644--- a/frontend/src/store/useStore.js+++ b/frontend/src/store/useStore.js@@ -21,7 +21,7 @@ const SYNC_KEY = 'gym_sync'const CHECK_MIN_MS = 3000 // rev checks closer together than this are the same event (focus + visibility)const POLL_MS = 30000 // while the app is open and signed in, ask the server for its revision this oftenexport const DEF = {- unit: 'kg', restSec: 90, restPauseSec: 15, sound: true, soundOnSilent: false, timerFlash: false, keepAwake: true, lang: 'en',+ unit: 'kg', restSec: 90, restPauseSec: 15, sound: true, soundOnSilent: false, timerFlash: false, timedSetOvertime: false, keepAwake: true, lang: 'en',theme: 'dark', accent: 'lime', body: 'male', targetW: null,bodyweight: [], routines: [], week: {}, dayPlan: {},exWeights: {}, workouts: [], active: null, customEx: [], gifSize: 'full',@@ -612,4 +612,4 @@ export const useStore = create((set, get) => {}})-export { hasData }\ No newline at end of file+export { hasData }diff --git a/frontend/src/store/useUI.js b/frontend/src/store/useUI.jsindex 801314e92..210a68dab 100644--- a/frontend/src/store/useUI.js+++ b/frontend/src/store/useUI.js@@ -65,13 +65,14 @@ let timerTick = nulllet workInt = nulllet workTick = nulllet workDone = null+const MAX_WORK_OVERTIME_SEC = 15 * 60export const useUI = create((set, get) => ({sheets: [], // { id, render:(close)=>JSX, kind:'sheet'|'center', locked }toastMsg: '',- timer: null, // rest countdown between sets — { left, total, endsAt, forIdx }+ timer: null, // rest countdown between sets — { left, total, endsAt, forIdx, ready? }// forIdx: index of the active entry whose set started the rest (undefined when unknown)- work: null, // work countdown DURING a timed set (issue #16) — { left, total, endsAt, label }+ work: null, // work countdown DURING a timed set (issue #16) — { left, total, endsAt, label, overtime? }timerFlashId: 0, // changing the id retriggers the theme-blink visual alertflashTimer() {@@ -105,7 +106,7 @@ export const useUI = create((set, get) => ({pushRestTimer(sec)timerTick = () => {const tm = get().timer- if (!tm) return+ if (!tm || tm.ready) returnconst left = Math.max(0, Math.round((tm.endsAt - Date.now()) / 1000))const seenLive = !document.hidden && pageHiddenAt === nullif (!document.hidden) pageHiddenAt = null@@ -120,7 +121,12 @@ export const useUI = create((set, get) => ({// without push permission, gets no notification, and a countdown that silently vanishes// on reopen reads like a bug. Only the loud parts (beep, vibration, flash) are gated.get().toast(t('Rest over — next set!'))- maybeRestNotification(); get().stopRest(); return+ maybeRestNotification()+ cancelPushRestTimer()+ if (timerInt) clearInterval(timerInt); timerInt = null+ if (timerTick) document.removeEventListener('visibilitychange', timerTick); timerTick = null+ set({ timer: { ...tm, left: 0, ready: true } })+ return}if (left <= 3) beep(snd, 660, 0.1)set({ timer: { ...tm, left } })@@ -131,6 +137,7 @@ export const useUI = create((set, get) => ({addRest(sec) {const tm = get().timerif (!tm) return+ if (tm.ready) { if (sec > 0) get().startRest(sec, tm.forIdx); else get().stopRest(); return }const left = tm.left + sec// taking off more than is left means "I'm ready now" — same as skipping, and it keeps a// negative duration out of both the progress bar and the server-side push schedule@@ -166,23 +173,24 @@ export const useUI = create((set, get) => ({const total = Math.max(1, Math.round(sec) || 1)const endsAt = Date.now() + total * 1000workDone = onDone- set({ work: { left: total, total, endsAt, label } })+ set({ work: { left: total, total, endsAt, label, overtime: useStore.getState().S.timedSetOvertime === true } })workTick = () => {const wk = get().workif (!wk) return- const left = Math.max(0, Math.round((wk.endsAt - Date.now()) / 1000))+ const left = Math.max(wk.overtime ? -MAX_WORK_OVERTIME_SEC : 0, Math.round((wk.endsAt - Date.now()) / 1000))const seenLive = !document.hidden && pageHiddenAt === nullif (!document.hidden) pageHiddenAt = nullif (left === wk.left) returnconst snd = useStore.getState().S.soundif (left <= 0) {- if (seenLive) {+ if (seenLive && !wk.alerted) {beep(snd, 880, 0.15); beep(snd, 880, 0.15, 0.25); beep(snd, 1320, 0.4, 0.5)vibrate([200, 100, 200]); get().flashTimer()}+ if (wk.overtime && left > -MAX_WORK_OVERTIME_SEC) { set({ work: { ...wk, left, alerted: true } }); return }const done = workDoneget().stopWork()- if (done) done(wk.total)+ if (done) done(wk.total - left)return}if (left <= 3) beep(snd, 660, 0.1)@@ -195,7 +203,8 @@ export const useUI = create((set, get) => ({finishWorkEarly() {const wk = get().workif (!wk) return- const elapsed = Math.max(1, wk.total - wk.left)+ const startedAt = wk.endsAt - wk.total * 1000+ const elapsed = Math.max(1, Math.min(wk.total + (wk.overtime ? MAX_WORK_OVERTIME_SEC : 0), Math.round((Date.now() - startedAt) / 1000)))const done = workDonevibrate(30)get().stopWork()diff --git a/frontend/src/store/useUI.test.js b/frontend/src/store/useUI.test.jsindex 2d7d2e33b..a38f58364 100644--- a/frontend/src/store/useUI.test.js+++ b/frontend/src/store/useUI.test.js@@ -69,14 +69,14 @@ describe('opt-in timer screen flash', () => {const goVisible = () => { Object.defineProperty(document, 'hidden', { value: false, configurable: true }); document.dispatchEvent(new Event('visibilitychange')) }afterEach(() => goVisible()) // leave document.hidden the way every other test expects it- it('does not flash a rest that expires while the app is hidden, even once reopened', () => {+ it('does not flash a rest that expires while the app is hidden, even once reopened, but keeps Ready visible', () => {useStore.setState({ S: { ...useStore.getState().S, timerFlash: true } })useUI.getState().startRest(90)goHidden()vi.setSystemTime(Date.now() + 91_000) // deadline passes with no ticks — the app was actually closed/suspendedgoVisible() // reopening re-fires visibilitychange, which is how the bug used to triggerexpect(useUI.getState().timerFlashId).toBe(0)- expect(useUI.getState().timer).toBe(null)+ expect(useUI.getState().timer).toMatchObject({ left: 0, ready: true })})it('does not flash a timed exercise that finishes while the app is hidden', () => {@@ -96,3 +96,69 @@ describe('opt-in timer screen flash', () => {expect(useUI.getState().timerFlashId).toBe(1)})})++describe('rest readiness and optional timed-set overtime', () => {+ let originalSettings++ beforeEach(() => {+ vi.useFakeTimers()+ originalSettings = useStore.getState().S+ useStore.setState({ S: { ...originalSettings, sound: false, timerFlash: true, timedSetOvertime: false } })+ useUI.setState({ timer: null, work: null, timerFlashId: 0 })+ })++ afterEach(() => {+ useUI.getState().stopRest()+ useUI.getState().stopWork()+ useStore.setState({ S: originalSettings })+ vi.useRealTimers()+ })++ it('keeps Ready and its rest owner until dismissed or restarted', () => {+ useUI.getState().startRest(1, 2)+ vi.advanceTimersByTime(1000)+ vi.advanceTimersByTime(5000)+ expect(useUI.getState().timer).toMatchObject({ left: 0, ready: true, forIdx: 2 })+ useUI.getState().addRest(15)+ expect(useUI.getState().timer).toMatchObject({ left: 15, forIdx: 2 })+ expect(useUI.getState().timer.ready).toBeUndefined()+ useUI.getState().addRest(-15)+ expect(useUI.getState().timer).toBeNull()+ })++ it('keeps an opted-in hold through its deadline and logs actual overtime on Done', () => {+ useStore.setState({ S: { ...useStore.getState().S, timedSetOvertime: true } })+ const done = vi.fn()+ useUI.getState().startWork(2, 'Hold', done)+ vi.advanceTimersByTime(2000)+ const flash = useUI.getState().timerFlashId+ vi.advanceTimersByTime(5000)+ expect(done).not.toHaveBeenCalled()+ expect(useUI.getState().work).toMatchObject({ left: -5, overtime: true, alerted: true })+ expect(useUI.getState().timerFlashId).toBe(flash)+ useUI.getState().finishWorkEarly()+ expect(done).toHaveBeenCalledExactlyOnceWith(7)+ })++ it('caps unattended overtime at 15 minutes and logs it once at the deadline', () => {+ useStore.setState({ S: { ...useStore.getState().S, timedSetOvertime: true } })+ const done = vi.fn()+ useUI.getState().startWork(1, 'Hold', done)+ vi.advanceTimersByTime(901000)+ expect(done).toHaveBeenCalledExactlyOnceWith(901)+ expect(useUI.getState().work).toBeNull()+ })++ it('cancels an overtime hold without logging and clears its old owner callback', () => {+ useStore.setState({ S: { ...useStore.getState().S, timedSetOvertime: true } })+ const canceled = vi.fn()+ const replacement = vi.fn()+ useUI.getState().startWork(2, 'Canceled', canceled)+ useUI.getState().stopWork()+ useUI.getState().startWork(2, 'Replacement', replacement)+ vi.advanceTimersByTime(2000)+ useUI.getState().stopWork()+ expect(canceled).not.toHaveBeenCalled()+ expect(replacement).not.toHaveBeenCalled()+ })+})diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsxindex 1682ba1cd..81b50d4c1 100644--- a/frontend/src/views/Settings.jsx+++ b/frontend/src/views/Settings.jsx@@ -324,6 +324,11 @@ export default function Settings() {<Row icon="sun" iconTint="var(--yellow)" title={t('Flash screen when timer ends')}><Switch checked={!!S.timerFlash} onChange={v => update(s => { s.timerFlash = v })} /></Row>+ <Row icon="timer" title={t('Keep timing after target')}+ subtitle={t('Timed sets continue up to 15 extra minutes. Tap Done to log the actual duration.')}>+ <Switch aria-label={t('Keep timing after target')} checked={!!S.timedSetOvertime}+ onChange={v => update(s => { s.timedSetOvertime = v })} />+ </Row>{/* Two names for the same judgement, so the column asks in the scale you already think in.The (i) sits before the control — you read it on the way to the choice, not after it. */}<Row icon="target" iconTint="var(--purple)" title={t('Effort per set')}>diff --git a/frontend/src/views/Settings.sound.test.jsx b/frontend/src/views/Settings.sound.test.jsxindex 10feccb1d..9af042db5 100644--- a/frontend/src/views/Settings.sound.test.jsx+++ b/frontend/src/views/Settings.sound.test.jsx@@ -130,3 +130,16 @@ describe('Settings — Sounds switch unlocks audio from the tap', () => {expect(unlock).not.toHaveBeenCalled()})})++describe('Settings — optional timed-set overtime', () => {+ it('offers the opt-in beside the timer alerts and writes the preference', () => {+ mount()+ const row = rowTitled('Keep timing after target')+ expect(row).toBeTruthy()+ expect(row.querySelector('.lrow-s').textContent).toBe('Timed sets continue up to 15 extra minutes. Tap Done to log the actual duration.')+ const sw = switchIn(row)+ expect(sw.getAttribute('aria-label')).toBe('Keep timing after target')+ act(() => { sw.click() })+ expect(mocks.S.timedSetOvertime).toBe(true)+ })+})