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.

feat(timer): add opt-in visual completion flash

mzspicoli1aef1d882be5
diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index 04487c7e4..84d9d6975 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -15,6 +15,7 @@ import ErrorBoundary from './components/ErrorBoundary.jsx'
import Modals from './components/Modals.jsx'
import Toast from './components/Toast.jsx'
import RestTimer from './components/RestTimer.jsx'
+import TimerFlash from './components/TimerFlash.jsx'
import Login from './views/Login.jsx'
import MobileOnboarding from './views/MobileOnboarding.jsx'
import Home from './views/Home.jsx'
@@ -103,6 +104,7 @@ function Shell() {
<RestTimer />
<Modals />
<Toast />
+ <TimerFlash />
</>
)
}
diff --git a/frontend/src/components/TimerFlash.jsx b/frontend/src/components/TimerFlash.jsx
new file mode 100644
index 000000000..f620237c7
--- /dev/null
+++ b/frontend/src/components/TimerFlash.jsx
@@ -0,0 +1,8 @@
+import { useUI } from '../store/useUI.js'
+
+// A new key restarts the CSS sequence even when two timers finish close together.
+// The layer never catches taps and ends transparent, so it can safely stay mounted.
+export default function TimerFlash() {
+ const id = useUI(s => s.timerFlashId)
+ return id ? <div key={id} className="timer-flash" aria-hidden="true" /> : null
+}
diff --git a/frontend/src/index.css b/frontend/src/index.css
index a34845995..9a35e26a0 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -751,6 +751,19 @@ h4.sec{
.glyph-cell:active{transform:scale(.92)}
.glyph-cell.on{background:var(--acc);color:var(--on-acc)}
+/* --- opt-in timer completion flash ---
+ Four deliberate pulses over 2.4s stay below three flashes per second. Transparent
+ gaps keep the black and white pulses visually distinct. */
+.timer-flash{
+ position:fixed;inset:0;z-index:1000;pointer-events:none;opacity:0;
+ animation:timer-flash-four 2.4s linear both;
+}
+@keyframes timer-flash-four{
+ 0%,20%,28%,48%,56%,76%,84%,100%{opacity:0}
+ 4%,16%,60%,72%{background:#000;opacity:1}
+ 32%,44%,88%,96%{background:#fff;opacity:1}
+}
+
/* --- big weight readout --- */
.bwstep{display:flex;align-items:center;justify-content:center;gap:18px;margin:14px 0 6px}
.bw-pm{
diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js
index 91a4a63a8..da2e4eaf8 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(291)
+ expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(292)
expect(inherited).toHaveLength(449)
// If this fails, review the changed keys and wording before accepting a new hash. From
// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list
diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js
index 8c911556c..880d00493 100644
--- a/frontend/src/locales/de.js
+++ b/frontend/src/locales/de.js
@@ -298,6 +298,7 @@ export default {
'Weight unit': 'Gewichtseinheit',
'Rest timer': 'Pausen-Timer',
'Sounds': 'Töne',
+ 'Flash screen when timer ends': 'Bildschirm bei Timer-Ende blinken lassen',
'Note: switching units only changes the label — logged numbers are not converted.': 'Hinweis: Der Einheitenwechsel ändert nur die Beschriftung — eingetragene Zahlen werden nicht umgerechnet.',
'Data': 'Daten',
'Export backup (JSON)': 'Backup exportieren (JSON)',
diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js
index b1ea117af..fc3d2df08 100644
--- a/frontend/src/locales/es.js
+++ b/frontend/src/locales/es.js
@@ -284,6 +284,7 @@ export default {
'Weight unit': 'Unidad de peso',
'Rest timer': 'Temporizador de descanso',
'Sounds': 'Sonidos',
+ 'Flash screen when timer ends': 'Hacer parpadear la pantalla al finalizar el temporizador',
'Note: switching units only changes the label — logged numbers are not converted.': 'Nota: cambiar la unidad solo cambia la etiqueta — los números registrados no se convierten.',
'Data': 'Datos',
'Export backup (JSON)': 'Exportar copia (JSON)',
diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js
index 387bf2564..7dbe6651b 100644
--- a/frontend/src/locales/fr.js
+++ b/frontend/src/locales/fr.js
@@ -284,6 +284,7 @@ export default {
'Weight unit': 'Unité de poids',
'Rest timer': 'Minuteur de repos',
'Sounds': 'Sons',
+ 'Flash screen when timer ends': 'Faire clignoter l’écran à la fin du minuteur',
'Note: switching units only changes the label — logged numbers are not converted.': 'Note : changer d’unité ne change que l’étiquette — les nombres enregistrés ne sont pas convertis.',
'Data': 'Données',
'Export backup (JSON)': 'Exporter une sauvegarde (JSON)',
diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js
index 09038df9c..e52606b77 100644
--- a/frontend/src/locales/hi.js
+++ b/frontend/src/locales/hi.js
@@ -284,6 +284,7 @@ export default {
'Weight unit': 'वज़न की इकाई',
'Rest timer': 'आराम टाइमर',
'Sounds': 'ध्वनियाँ',
+ 'Flash screen when timer ends': 'टाइमर खत्म होने पर स्क्रीन फ्लैश करें',
'Note: switching units only changes the label — logged numbers are not converted.': 'नोट: इकाई बदलने से केवल लेबल बदलता है — दर्ज संख्याएँ परिवर्तित नहीं होतीं।',
'Data': 'डेटा',
'Export backup (JSON)': 'बैकअप निर्यात करें (JSON)',
diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js
index 1c53c34ac..c7bdf88cb 100644
--- a/frontend/src/locales/it.js
+++ b/frontend/src/locales/it.js
@@ -284,6 +284,7 @@ export default {
'Weight unit': 'Unità di peso',
'Rest timer': 'Timer di riposo',
'Sounds': 'Suoni',
+ 'Flash screen when timer ends': 'Fai lampeggiare lo schermo alla fine del timer',
'Note: switching units only changes the label — logged numbers are not converted.': 'Nota: cambiare unità cambia solo l’etichetta — i numeri registrati non vengono convertiti.',
'Data': 'Dati',
'Export backup (JSON)': 'Esporta backup (JSON)',
diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js
index 170f6d375..398892986 100644
--- a/frontend/src/locales/ko.js
+++ b/frontend/src/locales/ko.js
@@ -284,6 +284,7 @@ export default {
'Weight unit': '무게 단위',
'Rest timer': '휴식 타이머',
'Sounds': '소리',
+ 'Flash screen when timer ends': '타이머 종료 시 화면 깜박임',
'Note: switching units only changes the label — logged numbers are not converted.': '참고: 단위 변경은 표기만 바꿉니다 — 기록된 숫자는 환산되지 않아요.',
'Data': '데이터',
'Export backup (JSON)': '백업 내보내기 (JSON)',
diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js
index b914fbc37..cac575e9f 100644
--- a/frontend/src/locales/pl.js
+++ b/frontend/src/locales/pl.js
@@ -284,6 +284,7 @@ export default {
'Weight unit': 'Jednostka wagi',
'Rest timer': 'Minutnik przerwy',
'Sounds': 'Dźwięki',
+ 'Flash screen when timer ends': 'Migaj ekranem po zakończeniu minutnika',
'Note: switching units only changes the label — logged numbers are not converted.': 'Uwaga: zmiana jednostki zmienia tylko etykietę — zapisane liczby nie są przeliczane.',
'Data': 'Dane',
'Export backup (JSON)': 'Eksportuj kopię (JSON)',
diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js
index 11022ba6b..3bc59b81c 100644
--- a/frontend/src/locales/pt-BR.js
+++ b/frontend/src/locales/pt-BR.js
@@ -90,6 +90,7 @@ export const PT_BR_OVERRIDES = {
'Create passkey profile': 'Criar perfil com chave de acesso',
'synced with your profile': 'sincronizado com seu perfil',
'The screen stays on while a workout is running, so you don’t have to unlock your phone between sets.': 'A tela permanece ligada durante o treino, para você não precisar desbloquear o celular entre as séries.',
+ 'Flash screen when timer ends': 'Piscar a tela quando o temporizador terminar',
'Note: switching units only changes the label — logged numbers are not converted.': 'Observação: trocar a unidade altera somente o rótulo — os valores registrados não são convertidos.',
'Export backup (JSON)': 'Exportar backup (JSON)',
'Import backup': 'Importar backup',
diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js
index d14ccb131..29403f385 100644
--- a/frontend/src/locales/pt.js
+++ b/frontend/src/locales/pt.js
@@ -284,6 +284,7 @@ export default {
'Weight unit': 'Unidade de peso',
'Rest timer': 'Temporizador de descanso',
'Sounds': 'Sons',
+ 'Flash screen when timer ends': 'Piscar o ecrã quando o temporizador terminar',
'Note: switching units only changes the label — logged numbers are not converted.': 'Nota: mudar a unidade só muda o rótulo — os números registados não são convertidos.',
'Data': 'Dados',
'Export backup (JSON)': 'Exportar cópia (JSON)',
diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js
index 1e260d196..b696e0960 100644
--- a/frontend/src/locales/ru.js
+++ b/frontend/src/locales/ru.js
@@ -284,6 +284,7 @@ export default {
'Weight unit': 'Единица веса',
'Rest timer': 'Таймер отдыха',
'Sounds': 'Звуки',
+ 'Flash screen when timer ends': 'Мигать экраном по окончании таймера',
'Note: switching units only changes the label — logged numbers are not converted.': 'Примечание: смена единиц меняет только подпись — записанные числа не пересчитываются.',
'Data': 'Данные',
'Export backup (JSON)': 'Экспорт резервной копии (JSON)',
diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js
index 79b312557..98623744c 100644
--- a/frontend/src/locales/tr.js
+++ b/frontend/src/locales/tr.js
@@ -284,6 +284,7 @@ export default {
'Weight unit': 'Ağırlık birimi',
'Rest timer': 'Dinlenme sayacı',
'Sounds': 'Sesler',
+ 'Flash screen when timer ends': 'Zamanlayıcı bitince ekranı yanıp söndür',
'Note: switching units only changes the label — logged numbers are not converted.': 'Not: birim değiştirmek sadece etiketi değiştirir — kayıtlı sayılar dönüştürülmez.',
'Data': 'Veriler',
'Export backup (JSON)': 'Yedeği dışa aktar (JSON)',
diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js
index 533434d66..58b1d5053 100644
--- a/frontend/src/locales/zh.js
+++ b/frontend/src/locales/zh.js
@@ -284,6 +284,7 @@ export default {
'Weight unit': '重量单位',
'Rest timer': '休息计时',
'Sounds': '声音',
+ 'Flash screen when timer ends': '计时结束时闪烁屏幕',
'Note: switching units only changes the label — logged numbers are not converted.': '注意:切换单位只改变标签——已记录的数字不会换算。',
'Data': '数据',
'Export backup (JSON)': '导出备份(JSON)',
diff --git a/frontend/src/store/useStore.js b/frontend/src/store/useStore.js
index 133dfcf61..6862673e7 100644
--- a/frontend/src/store/useStore.js
+++ b/frontend/src/store/useStore.js
@@ -9,7 +9,7 @@ import { loadRemote, chooseLocal, forgetRemote, connect } from '../lib/remote.js
const KEY = 'gym_state_v1'
export const DEF = {
- unit: 'kg', restSec: 90, restPauseSec: 15, sound: true, keepAwake: true, lang: 'en',
+ unit: 'kg', restSec: 90, restPauseSec: 15, sound: true, timerFlash: false, keepAwake: true, lang: 'en',
theme: 'dark', accent: 'lime', body: 'male', targetW: null,
bodyweight: [], routines: [], week: {}, dayPlan: {},
exWeights: {}, workouts: [], active: null, customEx: [], gifSize: 'full',
diff --git a/frontend/src/store/useUI.js b/frontend/src/store/useUI.js
index 53d292880..f9e5563b6 100644
--- a/frontend/src/store/useUI.js
+++ b/frontend/src/store/useUI.js
@@ -58,6 +58,12 @@ export const useUI = create((set, get) => ({
toastMsg: '',
timer: null, // rest countdown between sets — { left, total, endsAt }
work: null, // work countdown DURING a timed set (issue #16) — { left, total, endsAt, label }
+ timerFlashId: 0, // changing the id remounts the four-pulse visual alert
+
+ flashTimer() {
+ if (!useStore.getState().S.timerFlash) return
+ set(s => ({ timerFlashId: s.timerFlashId + 1 }))
+ },
openSheet(render, { kind = 'sheet', locked = false } = {}) {
const id = uid()
@@ -91,7 +97,7 @@ export const useUI = create((set, get) => ({
const snd = useStore.getState().S.sound
if (left <= 0) {
beep(snd, 880, 0.15); beep(snd, 880, 0.15, 0.25); beep(snd, 1320, 0.4, 0.5)
- vibrate([200, 100, 200]); maybeRestNotification(); get().toast(t('Rest over — next set!')); get().stopRest(); return
+ vibrate([200, 100, 200]); get().flashTimer(); maybeRestNotification(); get().toast(t('Rest over — next set!')); get().stopRest(); return
}
if (left <= 3) beep(snd, 660, 0.1)
set({ timer: { ...tm, left } })
@@ -139,7 +145,7 @@ export const useUI = create((set, get) => ({
const snd = useStore.getState().S.sound
if (left <= 0) {
beep(snd, 880, 0.15); beep(snd, 880, 0.15, 0.25); beep(snd, 1320, 0.4, 0.5)
- vibrate([200, 100, 200])
+ vibrate([200, 100, 200]); get().flashTimer()
const done = workDone
get().stopWork()
if (done) done(wk.total)
diff --git a/frontend/src/store/useUI.test.js b/frontend/src/store/useUI.test.js
index 32c9a1c57..bfd72d2b4 100644
--- a/frontend/src/store/useUI.test.js
+++ b/frontend/src/store/useUI.test.js
@@ -2,6 +2,7 @@
// useUI pulls in api.js, which reads navigator.userAgent at module scope.
import { describe, expect, it, beforeEach, afterEach, vi } from 'vitest'
import { useUI } from './useUI.js'
+import { useStore } from './useStore.js'
// "Off" has to hold at the timer itself, not at the four places that start one — the same
// reason the rest-after-a-set rule is a shared condition rather than four copies.
@@ -26,3 +27,41 @@ describe('rest timer set to Off', () => {
expect(useUI.getState().timer.total).toBe(90)
})
})
+
+describe('opt-in timer screen flash', () => {
+ let originalSettings
+
+ beforeEach(() => {
+ vi.useFakeTimers()
+ originalSettings = useStore.getState().S
+ useStore.setState({ S: { ...originalSettings, sound: false, timerFlash: false } })
+ useUI.setState({ timer: null, work: null, timerFlashId: 0 })
+ })
+
+ afterEach(() => {
+ useUI.getState().stopRest()
+ useUI.getState().stopWork()
+ useStore.setState({ S: originalSettings })
+ vi.useRealTimers()
+ })
+
+ it('stays off unless enabled in Settings', () => {
+ useUI.getState().startRest(1)
+ vi.advanceTimersByTime(1000)
+ expect(useUI.getState().timerFlashId).toBe(0)
+ })
+
+ it('flashes when the rest timer finishes', () => {
+ useStore.setState({ S: { ...useStore.getState().S, timerFlash: true } })
+ useUI.getState().startRest(1)
+ vi.advanceTimersByTime(1000)
+ expect(useUI.getState().timerFlashId).toBe(1)
+ })
+
+ it('flashes when a timed exercise finishes', () => {
+ useStore.setState({ S: { ...useStore.getState().S, timerFlash: true } })
+ useUI.getState().startWork(1, 'Plank', vi.fn())
+ vi.advanceTimersByTime(1000)
+ expect(useUI.getState().timerFlashId).toBe(1)
+ })
+})
diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsx
index 2f4c0a4c4..a303be2df 100644
--- a/frontend/src/views/Settings.jsx
+++ b/frontend/src/views/Settings.jsx
@@ -148,6 +148,9 @@ export default function Settings() {
<Row icon="bell" iconTint="var(--pink)" title={t('Sounds')}>
<Switch checked={!!S.sound} onChange={v => update(s => { s.sound = v })} />
</Row>
+ <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>
{/* 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')}>