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
fix(coach): failure and refusal messages in the app's language
Boris 'B' Kurktchiev96d23617f6c9
diff --git a/api/coach/routes.js b/api/coach/routes.jsindex bcf992b59..3df0d90f0 100644--- a/api/coach/routes.js+++ b/api/coach/routes.js@@ -27,11 +27,13 @@ const USER_ERROR = {const HTTP_FOR = { off: 503, busy: 409, cap: 429, consent: 403, shared: 409, unprivileged: 503 };export function coachRoutes({ json, readBody, readSession, requireAdmin }) {- /** Every user route starts the same way: signed in, feature on, feature reachable. */+ /** Every user route starts the same way: signed in, feature on, feature reachable. The class+ * goes beside the words, as enqueue's refusal sends it: the app shows its own translated line+ * for the class, and these English words only where it has none. */const guard = (req, res) => {const user = readSession(req);if (!user) { json(res, 401, { error: 'not signed in' }); return null; }- if (!cfgStore.isEnabled() || !cfgStore.isConnected()) { json(res, 503, { error: USER_ERROR.off }); return null; }+ if (!cfgStore.isEnabled() || !cfgStore.isConnected()) { json(res, 503, { error: USER_ERROR.off, code: 'off' }); return null; }return user;};const failEnqueue = (res, e) => {diff --git a/api/openapi.yaml b/api/openapi.yamlindex abb279e45..f61dc56b7 100644--- a/api/openapi.yaml+++ b/api/openapi.yaml@@ -2889,11 +2889,17 @@ components:description: >-The Coach is not set up on this instance — switched off, or no provider connected.Every Coach route answers this rather than pretending, so an unconfigured instance- renders exactly the app it was before the feature existed.+ renders exactly the app it was before the feature existed. `code` is `off`, the+ class a job refused at enqueue for the same reason carries; the app shows its own+ line for it.content:application/json:- schema: { $ref: '#/components/schemas/Error' }- example: { error: "the Coach is not set up on this instance" }+ schema:+ type: object+ properties:+ error: { type: string }+ code: { type: string, enum: [off] }+ example: { error: "the Coach is not set up on this instance", code: off }CoachJobQueued:description: >-Queued. The job runs in the background; its outcome arrives throughdiff --git a/api/test/routes.test.js b/api/test/routes.test.jsindex 93d457214..831512dfe 100644--- a/api/test/routes.test.js+++ b/api/test/routes.test.js@@ -234,3 +234,23 @@ test('an admin can raise the Coach message length past the old 1000-char defaultconst status = await call('GET /api/coach/status');assert.equal(status.body.maxMessageLen, 1800);});++// The guard in front of every user route answers 503 while the Coach is switched off or has no+// provider connected. It sent the words with no class, so the app could not pick its own,+// translated line for it and a German lifter read "the Coach is not set up on this instance". It+// names the class now: 'off', the class enqueue's own refusal carries for the same state.+test('the Coach-off guard names its class beside the words, on every guarded user route', async () => {+ const guarded = ['GET /api/coach/status', 'POST /api/coach/plan', 'POST /api/coach/review', 'POST /api/coach/debrief',+ 'GET /api/coach/cohort', 'POST /api/coach/cohort/share', 'POST /api/coach/pending/resolve'];+ const refusal = { error: 'the Coach is not set up on this instance', code: 'off' };+ const { call } = harness();+ for (const [state, patch] of [['switched off', { enabled: false }], ['no provider connected', { provider: 'anthropic' }]]) {+ fresh(patch);+ assert.equal(cfg.isConnected(), false, state);+ for (const key of guarded) {+ const r = await call(key, {});+ assert.equal(r.status, 503, `${state}: ${key}`);+ assert.deepEqual(r.body, refusal, `${state}: ${key}`);+ }+ }+});diff --git a/frontend/src/lib/coach-api.i18n.test.js b/frontend/src/lib/coach-api.i18n.test.jsnew file mode 100644index 000000000..3df85713b--- /dev/null+++ b/frontend/src/lib/coach-api.i18n.test.js@@ -0,0 +1,126 @@+// @vitest-environment happy-dom+/* JOB_ERRORS and BYOK_ERRORS are what a lifter reads when a Coach job fails, and they were English+ * literals that never went through t(): a German or Brazilian lifter read English in the middle of+ * an otherwise translated chat. They are getters over t() now. This reads every line in every+ * locale pack the way the app loads one (setLang), and pins that the text follows a language+ * picked after coach-api.js loaded, which a map translated once at load time would not.+ *+ * setLang sets the page's lang and dir (right-to-left for Arabic), so this runs with a DOM.+ */+import { readFileSync } from 'node:fs'+import { resolve } from 'node:path'+import { afterEach, describe, expect, it, vi } from 'vitest'++const mocks = vi.hoisted(() => ({ MOBILE: false, coachLocal: null }))+vi.mock('./demo.js', () => ({ DEMO: false, DEMO_SEEDED: 'gym_demo_seeded_v1', REPO: '' }))+vi.mock('./mobile.js', () => ({ get MOBILE() { return mocks.MOBILE } }))+vi.mock('./api.js', () => ({ api: vi.fn() }))+vi.mock('../store/useStore.js', () => ({ useStore: { getState: () => ({ S: {}, coachLocal: mocks.coachLocal }) } }))+vi.mock('../store/useUI.js', () => ({ useUI: { getState: () => ({ toast: vi.fn() }) } }))++const { JOB_ERRORS, BYOK_ERRORS, jobErrorText } = await import('./coach-api.js')+const { setLang, getLang } = await import('./i18n.js')++const PACKS = Object.fromEntries(Object.entries(import.meta.glob('../locales/*.js', { eager: true }))+ .map(([path, mod]) => [path.match(/([^/]+)\.js$/)[1], mod.default]))+const MAPS = { JOB_ERRORS, BYOK_ERRORS }+// Read before any pack is loaded. English ships no pack, so these lines are the keys the packs+// translate, and what t() hands back in English.+const EN = Object.fromEntries(Object.entries(MAPS).map(([name, map]) =>+ [name, Object.fromEntries(Object.keys(map).map(cls => [cls, map[cls]]))]))+const LINES = Object.entries(EN).flatMap(([name, lines]) => Object.keys(lines).map(cls => [name, cls]))++afterEach(async () => {+ await setLang('en')+ mocks.MOBILE = false+ mocks.coachLocal = null+})++describe('every failure line, in every pack', () => {+ it('reads all sixteen packs', () => {+ expect(Object.keys(PACKS)).toHaveLength(16)+ })++ it.each(Object.keys(PACKS).sort())('%s translates each one, and the map reads it from the pack', async lang => {+ const pack = PACKS[lang]+ await setLang(lang)+ expect(getLang()).toBe(lang)+ for (const [name, cls] of LINES) {+ const english = EN[name][cls]+ expect(pack[english], `${lang}: ${name}.${cls} has no entry for ${JSON.stringify(english)}`).toBeTruthy()+ expect(pack[english], `${lang}: ${name}.${cls} is still English`).not.toBe(english)+ expect(MAPS[name][cls], `${lang}: ${name}.${cls}`).toBe(pack[english])+ }+ })+})++describe('a language picked after coach-api.js loaded', () => {+ it('changes what the same map says, and switching back restores the English', async () => {+ expect(getLang()).toBe('en')+ expect(JOB_ERRORS.unprivileged).toBe(EN.JOB_ERRORS.unprivileged)++ await setLang('de')+ expect(JOB_ERRORS.unprivileged).toBe(PACKS.de[EN.JOB_ERRORS.unprivileged])+ expect(jobErrorText('timeout', 'gave up after 10 min')).toBe(PACKS.de[EN.JOB_ERRORS.timeout])++ await setLang('pt-BR')+ expect(JOB_ERRORS.unprivileged).toBe(PACKS['pt-BR'][EN.JOB_ERRORS.unprivileged])+ expect(jobErrorText('meteor')).toBe(PACKS['pt-BR'][EN.JOB_ERRORS.internal])+ expect(jobErrorText('meteor')).not.toBe(PACKS.pt[EN.JOB_ERRORS.internal]) // Brazil's own line, not Portugal's++ await setLang('en')+ expect(JOB_ERRORS.unprivileged).toBe(EN.JOB_ERRORS.unprivileged)+ expect(jobErrorText('timeout')).toBe(EN.JOB_ERRORS.timeout)+ })++ it('reaches the own-key phone lines, with the provider detail still attached', async () => {+ mocks.MOBILE = true+ mocks.coachLocal = { mode: 'byok' }+ await setLang('fr')+ expect(jobErrorText('provider', 'quota exceeded')).toBe(PACKS.fr[EN.BYOK_ERRORS.provider] + '\nquota exceeded')+ // A class the phone has no line of its own for falls back to the shared one, translated too.+ expect(jobErrorText('restart')).toBe(PACKS.fr[EN.JOB_ERRORS.restart])+ expect(jobErrorText(undefined)).toBe(PACKS.fr[EN.BYOK_ERRORS.internal])+ })+})++/* The composer, the quick actions and the intake toast a refused request by its class,+ * JOB_ERRORS[e.data?.code], and fall back to the server's English only where there is no line.+ * These read api/coach/routes.js, where the refusals are worded, and pin that every class it+ * sends has a line here. */+describe('every refusal the server sends has a line here', () => {+ // Read by path, like Library.test.jsx reads index.css: under a DOM environment import.meta.url is+ // not a file URL. The suite runs from frontend/.+ const routes = readFileSync(resolve(process.cwd(), '../api/coach/routes.js'), 'utf8')++ // The guard in front of every Coach route answers 503 while the Coach is switched off or has+ // no provider. Its body carried the words and no class, so the app toasted the server's English.+ it('the Coach-off guard in front of every route names a class this map has a line for', () => {+ const guard = routes.match(/const guard = [\s\S]*?\n {2}\};/)?.[0]+ expect(guard).toBeTruthy()+ const body = guard.match(/json\(res, 503, (\{[^}]*\})\)/)?.[1]+ expect(body).toBeTruthy()+ const cls = body.match(/code: '(\w+)'/)?.[1]+ expect(cls, `the 503 guard answers ${body}, with no class`).toBeTruthy()+ expect(body).toContain(`error: USER_ERROR.${cls}`) // its words are that class's words+ expect(Object.keys(JOB_ERRORS)).toContain(cls)+ expect(JOB_ERRORS[cls]).toBe('The Coach isn’t set up on this instance.')+ })++ // A refusal at enqueue sends { error: USER_ERROR[code], code }. 'shared' is worded verbatim on+ // purpose (it names who can resolve it), so it keeps the server's words; every other class+ // gets the app's line.+ it('every class the enqueue refusal words has a line, except the verbatim shared-account one', () => {+ const block = routes.match(/const USER_ERROR = \{([\s\S]*?)\n\};/)?.[1]+ expect(block).toBeTruthy()+ const classes = [...block.matchAll(/^\s*(\w+):/gm)].map(m => m[1])+ expect(classes).toEqual(expect.arrayContaining(['off', 'busy', 'cap', 'consent', 'shared', 'unprivileged']))+ for (const cls of classes.filter(c => c !== 'shared')) expect(Object.keys(JOB_ERRORS), cls).toContain(cls)+ })++ it('the unprivileged line says what the server says, in the app\'s voice', () => {+ const atEnqueue = routes.match(/^\s*unprivileged: '([^']+)'/m)?.[1]+ expect(atEnqueue).toBeTruthy()+ expect(EN.JOB_ERRORS.unprivileged).toBe(atEnqueue[0].toUpperCase() + atEnqueue.slice(1) + '.')+ })+})diff --git a/frontend/src/lib/coach-api.js b/frontend/src/lib/coach-api.jsindex 097f8d6da..c5cf503ea 100644--- a/frontend/src/lib/coach-api.js+++ b/frontend/src/lib/coach-api.js@@ -142,31 +142,38 @@ export function useCoachStatus(active = true) {// Server failure classes, in the app's voice. The provider's own words go to the admin card;// what a lifter needs is what it means for them and whether trying again will help.+//+// Each line is a getter, so it is translated when it is read, not when this module loads: the+// module loads once, in English, before any locale pack has arrived, and a language picked later+// would otherwise never reach these lines. The lookup is still JOB_ERRORS[cls].export const JOB_ERRORS = {- off: 'The Coach isn’t set up on this instance.',- busy: 'The Coach is already thinking about your training.',- cap: 'The Coach is resting — try again tomorrow.',- consent: 'The Coach needs your go-ahead first.',- timeout: 'The Coach took too long and gave up.',- auth: 'The Coach couldn’t sign in to its provider — the instance owner needs to check its setup.',- missing: 'The Coach isn’t installed properly on this instance.',- provider: 'The Coach couldn’t run — the instance owner needs to check its setup.',- unusable: 'The Coach answered with something the app couldn’t use.',- restart: 'The server restarted while the Coach was thinking.',- nostate: 'The Coach couldn’t read your training data.',- noworkout: 'There is no workout to look at yet — log one first.',- internal: 'Something went wrong on the server.'+ get off() { return t('The Coach isn’t set up on this instance.') },+ get busy() { return t('The Coach is already thinking about your training.') },+ get cap() { return t('The Coach is resting — try again tomorrow.') },+ get consent() { return t('The Coach needs your go-ahead first.') },+ get timeout() { return t('The Coach took too long and gave up.') },+ get auth() { return t('The Coach couldn’t sign in to its provider — the instance owner needs to check its setup.') },+ get missing() { return t('The Coach isn’t installed properly on this instance.') },+ get provider() { return t('The Coach couldn’t run — the instance owner needs to check its setup.') },+ get unusable() { return t('The Coach answered with something the app couldn’t use.') },+ get restart() { return t('The server restarted while the Coach was thinking.') },+ get nostate() { return t('The Coach couldn’t read your training data.') },+ get noworkout() { return t('There is no workout to look at yet — log one first.') },+ // The refusal at enqueue when the process cannot drop privileges (api/coach/jobs.js). The same+ // words as api/coach/routes.js USER_ERROR.unprivileged; what to fix goes to the admin card.+ get unprivileged() { return t('The Coach is switched off on this instance for safety reasons.') },+ get internal() { return t('Something went wrong on the server.') }}// The same failures on a phone that brought its own key: there is no instance owner to// check anything, the person reading this is the operator, and the provider's own words// are the only thing that lets them fix it (a spent quota, a wrong model, a rejected key).export const BYOK_ERRORS = {- auth: 'Your AI provider rejected the key on this phone — check it under Settings → AI Coach.',- missing: 'The Coach isn’t set up on this phone — check Settings → AI Coach.',- provider: 'Your AI provider couldn’t answer.',- unusable: 'The Coach answered with something the app couldn’t use.',- internal: 'Something went wrong on this phone.'+ get auth() { return t('Your AI provider rejected the key on this phone — check it under Settings → AI Coach.') },+ get missing() { return t('The Coach isn’t set up on this phone — check Settings → AI Coach.') },+ get provider() { return t('Your AI provider couldn’t answer.') },+ get unusable() { return t('The Coach answered with something the app couldn’t use.') },+ get internal() { return t('Something went wrong on this phone.') }}/** The line the person sees for a failed job — with the reason attached where they can act on it. */diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.jsindex 890175234..b6251af0d 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('9be6cc7996a836338e4c6d4aaa075dc40f350dad94c72ef67c0a021870720c49')+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('ff812e346abc11307fb114e5823627461cab65be7187adec6311286e5e0a500c')})test('does not leak European Portuguese UI terms', () => {diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.jsindex 07697206c..097c03057 100644--- a/frontend/src/locales/ar.js+++ b/frontend/src/locales/ar.js@@ -1716,4 +1716,20 @@ export default {'Teal': 'أزرق مخضر','Yellow': 'أصفر','Enter how long it took — at least 1 minute.': 'أدخل المدة التي استغرقها — دقيقة واحدة على الأقل.',+ // --- AI Coach: why a job failed or was refused (lib/coach-api.js JOB_ERRORS, BYOK_ERRORS) ---+ 'The Coach isn’t set up on this instance.': 'المدرب غير مُعدّ على هذا المثيل.',+ 'The Coach is resting — try again tomorrow.': 'المدرب يستريح — حاول مرة أخرى غدًا.',+ 'The Coach took too long and gave up.': 'استغرق المدرب وقتًا أطول من اللازم فتوقّف.',+ 'The Coach couldn’t sign in to its provider — the instance owner needs to check its setup.': 'تعذّر على المدرب تسجيل الدخول إلى مزوّده — على مالك المثيل التحقق من إعداده.',+ 'The Coach isn’t installed properly on this instance.': 'المدرب غير مُثبَّت بشكل صحيح على هذا المثيل.',+ 'The Coach couldn’t run — the instance owner needs to check its setup.': 'تعذّر تشغيل المدرب — على مالك المثيل التحقق من إعداده.',+ 'The Coach answered with something the app couldn’t use.': 'ردّ المدرب بشيء لا يمكن للتطبيق استخدامه.',+ 'The server restarted while the Coach was thinking.': 'أُعيد تشغيل الخادم بينما كان المدرب يفكر.',+ 'The Coach couldn’t read your training data.': 'تعذّر على المدرب قراءة بيانات تدريبك.',+ 'The Coach is switched off on this instance for safety reasons.': 'المدرب معطَّل على هذا المثيل لأسباب أمنية.',+ 'Something went wrong on the server.': 'حدث خطأ ما على الخادم.',+ 'Your AI provider rejected the key on this phone — check it under Settings → AI Coach.': 'رفض مزود الذكاء الاصطناعي المفتاح على هذا الهاتف — تحقّق منه في الإعدادات ← مدرب الذكاء الاصطناعي.',+ 'The Coach isn’t set up on this phone — check Settings → AI Coach.': 'المدرب غير مُعدّ على هذا الهاتف — تحقّق من الإعدادات ← مدرب الذكاء الاصطناعي.',+ 'Your AI provider couldn’t answer.': 'تعذّر على مزوّد الذكاء الاصطناعي الخاص بك الرد.',+ 'Something went wrong on this phone.': 'حدث خطأ ما على هذا الهاتف.',}diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex 663a5a5bb..194739a68 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -1683,4 +1683,20 @@ export default {'Teal': 'Türkis','Yellow': 'Gelb','Enter how long it took — at least 1 minute.': 'Gib ein, wie lange es gedauert hat — mindestens 1 Minute.',+ // --- AI Coach: why a job failed or was refused (lib/coach-api.js JOB_ERRORS, BYOK_ERRORS) ---+ 'The Coach isn’t set up on this instance.': 'Der Coach ist auf dieser Instanz nicht eingerichtet.',+ 'The Coach is resting — try again tomorrow.': 'Der Coach pausiert — versuch es morgen wieder.',+ 'The Coach took too long and gave up.': 'Der Coach hat zu lange gebraucht und aufgegeben.',+ 'The Coach couldn’t sign in to its provider — the instance owner needs to check its setup.': 'Der Coach konnte sich nicht bei seinem Anbieter anmelden — der Betreiber der Instanz muss die Einrichtung prüfen.',+ 'The Coach isn’t installed properly on this instance.': 'Der Coach ist auf dieser Instanz nicht richtig installiert.',+ 'The Coach couldn’t run — the instance owner needs to check its setup.': 'Der Coach konnte nicht laufen — der Betreiber der Instanz muss die Einrichtung prüfen.',+ 'The Coach answered with something the app couldn’t use.': 'Der Coach hat mit etwas geantwortet, das die App nicht verwenden kann.',+ 'The server restarted while the Coach was thinking.': 'Der Server wurde neu gestartet, während der Coach nachdachte.',+ 'The Coach couldn’t read your training data.': 'Der Coach konnte deine Trainingsdaten nicht lesen.',+ 'The Coach is switched off on this instance for safety reasons.': 'Der Coach ist auf dieser Instanz aus Sicherheitsgründen ausgeschaltet.',+ 'Something went wrong on the server.': 'Auf dem Server ist etwas schiefgelaufen.',+ 'Your AI provider rejected the key on this phone — check it under Settings → AI Coach.': 'Dein KI-Anbieter hat den Schlüssel auf diesem Handy abgelehnt — prüf ihn unter Einstellungen → KI-Coach.',+ 'The Coach isn’t set up on this phone — check Settings → AI Coach.': 'Der Coach ist auf diesem Handy nicht eingerichtet — schau unter Einstellungen → KI-Coach nach.',+ 'Your AI provider couldn’t answer.': 'Dein KI-Anbieter konnte nicht antworten.',+ 'Something went wrong on this phone.': 'Auf diesem Handy ist etwas schiefgelaufen.',}diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex 8e1d9aa99..951f82ba3 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -1663,4 +1663,20 @@ export default {'Teal': 'Turquesa','Yellow': 'Amarillo','Enter how long it took — at least 1 minute.': 'Indica cuánto duró — al menos 1 minuto.',+ // --- AI Coach: why a job failed or was refused (lib/coach-api.js JOB_ERRORS, BYOK_ERRORS) ---+ 'The Coach isn’t set up on this instance.': 'El entrenador no está configurado en esta instancia.',+ 'The Coach is resting — try again tomorrow.': 'El entrenador descansa: vuelve a intentarlo mañana.',+ 'The Coach took too long and gave up.': 'El entrenador tardó demasiado y se rindió.',+ 'The Coach couldn’t sign in to its provider — the instance owner needs to check its setup.': 'El entrenador no pudo iniciar sesión en su proveedor: el propietario de la instancia tiene que revisar la configuración.',+ 'The Coach isn’t installed properly on this instance.': 'El entrenador no está bien instalado en esta instancia.',+ 'The Coach couldn’t run — the instance owner needs to check its setup.': 'El entrenador no pudo ejecutarse: el propietario de la instancia tiene que revisar la configuración.',+ 'The Coach answered with something the app couldn’t use.': 'El entrenador respondió con algo que la app no puede usar.',+ 'The server restarted while the Coach was thinking.': 'El servidor se reinició mientras el entrenador pensaba.',+ 'The Coach couldn’t read your training data.': 'El entrenador no pudo leer tus datos de entrenamiento.',+ 'The Coach is switched off on this instance for safety reasons.': 'El entrenador está desactivado en esta instancia por motivos de seguridad.',+ 'Something went wrong on the server.': 'Algo ha salido mal en el servidor.',+ 'Your AI provider rejected the key on this phone — check it under Settings → AI Coach.': 'Tu proveedor de IA rechazó la clave de este teléfono: revísala en Ajustes → Entrenador IA.',+ 'The Coach isn’t set up on this phone — check Settings → AI Coach.': 'El entrenador no está configurado en este teléfono: revisa Ajustes → Entrenador IA.',+ 'Your AI provider couldn’t answer.': 'Tu proveedor de IA no pudo responder.',+ 'Something went wrong on this phone.': 'Algo ha salido mal en este teléfono.',}diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex ee904194c..84c74fd94 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -1663,4 +1663,20 @@ export default {'Teal': 'Turquoise','Yellow': 'Jaune','Enter how long it took — at least 1 minute.': 'Indique combien de temps ça a duré — au moins 1 minute.',+ // --- AI Coach: why a job failed or was refused (lib/coach-api.js JOB_ERRORS, BYOK_ERRORS) ---+ 'The Coach isn’t set up on this instance.': 'Le coach n’est pas configuré sur cette instance.',+ 'The Coach is resting — try again tomorrow.': 'Le coach se repose — réessaie demain.',+ 'The Coach took too long and gave up.': 'Le coach a mis trop de temps et a abandonné.',+ 'The Coach couldn’t sign in to its provider — the instance owner needs to check its setup.': 'Le coach n’a pas pu se connecter à son fournisseur — le propriétaire de l’instance doit vérifier sa configuration.',+ 'The Coach isn’t installed properly on this instance.': 'Le coach n’est pas correctement installé sur cette instance.',+ 'The Coach couldn’t run — the instance owner needs to check its setup.': 'Le coach n’a pas pu fonctionner — le propriétaire de l’instance doit vérifier sa configuration.',+ 'The Coach answered with something the app couldn’t use.': 'Le coach a répondu quelque chose que l’app ne peut pas utiliser.',+ 'The server restarted while the Coach was thinking.': 'Le serveur a redémarré pendant que le coach réfléchissait.',+ 'The Coach couldn’t read your training data.': 'Le coach n’a pas pu lire tes données d’entraînement.',+ 'The Coach is switched off on this instance for safety reasons.': 'Le coach est désactivé sur cette instance pour des raisons de sécurité.',+ 'Something went wrong on the server.': 'Une erreur est survenue sur le serveur.',+ 'Your AI provider rejected the key on this phone — check it under Settings → AI Coach.': 'Ton fournisseur d’IA a refusé la clé de ce téléphone — vérifie-la dans Réglages → Coach IA.',+ 'The Coach isn’t set up on this phone — check Settings → AI Coach.': 'Le coach n’est pas configuré sur ce téléphone — va dans Réglages → Coach IA.',+ 'Your AI provider couldn’t answer.': 'Ton fournisseur d’IA n’a pas pu répondre.',+ 'Something went wrong on this phone.': 'Une erreur est survenue sur ce téléphone.',}diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex ccb0ca2aa..33f6b0766 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -1663,4 +1663,20 @@ export default {'Teal': 'फ़िरोज़ी','Yellow': 'पीला','Enter how long it took — at least 1 minute.': 'बताएँ कि इसमें कितना समय लगा — कम से कम 1 मिनट।',+ // --- AI Coach: why a job failed or was refused (lib/coach-api.js JOB_ERRORS, BYOK_ERRORS) ---+ 'The Coach isn’t set up on this instance.': 'इस इंस्टेंस पर कोच सेट नहीं है।',+ 'The Coach is resting — try again tomorrow.': 'कोच आराम कर रहा है — कल फिर कोशिश करें।',+ 'The Coach took too long and gave up.': 'कोच को बहुत देर लगी और उसने हार मान ली।',+ 'The Coach couldn’t sign in to its provider — the instance owner needs to check its setup.': 'कोच अपने प्रदाता में साइन इन नहीं कर सका — इंस्टेंस स्वामी को इसका सेटअप जाँचना होगा।',+ 'The Coach isn’t installed properly on this instance.': 'इस इंस्टेंस पर कोच ठीक से इंस्टॉल नहीं है।',+ 'The Coach couldn’t run — the instance owner needs to check its setup.': 'कोच चल नहीं सका — इंस्टेंस स्वामी को इसका सेटअप जाँचना होगा।',+ 'The Coach answered with something the app couldn’t use.': 'कोच ने ऐसा जवाब दिया जिसे ऐप इस्तेमाल नहीं कर सकता।',+ 'The server restarted while the Coach was thinking.': 'कोच के सोचते समय सर्वर रीस्टार्ट हो गया।',+ 'The Coach couldn’t read your training data.': 'कोच आपका प्रशिक्षण डेटा नहीं पढ़ सका।',+ 'The Coach is switched off on this instance for safety reasons.': 'सुरक्षा कारणों से इस इंस्टेंस पर कोच बंद है।',+ 'Something went wrong on the server.': 'सर्वर पर कुछ गड़बड़ हो गई।',+ 'Your AI provider rejected the key on this phone — check it under Settings → AI Coach.': 'आपके AI प्रदाता ने इस फ़ोन की कुंजी अस्वीकार कर दी — इसे सेटिंग्स → AI कोच में जाँचें।',+ 'The Coach isn’t set up on this phone — check Settings → AI Coach.': 'इस फ़ोन पर कोच सेट नहीं है — सेटिंग्स → AI कोच देखें।',+ 'Your AI provider couldn’t answer.': 'आपका AI प्रदाता जवाब नहीं दे सका।',+ 'Something went wrong on this phone.': 'इस फ़ोन पर कुछ गड़बड़ हो गई।',}diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex 61b151edc..4e622f54e 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -1666,4 +1666,20 @@ export default {'Teal': 'Türkiz','Yellow': 'Sárga','Enter how long it took — at least 1 minute.': 'Add meg, meddig tartott — legalább 1 perc.',+ // --- AI Coach: why a job failed or was refused (lib/coach-api.js JOB_ERRORS, BYOK_ERRORS) ---+ 'The Coach isn’t set up on this instance.': 'Az Edző nincs beállítva ezen a példányon.',+ 'The Coach is resting — try again tomorrow.': 'Az Edző pihen — próbáld újra holnap.',+ 'The Coach took too long and gave up.': 'Az Edző túl sokáig gondolkodott, és feladta.',+ 'The Coach couldn’t sign in to its provider — the instance owner needs to check its setup.': 'Az Edző nem tudott bejelentkezni a szolgáltatójához — a példány tulajdonosának ellenőriznie kell a beállítást.',+ 'The Coach isn’t installed properly on this instance.': 'Az Edző nincs megfelelően telepítve ezen a példányon.',+ 'The Coach couldn’t run — the instance owner needs to check its setup.': 'Az Edző nem tudott elindulni — a példány tulajdonosának ellenőriznie kell a beállítást.',+ 'The Coach answered with something the app couldn’t use.': 'Az Edző olyan választ adott, amelyet az app nem tud használni.',+ 'The server restarted while the Coach was thinking.': 'A szerver újraindult, miközben az Edző gondolkodott.',+ 'The Coach couldn’t read your training data.': 'Az Edző nem tudta beolvasni az edzésadataidat.',+ 'The Coach is switched off on this instance for safety reasons.': 'Az Edző biztonsági okokból ki van kapcsolva ezen a példányon.',+ 'Something went wrong on the server.': 'Hiba történt a szerveren.',+ 'Your AI provider rejected the key on this phone — check it under Settings → AI Coach.': 'Az MI-szolgáltatód elutasította a telefonon lévő kulcsot — ellenőrizd itt: Beállítások → MI-edző.',+ 'The Coach isn’t set up on this phone — check Settings → AI Coach.': 'Az Edző nincs beállítva ezen a telefonon — nézd meg itt: Beállítások → MI-edző.',+ 'Your AI provider couldn’t answer.': 'Az MI-szolgáltatód nem tudott válaszolni.',+ 'Something went wrong on this phone.': 'Hiba történt ezen a telefonon.',}diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 48e5dd34d..208f41157 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -1663,4 +1663,20 @@ export default {'Teal': 'Turchese','Yellow': 'Giallo','Enter how long it took — at least 1 minute.': 'Inserisci quanto è durato — almeno 1 minuto.',+ // --- AI Coach: why a job failed or was refused (lib/coach-api.js JOB_ERRORS, BYOK_ERRORS) ---+ 'The Coach isn’t set up on this instance.': 'Il Coach non è configurato su questa istanza.',+ 'The Coach is resting — try again tomorrow.': 'Il Coach riposa: riprova domani.',+ 'The Coach took too long and gave up.': 'Il Coach ci ha messo troppo e ha rinunciato.',+ 'The Coach couldn’t sign in to its provider — the instance owner needs to check its setup.': 'Il Coach non è riuscito ad accedere al suo provider: il proprietario dell’istanza deve controllarne la configurazione.',+ 'The Coach isn’t installed properly on this instance.': 'Il Coach non è installato correttamente su questa istanza.',+ 'The Coach couldn’t run — the instance owner needs to check its setup.': 'Il Coach non è riuscito a partire: il proprietario dell’istanza deve controllarne la configurazione.',+ 'The Coach answered with something the app couldn’t use.': 'Il Coach ha risposto con qualcosa che l’app non può usare.',+ 'The server restarted while the Coach was thinking.': 'Il server si è riavviato mentre il Coach ci stava pensando.',+ 'The Coach couldn’t read your training data.': 'Il Coach non è riuscito a leggere i tuoi dati di allenamento.',+ 'The Coach is switched off on this instance for safety reasons.': 'Il Coach è disattivato su questa istanza per motivi di sicurezza.',+ 'Something went wrong on the server.': 'Qualcosa è andato storto sul server.',+ 'Your AI provider rejected the key on this phone — check it under Settings → AI Coach.': 'Il tuo provider di IA ha rifiutato la chiave di questo telefono: controllala in Impostazioni → Coach IA.',+ 'The Coach isn’t set up on this phone — check Settings → AI Coach.': 'Il Coach non è configurato su questo telefono: controlla Impostazioni → Coach IA.',+ 'Your AI provider couldn’t answer.': 'Il tuo provider di IA non è riuscito a rispondere.',+ 'Something went wrong on this phone.': 'Qualcosa è andato storto su questo telefono.',}diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex 02628fa0a..369a8ba15 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -1663,4 +1663,20 @@ export default {'Teal': '청록','Yellow': '노랑','Enter how long it took — at least 1 minute.': '걸린 시간을 입력하세요 — 최소 1분.',+ // --- AI Coach: why a job failed or was refused (lib/coach-api.js JOB_ERRORS, BYOK_ERRORS) ---+ 'The Coach isn’t set up on this instance.': '이 인스턴스에는 코치가 설정되어 있지 않습니다.',+ 'The Coach is resting — try again tomorrow.': '코치가 쉬는 중입니다 — 내일 다시 시도하세요.',+ 'The Coach took too long and gave up.': '코치가 너무 오래 걸려서 중단했습니다.',+ 'The Coach couldn’t sign in to its provider — the instance owner needs to check its setup.': '코치가 제공자에 로그인하지 못했습니다 — 인스턴스 소유자가 설정을 확인해야 합니다.',+ 'The Coach isn’t installed properly on this instance.': '이 인스턴스에 코치가 제대로 설치되어 있지 않습니다.',+ 'The Coach couldn’t run — the instance owner needs to check its setup.': '코치를 실행하지 못했습니다 — 인스턴스 소유자가 설정을 확인해야 합니다.',+ 'The Coach answered with something the app couldn’t use.': '코치가 앱에서 사용할 수 없는 답변을 보냈습니다.',+ 'The server restarted while the Coach was thinking.': '코치가 생각하는 동안 서버가 다시 시작되었습니다.',+ 'The Coach couldn’t read your training data.': '코치가 훈련 데이터를 읽지 못했습니다.',+ 'The Coach is switched off on this instance for safety reasons.': '보안상의 이유로 이 인스턴스에서는 코치가 꺼져 있습니다.',+ 'Something went wrong on the server.': '서버에서 문제가 발생했습니다.',+ 'Your AI provider rejected the key on this phone — check it under Settings → AI Coach.': 'AI 제공자가 이 휴대폰의 키를 거부했습니다 — 설정 → AI 코치에서 확인하세요.',+ 'The Coach isn’t set up on this phone — check Settings → AI Coach.': '이 휴대폰에는 코치가 설정되어 있지 않습니다 — 설정 → AI 코치를 확인하세요.',+ 'Your AI provider couldn’t answer.': 'AI 제공자가 응답하지 못했습니다.',+ 'Something went wrong on this phone.': '이 휴대폰에서 문제가 발생했습니다.',}diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex f5910a684..351f97b5a 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -1663,4 +1663,20 @@ export default {'Teal': 'Turkusowy','Yellow': 'Żółty','Enter how long it took — at least 1 minute.': 'Wpisz, ile to trwało — co najmniej 1 minutę.',+ // --- AI Coach: why a job failed or was refused (lib/coach-api.js JOB_ERRORS, BYOK_ERRORS) ---+ 'The Coach isn’t set up on this instance.': 'Trener nie jest skonfigurowany na tej instancji.',+ 'The Coach is resting — try again tomorrow.': 'Trener odpoczywa — spróbuj ponownie jutro.',+ 'The Coach took too long and gave up.': 'Trener myślał zbyt długo i zrezygnował.',+ 'The Coach couldn’t sign in to its provider — the instance owner needs to check its setup.': 'Trener nie mógł zalogować się u swojego dostawcy — właściciel instancji musi sprawdzić konfigurację.',+ 'The Coach isn’t installed properly on this instance.': 'Trener nie jest poprawnie zainstalowany na tej instancji.',+ 'The Coach couldn’t run — the instance owner needs to check its setup.': 'Nie udało się uruchomić trenera — właściciel instancji musi sprawdzić konfigurację.',+ 'The Coach answered with something the app couldn’t use.': 'Trener odpowiedział czymś, czego aplikacja nie może użyć.',+ 'The server restarted while the Coach was thinking.': 'Serwer uruchomił się ponownie, gdy trener myślał.',+ 'The Coach couldn’t read your training data.': 'Trener nie mógł odczytać Twoich danych treningowych.',+ 'The Coach is switched off on this instance for safety reasons.': 'Trener jest wyłączony na tej instancji ze względów bezpieczeństwa.',+ 'Something went wrong on the server.': 'Coś poszło nie tak na serwerze.',+ 'Your AI provider rejected the key on this phone — check it under Settings → AI Coach.': 'Twój dostawca AI odrzucił klucz z tego telefonu — sprawdź go w Ustawieniach → Trener AI.',+ 'The Coach isn’t set up on this phone — check Settings → AI Coach.': 'Trener nie jest skonfigurowany na tym telefonie — zajrzyj do Ustawień → Trener AI.',+ 'Your AI provider couldn’t answer.': 'Twój dostawca AI nie mógł odpowiedzieć.',+ 'Something went wrong on this phone.': 'Coś poszło nie tak na tym telefonie.',}diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.jsindex 41505d76e..1d86347d8 100644--- a/frontend/src/locales/pt-BR.js+++ b/frontend/src/locales/pt-BR.js@@ -1008,6 +1008,19 @@ export const PT_BR_OVERRIDES = {'Teal': 'Turquesa','Yellow': 'Amarelo','Enter how long it took — at least 1 minute.': 'Informe quanto tempo levou — pelo menos 1 minuto.',+ // --- AI Coach: why a job failed or was refused (lib/coach-api.js JOB_ERRORS, BYOK_ERRORS) ---+ 'The Coach is resting — try again tomorrow.': 'O Treinador está descansando — tente de novo amanhã.',+ 'The Coach took too long and gave up.': 'O Treinador demorou demais e desistiu.',+ 'The Coach couldn’t sign in to its provider — the instance owner needs to check its setup.': 'O Treinador não conseguiu fazer login no provedor — o proprietário da instância precisa verificar a configuração.',+ 'The Coach couldn’t run — the instance owner needs to check its setup.': 'O Treinador não conseguiu rodar — o proprietário da instância precisa verificar a configuração.',+ 'The Coach answered with something the app couldn’t use.': 'O Treinador respondeu com algo que o app não consegue usar.',+ 'The server restarted while the Coach was thinking.': 'O servidor reiniciou enquanto o Treinador estava pensando.',+ 'The Coach couldn’t read your training data.': 'O Treinador não conseguiu ler seus dados de treino.',+ 'Something went wrong on the server.': 'Algo deu errado no servidor.',+ 'Your AI provider rejected the key on this phone — check it under Settings → AI Coach.': 'Seu provedor de IA rejeitou a chave deste celular — verifique em Configurações → Treinador IA.',+ 'The Coach isn’t set up on this phone — check Settings → AI Coach.': 'O Treinador não está configurado neste celular — verifique Configurações → Treinador IA.',+ 'Your AI provider couldn’t answer.': 'Seu provedor de IA não conseguiu responder.',+ 'Something went wrong on this phone.': 'Algo deu errado neste celular.',}export default { ...pt, ...PT_BR_OVERRIDES }diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex 65dd8ff54..b219afe64 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -1663,4 +1663,20 @@ export default {'Teal': 'Turquesa','Yellow': 'Amarelo','Enter how long it took — at least 1 minute.': 'Indica quanto tempo demorou — pelo menos 1 minuto.',+ // --- AI Coach: why a job failed or was refused (lib/coach-api.js JOB_ERRORS, BYOK_ERRORS) ---+ 'The Coach isn’t set up on this instance.': 'O Treinador não está configurado nesta instância.',+ 'The Coach is resting — try again tomorrow.': 'O Treinador está a descansar — tenta outra vez amanhã.',+ 'The Coach took too long and gave up.': 'O Treinador demorou demasiado e desistiu.',+ 'The Coach couldn’t sign in to its provider — the instance owner needs to check its setup.': 'O Treinador não conseguiu iniciar sessão no seu fornecedor — o proprietário da instância tem de verificar a configuração.',+ 'The Coach isn’t installed properly on this instance.': 'O Treinador não está instalado corretamente nesta instância.',+ 'The Coach couldn’t run — the instance owner needs to check its setup.': 'O Treinador não conseguiu funcionar — o proprietário da instância tem de verificar a configuração.',+ 'The Coach answered with something the app couldn’t use.': 'O Treinador respondeu com algo que a app não consegue usar.',+ 'The server restarted while the Coach was thinking.': 'O servidor reiniciou enquanto o Treinador estava a pensar.',+ 'The Coach couldn’t read your training data.': 'O Treinador não conseguiu ler os teus dados de treino.',+ 'The Coach is switched off on this instance for safety reasons.': 'O Treinador está desativado nesta instância por motivos de segurança.',+ 'Something went wrong on the server.': 'Algo correu mal no servidor.',+ 'Your AI provider rejected the key on this phone — check it under Settings → AI Coach.': 'O teu fornecedor de IA rejeitou a chave deste telemóvel — verifica-a em Definições → Treinador IA.',+ 'The Coach isn’t set up on this phone — check Settings → AI Coach.': 'O Treinador não está configurado neste telemóvel — verifica Definições → Treinador IA.',+ 'Your AI provider couldn’t answer.': 'O teu fornecedor de IA não conseguiu responder.',+ 'Something went wrong on this phone.': 'Algo correu mal neste telemóvel.',}diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex 2df1568f7..7d92d2d2b 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -1663,4 +1663,20 @@ export default {'Teal': 'Бирюзовый','Yellow': 'Жёлтый','Enter how long it took — at least 1 minute.': 'Укажите, сколько это длилось — не меньше 1 минуты.',+ // --- AI Coach: why a job failed or was refused (lib/coach-api.js JOB_ERRORS, BYOK_ERRORS) ---+ 'The Coach isn’t set up on this instance.': 'Тренер не настроен на этом сервере.',+ 'The Coach is resting — try again tomorrow.': 'Тренер отдыхает — попробуйте ещё раз завтра.',+ 'The Coach took too long and gave up.': 'Тренер думал слишком долго и сдался.',+ 'The Coach couldn’t sign in to its provider — the instance owner needs to check its setup.': 'Тренеру не удалось войти в аккаунт провайдера — владельцу сервера нужно проверить настройки.',+ 'The Coach isn’t installed properly on this instance.': 'Тренер неправильно установлен на этом сервере.',+ 'The Coach couldn’t run — the instance owner needs to check its setup.': 'Тренеру не удалось запуститься — владельцу сервера нужно проверить настройки.',+ 'The Coach answered with something the app couldn’t use.': 'Тренер прислал ответ, которым приложение не может воспользоваться.',+ 'The server restarted while the Coach was thinking.': 'Сервер перезапустился, пока тренер думал.',+ 'The Coach couldn’t read your training data.': 'Тренеру не удалось прочитать ваши данные о тренировках.',+ 'The Coach is switched off on this instance for safety reasons.': 'Тренер отключён на этом сервере из соображений безопасности.',+ 'Something went wrong on the server.': 'На сервере что-то пошло не так.',+ 'Your AI provider rejected the key on this phone — check it under Settings → AI Coach.': 'Ваш провайдер ИИ отклонил ключ на этом телефоне — проверьте его в Настройках → ИИ-тренер.',+ 'The Coach isn’t set up on this phone — check Settings → AI Coach.': 'Тренер не настроен на этом телефоне — проверьте Настройки → ИИ-тренер.',+ 'Your AI provider couldn’t answer.': 'Ваш провайдер ИИ не смог ответить.',+ 'Something went wrong on this phone.': 'На этом телефоне что-то пошло не так.',}diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex 3604d80fa..34eeea64b 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -1674,4 +1674,20 @@ export default {'Teal': 'เขียวน้ำทะเล','Yellow': 'เหลือง','Enter how long it took — at least 1 minute.': 'ใส่ระยะเวลาที่ใช้ — อย่างน้อย 1 นาที',+ // --- AI Coach: why a job failed or was refused (lib/coach-api.js JOB_ERRORS, BYOK_ERRORS) ---+ 'The Coach isn’t set up on this instance.': 'ยังไม่ได้ตั้งค่าโค้ชบนอินสแตนซ์นี้',+ 'The Coach is resting — try again tomorrow.': 'โค้ชกำลังพัก — ลองใหม่พรุ่งนี้',+ 'The Coach took too long and gave up.': 'โค้ชใช้เวลานานเกินไปจึงยกเลิก',+ 'The Coach couldn’t sign in to its provider — the instance owner needs to check its setup.': 'โค้ชลงชื่อเข้าใช้ผู้ให้บริการของตนไม่ได้ — เจ้าของอินสแตนซ์ต้องตรวจสอบการตั้งค่า',+ 'The Coach isn’t installed properly on this instance.': 'ติดตั้งโค้ชบนอินสแตนซ์นี้ไม่ถูกต้อง',+ 'The Coach couldn’t run — the instance owner needs to check its setup.': 'โค้ชทำงานไม่ได้ — เจ้าของอินสแตนซ์ต้องตรวจสอบการตั้งค่า',+ 'The Coach answered with something the app couldn’t use.': 'โค้ชตอบกลับมาในรูปแบบที่แอปใช้ไม่ได้',+ 'The server restarted while the Coach was thinking.': 'เซิร์ฟเวอร์รีสตาร์ตขณะที่โค้ชกำลังคิด',+ 'The Coach couldn’t read your training data.': 'โค้ชอ่านข้อมูลการฝึกของคุณไม่ได้',+ 'The Coach is switched off on this instance for safety reasons.': 'โค้ชถูกปิดบนอินสแตนซ์นี้ด้วยเหตุผลด้านความปลอดภัย',+ 'Something went wrong on the server.': 'มีบางอย่างผิดพลาดบนเซิร์ฟเวอร์',+ 'Your AI provider rejected the key on this phone — check it under Settings → AI Coach.': 'ผู้ให้บริการ AI ของคุณปฏิเสธคีย์บนโทรศัพท์นี้ — ตรวจสอบได้ที่ ตั้งค่า → โค้ช AI',+ 'The Coach isn’t set up on this phone — check Settings → AI Coach.': 'ยังไม่ได้ตั้งค่าโค้ชบนโทรศัพท์นี้ — ตรวจสอบที่ ตั้งค่า → โค้ช AI',+ 'Your AI provider couldn’t answer.': 'ผู้ให้บริการ AI ของคุณตอบกลับไม่ได้',+ 'Something went wrong on this phone.': 'มีบางอย่างผิดพลาดบนโทรศัพท์นี้',}diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex 1c96ebc30..bc0dadc75 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -1663,4 +1663,20 @@ export default {'Teal': 'Turkuaz','Yellow': 'Sarı','Enter how long it took — at least 1 minute.': 'Ne kadar sürdüğünü gir — en az 1 dakika.',+ // --- AI Coach: why a job failed or was refused (lib/coach-api.js JOB_ERRORS, BYOK_ERRORS) ---+ 'The Coach isn’t set up on this instance.': 'Koç bu sunucuda kurulu değil.',+ 'The Coach is resting — try again tomorrow.': 'Koç dinleniyor — yarın tekrar dene.',+ 'The Coach took too long and gave up.': 'Koç fazla uzun düşündü ve vazgeçti.',+ 'The Coach couldn’t sign in to its provider — the instance owner needs to check its setup.': 'Koç sağlayıcısında oturum açamadı — sunucu sahibinin kurulumu kontrol etmesi gerekiyor.',+ 'The Coach isn’t installed properly on this instance.': 'Koç bu sunucuya düzgün yüklenmemiş.',+ 'The Coach couldn’t run — the instance owner needs to check its setup.': 'Koç çalışamadı — sunucu sahibinin kurulumu kontrol etmesi gerekiyor.',+ 'The Coach answered with something the app couldn’t use.': 'Koç, uygulamanın kullanamayacağı bir yanıt verdi.',+ 'The server restarted while the Coach was thinking.': 'Koç düşünürken sunucu yeniden başladı.',+ 'The Coach couldn’t read your training data.': 'Koç antrenman verilerini okuyamadı.',+ 'The Coach is switched off on this instance for safety reasons.': 'Koç güvenlik nedeniyle bu sunucuda kapalı.',+ 'Something went wrong on the server.': 'Sunucuda bir şeyler ters gitti.',+ 'Your AI provider rejected the key on this phone — check it under Settings → AI Coach.': 'Yapay zekâ sağlayıcın bu telefondaki anahtarı reddetti — Ayarlar → Yapay Zekâ Koçu bölümünden kontrol et.',+ 'The Coach isn’t set up on this phone — check Settings → AI Coach.': 'Koç bu telefonda kurulu değil — Ayarlar → Yapay Zekâ Koçu bölümüne bak.',+ 'Your AI provider couldn’t answer.': 'Yapay zekâ sağlayıcın yanıt veremedi.',+ 'Something went wrong on this phone.': 'Bu telefonda bir şeyler ters gitti.',}diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.jsindex ba239e0c8..3df53ef1a 100644--- a/frontend/src/locales/uk.js+++ b/frontend/src/locales/uk.js@@ -1660,4 +1660,20 @@ export default {'Teal': 'Бірюзовий','Yellow': 'Жовтий','Enter how long it took — at least 1 minute.': 'Вкажи, скільки це тривало — щонайменше 1 хвилину.',+ // --- AI Coach: why a job failed or was refused (lib/coach-api.js JOB_ERRORS, BYOK_ERRORS) ---+ 'The Coach isn’t set up on this instance.': 'Тренер не налаштований на цьому сервері.',+ 'The Coach is resting — try again tomorrow.': 'Тренер відпочиває — спробуй ще раз завтра.',+ 'The Coach took too long and gave up.': 'Тренер думав занадто довго й здався.',+ 'The Coach couldn’t sign in to its provider — the instance owner needs to check its setup.': 'Тренеру не вдалося авторизуватися в постачальника — власнику сервера потрібно перевірити налаштування.',+ 'The Coach isn’t installed properly on this instance.': 'Тренер неправильно встановлений на цьому сервері.',+ 'The Coach couldn’t run — the instance owner needs to check its setup.': 'Тренеру не вдалося запуститися — власнику сервера потрібно перевірити налаштування.',+ 'The Coach answered with something the app couldn’t use.': 'Тренер відповів чимось, що застосунок не зміг використати.',+ 'The server restarted while the Coach was thinking.': 'Сервер перезапустився, поки Тренер думав.',+ 'The Coach couldn’t read your training data.': 'Тренеру не вдалося прочитати дані твоїх тренувань.',+ 'The Coach is switched off on this instance for safety reasons.': 'Тренер вимкнений на цьому сервері з міркувань безпеки.',+ 'Something went wrong on the server.': 'Щось пішло не так на сервері.',+ 'Your AI provider rejected the key on this phone — check it under Settings → AI Coach.': 'Твій постачальник ШІ відхилив ключ із цього телефона — перевір його в Налаштуваннях → ШІ-тренер.',+ 'The Coach isn’t set up on this phone — check Settings → AI Coach.': 'Тренер на цьому телефоні не налаштований — перевір Налаштування → ШІ-тренер.',+ 'Your AI provider couldn’t answer.': 'Твій постачальник ШІ не зміг відповісти.',+ 'Something went wrong on this phone.': 'Щось пішло не так на цьому телефоні.',}diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex 84237894a..1cfc81deb 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -1663,4 +1663,20 @@ export default {'Teal': '青色','Yellow': '黄色','Enter how long it took — at least 1 minute.': '请输入用时 — 至少 1 分钟。',+ // --- AI Coach: why a job failed or was refused (lib/coach-api.js JOB_ERRORS, BYOK_ERRORS) ---+ 'The Coach isn’t set up on this instance.': '此实例上尚未设置教练。',+ 'The Coach is resting — try again tomorrow.': '教练正在休息——明天再试。',+ 'The Coach took too long and gave up.': '教练耗时太久,已放弃。',+ 'The Coach couldn’t sign in to its provider — the instance owner needs to check its setup.': '教练无法登录其提供商——需要实例所有者检查配置。',+ 'The Coach isn’t installed properly on this instance.': '此实例上的教练安装不正确。',+ 'The Coach couldn’t run — the instance owner needs to check its setup.': '教练无法运行——需要实例所有者检查配置。',+ 'The Coach answered with something the app couldn’t use.': '应用无法使用教练给出的回答。',+ 'The server restarted while the Coach was thinking.': '教练思考时服务器重启了。',+ 'The Coach couldn’t read your training data.': '教练无法读取你的训练数据。',+ 'The Coach is switched off on this instance for safety reasons.': '出于安全原因,此实例已关闭教练。',+ 'Something went wrong on the server.': '服务器出了点问题。',+ 'Your AI provider rejected the key on this phone — check it under Settings → AI Coach.': '你的 AI 提供商拒绝了此手机上的密钥——请在“设置 → AI 教练”中检查。',+ 'The Coach isn’t set up on this phone — check Settings → AI Coach.': '此手机上尚未设置教练——请查看“设置 → AI 教练”。',+ 'Your AI provider couldn’t answer.': '你的 AI 提供商未能给出回答。',+ 'Something went wrong on this phone.': '此手机上出了点问题。',}diff --git a/frontend/src/views/CoachChat.jsx b/frontend/src/views/CoachChat.jsxindex f1aafe166..d13328ddd 100644--- a/frontend/src/views/CoachChat.jsx+++ b/frontend/src/views/CoachChat.jsx@@ -28,7 +28,7 @@ import {changeTitle, changeValues, exName, canRevert, revertLast} from '../lib/coach.js'import { insightsFor, sessionInsights } from '../lib/coach-insights.js'-import { useCoachStatus, requestReview, requestDebrief, requestPlan, refinePlan, resolvePending, cohortStats, setCohortShare, jobErrorText, awaitedJob, settleAwaited } from '../lib/coach-api.js'+import { useCoachStatus, requestReview, requestDebrief, requestPlan, refinePlan, resolvePending, cohortStats, setCohortShare, jobErrorText, awaitedJob, settleAwaited, JOB_ERRORS } from '../lib/coach-api.js'import { confirmSheet } from '../sheets.jsx'import Icon from '../components/Icon.jsx'import { glyphOf } from '../lib/glyphs.js'@@ -113,7 +113,9 @@ export default function CoachChat() {setText('')refresh()} catch (e) {- toast(e.message || t('Could not ask the Coach'))+ // A server that refuses the job says so in English, with its class beside it: the class+ // picks the translated line. One with no line here ('shared') keeps the server's words.+ toast(JOB_ERRORS[e.data?.code] || e.message || t('Could not ask the Coach'))}setBusy(false)}@@ -124,7 +126,7 @@ export default function CoachChat() {await fn()update(s => appendChat(s, { role: 'user', kind: 'text', text: line }))refresh()- } catch (e) { toast(e.message || t('Could not ask the Coach')) }+ } catch (e) { toast(JOB_ERRORS[e.data?.code] || e.message || t('Could not ask the Coach')) }setBusy(false)}const askReview = () => ask(() => requestReview(''), t('Have a look at my training and tell me what you would change.'))diff --git a/frontend/src/views/CoachChat.refusal.test.jsx b/frontend/src/views/CoachChat.refusal.test.jsxnew file mode 100644index 000000000..7821578cd--- /dev/null+++ b/frontend/src/views/CoachChat.refusal.test.jsx@@ -0,0 +1,125 @@+// @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 CoachChat from './CoachChat.jsx'+import { requestReview } from '../lib/coach-api.js'+import { CONSENT_VERSION } from '../lib/coach.js'++// When the server refuses a Coach request at enqueue it answers in English, with the refusal's+// class beside the words: { error: 'the Coach is already thinking about your training',+// code: 'busy' }. The composer and the quick actions toasted e.message, those English words,+// in the middle of a translated screen. The class now picks the app's own line (JOB_ERRORS,+// translated); a class with no line of its own keeps the server's words.+globalThis.IS_REACT_ACT_ENVIRONMENT = true++const mocks = vi.hoisted(() => {+ const state = { S: null, nav: vi.fn(), toast: vi.fn(), openSheet: vi.fn(), refresh: vi.fn() }+ state.storeSnapshot = () => ({+ S: state.S, user: { id: 'u1' }, ready: true,+ config: { coach: { enabled: true } }, coachLocal: null,+ update: mut => mut(state.S),+ })+ state.uiSnapshot = () => ({ toast: state.toast, openSheet: state.openSheet })+ return state+})++vi.mock('../store/useStore.js', () => {+ const useStore = selector => selector(mocks.storeSnapshot())+ useStore.getState = mocks.storeSnapshot+ return { useStore }+})+vi.mock('../store/useUI.js', () => {+ const useUI = selector => (selector ? selector(mocks.uiSnapshot()) : mocks.uiSnapshot())+ useUI.getState = mocks.uiSnapshot+ return { useUI }+})+vi.mock('react-router-dom', () => ({ useNavigate: () => mocks.nav }))+vi.mock('../lib/coach-api.js', () => ({+ awaitedJob: () => null,+ settleAwaited: vi.fn(),+ useCoachStatus: () => ({ pending: null, job: null, cap: null, loading: false, lastError: null, last: null, refresh: mocks.refresh, maxMessageLen: 2200 }),+ resolvePending: vi.fn(() => Promise.resolve({})),+ refinePlan: vi.fn(() => Promise.resolve({})),+ requestReview: vi.fn(() => Promise.resolve({})),+ requestDebrief: vi.fn(() => Promise.resolve({})),+ requestPlan: vi.fn(() => Promise.resolve({})),+ cohortStats: vi.fn(() => Promise.resolve({ ok: false })),+ setCohortShare: vi.fn(() => Promise.resolve({ ok: true })),+ jobErrorText: () => 'err',+ JOB_ERRORS: { busy: 'the app’s busy line' },+}))+vi.mock('../sheets.jsx', () => ({ startFlow: vi.fn(), confirmSheet: vi.fn() }))+vi.mock('../lib/api.js', () => ({+ api: vi.fn(() => Promise.resolve({})), IS_APPLE: false, IS_ANDROID: false, BIO: 'biometrics',+}))+vi.mock('../coach.css', () => ({}))++// Setting el.value directly does not notify React's value tracker, so the native prototype+// setter has to be called first.+function type(el, value) {+ Object.getOwnPropertyDescriptor(el.constructor.prototype, 'value').set.call(el, value)+ el.dispatchEvent(new Event('input', { bubbles: true }))+}++const state = () => ({+ unit: 'kg', lang: 'en', customEx: [], workouts: [], bodyweight: [], exWeights: {},+ dayPlan: {}, routines: [{ id: 'r1', name: 'Full body', ex: [] }], week: {},+ coach: {+ consent: { agreedAt: '2026-07-01T00:00:00Z', version: CONSENT_VERSION },+ profile: { goal: 'muscle', experience: 'new', daysPerWeek: 3, sessionMin: 60, preferredDays: [1, 3, 5], equipment: [] },+ log: [], snapshots: [], chat: [{ id: 'c1', role: 'user', kind: 'intake', at: 1 }], timings: []+ },+})+// What api.js throws for a refusal: the server's words as the message, its body on `data`.+const refusal = (error, code, status = 409) => Object.assign(new Error(error), { status, data: { error, code } })++let host, root+beforeEach(() => {+ vi.clearAllMocks()+ mocks.S = state()+ host = document.createElement('div')+ document.body.appendChild(host)+ root = createRoot(host)+})+afterEach(() => {+ act(() => { root.unmount() })+ host.remove()+})++const mount = () => act(() => { root.render(<CoachChat />) })+const send = async text => {+ act(() => { type(host.querySelector('.composer textarea'), text) })+ await act(async () => { host.querySelector('.composer .send').dispatchEvent(new Event('click', { bubbles: true })); await Promise.resolve() })+}+const chip = re => [...host.querySelectorAll('button')].find(b => re.test(b.textContent || ''))++describe('a request the server refuses', () => {+ it('from the composer, toasts the app\'s line for its class, not the server\'s English', async () => {+ vi.mocked(requestReview).mockRejectedValueOnce(refusal('the Coach is already thinking about your training', 'busy'))+ mount()+ await send('x')+ expect(mocks.toast).toHaveBeenCalledWith('the app’s busy line')+ })++ it('whose class has no line of its own keeps the server\'s words', async () => {+ vi.mocked(requestReview).mockRejectedValueOnce(refusal('this Coach account is shared; ask the owner', 'shared'))+ mount()+ await send('x')+ expect(mocks.toast).toHaveBeenCalledWith('this Coach account is shared; ask the owner')+ })++ it('from a quick action, toasts the app\'s line for its class too', async () => {+ vi.mocked(requestReview).mockRejectedValueOnce(refusal('the Coach is already thinking about your training', 'busy'))+ mount()+ await act(async () => { chip(/Review my training/).dispatchEvent(new Event('click', { bubbles: true })); await Promise.resolve() })+ expect(mocks.toast).toHaveBeenCalledWith('the app’s busy line')+ })++ it('with no class at all (a network failure) still shows what went wrong', async () => {+ vi.mocked(requestReview).mockRejectedValueOnce(new Error('Network unreachable'))+ mount()+ await send('x')+ expect(mocks.toast).toHaveBeenCalledWith('Network unreachable')+ })+})diff --git a/frontend/src/views/CoachIntake.jsx b/frontend/src/views/CoachIntake.jsxindex a5f859752..981f98dbd 100644--- a/frontend/src/views/CoachIntake.jsx+++ b/frontend/src/views/CoachIntake.jsx@@ -16,7 +16,7 @@ import { t } from '../lib/i18n.js'import { DAYN } from '../lib/format.js'import { EXDB } from '../lib/exercises.js'import { emptyCoach, coachAvailable, hasConsent, CONSENT_VERSION, CATEGORY_TEXT, appendChat } from '../lib/coach.js'-import { requestPlan, disclosure } from '../lib/coach-api.js'+import { requestPlan, disclosure, JOB_ERRORS } from '../lib/coach-api.js'import { DEMO } from '../lib/demo.js'import { MOBILE } from '../lib/mobile.js'import Icon from '../components/Icon.jsx'@@ -102,7 +102,10 @@ export default function CoachIntake() {try {await requestPlan(profile)nav('/coach', { replace: true })- } catch (e) { toast(e.message || t('Could not ask the Coach')); setBusy(false) }+ } catch (e) {+ // The server's refusal is English with its class beside it; the class picks the line.+ toast(JOB_ERRORS[e.data?.code] || e.message || t('Could not ask the Coach')); setBusy(false)+ }}const toggleDay = d => set({diff --git a/frontend/src/views/CoachIntake.test.jsx b/frontend/src/views/CoachIntake.test.jsxindex 9cdf5aefa..3b231a7e0 100644--- a/frontend/src/views/CoachIntake.test.jsx+++ b/frontend/src/views/CoachIntake.test.jsx@@ -48,6 +48,7 @@ vi.mock('react-router-dom', () => ({vi.mock('../lib/coach-api.js', () => ({requestPlan: vi.fn(() => Promise.resolve({})),disclosure: vi.fn(() => Promise.resolve(null)),+ JOB_ERRORS: { busy: 'the app’s busy line' },}))vi.mock('../coach.css', () => ({}))@@ -374,6 +375,14 @@ describe('CoachIntake — building the plan', () => {expect(mocks.S.coach.chat[0]).toMatchObject({ role: 'user', kind: 'intake' })})+ // The server's refusal is English; the class beside it picks the app's own, translated line.+ it('a refusal the server names a class for says the app\'s line for it, not the server\'s English', async () => {+ vi.mocked(requestPlan).mockRejectedValueOnce(Object.assign(new Error('the Coach is already thinking about your training'), { status: 409, data: { error: 'the Coach is already thinking about your training', code: 'busy' } }))+ mount(); walkTo('Almost there')+ cont(); await settle()+ expect(mocks.toast).toHaveBeenCalledWith('the app’s busy line')+ })+it('falls back to a generic message when the failure carries none', async () => {vi.mocked(requestPlan).mockRejectedValueOnce(new Error())mount(); walkTo('Almost there')diff --git a/website/api.html b/website/api.htmlindex 9a2713946..5836742b7 100644--- a/website/api.html+++ b/website/api.html@@ -2096,7 +2096,7 @@ main.api-main .lead { color: var(--fg-2); max-width: 58ch; margin: 14px 0 0; fon</div><div class="prow rrow"><span class="r-code s5">503</span>- <span class="p-desc">The Coach is not set up on this instance — switched off, or no provider connected. Every Coach route answers this rather than pretending, so an unconfigured instance renders exactly the app it was before the feature existed.<span class="r-sig"><code>{"error":"the Coach is not set up on this instance"}</code></span></span>+ <span class="p-desc">The Coach is not set up on this instance — switched off, or no provider connected. Every Coach route answers this rather than pretending, so an unconfigured instance renders exactly the app it was before the feature existed. <code>code</code> is <code>off</code>, the class a job refused at enqueue for the same reason carries; the app shows its own line for it.<span class="r-sig"><code>{"error":"the Coach is not set up on this instance"}</code></span></span></div></div></div>@@ -2165,7 +2165,7 @@ main.api-main .lead { color: var(--fg-2); max-width: 58ch; margin: 14px 0 0; fon</div><div class="prow rrow"><span class="r-code s5">503</span>- <span class="p-desc">The Coach is not set up on this instance — switched off, or no provider connected. Every Coach route answers this rather than pretending, so an unconfigured instance renders exactly the app it was before the feature existed.<span class="r-sig"><code>{"error":"the Coach is not set up on this instance"}</code></span></span>+ <span class="p-desc">The Coach is not set up on this instance — switched off, or no provider connected. Every Coach route answers this rather than pretending, so an unconfigured instance renders exactly the app it was before the feature existed. <code>code</code> is <code>off</code>, the class a job refused at enqueue for the same reason carries; the app shows its own line for it.<span class="r-sig"><code>{"error":"the Coach is not set up on this instance"}</code></span></span></div></div></div>@@ -2218,7 +2218,7 @@ main.api-main .lead { color: var(--fg-2); max-width: 58ch; margin: 14px 0 0; fon</div><div class="prow rrow"><span class="r-code s5">503</span>- <span class="p-desc">The Coach is not set up on this instance — switched off, or no provider connected. Every Coach route answers this rather than pretending, so an unconfigured instance renders exactly the app it was before the feature existed.<span class="r-sig"><code>{"error":"the Coach is not set up on this instance"}</code></span></span>+ <span class="p-desc">The Coach is not set up on this instance — switched off, or no provider connected. Every Coach route answers this rather than pretending, so an unconfigured instance renders exactly the app it was before the feature existed. <code>code</code> is <code>off</code>, the class a job refused at enqueue for the same reason carries; the app shows its own line for it.<span class="r-sig"><code>{"error":"the Coach is not set up on this instance"}</code></span></span></div></div></div>@@ -2271,7 +2271,7 @@ main.api-main .lead { color: var(--fg-2); max-width: 58ch; margin: 14px 0 0; fon</div><div class="prow rrow"><span class="r-code s5">503</span>- <span class="p-desc">The Coach is not set up on this instance — switched off, or no provider connected. Every Coach route answers this rather than pretending, so an unconfigured instance renders exactly the app it was before the feature existed.<span class="r-sig"><code>{"error":"the Coach is not set up on this instance"}</code></span></span>+ <span class="p-desc">The Coach is not set up on this instance — switched off, or no provider connected. Every Coach route answers this rather than pretending, so an unconfigured instance renders exactly the app it was before the feature existed. <code>code</code> is <code>off</code>, the class a job refused at enqueue for the same reason carries; the app shows its own line for it.<span class="r-sig"><code>{"error":"the Coach is not set up on this instance"}</code></span></span></div></div></div>@@ -2317,7 +2317,7 @@ main.api-main .lead { color: var(--fg-2); max-width: 58ch; margin: 14px 0 0; fon</div><div class="prow rrow"><span class="r-code s5">503</span>- <span class="p-desc">The Coach is not set up on this instance — switched off, or no provider connected. Every Coach route answers this rather than pretending, so an unconfigured instance renders exactly the app it was before the feature existed.<span class="r-sig"><code>{"error":"the Coach is not set up on this instance"}</code></span></span>+ <span class="p-desc">The Coach is not set up on this instance — switched off, or no provider connected. Every Coach route answers this rather than pretending, so an unconfigured instance renders exactly the app it was before the feature existed. <code>code</code> is <code>off</code>, the class a job refused at enqueue for the same reason carries; the app shows its own line for it.<span class="r-sig"><code>{"error":"the Coach is not set up on this instance"}</code></span></span></div></div></div>@@ -2347,7 +2347,7 @@ main.api-main .lead { color: var(--fg-2); max-width: 58ch; margin: 14px 0 0; fon</div><div class="prow rrow"><span class="r-code s5">503</span>- <span class="p-desc">The Coach is not set up on this instance — switched off, or no provider connected. Every Coach route answers this rather than pretending, so an unconfigured instance renders exactly the app it was before the feature existed.<span class="r-sig"><code>{"error":"the Coach is not set up on this instance"}</code></span></span>+ <span class="p-desc">The Coach is not set up on this instance — switched off, or no provider connected. Every Coach route answers this rather than pretending, so an unconfigured instance renders exactly the app it was before the feature existed. <code>code</code> is <code>off</code>, the class a job refused at enqueue for the same reason carries; the app shows its own line for it.<span class="r-sig"><code>{"error":"the Coach is not set up on this instance"}</code></span></span></div></div></div>@@ -2386,7 +2386,7 @@ main.api-main .lead { color: var(--fg-2); max-width: 58ch; margin: 14px 0 0; fon</div><div class="prow rrow"><span class="r-code s5">503</span>- <span class="p-desc">The Coach is not set up on this instance — switched off, or no provider connected. Every Coach route answers this rather than pretending, so an unconfigured instance renders exactly the app it was before the feature existed.<span class="r-sig"><code>{"error":"the Coach is not set up on this instance"}</code></span></span>+ <span class="p-desc">The Coach is not set up on this instance — switched off, or no provider connected. Every Coach route answers this rather than pretending, so an unconfigured instance renders exactly the app it was before the feature existed. <code>code</code> is <code>off</code>, the class a job refused at enqueue for the same reason carries; the app shows its own line for it.<span class="r-sig"><code>{"error":"the Coach is not set up on this instance"}</code></span></span></div></div></div>