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
Plan: loop Undo no longer drags you back into Rotation after Fixed week or over a coach's queue; Undo says so when it is too late or the routine is already back; Duplicate gets its own Undo
Duarte Santos29d607976837
diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.jsindex 5899e02e3..d434543d2 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('b964d1203ec8e193a57271572dce072496598bb71929870afeafac4969e63dc3')+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('d9473920d8a45d4618e89a4ab23e7124b85c8edc3228639e3e94d3a1104250b7')})test('does not leak European Portuguese UI terms', () => {diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.jsindex c2a3b0171..1ac6ddbe2 100644--- a/frontend/src/locales/ar.js+++ b/frontend/src/locales/ar.js@@ -1979,6 +1979,7 @@ export default {'Duplicate': 'تكرار','Copied as “{0}”.': 'نُسخ باسم «{0}».','“{0}” gone.': 'ذهب «{0}».',+ 'It’s already back.': 'لقد عاد بالفعل.','“{0}” is out of the loop.': 'خرج «{0}» من الدورة.','“{0}” left the routine.': 'غادر «{0}» الروتين.','Swipe actions': 'إجراءات السحب',diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex 7b4625984..5b9755d19 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -1946,6 +1946,7 @@ export default {'Duplicate': 'Duplizieren','Copied as “{0}”.': 'Kopiert als „{0}“.','“{0}” gone.': '„{0}“ ist weg.',+ 'It’s already back.': 'Ist schon wieder da.','“{0}” is out of the loop.': '„{0}“ ist raus aus dem Kreislauf.','“{0}” left the routine.': '„{0}“ hat die Routine verlassen.','Swipe actions': 'Wischaktionen',diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex eb6b328c7..12c13da68 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -1926,6 +1926,7 @@ export default {'Duplicate': 'Duplicar','Copied as “{0}”.': 'Copiada como «{0}».','“{0}” gone.': '«{0}» ya no está.',+ 'It’s already back.': 'Ya está de vuelta.','“{0}” is out of the loop.': '«{0}» sale del bucle.','“{0}” left the routine.': '«{0}» dejó la rutina.','Swipe actions': 'Acciones al deslizar',diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex 780fc8c07..b9811bd7e 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -1926,6 +1926,7 @@ export default {'Duplicate': 'Dupliquer','Copied as “{0}”.': 'Copiée sous « {0} ».','“{0}” gone.': '« {0} » est partie.',+ 'It’s already back.': 'Elle est déjà revenue.','“{0}” is out of the loop.': '« {0} » sort de la boucle.','“{0}” left the routine.': '« {0} » a quitté la routine.','Swipe actions': 'Actions de glissement',diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex ac305f42f..4e43881a4 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -1926,6 +1926,7 @@ export default {'Duplicate': 'डुप्लिकेट','Copied as “{0}”.': '"{0}" नाम से कॉपी हुआ।','“{0}” gone.': '"{0}" चला गया।',+ 'It’s already back.': 'वो पहले ही वापस आ गया।','“{0}” is out of the loop.': '"{0}" चक्र से बाहर।','“{0}” left the routine.': '"{0}" ने रूटीन छोड़ दिया।','Swipe actions': 'स्वाइप ऐक्शन',diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex fb8860346..ae7600b0d 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -1929,6 +1929,7 @@ export default {'Duplicate': 'Duplikálás','Copied as “{0}”.': 'Másolva ezen a néven: „{0}”.','“{0}” gone.': '„{0}” eltűnt.',+ 'It’s already back.': 'Már visszajött.','“{0}” is out of the loop.': '„{0}” kikerült a körből.','“{0}” left the routine.': '„{0}” kilépett a rutinból.','Swipe actions': 'Húzásos műveletek',diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 675a12265..b799aec7c 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -1926,6 +1926,7 @@ export default {'Duplicate': 'Duplica','Copied as “{0}”.': 'Copiata come «{0}».','“{0}” gone.': '«{0}» è andata.',+ 'It’s already back.': 'È già tornata.','“{0}” is out of the loop.': '«{0}» esce dal ciclo.','“{0}” left the routine.': '«{0}» ha lasciato la routine.','Swipe actions': 'Azioni con scorrimento',diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex d94469e3f..874c83747 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -1926,6 +1926,7 @@ export default {'Duplicate': '복제','Copied as “{0}”.': '"{0}"(으)로 복사했어요.','“{0}” gone.': '"{0}" 삭제됨.',+ 'It’s already back.': '이미 돌아와 있어요.','“{0}” is out of the loop.': '"{0}"이(가) 순환에서 빠졌어요.','“{0}” left the routine.': '"{0}"이(가) 루틴에서 빠졌어요.','Swipe actions': '스와이프 동작',diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex b7b7080e5..d7c53611a 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -1926,6 +1926,7 @@ export default {'Duplicate': 'Duplikuj','Copied as “{0}”.': 'Skopiowano jako „{0}”.','“{0}” gone.': '„{0}” zniknęła.',+ 'It’s already back.': 'Już wróciła.','“{0}” is out of the loop.': '„{0}” wypada z pętli.','“{0}” left the routine.': '„{0}” opuszcza rutynę.','Swipe actions': 'Akcje przesuwania',diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex d26ae7a1a..384aa420a 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -1926,6 +1926,7 @@ export default {'Duplicate': 'Duplicar','Copied as “{0}”.': 'Copiada como «{0}».','“{0}” gone.': '«{0}» já foi.',+ 'It’s already back.': 'Já voltou.','“{0}” is out of the loop.': '«{0}» saiu do ciclo.','“{0}” left the routine.': '«{0}» saiu da rotina.','Swipe actions': 'Ações ao deslizar',diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex b5f879e66..fd34bc49b 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -1930,6 +1930,7 @@ export default {'Duplicate': 'Дублировать','Copied as “{0}”.': 'Скопировано как «{0}».','“{0}” gone.': '«{0}» больше нет.',+ 'It’s already back.': 'Уже на месте.','“{0}” is out of the loop.': '«{0}» выбывает из круга.','“{0}” left the routine.': '«{0}» покидает тренировку.','Swipe actions': 'Действия свайпом',diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex f946eb8c7..ae86f3215 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -1937,6 +1937,7 @@ export default {'Duplicate': 'ทำสำเนา','Copied as “{0}”.': 'คัดลอกเป็น “{0}” แล้ว','“{0}” gone.': '“{0}” ไปแล้ว',+ 'It’s already back.': 'กลับมาแล้ว','“{0}” is out of the loop.': '“{0}” ออกจากการวนรอบแล้ว','“{0}” left the routine.': '“{0}” ออกจากรูทีนแล้ว','Swipe actions': 'การปัดเพื่อสั่งงาน',diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex bd425c1af..2ba416860 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -1926,6 +1926,7 @@ export default {'Duplicate': 'Çoğalt','Copied as “{0}”.': '“{0}” olarak kopyalandı.','“{0}” gone.': '“{0}” gitti.',+ 'It’s already back.': 'Zaten geri geldi.','“{0}” is out of the loop.': '“{0}” döngüden çıktı.','“{0}” left the routine.': '“{0}” rutinden ayrıldı.','Swipe actions': 'Kaydırma eylemleri',diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.jsindex d28d75d5a..244ca99bf 100644--- a/frontend/src/locales/uk.js+++ b/frontend/src/locales/uk.js@@ -1923,6 +1923,7 @@ export default {'Duplicate': 'Дублювати','Copied as “{0}”.': 'Скопійовано як «{0}».','“{0}” gone.': '«{0}» більше нема.',+ 'It’s already back.': 'Уже на місці.','“{0}” is out of the loop.': '«{0}» вибуває з кола.','“{0}” left the routine.': '«{0}» покидає тренування.','Swipe actions': 'Дії свайпом',diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.jsindex f58f15510..77bd3b4fb 100644--- a/frontend/src/locales/zh-TW.js+++ b/frontend/src/locales/zh-TW.js@@ -1919,6 +1919,7 @@ export default {'Duplicate': '複製一份','Copied as “{0}”.': '已複製為「{0}」。','“{0}” gone.': '「{0}」沒了。',+ 'It’s already back.': '它已經回來了。','“{0}” is out of the loop.': '「{0}」已移出循環。','“{0}” left the routine.': '「{0}」已離開課表。','Swipe actions': '滑動操作',diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex 59493796a..999336e31 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -1926,6 +1926,7 @@ export default {'Duplicate': '复制一份','Copied as “{0}”.': '已复制为“{0}”。','“{0}” gone.': '“{0}”没了。',+ 'It’s already back.': '它已经回来了。','“{0}” is out of the loop.': '“{0}”已移出循环。','“{0}” left the routine.': '“{0}”已离开计划。','Swipe actions': '滑动操作',diff --git a/frontend/src/views/Plan.jsx b/frontend/src/views/Plan.jsxindex 6e10cd3a0..3c727e3d1 100644--- a/frontend/src/views/Plan.jsx+++ b/frontend/src/views/Plan.jsx@@ -50,6 +50,8 @@ export function deleteRoutineWithUndo(id) {export function undoDeleteRoutine(snap) {let ok = falseuseStore.getState().update(s => { ok = restoreRoutine(s, snap) })+ // False when a sync brought it back first (another device's Undo, or its later edit).+ if (!ok) useUI.getState().toast(t('It’s already back.'))return ok}@@ -65,27 +67,47 @@ export function takeOutOfLoop(id, setSeq, seq, label) {const snap = structuredClone({ rotation: before.rotation ?? null, queue: before.queue ?? null, dayPlan: before.dayPlan ?? {} })setSeq(seq.filter(x => x !== id))const after = useStore.getState().S- const mark = JSON.stringify([after.rotation ?? null, after.queue ?? null])+ const mark = loopMark(after)const name = before.routines.find(r => r.id === id)?.name ?? iduseUI.getState().toast(t('“{0}” is out of the loop.', name), { action: t('Undo'), onAction: () => undoTakeOut({ id, at, label, snap, mark }) })return true}+// What the loop looked like right after a removal: the saved loop, the pass and the mode switch.+const loopMark = S => JSON.stringify([S.rotation ?? null, S.queue ?? null, S.scheduleMode ?? null])export function undoTakeOut({ id, at, label, snap, mark }) {+ if (!useStore.getState().S.routines.some(r => r.id === id)) {+ useUI.getState().toast(t('Too late, that one’s gone'))+ return false+ }useStore.getState().update(s => {- if (!s.routines.some(r => r.id === id)) return- if (JSON.stringify([s.rotation ?? null, s.queue ?? null]) === mark) {+ if (loopMark(s) === mark) {s.rotation = snap.rotations.queue = snap.queueconst pins = Object.entries(snap.dayPlan).filter(([iso]) => s.dayPlan?.[iso] == null)if (pins.length) s.dayPlan = { ...(s.dayPlan || {}), ...Object.fromEntries(pins) }return}- const ids = queueOf(s)?.ids ?? rotationIds(s)+ // Only a loop that is still this app's and still running gets a pass written. After "Fixed+ // week", or with a coach's or planner's queue in charge, a new pass would quietly take over+ // again, so the routine just goes back into the saved loop for the next time it starts.+ const q = queueOf(s)+ const ours = scheduleModeOf(s) === 'rotation' && (!s.queue || (!!q && !!s.rotation && q.rotationId === s.rotation.id))+ if (!ours) {+ const seq = Array.isArray(s.rotation?.sequence) ? s.rotation.sequence : null+ if (seq && !seq.includes(id)) {+ const next = seq.slice()+ next.splice(Math.min(at, next.length), 0, id)+ s.rotation = { ...s.rotation, sequence: next }+ }+ return+ }+ const ids = q?.ids ?? rotationIds(s)if (ids.includes(id)) returnconst next = ids.slice()next.splice(Math.min(at, next.length), 0, id)saveRotation(s, next, s.queue?.label || s.rotation?.label || label)})+ return true}// The flash a row lands with when a swipe brought it (a duplicate, an undo): one per new value.@@ -373,7 +395,11 @@ function Routines({ S, update, nav }) {s.routines.splice(at < 0 ? s.routines.length : at + 1, 0, copy)})setFlash({ id: copy.id, n: ++flashSeq })- useUI.getState().toast(t('Copied as “{0}”.', copy.name))+ // With its own Undo: the toast takes the place of any Undo still showing (one toast at a+ // time), so the newest swipe is at least the one you can take back.+ useUI.getState().toast(t('Copied as “{0}”.', copy.name), { action: t('Undo'), onAction: () => {+ update(s => { if (s.routines.some(x => x.id === copy.id)) deleteRoutine(s, copy.id) })+ } })}// The weekdays a routine is on, short, in the order the week runs.const order = weekOrder(weekStartOf(S))diff --git a/frontend/src/views/Plan.swipe.test.jsx b/frontend/src/views/Plan.swipe.test.jsxindex 0550e3ce3..e67ef00ab 100644--- a/frontend/src/views/Plan.swipe.test.jsx+++ b/frontend/src/views/Plan.swipe.test.jsx@@ -9,7 +9,8 @@ import { DEF, useStore } from '../store/useStore.js'import { useUI } from '../store/useUI.js'import { closeOpenRow } from '../lib/use-swipe-row.js'import { restoreRoutine, routineSnapshot, deleteRoutine } from '../lib/routines.js'-import Plan from './Plan.jsx'+import Plan, { deleteRoutineWithUndo, takeOutOfLoop } from './Plan.jsx'+import { chooseFixedWeek, saveRotation, scheduleModeOf } from '../lib/rotation.js'const nav = vi.fn()vi.mock('react-router-dom', () => ({ useNavigate: () => nav }))@@ -125,6 +126,25 @@ describe('the routines list', () => {expect(nav).not.toHaveBeenCalled()})+ it('the duplicate’s toast has its own Undo, which takes the copy away again', () => {+ mount('routines')+ swipe(rowOf('Push A'), 100, 330)+ expect(S().routines).toHaveLength(4)+ expect(useUI.getState().toastAction).toBeTruthy()+ undo()+ expect(S().routines.map(r => r.id)).toEqual(['a', 'b', 'c'])+ })++ it('an Undo that finds the routine already back says so instead of nothing', () => {+ mount('routines')+ act(() => { deleteRoutineWithUndo('b') })+ const pending = useUI.getState().toastAction+ act(() => useStore.getState().update(s => { s.routines.splice(1, 0, routine('b', 'Pull A')) })) // a sync brought it back+ act(() => pending.run())+ expect(S().routines.map(r => r.id)).toEqual(['a', 'b', 'c'])+ expect(useUI.getState().toastMsg).toBe('It’s already back.')+ })+it('Edit’s minus deletes the same way, with the Undo in place of the confirm', () => {mount('routines')click(host.querySelector('.plan-textbtn'))@@ -180,6 +200,56 @@ describe('the loop', () => {expect(S().rotation.sequence).toEqual(['c', 'b', 'a'])})+ // The store's update, the way Plan's editor saves (Plan.jsx setSeq).+ const setSeq = ids => useStore.getState().update(s => {+ if (ids.length) saveRotation(s, ids, 'My loop')+ else { s.queue = null; s.rotation = { ...s.rotation, sequence: [] }; s.scheduleMode = 'rotation' }+ })++ it('Undo after switching to Fixed week puts the routine back in the saved loop and stays on Fixed week', () => {+ mount('schedule', clone(loop))+ act(() => { takeOutOfLoop('b', setSeq, ['a', 'b', 'c'], 'My loop') })+ const pending = useUI.getState().toastAction+ act(() => useStore.getState().update(s => { chooseFixedWeek(s) }))+ act(() => pending.run())+ expect(S().queue).toBeNull()+ expect(scheduleModeOf(S())).toBe('week')+ expect(S().rotation.sequence).toEqual(['a', 'b', 'c'])+ })++ it('the same after taking out the last routine, where the loop itself did not change', () => {+ mount('schedule', { ...clone(loop), rotation: { ...loop.rotation, sequence: ['a'] }, queue: { ...loop.queue, ids: ['a'] } })+ act(() => { takeOutOfLoop('a', setSeq, ['a'], 'My loop') })+ expect(S().queue).toBeNull()+ const pending = useUI.getState().toastAction+ act(() => useStore.getState().update(s => { chooseFixedWeek(s) }))+ act(() => pending.run())+ expect(S().queue).toBeNull()+ expect(scheduleModeOf(S())).toBe('week')+ expect(S().rotation.sequence).toEqual(['a'])+ })++ it('a coach’s queue written meanwhile is left alone by the Undo', () => {+ mount('schedule', clone(loop))+ act(() => { takeOutOfLoop('b', setSeq, ['a', 'b', 'c'], 'My loop') })+ const pending = useUI.getState().toastAction+ const coach = { ids: ['c', 'a'], since: 5, startsOn: '2026-10-02', label: 'Coach' }+ act(() => useStore.getState().update(s => { s.queue = clone(coach) }))+ act(() => pending.run())+ expect(S().queue).toEqual(coach)+ expect(S().rotation.sequence).toEqual(['a', 'b', 'c'])+ })++ it('Undo for a routine deleted meanwhile says it is too late', () => {+ mount('schedule', clone(loop))+ act(() => { takeOutOfLoop('b', setSeq, ['a', 'b', 'c'], 'My loop') })+ const pending = useUI.getState().toastAction+ act(() => useStore.getState().update(s => { deleteRoutine(s, 'b') }))+ act(() => pending.run())+ expect(S().queue.ids).toEqual(['a', 'c'])+ expect(useUI.getState().toastMsg).toBe('Too late, that one’s gone')+ })+it('the edit-mode minus has the same Undo, and weekday rows never swipe', () => {mount('schedule', { ...clone(loop), week: { 1: ['c'], 2: ['a'] } })click([...host.querySelectorAll('.plan-textbtn')].find(b => b.textContent === 'Edit'))