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
Tabs: a guest tab is not left blank when the other tab creates a profile, and follows a sign-in with its workout
Duarte Santos4888729c8a54
diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.jsindex 586a1106e..a56874516 100644--- a/frontend/src/locales/ar.js+++ b/frontend/src/locales/ar.js@@ -2002,4 +2002,5 @@ export default {'Greys show lighter in dark mode, so buttons don’t look switched off.': 'تظهر الألوان الرمادية أفتح في الوضع الداكن، حتى لا تبدو الأزرار مُعطّلة.','Greys show darker in light mode, so buttons don’t look switched off.': 'تظهر الألوان الرمادية أغمق في الوضع الفاتح، حتى لا تبدو الأزرار مُعطّلة.','custom color picker': 'لون خاص مخصص منتقي الألوان',+ 'Signed in from another tab. Your workout came along, pick it up there.': 'تم تسجيل الدخول من علامة تبويب أخرى. انتقل تمرينك معه، تابعه هناك.',}diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex 598e45a83..88f967104 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -1969,4 +1969,5 @@ export default {'Greys show lighter in dark mode, so buttons don’t look switched off.': 'Grautöne werden im dunklen Modus heller, damit Buttons nicht ausgeschaltet wirken.','Greys show darker in light mode, so buttons don’t look switched off.': 'Grautöne werden im hellen Modus dunkler, damit Buttons nicht ausgeschaltet wirken.','custom color picker': 'eigene Farbe benutzerdefiniert Farbwähler Farbauswahl',+ 'Signed in from another tab. Your workout came along, pick it up there.': 'In einem anderen Tab angemeldet. Dein Training ist mitgekommen, mach dort weiter.',}diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex c7d9e98db..a908dd7c9 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -1949,4 +1949,5 @@ export default {'Greys show lighter in dark mode, so buttons don’t look switched off.': 'Los grises se ven más claros en modo oscuro, para que los botones no parezcan apagados.','Greys show darker in light mode, so buttons don’t look switched off.': 'Los grises se ven más oscuros en modo claro, para que los botones no parezcan apagados.','custom color picker': 'color propio personalizado selector de color',+ 'Signed in from another tab. Your workout came along, pick it up there.': 'Sesión iniciada en otra pestaña. Tu entreno se fue con ella, sigue allí.',}diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex 0f99a7ae0..2da696b31 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -1949,4 +1949,5 @@ export default {'Greys show lighter in dark mode, so buttons don’t look switched off.': 'Les gris s’éclaircissent en mode sombre, pour que les boutons n’aient pas l’air éteints.','Greys show darker in light mode, so buttons don’t look switched off.': 'Les gris foncent en mode clair, pour que les boutons n’aient pas l’air éteints.','custom color picker': 'couleur perso personnalisée sélecteur nuancier',+ 'Signed in from another tab. Your workout came along, pick it up there.': 'Connecté depuis un autre onglet. Ta séance a suivi, reprends-la là-bas.',}diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex d63903a2e..4076dfd0a 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -1949,4 +1949,5 @@ export default {'Greys show lighter in dark mode, so buttons don’t look switched off.': 'डार्क मोड में ग्रे रंग हल्के दिखते हैं, ताकि बटन बंद जैसे न लगें।','Greys show darker in light mode, so buttons don’t look switched off.': 'लाइट मोड में ग्रे रंग गहरे दिखते हैं, ताकि बटन बंद जैसे न लगें।','custom color picker': 'अपना रंग कस्टम रंग चुनने वाला',+ 'Signed in from another tab. Your workout came along, pick it up there.': 'दूसरे टैब से साइन इन हुआ। आपका वर्कआउट साथ चला गया, वहीं जारी रखें।',}diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex 711ab7dd4..a90c2b1b4 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -1952,4 +1952,5 @@ export default {'Greys show lighter in dark mode, so buttons don’t look switched off.': 'A szürkék sötét módban világosabbak, hogy a gombok ne tűnjenek kikapcsoltnak.','Greys show darker in light mode, so buttons don’t look switched off.': 'A szürkék világos módban sötétebbek, hogy a gombok ne tűnjenek kikapcsoltnak.','custom color picker': 'saját szín egyéni színválasztó',+ 'Signed in from another tab. Your workout came along, pick it up there.': 'Bejelentkeztél egy másik lapon. Az edzésed is átment, ott folytasd.',}diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex bd1169898..feb259512 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -1949,4 +1949,5 @@ export default {'Greys show lighter in dark mode, so buttons don’t look switched off.': 'I grigi diventano più chiari in modalità scura, così i pulsanti non sembrano spenti.','Greys show darker in light mode, so buttons don’t look switched off.': 'I grigi diventano più scuri in modalità chiara, così i pulsanti non sembrano spenti.','custom color picker': 'colore personalizzato proprio selettore colore',+ 'Signed in from another tab. Your workout came along, pick it up there.': 'Accesso fatto da un’altra scheda. Il tuo allenamento è andato con lei, riprendilo lì.',}diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex d642385c4..eb3b1c369 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -1949,4 +1949,5 @@ export default {'Greys show lighter in dark mode, so buttons don’t look switched off.': '다크 모드에서는 버튼이 꺼진 것처럼 보이지 않게 회색을 밝게 표시해요.','Greys show darker in light mode, so buttons don’t look switched off.': '라이트 모드에서는 버튼이 꺼진 것처럼 보이지 않게 회색을 어둡게 표시해요.','custom color picker': '나만의 색상 사용자 지정 색상 선택기',+ 'Signed in from another tab. Your workout came along, pick it up there.': '다른 탭에서 로그인했어요. 운동도 함께 넘어갔으니 거기서 이어서 하세요.',}diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex 34f453e10..fd0ddf908 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -1949,4 +1949,5 @@ export default {'Greys show lighter in dark mode, so buttons don’t look switched off.': 'Szarości są jaśniejsze w trybie ciemnym, żeby przyciski nie wyglądały na wyłączone.','Greys show darker in light mode, so buttons don’t look switched off.': 'Szarości są ciemniejsze w trybie jasnym, żeby przyciski nie wyglądały na wyłączone.','custom color picker': 'własny kolor niestandardowy próbnik wybór koloru',+ 'Signed in from another tab. Your workout came along, pick it up there.': 'Zalogowano w innej karcie. Twój trening poszedł razem z nią, kontynuuj tam.',}diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.jsindex 5789de61f..a3645ce9c 100644--- a/frontend/src/locales/pt-BR.js+++ b/frontend/src/locales/pt-BR.js@@ -1211,6 +1211,7 @@ export const PT_BR_OVERRIDES = {'A touch darker in light mode, so you can still read it.': 'Um pouco mais escura no modo claro, para você continuar lendo.','Greys show lighter in dark mode, so buttons don’t look switched off.': 'Os cinzas ficam mais claros no modo escuro, para os botões não parecerem desligados.','Greys show darker in light mode, so buttons don’t look switched off.': 'Os cinzas ficam mais escuros no modo claro, para os botões não parecerem desligados.',+ 'Signed in from another tab. Your workout came along, pick it up there.': 'Login feito em outra aba. Seu treino foi junto, continue por lá.',}export default { ...pt, ...PT_BR_OVERRIDES }diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex 1497a8de5..47dd631cd 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -1949,4 +1949,5 @@ export default {'Greys show lighter in dark mode, so buttons don’t look switched off.': 'Os cinzentos ficam mais claros no modo escuro, para os botões não parecerem desligados.','Greys show darker in light mode, so buttons don’t look switched off.': 'Os cinzentos ficam mais escuros no modo claro, para os botões não parecerem desligados.','custom color picker': 'cor própria personalizada seletor de cor',+ 'Signed in from another tab. Your workout came along, pick it up there.': 'Sessão iniciada noutro separador. O teu treino foi junto, continua-o lá.',}diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex 676be772c..310bad2c7 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -1953,4 +1953,5 @@ export default {'Greys show lighter in dark mode, so buttons don’t look switched off.': 'Серые оттенки в тёмной теме светлее, чтобы кнопки не казались выключенными.','Greys show darker in light mode, so buttons don’t look switched off.': 'Серые оттенки в светлой теме темнее, чтобы кнопки не казались выключенными.','custom color picker': 'свой цвет пользовательский палитра выбор цвета',+ 'Signed in from another tab. Your workout came along, pick it up there.': 'Вход выполнен в другой вкладке. Тренировка перешла туда, продолжай там.',}diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex 315e31726..5d3c1939d 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -1960,4 +1960,5 @@ export default {'Greys show lighter in dark mode, so buttons don’t look switched off.': 'สีเทาจะสว่างขึ้นในโหมดมืด ปุ่มจะได้ไม่ดูเหมือนถูกปิดอยู่','Greys show darker in light mode, so buttons don’t look switched off.': 'สีเทาจะเข้มขึ้นในโหมดสว่าง ปุ่มจะได้ไม่ดูเหมือนถูกปิดอยู่','custom color picker': 'สีเอง กำหนดเอง ตัวเลือกสี',+ 'Signed in from another tab. Your workout came along, pick it up there.': 'ลงชื่อเข้าใช้จากแท็บอื่นแล้ว การออกกำลังกายของคุณย้ายไปด้วย ไปทำต่อที่นั่นได้เลย',}diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex 42cfabac5..2d45c7376 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -1949,4 +1949,5 @@ export default {'Greys show lighter in dark mode, so buttons don’t look switched off.': 'Griler karanlık modda daha açık görünür, düğmeler kapalıymış gibi durmasın diye.','Greys show darker in light mode, so buttons don’t look switched off.': 'Griler aydınlık modda daha koyu görünür, düğmeler kapalıymış gibi durmasın diye.','custom color picker': 'kendi renk özel renk seçici',+ 'Signed in from another tab. Your workout came along, pick it up there.': 'Başka bir sekmede giriş yapıldı. Antrenmanın da oraya geçti, oradan devam et.',}diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.jsindex ee17a3d7c..fedb4aa30 100644--- a/frontend/src/locales/uk.js+++ b/frontend/src/locales/uk.js@@ -1946,4 +1946,5 @@ export default {'Greys show lighter in dark mode, so buttons don’t look switched off.': 'Сірі відтінки в темній темі світліші, щоб кнопки не здавалися вимкненими.','Greys show darker in light mode, so buttons don’t look switched off.': 'Сірі відтінки у світлій темі темніші, щоб кнопки не здавалися вимкненими.','custom color picker': 'свій колір власний палітра вибір кольору',+ 'Signed in from another tab. Your workout came along, pick it up there.': 'Вхід виконано в іншій вкладці. Тренування перейшло туди, продовжуй там.',}diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.jsindex d3b71e66d..79782b1ac 100644--- a/frontend/src/locales/zh-TW.js+++ b/frontend/src/locales/zh-TW.js@@ -1942,4 +1942,5 @@ export default {'Greys show lighter in dark mode, so buttons don’t look switched off.': '深色模式下灰色會調亮一些,免得按鈕看起來像被停用了。','Greys show darker in light mode, so buttons don’t look switched off.': '淺色模式下灰色會調暗一些,免得按鈕看起來像被停用了。','custom color picker': '自訂顏色 自己的顏色 取色器 調色盤',+ 'Signed in from another tab. Your workout came along, pick it up there.': '已在另一個分頁登入。你的訓練也一起過去了,在那裡繼續吧。',}diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex df2bdca1b..b5ea37cae 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -1949,4 +1949,5 @@ export default {'Greys show lighter in dark mode, so buttons don’t look switched off.': '深色模式下灰色会调亮一些,免得按钮看起来像被停用了。','Greys show darker in light mode, so buttons don’t look switched off.': '浅色模式下灰色会调暗一些,免得按钮看起来像被停用了。','custom color picker': '自定义颜色 自己的颜色 取色器 调色板',+ 'Signed in from another tab. Your workout came along, pick it up there.': '已在另一个标签页登录。你的训练也一起过去了,在那里继续吧。',}diff --git a/frontend/src/store/useStore.js b/frontend/src/store/useStore.jsindex 8c72f8c42..6baa82b4b 100644--- a/frontend/src/store/useStore.js+++ b/frontend/src/store/useStore.js@@ -767,6 +767,14 @@ export const useStore = create((set, get) => {if (owner === seenOwner) returnclearTimeout(pushTm)pushTm = null+ // A guest's workout running here went along with the sign-in in the other tab (it joined this+ // browser's saved copy first, setUser), and this tab shows it again once that tab is done+ // (followSignIn). Said, so a workout that leaves the screen mid-set is not taken for lost.+ if (!seenOwner && owner && get().S.active) {+ import('./useUI.js')+ .then(({ useUI }) => useUI.getState().toast(t('Signed in from another tab. Your workout came along, pick it up there.')))+ .catch(() => {})+ }const S = restartedState(get().S)meta.set(S, { base: null, owed: false })seenWid = readWid()@@ -784,6 +792,7 @@ export const useStore = create((set, get) => {// guards the push either way: a copy this tab has not refreshed gets a 409 and a merge.window.addEventListener('storage', e => {if (e.key !== SYNC_KEY || !e.newValue) return+ if (!get().user && !followSignIn()) returnconst user = get().userif (!user || localStorage.getItem('gym_owner') !== user.id) returnlet theirs = null@@ -812,8 +821,36 @@ export const useStore = create((set, get) => {meta.set(S, { base: readStoredSync(), owed: storedOwed() })registerCustom(S.customEx)set({ S })+ followSignIn()+ return true+ }+ // A tab signed out, or a guest's, whose browser another tab signed in: once that sign-in is+ // settled (its question answered, its copy saved under the account and in step with a revision),+ // this tab is signed in too, as a tab opened now would be. The session cookie is the browser's.+ // A guest's workout carried into the account shows here again.+ const followSignIn = () => {+ if (get()?.user || handedOver) return false+ const owner = readOwner()+ if (!owner || owner !== seenOwner || readWidOwner() !== owner || readWid() !== seenWid) return false+ let u = null+ try { u = JSON.parse(localStorage.getItem('gym_user')) } catch { return false }+ if (!u || u.id !== owner) return false+ const m = readAdopt()+ if (m && m.uid === owner) return false+ const base = readStoredSync()+ if (!base) return false+ meta.set(get().S, { base, owed: storedOwed() })+ set({ user: u })+ setSync({ held: false })return true}+ // The answered sign-in's copy saved under its account once, whatever the answer did: an answer+ // that changed nothing here ("Add them" with nothing to add, a profile with no copy yet) wrote+ // no save, and another tab waited on one (takeSaved).+ const claimSaved = () => {+ const u = get().user+ if (u && readOwner() === u.id && readWidOwner() !== u.id) persist(get().S, false, false)+ }const syncFromSaved = () => {if (handedOver) { takeSaved(); return }const wid = readWid()@@ -1486,6 +1523,10 @@ export const useStore = create((set, get) => {handedOver = falselocalStorage.setItem('gym_user', JSON.stringify(u)); localStorage.removeItem('gym_guest')logoutOwed(false) // this sign-in's cookie replaced the one a failed sign-out left behind+ // A profile created here (no question: this copy becomes it) is saved once under its owner+ // now. Another tab of this browser takes only a copy saved under the new owner, and went+ // blank until this one happened to save something (takeSaved).+ if (!adopt && !other && owner !== u.id) persist(get().S, false, false)// The file follows at once, as the new account's: until then it holds the previous one's.if (other && MOBILE) nativePersist(true)// The server answers /api/config with a `coach` key only to a session — the block, or@@ -1650,6 +1691,7 @@ export const useStore = create((set, get) => {// stays held, and the next check or "Sync now" runs it again; a bare call has nothing to// hold for and lets go.adopting = runAdopt(ask, opts)+ .then(r => { claimSaved(); return r }).catch(e => { if (!adoptOwed()) releaseAdopt(); throw e }).finally(() => { adopting = null })return adoptingdiff --git a/frontend/src/store/useStore.tabs-owner.test.jsx b/frontend/src/store/useStore.tabs-owner.test.jsxindex bc332b8c8..91859273d 100644--- a/frontend/src/store/useStore.tabs-owner.test.jsx+++ b/frontend/src/store/useStore.tabs-owner.test.jsx@@ -9,9 +9,9 @@storage events are replayed in the order the writes happened, as the browser delivers them. */import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'-const h = vi.hoisted(() => ({ api: null }))+const h = vi.hoisted(() => ({ api: null, toasts: [] }))vi.mock('../lib/api.js', () => ({ api: (...a) => h.api(...a), setRemoteAuth: () => {} }))-vi.mock('./useUI.js', () => ({ useUI: { getState: () => ({ toast: () => {}, stopRest: () => {}, abandonWork: () => {} }) } }))+vi.mock('./useUI.js', () => ({ useUI: { getState: () => ({ toast: m => h.toasts.push(m), stopRest: () => {}, abandonWork: () => {} }) } }))const clone = v => JSON.parse(JSON.stringify(v))const w = (id, d = '2026-09-01') => ({ id, d, start: 1, end: 2, entries: [] })@@ -209,3 +209,66 @@ describe('a second tab while the first one changes owner', () => {expect(Object.values(stash).some(e => (e.state.bodyweight || []).some(b => b.w === 60))).toBe(true)})})++// RC review 2026-10-07: a guest tab left open while the other tab created a profile went blank+// until that tab saved something, and one mid-workout jumped to the sign-in screen with its+// workout gone from view (it had gone into the account) and nothing said.+describe('a guest tab while the other tab signs in or creates a profile', () => {+ const running = () => ({ id: 'act1', start: Date.now() - 600000, entries: [{ id: 'bench', sets: [{ w: 60, r: 5, done: true }] }] })+ const guestCopy = active => ({ ...clone(DEF), _ts: Date.now(), workouts: [w('gW1', '2026-09-04')], active })++ it('a profile created in the other tab shows in the guest tab at once, and the workout with it', async () => {+ DEF = (await import('./useStore.js')).DEF+ const srv = server(null)+ localStorage.setItem('gym_state_v1', JSON.stringify(guestCopy(running())))+ localStorage.setItem('gym_guest', '1')+ const A = await openTab(null)+ const B = await openTab(null)+ expect(B.getState().S.active?.id).toBe('act1')+ h.toasts = []+ // Register (views/Login.jsx): setUser without a question, then the push of this copy.+ await act(A, () => A.getState().setUser({ id: OWNER, name: 'Nova' }))+ expect(ids(B.getState().S)).toEqual(['gW1']) // not blank+ expect(B.getState().S.active?.id).toBe('act1')+ await new Promise(r => setTimeout(r, 0)) // the toast comes through a lazy import+ expect(h.toasts.some(m => /another tab/.test(m))).toBe(true)+ await act(A, () => A.getState().pushState())+ expect(ids(srv.doc)).toEqual(['gW1'])+ // B follows the sign-in once the copy is the account's and in step with the server.+ expect(B.getState().user?.id).toBe(OWNER)+ expect(B.getState().S.active?.id).toBe('act1')+ })++ it('a sign-in to an existing account: the guest tab gets the account, the running workout included, once it is answered', async () => {+ DEF = (await import('./useStore.js')).DEF+ const srv = server({ ...account(), _rev: 3 })+ localStorage.setItem('gym_state_v1', JSON.stringify(guestCopy(running())))+ localStorage.setItem('gym_guest', '1')+ const A = await openTab(null)+ const B = await openTab(null)+ h.toasts = []+ await act(A, () => A.getState().setUser({ id: OWNER, name: 'Xavi' }, { adopt: true }))+ await new Promise(r => setTimeout(r, 0)) // the toast comes through a lazy import+ expect(h.toasts.some(m => /another tab/.test(m))).toBe(true)+ expect(B.getState().user).toBe(null) // nothing taken while the question is open+ await act(A, () => A.getState().adoptProfile(async () => false)) // "Keep profile as is"+ expect(ids(srv.doc)).toEqual(['x1', 'x2', 'x3'])+ expect(A.getState().S.active?.id).toBe('act1')+ expect(ids(B.getState().S)).toEqual(['x1', 'x2', 'x3'])+ expect(B.getState().S.active?.id).toBe('act1')+ expect(B.getState().user?.id).toBe(OWNER)+ })++ it('a new profile with nothing in it: the other tab takes it without waiting for a save', async () => {+ DEF = (await import('./useStore.js')).DEF+ server(null)+ localStorage.setItem('gym_state_v1', JSON.stringify({ ...clone(DEF), _ts: Date.now(), restSec: 75 }))+ const A = await openTab(null)+ const B = await openTab(null)+ await act(A, () => A.getState().setUser({ id: OWNER, name: 'Empty' }, { adopt: true }))+ await act(A, () => A.getState().adoptProfile(async () => true))+ expect(B.getState().S.restSec).toBe(75)+ expect(localStorage.getItem('gym_state_owner')).toBe(OWNER)+ })+})+