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
Coach: automatic reviews and questions on the phone follow the Advanced dials (#527)
Duarte Santos4db236a4c93d
diff --git a/frontend/src/lib/coach-local.js b/frontend/src/lib/coach-local.jsindex 8b0429614..29790dfc4 100644--- a/frontend/src/lib/coach-local.js+++ b/frontend/src/lib/coach-local.js@@ -102,7 +102,10 @@ export const localRefine = async (S, text) => {return start(S, 'create', { refine: String(text || '').slice(0, coachLimits(d).maxMessageLen), previous: pendingCreate?.bundle || null, iteration: (pendingCreate?.iteration || 1) + 1 })}export const localDebrief = (S, workoutId) => start(S, 'debrief', { workoutId: workoutId || null })-export const localAsk = (S, text, today) => start(S, 'ask', { note: String(text || '').slice(0, 1000), today: today || null })+export const localAsk = async (S, text, today) => {+ const d = await loadCoachDevice()+ return start(S, 'ask', { note: String(text || '').slice(0, coachLimits(d).maxMessageLen), today: today || null })+}/* Automatic reviews. On a server the cadence tick runs them (api/coach/cadence.js); a phone withits own key has no server, and for a long time nothing ran them at all: the setting saved, the@@ -119,7 +122,8 @@ export async function localScheduled(S, now = new Date()) {if (d.mode !== 'byok' || !ADAPTERS[d.provider]) return null// A proposal nobody has answered is not replaced by the next one, as on the server.if (d.pending && !(d.pending.expiresAt && d.pending.expiresAt < now.getTime())) return null- if ((await capState()).used >= LOCAL_DAILY_CAP) return null+ const cap = await capState()+ if (cap.limit > 0 && cap.used >= cap.limit) return nullconst tz = deviceZone()if (!isDue(S.coach, S, wallClock(now), d.reviewedAt || 0, tz)) return nulltry { return await start(S, 'review', { scheduled: true }) } catch { return null }diff --git a/frontend/src/lib/coach-local.schedule.test.js b/frontend/src/lib/coach-local.schedule.test.jsindex b4c817879..5eaa5d126 100644--- a/frontend/src/lib/coach-local.schedule.test.js+++ b/frontend/src/lib/coach-local.schedule.test.js@@ -23,6 +23,7 @@ vi.mock('./capacitor-fetch.js', () => ({const local = await import('./coach-local.js')const { _resetCoachDevice, loadCoachDevice } = await import('./coach-device.js')const { EXERCISES } = await import('../../../api/coach/core/library-data.js')+const { todayISO } = await import('./format.js')const EX = EXERCISES[0].idconst chat = content => ({ status: 200, body: { choices: [{ finish_reason: 'stop', message: { content } }] } })@@ -111,6 +112,16 @@ describe('automatic reviews on a phone with its own key', () => {expect(wire.calls).toHaveLength(1)})+ it('respects the daily runs dial from Advanced, where 0 is no limit (#527)', async () => {+ const two = [workout('w1', at(12)), workout('w2', at(13))]+ device.data = { ...device.data, daily: { d: todayISO(), n: 10 } }+ expect(await local.localScheduled(state({ everyWorkouts: 1 }, two), at(14))).toBeNull()+ device.data = { ...device.data, limits: { daily: 0 } }; _resetCoachDevice()+ expect(await local.localScheduled(state({ everyWorkouts: 1 }, two), at(14))).toBeTruthy()+ await settle()+ expect(wire.calls).toHaveLength(1)+ })+it('stays out of the way: off, no consent, another mode, a job running', async () => {const two = [workout('w1', at(12)), workout('w2', at(13))]expect(await local.localScheduled(state('off', two), at(14))).toBeNull()diff --git a/frontend/src/lib/coach-local.test.js b/frontend/src/lib/coach-local.test.jsindex 170d66b5e..28658abc5 100644--- a/frontend/src/lib/coach-local.test.js+++ b/frontend/src/lib/coach-local.test.js@@ -192,6 +192,16 @@ describe('the Coach on a phone with its own key', () => {expect(sent).not.toContain('x'.repeat(COACH_LIMITS.maxMessageLen.min + 1))})+ it('a question is clipped to the same message dial', async () => {+ await saveCoachDevice({ limits: { maxMessageLen: 2400 } })+ wire.answer = chat(JSON.stringify({ coach_contract: 1, answer: 'Yes.' }))+ await local.localAsk(state(), 'q'.repeat(3000), null)+ await settle()+ const sent = wire.calls.at(-1).body.messages[1].content+ expect(sent).toContain('q'.repeat(2400))+ expect(sent).not.toContain('q'.repeat(2401))+ })+it('a proposal waits in the device file, expires, and is cleared by resolve', async () => {await local.localReview(state())await settle()diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex 0c80a9487..9ea1434c6 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -2468,9 +2468,9 @@ export default {// --- AI Coach on the phone: the BYOK limits (#527) ---'Advanced': 'Avancé','Max output tokens': 'Jetons de sortie max.',- 'The ceiling on one answer. Reasoning models count its hidden thinking against it, so raise it if a plan is cut off.': 'Le plafond d’une réponse. Les modèles de raisonnement comptent leur réflexion cachée dans ce plafond, alors augmentez-le si un plan est coupé.',+ 'The ceiling on one answer. Reasoning models count its hidden thinking against it, so raise it if a plan is cut off.': 'Le plafond d’une réponse. Les modèles de raisonnement comptent leur réflexion cachée dans ce plafond, alors augmente-le si un plan est coupé.','Daily runs': 'Exécutions par jour',- 'Every Coach run is one request on your provider account. 0 means no limit.': 'Chaque exécution du Coach est une requête sur votre compte fournisseur. 0 signifie aucune limite.',+ 'Every Coach run is one request on your provider account. 0 means no limit.': 'Chaque exécution du Coach est une requête sur ton compte fournisseur. 0 signifie aucune limite.','Max message length': 'Longueur maximale du message','How long a message, refinement or review note can be.': 'La longueur autorisée d’un message, d’une demande de révision ou d’une note d’analyse.',}diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex a6bc34384..eec0a9015 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -2474,7 +2474,7 @@ export default {'Max output tokens': 'Макс. токенов вывода','The ceiling on one answer. Reasoning models count its hidden thinking against it, so raise it if a plan is cut off.': 'Потолок одного ответа. Рассуждающие модели учитывают в нём свои скрытые размышления, поэтому увеличьте его, если план обрывается.','Daily runs': 'Запусков в день',- 'Every Coach run is one request on your provider account. 0 means no limit.': 'Каждый запуск Тренера — один запрос на вашем аккаунте провайдера. 0 означает без ограничений.',+ 'Every Coach run is one request on your provider account. 0 means no limit.': 'Каждый запуск Тренера это один запрос с вашего аккаунта у провайдера. 0 означает без ограничений.','Max message length': 'Макс. длина сообщения','How long a message, refinement or review note can be.': 'Насколько длинным может быть сообщение, просьба о доработке или заметка к разбору.',}diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.jsindex 4646b32e8..cf1f25d31 100644--- a/frontend/src/locales/uk.js+++ b/frontend/src/locales/uk.js@@ -2465,9 +2465,9 @@ export default {// --- AI Coach on the phone: the BYOK limits (#527) ---'Advanced': 'Додатково','Max output tokens': 'Макс. вихідних токенів',- 'The ceiling on one answer. Reasoning models count its hidden thinking against it, so raise it if a plan is cut off.': 'Стеля однієї відповіді. Міркувальні моделі враховують у ній свої приховані роздуми, тож підніміть її, якщо план обривається.',+ 'The ceiling on one answer. Reasoning models count its hidden thinking against it, so raise it if a plan is cut off.': 'Стеля однієї відповіді. Міркувальні моделі враховують у ній свої приховані роздуми, тож підніми її, якщо план обривається.','Daily runs': 'Запусків на день',- 'Every Coach run is one request on your provider account. 0 means no limit.': 'Кожен запуск Тренера — це один запит на вашому акаунті постачальника. 0 означає без обмежень.',+ 'Every Coach run is one request on your provider account. 0 means no limit.': 'Кожен запуск Тренера це один запит з твого акаунта в постачальника. 0 означає без обмежень.','Max message length': 'Макс. довжина повідомлення','How long a message, refinement or review note can be.': 'Наскільки довгим може бути повідомлення, прохання про доопрацювання чи нотатка до розбору.',}