Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Sync: a page that is not the server's answer, a phone without a pairing, or a request that never answers no longer counts as synced

Duarte Santos2d5d4accf033
diff --git a/frontend/src/lib/api.js b/frontend/src/lib/api.js
index 5f3a16671..eea1944f7 100644
--- a/frontend/src/lib/api.js
+++ b/frontend/src/lib/api.js
@@ -1,4 +1,8 @@
// Backend + WebAuthn helpers (ported from the vanilla app).
+import { t } from './i18n-core.js'
+import { MOBILE } from './mobile.js'
+import { appBase } from './app-base.js'
+
export const IS_APPLE = /iPhone|iPad|iPod|Macintosh/.test(navigator.userAgent)
export const IS_ANDROID = /Android/.test(navigator.userAgent)
export const BIO = IS_APPLE ? 'Face ID / Touch ID' : IS_ANDROID ? 'fingerprint or face unlock' : 'your fingerprint, face or PIN'
@@ -15,45 +19,77 @@ let remoteBase = ''
let remoteToken = null
export function setRemoteAuth(base, token) { remoteBase = base || ''; remoteToken = token || null }
-/* Where this copy of the app is served from, e.g. "/" or "/myGym/" (issue #238).
- *
- * The app routes behind the hash and its assets are relative (vite `base: './'`), so the only
- * thing that assumed the site root was the API call. A reverse proxy that puts openGym under a
- * subpath — and strips that prefix before the container sees it, which is what Caddy's
- * `handle_path` and its equivalents do — got `/api/...` at the proxy's own root, where there is
- * nothing to answer it.
- *
- * `location.pathname` is the base because the router never leaves it: every screen is a hash,
- * and a path that is not a file is sent back to the app's root before React boots
- * (web/nginx.conf.template). Anything after the last slash is therefore index.html or a stale
- * deep link, and is dropped.
- */
-export function appBase(loc = typeof location !== 'undefined' ? location : null) {
- const path = (loc && loc.pathname) || '/'
- return path.slice(0, path.lastIndexOf('/') + 1) || '/'
-}
+export { appBase }
+
+// How long one request may take before it counts as no answer at all. A black-holed connection
+// (captive portal, half-open socket, a phone between two networks) never settles on its own, and
+// the store runs one push and one pull at a time: a single hung request used to hold every later
+// sync behind it, silently, for as long as the socket hung. A GET is small; a PUT carries the
+// whole profile over what may be a slow uplink. A caller that knows its request is slow on
+// purpose (the admin's provider test) passes its own `timeout`; 0 means none.
+const TIMEOUT_GET_MS = 20000
+const TIMEOUT_MS = 60000
+
+const failure = (message, code, status) => Object.assign(new Error(message), { code, status })
export async function api(path, opts) {
- const headers = Object.assign({ 'Content-Type': 'application/json' }, opts && opts.headers)
+ const { timeout, ...init } = opts || {}
+ // A phone with no server to talk to: local mode, or a pairing that is gone. There is no
+ // relative URL to fall back on here — the WebView's own origin is Capacitor's local asset
+ // server, which answers ANY path, PUT included, with index.html and a 200, so a push "landed"
+ // there and the change was marked as synced while the server never saw it. status 0, not
+ // undefined: this is not "offline", and the store must not show it as such.
+ if (MOBILE && !remoteBase) throw failure(t('This phone is not connected to a server.'), 'not-paired', 0)
+ const headers = Object.assign({ 'Content-Type': 'application/json' }, init.headers)
if (remoteToken) headers.Authorization = 'Bearer ' + remoteToken
// A paired phone has an absolute base of its own; everyone else is relative to where the app
// is served, so a subpath deployment reaches its own API instead of the proxy's root.
const url = remoteBase ? remoteBase + path : appBase().replace(/\/$/, '') + path
- const r = await fetch(url, Object.assign({}, opts, { headers }))
- const data = await r.json().catch(() => ({}))
+ const ms = timeout != null ? timeout : (init.method || 'GET').toUpperCase() === 'GET' ? TIMEOUT_GET_MS : TIMEOUT_MS
+ return request(url, Object.assign({}, init, { headers }), ms)
+}
+
+// One exchange, bounded by `ms`. No status on the timeout, like a fetch that failed outright: to
+// the store both mean the server could not be reached, and the device says it is offline instead
+// of waiting forever.
+async function request(url, init, ms) {
+ const ctl = typeof AbortController === 'function' ? new AbortController() : null
+ let timer = null
+ const expired = new Promise((_, reject) => {
+ if (ms > 0) timer = setTimeout(() => { if (ctl) ctl.abort(); reject(failure(t('The server did not answer in time.'), 'timeout')) }, ms)
+ })
+ const answer = exchange(url, ctl ? Object.assign({}, init, { signal: ctl.signal }) : init)
+ answer.catch(() => {}) // it may still settle after the timeout has answered; nobody is listening then
+ try { return await Promise.race([answer, expired]) }
+ finally { clearTimeout(timer) }
+}
+
+// Every route of the API answers JSON (api/server.js json()). A 2xx whose body is not JSON is
+// therefore someone else's answer: Capacitor's local server on a phone that lost its pairing, an
+// auth proxy's login page, a proxy that sends /api/* to the app's index.html. Reading it as {}
+// made a push look accepted by a server "from before revisions" — the change was marked synced
+// and dropped from the queue. It is an error, with the status it came with.
+async function exchange(url, init) {
+ const r = await fetch(url, init)
+ let data
+ let parsed = true
+ try { data = await r.json() } catch { parsed = false }
+ const body = parsed && data && typeof data === 'object' ? data : null
// The body rides along on the error: a 409 from /api/data carries the server's document.
- if (!r.ok) { const e = new Error(data.error || ('HTTP ' + r.status)); e.status = r.status; e.data = data; throw e }
- return data
+ if (!r.ok) { const e = new Error((body && body.error) || ('HTTP ' + r.status)); e.status = r.status; e.data = body || {}; throw e }
+ if (!body) throw failure(t('The server answered with something other than openGym data.'), 'bad-response', r.status)
+ return body
}
// Bootstraps the connection itself: the base isn't configured yet (that's what this call decides),
// so it talks straight to the server the user typed in, no Authorization header.
export async function pairRedeem(serverBase, code) {
- const r = await fetch(serverBase + '/api/pair/redeem', {
+ const data = await request(serverBase + '/api/pair/redeem', {
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ code })
- })
- const data = await r.json().catch(() => ({}))
- if (!r.ok) { const e = new Error(data.error || ('HTTP ' + r.status)); e.status = r.status; throw e }
+ }, TIMEOUT_GET_MS)
+ // Anything that is not a pairing would be saved as one — and the phone would then send every
+ // change to a server that never gave it a token.
+ if (!data.token || !data.user) throw failure(t('The server answered with something other than openGym data.'), 'bad-response', 200)
return data
}
diff --git a/frontend/src/lib/api.mobile.test.js b/frontend/src/lib/api.mobile.test.js
new file mode 100644
index 000000000..7c1b23768
--- /dev/null
+++ b/frontend/src/lib/api.mobile.test.js
@@ -0,0 +1,32 @@
+// @vitest-environment happy-dom
+
+/* The phone build with no server to talk to. Its WebView's own origin is Capacitor's local asset
+ server, which answers every path — PUT /api/data included — with index.html and a 200. A phone
+ whose pairing was gone sent its pushes there and marked every change as synced. Without a
+ paired base, api() now refuses before any request goes out. */
+import { afterEach, describe, expect, it, vi } from 'vitest'
+
+vi.mock('./mobile.js', () => ({ MOBILE: true }))
+
+import { api, setRemoteAuth } from './api.js'
+
+afterEach(() => { vi.unstubAllGlobals(); setRemoteAuth('', null) })
+
+describe('api() on the phone build', () => {
+ it('without a paired server it refuses with not-paired (status 0) and never calls fetch', async () => {
+ const fetch = vi.fn()
+ vi.stubGlobal('fetch', fetch)
+ await expect(api('/api/data', { method: 'PUT', body: '{}' })).rejects.toMatchObject({ code: 'not-paired', status: 0 })
+ await expect(api('/api/me')).rejects.toMatchObject({ code: 'not-paired', status: 0 })
+ expect(fetch).not.toHaveBeenCalled()
+ })
+
+ it('paired, it talks to the server with the pairing token', async () => {
+ const fetch = vi.fn(async () => new Response(JSON.stringify({ rev: 3 }), { status: 200, headers: { 'content-type': 'application/json' } }))
+ vi.stubGlobal('fetch', fetch)
+ setRemoteAuth('https://gym.example.com', 'TOKEN')
+ await expect(api('/api/data/rev')).resolves.toEqual({ rev: 3 })
+ expect(fetch.mock.calls[0][0]).toBe('https://gym.example.com/api/data/rev')
+ expect(fetch.mock.calls[0][1].headers.Authorization).toBe('Bearer TOKEN')
+ })
+})
diff --git a/frontend/src/lib/api.test.js b/frontend/src/lib/api.test.js
index 30618a7b9..ab0a8c41d 100644
--- a/frontend/src/lib/api.test.js
+++ b/frontend/src/lib/api.test.js
@@ -1,5 +1,5 @@
// @vitest-environment happy-dom
-import { afterEach, describe, expect, it } from 'vitest'
+import { afterEach, describe, expect, it, vi } from 'vitest'
import { webauthnOK } from './api.js'
const originalPublicKeyCredential = window.PublicKeyCredential
@@ -46,3 +46,90 @@ describe('api()', () => {
} finally { globalThis.fetch = original }
})
})
+
+// Every API route answers JSON. A 2xx that is not JSON is somebody else answering — Capacitor's
+// local server on a phone without a pairing, an auth proxy's login page, a proxy that sends /api/*
+// to index.html — and must never read as a server that took the change.
+describe('api() refuses an answer that is not the server\'s', () => {
+ const html = () => new Response('<!doctype html><title>Sign in</title>', { status: 200, headers: { 'content-type': 'text/html' } })
+ afterEach(() => { vi.unstubAllGlobals(); vi.useRealTimers() })
+
+ it('a 200 page of HTML is an error with the status it came with', async () => {
+ const { api } = await import('./api.js')
+ vi.stubGlobal('fetch', async () => html())
+ await expect(api('/api/data', { method: 'PUT', body: '{}' })).rejects.toMatchObject({ code: 'bad-response', status: 200 })
+ await expect(api('/api/me')).rejects.toMatchObject({ code: 'bad-response', status: 200 })
+ })
+
+ it('a JSON answer still comes back as it is', async () => {
+ const { api } = await import('./api.js')
+ vi.stubGlobal('fetch', async () => new Response(JSON.stringify({ ok: true, rev: 4 }), { status: 200, headers: { 'content-type': 'application/json' } }))
+ await expect(api('/api/data', { method: 'PUT', body: '{}' })).resolves.toEqual({ ok: true, rev: 4 })
+ })
+
+ it('a refused request whose body is not JSON keeps its HTTP status', async () => {
+ const { api } = await import('./api.js')
+ vi.stubGlobal('fetch', async () => new Response('<html>Bad gateway</html>', { status: 502, headers: { 'content-type': 'text/html' } }))
+ await expect(api('/api/data')).rejects.toMatchObject({ status: 502, message: 'HTTP 502', data: {} })
+ })
+
+ it('pairing with something that is not an openGym server fails instead of saving an empty pairing', async () => {
+ const { pairRedeem } = await import('./api.js')
+ vi.stubGlobal('fetch', async () => html())
+ await expect(pairRedeem('https://gym.example.com', 'ABCD2345')).rejects.toMatchObject({ code: 'bad-response' })
+ vi.stubGlobal('fetch', async () => new Response('{}', { status: 200, headers: { 'content-type': 'application/json' } }))
+ await expect(pairRedeem('https://gym.example.com', 'ABCD2345')).rejects.toMatchObject({ code: 'bad-response' })
+ })
+})
+
+// A request that never answers used to hold every later push and pull behind it, silently, for
+// as long as the socket hung. It gives up instead — with no status, so it reads as offline.
+describe('api() gives up on a request that never answers', () => {
+ afterEach(() => { vi.unstubAllGlobals(); vi.useRealTimers() })
+ const hang = () => {
+ const seen = []
+ vi.stubGlobal('fetch', vi.fn((url, init) => { seen.push(init.signal); return new Promise(() => {}) }))
+ return seen
+ }
+
+ it('a GET after 20 s, and the request itself is aborted', async () => {
+ vi.useFakeTimers()
+ const { api } = await import('./api.js')
+ const signals = hang()
+ const p = api('/api/data/rev')
+ const done = vi.fn()
+ p.catch(done)
+ await vi.advanceTimersByTimeAsync(19000)
+ expect(done).not.toHaveBeenCalled()
+ await vi.advanceTimersByTimeAsync(1500)
+ await expect(p).rejects.toMatchObject({ code: 'timeout', status: undefined })
+ expect(signals[0].aborted).toBe(true)
+ })
+
+ it('a PUT after 60 s, since it carries the whole profile', async () => {
+ vi.useFakeTimers()
+ const { api } = await import('./api.js')
+ hang()
+ const p = api('/api/data', { method: 'PUT', body: '{}' })
+ const done = vi.fn()
+ p.catch(done)
+ await vi.advanceTimersByTimeAsync(30000)
+ expect(done).not.toHaveBeenCalled()
+ await vi.advanceTimersByTimeAsync(31000)
+ await expect(p).rejects.toMatchObject({ code: 'timeout' })
+ })
+
+ it('a caller that knows its request is slow sets its own limit, and the option is not sent along', async () => {
+ vi.useFakeTimers()
+ const { api } = await import('./api.js')
+ hang()
+ const p = api('/api/admin/coach/test', { method: 'POST', body: '{}', timeout: 150000 })
+ const done = vi.fn()
+ p.catch(done)
+ await vi.advanceTimersByTimeAsync(120000)
+ expect(done).not.toHaveBeenCalled()
+ expect('timeout' in fetch.mock.calls[0][1]).toBe(false)
+ await vi.advanceTimersByTimeAsync(31000)
+ await expect(p).rejects.toMatchObject({ code: 'timeout' })
+ })
+})
diff --git a/frontend/src/lib/app-base.js b/frontend/src/lib/app-base.js
new file mode 100644
index 000000000..38a622142
--- /dev/null
+++ b/frontend/src/lib/app-base.js
@@ -0,0 +1,20 @@
+/* Where this copy of the app is served from, e.g. "/" or "/myGym/" (issue #238).
+ *
+ * The app routes behind the hash and its assets are relative (vite `base: './'`), so the only
+ * thing that assumed the site root was the API call. A reverse proxy that puts openGym under a
+ * subpath — and strips that prefix before the container sees it, which is what Caddy's
+ * `handle_path` and its equivalents do — got `/api/...` at the proxy's own root, where there is
+ * nothing to answer it.
+ *
+ * `location.pathname` is the base because the router never leaves it: every screen is a hash,
+ * and a path that is not a file is sent back to the app's root before React boots
+ * (web/nginx.conf.template). Anything after the last slash is therefore index.html or a stale
+ * deep link, and is dropped.
+ *
+ * Its own module, not api.js, because the store needs it too (the server a signed-in browser
+ * syncs with) and many tests replace api.js wholesale.
+ */
+export function appBase(loc = typeof location !== 'undefined' ? location : null) {
+ const path = (loc && loc.pathname) || '/'
+ return path.slice(0, path.lastIndexOf('/') + 1) || '/'
+}
diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js
index 13da600c2..ea614c398 100644
--- a/frontend/src/lib/pt-br-locale.test.js
+++ b/frontend/src/lib/pt-br-locale.test.js
@@ -27,11 +27,11 @@ describe('Brazilian Portuguese locale', () => {
.sort(byCodeUnit)
const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex')
- expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(646)
- expect(inherited).toHaveLength(660)
+ expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(647)
+ expect(inherited).toHaveLength(662)
// If this fails, review the changed keys and wording before accepting a new hash. From
// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list
- expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('a2027d64b3944dcef644b11b4d9688b88fe5cff0693acf04c73f0667e2b86825')
+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('d744ba3d33a10d1637cfef9943d1f7016d4e5822a9a2a436080198ab89fd01a3')
})
test('does not leak European Portuguese UI terms', () => {
diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js
index be8751c19..9dd0e1070 100644
--- a/frontend/src/locales/de.js
+++ b/frontend/src/locales/de.js
@@ -1266,6 +1266,9 @@ export default {
'Offline — showing the last copy synced with the server.': 'Offline — zeigt die zuletzt mit dem Server synchronisierte Kopie.',
'Not synced yet — tap to retry.': 'Noch nicht synchronisiert — tippen zum Wiederholen.',
'Back online — synced with the server.': 'Wieder online — mit dem Server synchronisiert.',
+ 'This phone is not connected to a server.': 'Dieses Handy ist mit keinem Server verbunden.',
+ 'The server did not answer in time.': 'Der Server hat nicht rechtzeitig geantwortet.',
+ 'The server answered with something other than openGym data.': 'Der Server hat mit etwas anderem als openGym-Daten geantwortet.',
// --- combine-routines sheet + custom-exercise equipment (v1.3.6) ---
'{0} added — {1}': '{0} hinzugefügt — {1}',
'already added': 'schon drin',
diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js
index ff9ea1936..de4c77837 100644
--- a/frontend/src/locales/es.js
+++ b/frontend/src/locales/es.js
@@ -1246,6 +1246,9 @@ export default {
'Offline — showing the last copy synced with the server.': 'Sin conexión: se muestra la última copia sincronizada con el servidor.',
'Not synced yet — tap to retry.': 'Aún no sincronizado: toca para reintentar.',
'Back online — synced with the server.': 'De nuevo en línea: sincronizado con el servidor.',
+ 'This phone is not connected to a server.': 'Este teléfono no está conectado a ningún servidor.',
+ 'The server did not answer in time.': 'El servidor no respondió a tiempo.',
+ 'The server answered with something other than openGym data.': 'El servidor respondió con algo que no son datos de openGym.',
// --- combine-routines sheet + custom-exercise equipment (v1.3.6) ---
'{0} added — {1}': '{0} añadido — {1}',
'already added': 'ya añadido',
diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js
index 993b89beb..84e13a74b 100644
--- a/frontend/src/locales/fr.js
+++ b/frontend/src/locales/fr.js
@@ -1246,6 +1246,9 @@ export default {
'Offline — showing the last copy synced with the server.': 'Hors ligne — affichage de la dernière copie synchronisée avec le serveur.',
'Not synced yet — tap to retry.': 'Pas encore synchronisé — touchez pour réessayer.',
'Back online — synced with the server.': 'De retour en ligne — synchronisé avec le serveur.',
+ 'This phone is not connected to a server.': "Ce téléphone n'est connecté à aucun serveur.",
+ 'The server did not answer in time.': "Le serveur n'a pas répondu à temps.",
+ 'The server answered with something other than openGym data.': 'Le serveur a répondu avec autre chose que des données openGym.',
// --- combine-routines sheet + custom-exercise equipment (v1.3.6) ---
'{0} added — {1}': '{0} ajouté — {1}',
'already added': 'déjà ajouté',
diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js
index 80ee1ef33..ba0bdb070 100644
--- a/frontend/src/locales/hi.js
+++ b/frontend/src/locales/hi.js
@@ -1246,6 +1246,9 @@ export default {
'Offline — showing the last copy synced with the server.': 'ऑफ़लाइन — सर्वर से सिंक की गई आख़िरी प्रति दिखाई जा रही है।',
'Not synced yet — tap to retry.': 'अभी सिंक नहीं हुआ — फिर से कोशिश के लिए टैप करें।',
'Back online — synced with the server.': 'फिर से ऑनलाइन — सर्वर से सिंक हो गया।',
+ 'This phone is not connected to a server.': 'यह फ़ोन किसी सर्वर से कनेक्ट नहीं है।',
+ 'The server did not answer in time.': 'सर्वर ने समय पर जवाब नहीं दिया।',
+ 'The server answered with something other than openGym data.': 'सर्वर ने openGym डेटा के बजाय कुछ और भेजा।',
// --- combine-routines sheet + custom-exercise equipment (v1.3.6) ---
'{0} added — {1}': '{0} जोड़ा गया — {1}',
'already added': 'पहले से जोड़ा हुआ',
diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js
index 3f9a82eef..c3055a493 100644
--- a/frontend/src/locales/hu.js
+++ b/frontend/src/locales/hu.js
@@ -1249,6 +1249,9 @@ export default {
'Offline — showing the last copy synced with the server.': 'Offline — a szerverrel utoljára szinkronizált másolat látható.',
'Not synced yet — tap to retry.': 'Még nincs szinkronizálva — koppints az újrapróbáláshoz.',
'Back online — synced with the server.': 'Újra online — szinkronizálva a szerverrel.',
+ 'This phone is not connected to a server.': 'Ez a telefon nem csatlakozik szerverhez.',
+ 'The server did not answer in time.': 'A szerver nem válaszolt időben.',
+ 'The server answered with something other than openGym data.': 'A szerver nem openGym-adatokkal válaszolt.',
// --- combine-routines sheet + custom-exercise equipment (v1.3.6) ---
'{0} added — {1}': '{0} hozzáadva — {1}',
'already added': 'már hozzáadva',
diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js
index 0b2d69b12..b4503ddaf 100644
--- a/frontend/src/locales/it.js
+++ b/frontend/src/locales/it.js
@@ -1246,6 +1246,9 @@ export default {
'Offline — showing the last copy synced with the server.': 'Offline — viene mostrata l’ultima copia sincronizzata con il server.',
'Not synced yet — tap to retry.': 'Non ancora sincronizzato — tocca per riprovare.',
'Back online — synced with the server.': 'Di nuovo online — sincronizzato con il server.',
+ 'This phone is not connected to a server.': 'Questo telefono non è collegato a nessun server.',
+ 'The server did not answer in time.': 'Il server non ha risposto in tempo.',
+ 'The server answered with something other than openGym data.': 'Il server ha risposto con qualcosa che non sono dati di openGym.',
// --- combine-routines sheet + custom-exercise equipment (v1.3.6) ---
'{0} added — {1}': '{0} aggiunto — {1}',
'already added': 'già aggiunto',
diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js
index 34c46fe56..7a64994ce 100644
--- a/frontend/src/locales/ko.js
+++ b/frontend/src/locales/ko.js
@@ -1246,6 +1246,9 @@ export default {
'Offline — showing the last copy synced with the server.': '오프라인 — 서버와 마지막으로 동기화된 사본을 표시합니다.',
'Not synced yet — tap to retry.': '아직 동기화되지 않음 — 다시 시도하려면 탭하세요.',
'Back online — synced with the server.': '다시 온라인 — 서버와 동기화되었습니다.',
+ 'This phone is not connected to a server.': '이 휴대폰은 서버에 연결되어 있지 않습니다.',
+ 'The server did not answer in time.': '서버가 제시간에 응답하지 않았습니다.',
+ 'The server answered with something other than openGym data.': '서버가 openGym 데이터가 아닌 응답을 보냈습니다.',
// --- combine-routines sheet + custom-exercise equipment (v1.3.6) ---
'{0} added — {1}': '{0} 추가됨 — {1}',
'already added': '이미 추가됨',
diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js
index fb9551997..3a2e9e8d3 100644
--- a/frontend/src/locales/pl.js
+++ b/frontend/src/locales/pl.js
@@ -1246,6 +1246,9 @@ export default {
'Offline — showing the last copy synced with the server.': 'Offline — wyświetlana jest ostatnia kopia zsynchronizowana z serwerem.',
'Not synced yet — tap to retry.': 'Jeszcze nie zsynchronizowano — dotknij, aby ponowić.',
'Back online — synced with the server.': 'Znów online — zsynchronizowano z serwerem.',
+ 'This phone is not connected to a server.': 'Ten telefon nie jest połączony z żadnym serwerem.',
+ 'The server did not answer in time.': 'Serwer nie odpowiedział na czas.',
+ 'The server answered with something other than openGym data.': 'Serwer odpowiedział czymś innym niż danymi openGym.',
// --- combine-routines sheet + custom-exercise equipment (v1.3.6) ---
'{0} added — {1}': 'Dodano {0} — {1}',
'already added': 'już dodano',
diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js
index 3ab28613a..487fe8849 100644
--- a/frontend/src/locales/pt-BR.js
+++ b/frontend/src/locales/pt-BR.js
@@ -673,6 +673,7 @@ export const PT_BR_OVERRIDES = {
'Download & Install': 'Baixar e instalar',
'Starting download…': 'Iniciando download…',
'Downloading update…': 'Baixando atualização…',
+ 'This phone is not connected to a server.': 'Este celular não está conectado a nenhum servidor.',
}
export default { ...pt, ...PT_BR_OVERRIDES }
diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js
index fc28ddbcf..6030e1c33 100644
--- a/frontend/src/locales/pt.js
+++ b/frontend/src/locales/pt.js
@@ -1246,6 +1246,9 @@ export default {
'Offline — showing the last copy synced with the server.': 'Offline — a mostrar a última cópia sincronizada com o servidor.',
'Not synced yet — tap to retry.': 'Ainda não sincronizado — toca para tentar de novo.',
'Back online — synced with the server.': 'De volta online — sincronizado com o servidor.',
+ 'This phone is not connected to a server.': 'Este telemóvel não está ligado a nenhum servidor.',
+ 'The server did not answer in time.': 'O servidor não respondeu a tempo.',
+ 'The server answered with something other than openGym data.': 'O servidor respondeu com algo que não são dados do openGym.',
// --- combine-routines sheet + custom-exercise equipment (v1.3.6) ---
'{0} added — {1}': '{0} adicionado — {1}',
'already added': 'já adicionado',
diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js
index f8ebf9c8c..2ae297a67 100644
--- a/frontend/src/locales/ru.js
+++ b/frontend/src/locales/ru.js
@@ -1246,6 +1246,9 @@ export default {
'Offline — showing the last copy synced with the server.': 'Офлайн — показана последняя копия, синхронизированная с сервером.',
'Not synced yet — tap to retry.': 'Ещё не синхронизировано — нажмите, чтобы повторить.',
'Back online — synced with the server.': 'Снова онлайн — синхронизировано с сервером.',
+ 'This phone is not connected to a server.': 'Этот телефон не подключён ни к одному серверу.',
+ 'The server did not answer in time.': 'Сервер не ответил вовремя.',
+ 'The server answered with something other than openGym data.': 'Сервер ответил чем-то, что не является данными openGym.',
// --- combine-routines sheet + custom-exercise equipment (v1.3.6) ---
'{0} added — {1}': '{0} добавлено — {1}',
'already added': 'уже добавлено',
diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js
index 002b4f0cd..88732e969 100644
--- a/frontend/src/locales/th.js
+++ b/frontend/src/locales/th.js
@@ -1257,6 +1257,9 @@ export default {
'Offline — showing the last copy synced with the server.': 'ออฟไลน์ — แสดงสำเนาล่าสุดที่ซิงค์กับเซิร์ฟเวอร์',
'Not synced yet — tap to retry.': 'ยังไม่ได้ซิงค์ — แตะเพื่อลองใหม่',
'Back online — synced with the server.': 'กลับมาออนไลน์แล้ว — ซิงค์กับเซิร์ฟเวอร์แล้ว',
+ 'This phone is not connected to a server.': 'โทรศัพท์เครื่องนี้ไม่ได้เชื่อมต่อกับเซิร์ฟเวอร์ใด',
+ 'The server did not answer in time.': 'เซิร์ฟเวอร์ไม่ตอบกลับภายในเวลาที่กำหนด',
+ 'The server answered with something other than openGym data.': 'เซิร์ฟเวอร์ตอบกลับด้วยข้อมูลที่ไม่ใช่ข้อมูลของ openGym',
// --- combine-routines sheet + custom-exercise equipment (v1.3.6) ---
'{0} added — {1}': 'เพิ่ม {0} แล้ว — {1}',
'already added': 'เพิ่มแล้ว',
diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js
index 0a13c479c..40102e025 100644
--- a/frontend/src/locales/tr.js
+++ b/frontend/src/locales/tr.js
@@ -1246,6 +1246,9 @@ export default {
'Offline — showing the last copy synced with the server.': 'Çevrimdışı — sunucuyla en son eşitlenen kopya gösteriliyor.',
'Not synced yet — tap to retry.': 'Henüz eşitlenmedi — yeniden denemek için dokun.',
'Back online — synced with the server.': 'Yeniden çevrimiçi — sunucuyla eşitlendi.',
+ 'This phone is not connected to a server.': 'Bu telefon hiçbir sunucuya bağlı değil.',
+ 'The server did not answer in time.': 'Sunucu zamanında yanıt vermedi.',
+ 'The server answered with something other than openGym data.': 'Sunucu openGym verisi dışında bir şeyle yanıt verdi.',
// --- combine-routines sheet + custom-exercise equipment (v1.3.6) ---
'{0} added — {1}': '{0} eklendi — {1}',
'already added': 'zaten ekli',
diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js
index 85360be61..ea5cd4eb2 100644
--- a/frontend/src/locales/zh.js
+++ b/frontend/src/locales/zh.js
@@ -1246,6 +1246,9 @@ export default {
'Offline — showing the last copy synced with the server.': '离线 — 正在显示最后一次与服务器同步的副本。',
'Not synced yet — tap to retry.': '尚未同步 — 点按重试。',
'Back online — synced with the server.': '已恢复联网 — 已与服务器同步。',
+ 'This phone is not connected to a server.': '这部手机没有连接到任何服务器。',
+ 'The server did not answer in time.': '服务器没有及时响应。',
+ 'The server answered with something other than openGym data.': '服务器返回的不是 openGym 数据。',
// --- combine-routines sheet + custom-exercise equipment (v1.3.6) ---
'{0} added — {1}': '已添加 {0} — {1}',
'already added': '已添加',
diff --git a/frontend/src/views/AdminCoach.jsx b/frontend/src/views/AdminCoach.jsx
index 54bd8f05f..98eedada5 100644
--- a/frontend/src/views/AdminCoach.jsx
+++ b/frontend/src/views/AdminCoach.jsx
@@ -62,7 +62,9 @@ export default function AdminCoach() {
const test = async () => {
setBusy(true); setTestResult({ pending: true })
try {
- const r = await api('/api/admin/coach/test', { method: 'POST', body: '{}' })
+ // The server gives the provider up to 90 s for this round-trip (api/coach/jobs.js testRun),
+ // longer than api()'s default for a request; a slow local model must still get its answer.
+ const r = await api('/api/admin/coach/test', { method: 'POST', body: '{}', timeout: 150000 })
setTestResult(r)
toast(r.ok ? 'Coach test passed ✅' : 'Test failed')
await load()