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
Bugfix-Runde vom Board: Coach-Speichern auf Android (#42), Baender wie Koerpergewicht (#39), Einheitenwechsel rechnet um (#22), Mitte-Tab im Workout (#29/#21), Kopie-Namen, Geister-Wochentag, Swap-Picker
Duarte Santosb5769b9c389d
diff --git a/frontend/src/components/TabBar.jsx b/frontend/src/components/TabBar.jsxindex d54e31cc3..97d27db84 100644--- a/frontend/src/components/TabBar.jsx+++ b/frontend/src/components/TabBar.jsx@@ -32,9 +32,12 @@ export default function TabBar({ onStart }) {<nav id="tabbar"><Tab k="home" icon="house" to="/home" label={t('Home')} /><Tab k="plan" icon="calendar" to="/plan" label={t('Plan')} />- <button className={'start' + (S.active ? ' rec' : '')} onClick={startWorkout}>- <span className="cir"><Icon name={S.active ? 'play' : 'dumbbell'} /></span>- <span>{S.active ? t('Resume') : t('Start')}</span>+ {/* On the workout screen itself there is nothing to resume, so the button reads as the+ tab it is and stays lit (#29); anywhere else it brings you back to the exercise you+ were on — the marker is kept in S.active.cur and never moves on its own (#21). */}+ <button className={'start' + (S.active ? ' rec' : '') + (S.active && cur === 'workout' ? ' on' : '')} onClick={startWorkout}>+ <span className="cir"><Icon name={S.active ? (cur === 'workout' ? 'dumbbell' : 'play') : 'dumbbell'} /></span>+ <span>{S.active ? (cur === 'workout' ? t('Workout') : t('Resume')) : t('Start')}</span></button><Tab k="stats" icon="chart" to="/stats" label={t('Stats')} /><Tab k="library" icon="list" to="/library" label={t('Exercises')} />diff --git a/frontend/src/lib/coach-secrets.js b/frontend/src/lib/coach-secrets.jsindex f97fd9415..4ed7aa91b 100644--- a/frontend/src/lib/coach-secrets.js+++ b/frontend/src/lib/coach-secrets.js@@ -20,10 +20,19 @@ function plugin() {return pluginPromise}+// A native call that never answers must not hang the setup screen behind a greyed-out button+// (issue #42: "Save and use the Coach" stayed disabled forever on one Android 16 phone). After+// this long the platform store is treated as unavailable and the process-local map takes over.+const NATIVE_TIMEOUT_MS = 4000+export const withTimeout = (promise, ms = NATIVE_TIMEOUT_MS) => new Promise((resolve, reject) => {+ const tm = setTimeout(() => reject(new Error('secure storage timed out')), ms)+ promise.then(v => { clearTimeout(tm); resolve(v) }, e => { clearTimeout(tm); reject(e) })+})+export async function getApiKey() {const p = await plugin()if (p) {- try { const v = await p.get(KEY); return typeof v === 'string' && v ? v : null } catch { /* fall through */ }+ try { const v = await withTimeout(p.get(KEY)); return typeof v === 'string' && v ? v : null } catch { /* fall through */ }}return memory.get(KEY) || null}@@ -32,12 +41,12 @@ export async function setApiKey(value) {if (!v) return clearApiKey()const p = await plugin()if (p) {- try { await p.set(KEY, v); memory.delete(KEY); return } catch { /* fall through */ }+ try { await withTimeout(p.set(KEY, v)); memory.delete(KEY); return } catch { /* fall through */ }}memory.set(KEY, v)}export async function clearApiKey() {const p = await plugin()- if (p) { try { await p.remove(KEY) } catch { /* nothing to clear */ } }+ if (p) { try { await withTimeout(p.remove(KEY)) } catch { /* nothing to clear */ } }memory.delete(KEY)}diff --git a/frontend/src/lib/exercises.js b/frontend/src/lib/exercises.jsindex b41448e95..81173a582 100644--- a/frontend/src/lib/exercises.js+++ b/frontend/src/lib/exercises.js@@ -142,8 +142,12 @@ export const isCardio = idOrEx => (typeof idOrEx === 'string' ? EXIDX[idOrEx] :// catalogue. This seeds the `bw` flag on a fresh config so a push-up never asks for a weight// nobody was going to enter. It is only the default: the flag lives on the config, so a dip// done with a belt can turn it off and a custom exercise can turn it on.+// Equipment with no meaningful load in kg: your own body, or a band whose "weight" is a colour.+// Both default to the bodyweight model (one reps stepper, progression in reps then sets); the+// per-exercise Bodyweight switch still overrides it either way (issue #39).+const BODYWEIGHT_EQ = new Set(['body weight', 'band', 'resistance band'])export const isBodyweightEq = idOrEx =>- (typeof idOrEx === 'string' ? EXIDX[idOrEx] : idOrEx)?.eq === 'body weight'+ BODYWEIGHT_EQ.has((typeof idOrEx === 'string' ? EXIDX[idOrEx] : idOrEx)?.eq)// An id that resolves to nothing — a plan file built against a different exercise dataset,// a custom exercise deleted on another device before the sync arrived — still has todiff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.jsindex bd9f68985..a916f6af8 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(618)- expect(inherited).toHaveLength(596)+ expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(620)+ expect(inherited).toHaveLength(598)// 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('1f6ae623aa2a6234b7454b5b6b59512e66a03b39dda46b1b0f359942b970907d')+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('5f1f5dcac5d51dd96f9d1e3506c6a65fd098071b971739686f3cc0360cca35ec')})test('does not leak European Portuguese UI terms', () => {diff --git a/frontend/src/lib/routines.js b/frontend/src/lib/routines.jsindex 7613b302b..13678f012 100644--- a/frontend/src/lib/routines.js+++ b/frontend/src/lib/routines.js@@ -7,6 +7,9 @@ import { uid } from './format.js'export function copyRoutine(routine, suffix = 'Copy') {const copy = structuredClone(routine)copy.id = uid()- copy.name = routine.name + ' (' + suffix + ')'+ // "Push (Copy)" copied again becomes "Push (Copy 2)", not "Push (Copy) (Copy)".+ const esc = suffix.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')+ const m = new RegExp('^(.*) \\(' + esc + '(?: (\\d+))?\\)$').exec(routine.name || '')+ copy.name = m ? m[1] + ' (' + suffix + ' ' + ((Number(m[2]) || 1) + 1) + ')' : routine.name + ' (' + suffix + ')'return copy}diff --git a/frontend/src/lib/routines.test.js b/frontend/src/lib/routines.test.jsindex 8c6912bfc..8f14ebca2 100644--- a/frontend/src/lib/routines.test.js+++ b/frontend/src/lib/routines.test.js@@ -77,3 +77,14 @@ describe('copyRoutine', () => {expect(copy.id).not.toBe('r2')})})++describe('copyRoutine of a copy', () => {+ it('numbers the copies instead of stacking suffixes', () => {+ const first = copyRoutine({ id: 'r', name: 'Push', ex: [] })+ expect(first.name).toBe('Push (Copy)')+ const second = copyRoutine(first)+ expect(second.name).toBe('Push (Copy 2)')+ expect(copyRoutine(second).name).toBe('Push (Copy 3)')+ expect(copyRoutine({ id: 'r', name: 'Push (Kopie)', ex: [] }, 'Kopie').name).toBe('Push (Kopie 2)')+ })+})diff --git a/frontend/src/lib/units.js b/frontend/src/lib/units.jsnew file mode 100644index 000000000..2fb82432c--- /dev/null+++ b/frontend/src/lib/units.js@@ -0,0 +1,54 @@+// Converting a profile between kg and lb. Until now the unit switch only relabelled the numbers+// (60 kg became "60 lb", issue #22); this walks every stored weight once. Rounded to what a gym+// can load: lb to the nearest 0.5, kg to the nearest 0.25 — enough that a value converted there+// and back lands where it started for any plate-loadable number.+const LB_PER_KG = 2.2046226218++export function convertWeight(value, from, to) {+ if (from === to || value == null || value === '' || !Number.isFinite(Number(value))) return value+ const v = Number(value)+ if (to === 'lb') return Math.round(v * LB_PER_KG * 2) / 2+ return Math.round(v / LB_PER_KG * 4) / 4+}++const convSet = (set, from, to) => {+ if (!set || typeof set !== 'object') return set+ const out = { ...set }+ if (out.w != null) out.w = convertWeight(out.w, from, to)+ if (Array.isArray(out.drops)) out.drops = out.drops.map(d => ({ ...d, w: convertWeight(d.w, from, to) }))+ return out+}+const convTarget = (cfg, from, to) => {+ if (!cfg || typeof cfg !== 'object') return cfg+ const out = { ...cfg }+ if (out.weight != null) out.weight = convertWeight(out.weight, from, to)+ // A per-exercise increment is a load too — 2.5 kg is 5 lb, not 2.5 lb.+ if (out.inc > 0 && (out.mode == null || out.mode === 'reps')) out.inc = convertWeight(out.inc, from, to)+ if (Array.isArray(out.warmup)) out.warmup = out.warmup.map(w => (w && w.weight != null ? { ...w, weight: convertWeight(w.weight, from, to) } : w))+ return out+}+const convEntry = (e, from, to) => {+ if (!e || typeof e !== 'object') return e+ return {+ ...e,+ ...(e.topW != null ? { topW: convertWeight(e.topW, from, to) } : {}),+ ...(e.target ? { target: convTarget(e.target, from, to) } : {}),+ ...(Array.isArray(e.sets) ? { sets: e.sets.map(s => convSet(s, from, to)) } : {}),+ }+}++/** A new state object with every weight expressed in `to`, and `unit` set to it. */+export function convertStateUnit(S, to) {+ const from = S.unit || 'kg'+ if (from === to) return S+ const c = v => convertWeight(v, from, to)+ const out = { ...S, unit: to }+ if (Array.isArray(S.bodyweight)) out.bodyweight = S.bodyweight.map(b => ({ ...b, w: c(b.w) }))+ if (S.targetW != null) out.targetW = c(S.targetW)+ if (S.exWeights) out.exWeights = Object.fromEntries(Object.entries(S.exWeights).map(([k, v]) => [k, v && typeof v === 'object' ? { ...v, w: c(v.w) } : c(v)]))+ if (S.barWeights) out.barWeights = Object.fromEntries(Object.entries(S.barWeights).map(([k, v]) => [k, c(v)]))+ if (Array.isArray(S.routines)) out.routines = S.routines.map(r => ({ ...r, ex: (r.ex || []).map(cfg => convTarget(cfg, from, to)) }))+ if (Array.isArray(S.workouts)) out.workouts = S.workouts.map(w => ({ ...w, entries: (w.entries || []).map(e => convEntry(e, from, to)) }))+ if (S.active) out.active = { ...S.active, entries: (S.active.entries || []).map(e => convEntry(e, from, to)) }+ return out+}diff --git a/frontend/src/lib/units.test.js b/frontend/src/lib/units.test.jsnew file mode 100644index 000000000..cfdd40452--- /dev/null+++ b/frontend/src/lib/units.test.js@@ -0,0 +1,52 @@+import { describe, it, expect } from 'vitest'+import { convertWeight, convertStateUnit } from './units.js'++describe('convertWeight', () => {+ it('rounds lb to a half and kg to a quarter', () => {+ expect(convertWeight(60, 'kg', 'lb')).toBe(132.5)+ expect(convertWeight(135, 'lb', 'kg')).toBe(61.25)+ expect(convertWeight(2.5, 'kg', 'lb')).toBe(5.5)+ })+ it('leaves the value alone for the same unit, nothing, or garbage', () => {+ expect(convertWeight(60, 'kg', 'kg')).toBe(60)+ expect(convertWeight(null, 'kg', 'lb')).toBe(null)+ expect(convertWeight('', 'kg', 'lb')).toBe('')+ expect(convertWeight('abc', 'kg', 'lb')).toBe('abc')+ })+ it('round-trips plate-loadable numbers', () => {+ for (const kg of [20, 42.5, 60, 100, 142.5]) {+ expect(convertWeight(convertWeight(kg, 'kg', 'lb'), 'lb', 'kg')).toBe(kg)+ }+ })+})++describe('convertStateUnit', () => {+ const S = {+ unit: 'kg', targetW: 80, bodyweight: [{ d: '2026-01-01', w: 82.4, t: 1 }],+ exWeights: { '0025': { w: 80, d: '2026-01-01' }, legacy: 100 }, barWeights: { '0025': 20 },+ routines: [{ id: 'r', ex: [{ id: '0025', sets: 3, reps: 5, weight: 80, inc: 2.5, warmup: [{ weight: 40, reps: 8 }] }, { id: 'plank', mode: 'time', sec: 30, inc: 5 }] }],+ workouts: [{ id: 'w', entries: [{ id: '0025', topW: 80, target: { weight: 80 }, sets: [{ w: 80, r: 5, done: true, drops: [{ w: 60, r: 5 }] }] }] }],+ active: { id: 'a', entries: [{ id: '0025', sets: [{ w: 82.5, r: 5, done: false }] }] },+ workoutView: 'list',+ }+ it('converts every stored weight and keeps everything else', () => {+ const out = convertStateUnit(S, 'lb')+ expect(out.unit).toBe('lb')+ expect(out.targetW).toBe(176.5)+ expect(out.bodyweight[0]).toEqual({ d: '2026-01-01', w: 181.5, t: 1 })+ expect(out.exWeights['0025'].w).toBe(176.5)+ expect(out.exWeights.legacy).toBe(220.5)+ expect(out.barWeights['0025']).toBe(44)+ expect(out.routines[0].ex[0]).toMatchObject({ weight: 176.5, inc: 5.5, warmup: [{ weight: 88, reps: 8 }] })+ expect(out.routines[0].ex[1]).toEqual({ id: 'plank', mode: 'time', sec: 30, inc: 5 }) // seconds stay seconds+ expect(out.workouts[0].entries[0]).toMatchObject({ topW: 176.5, target: { weight: 176.5 } })+ expect(out.workouts[0].entries[0].sets[0]).toMatchObject({ w: 176.5, done: true, drops: [{ w: 132.5, r: 5 }] })+ expect(out.active.entries[0].sets[0].w).toBe(182)+ expect(out.workoutView).toBe('list')+ expect(S.unit).toBe('kg') // the input is not mutated+ expect(S.workouts[0].entries[0].sets[0].w).toBe(80)+ })+ it('is a no-op for the unit already in use', () => {+ expect(convertStateUnit(S, 'kg')).toBe(S)+ })+})diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex 1dd82aafd..b2f0cd041 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -327,7 +327,6 @@ export default {'Rest timer': 'Pausen-Timer','Sounds': 'Töne','Flash screen when timer ends': 'Bildschirm bei Timer-Ende blinken lassen',- 'Note: switching units only changes the label — logged numbers are not converted.': 'Hinweis: Der Einheitenwechsel ändert nur die Beschriftung — eingetragene Zahlen werden nicht umgerechnet.','Data': 'Daten','Export backup (JSON)': 'Backup exportieren (JSON)','Import backup': 'Backup importieren',@@ -1175,4 +1174,9 @@ export default {'Superset buttons in the exercise header': 'Superset-Tasten im Übungskopf','Move, swap and remove buttons below the exercise': 'Verschieben/Tauschen/Entfernen-Tasten unter der Übung','Everything hidden here stays one tap away: the ⋯ button of an exercise and the number of a set.': 'Alles, was hier ausgeblendet ist, bleibt einen Tipp entfernt: die ⋯-Taste einer Übung und die Nummer eines Satzes.',+ 'Convert to {0}?': 'In {0} umrechnen?',+ 'Every stored weight — logged sets, working weights, routine targets, body weight, bar weights — is in {0}. Convert the numbers, or keep them and only change the label?': 'Jedes gespeicherte Gewicht — eingetragene Sätze, Arbeitsgewichte, Routinenziele, Körpergewicht, Stangengewichte — steht in {0}. Zahlen umrechnen, oder behalten und nur die Beschriftung ändern?',+ 'Convert the numbers': 'Zahlen umrechnen',+ 'Keep the numbers, change the label': 'Zahlen behalten, nur Beschriftung ändern',+ 'Switching the unit offers to convert every stored weight.': 'Beim Einheitenwechsel wird angeboten, alle gespeicherten Gewichte umzurechnen.',}diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex de8a89f07..01e3b64bc 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -313,7 +313,6 @@ export default {'Rest timer': 'Temporizador de descanso','Sounds': 'Sonidos','Flash screen when timer ends': 'Hacer parpadear la pantalla al finalizar el temporizador',- 'Note: switching units only changes the label — logged numbers are not converted.': 'Nota: cambiar la unidad solo cambia la etiqueta — los números registrados no se convierten.','Data': 'Datos','Export backup (JSON)': 'Exportar copia (JSON)','Import backup': 'Importar copia',@@ -1156,4 +1155,9 @@ export default {'Superset buttons in the exercise header': 'Botones de superserie en la cabecera del ejercicio','Move, swap and remove buttons below the exercise': 'Botones mover, cambiar y quitar debajo del ejercicio','Everything hidden here stays one tap away: the ⋯ button of an exercise and the number of a set.': 'Todo lo que ocultes aquí sigue a un toque: el botón ⋯ de un ejercicio y el número de una serie.',+ 'Convert to {0}?': '¿Convertir a {0}?',+ 'Every stored weight — logged sets, working weights, routine targets, body weight, bar weights — is in {0}. Convert the numbers, or keep them and only change the label?': 'Todos los pesos guardados — series registradas, pesos de trabajo, objetivos de rutina, peso corporal, pesos de barra — están en {0}. ¿Convertir los números o mantenerlos y cambiar solo la etiqueta?',+ 'Convert the numbers': 'Convertir los números',+ 'Keep the numbers, change the label': 'Mantener los números, cambiar la etiqueta',+ 'Switching the unit offers to convert every stored weight.': 'Al cambiar la unidad se ofrece convertir todos los pesos guardados.',}diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex cd6539dd0..687918725 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -313,7 +313,6 @@ export default {'Rest timer': 'Minuteur de repos','Sounds': 'Sons','Flash screen when timer ends': 'Faire clignoter l’écran à la fin du minuteur',- 'Note: switching units only changes the label — logged numbers are not converted.': 'Note : changer d’unité ne change que l’étiquette — les nombres enregistrés ne sont pas convertis.','Data': 'Données','Export backup (JSON)': 'Exporter une sauvegarde (JSON)','Import backup': 'Importer une sauvegarde',@@ -1156,4 +1155,9 @@ export default {'Superset buttons in the exercise header': 'Boutons superset dans l\'en-tête de l\'exercice','Move, swap and remove buttons below the exercise': 'Boutons déplacer, remplacer et retirer sous l\'exercice','Everything hidden here stays one tap away: the ⋯ button of an exercise and the number of a set.': 'Tout ce qui est masqué ici reste à un tap : le bouton ⋯ d\'un exercice et le numéro d\'une série.',+ 'Convert to {0}?': 'Convertir en {0} ?',+ 'Every stored weight — logged sets, working weights, routine targets, body weight, bar weights — is in {0}. Convert the numbers, or keep them and only change the label?': 'Tous les poids enregistrés — séries, charges de travail, cibles des routines, poids de corps, poids des barres — sont en {0}. Convertir les nombres, ou les garder et ne changer que l’étiquette ?',+ 'Convert the numbers': 'Convertir les nombres',+ 'Keep the numbers, change the label': 'Garder les nombres, changer l’étiquette',+ 'Switching the unit offers to convert every stored weight.': 'Changer d’unité propose de convertir tous les poids enregistrés.',}diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex 01ab8d773..96a1a2f43 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -313,7 +313,6 @@ export default {'Rest timer': 'आराम टाइमर','Sounds': 'ध्वनियाँ','Flash screen when timer ends': 'टाइमर खत्म होने पर स्क्रीन फ्लैश करें',- 'Note: switching units only changes the label — logged numbers are not converted.': 'नोट: इकाई बदलने से केवल लेबल बदलता है — दर्ज संख्याएँ परिवर्तित नहीं होतीं।','Data': 'डेटा','Export backup (JSON)': 'बैकअप निर्यात करें (JSON)','Import backup': 'बैकअप आयात करें',@@ -1156,4 +1155,9 @@ export default {'Superset buttons in the exercise header': 'व्यायाम शीर्षक में सुपरसेट बटन','Move, swap and remove buttons below the exercise': 'व्यायाम के नीचे स्थानांतरित, बदलें और हटाएँ बटन','Everything hidden here stays one tap away: the ⋯ button of an exercise and the number of a set.': 'यहाँ छिपाया गया सब कुछ एक टैप दूर रहता है: व्यायाम का ⋯ बटन और सेट की संख्या।',+ 'Convert to {0}?': '{0} में बदलें?',+ 'Every stored weight — logged sets, working weights, routine targets, body weight, bar weights — is in {0}. Convert the numbers, or keep them and only change the label?': 'हर सहेजा गया वज़न — दर्ज सेट, कार्य वज़न, रूटीन लक्ष्य, शरीर का वज़न, बार वज़न — {0} में है। संख्याएँ बदलें, या उन्हें रखें और केवल लेबल बदलें?',+ 'Convert the numbers': 'संख्याएँ बदलें',+ 'Keep the numbers, change the label': 'संख्याएँ रखें, लेबल बदलें',+ 'Switching the unit offers to convert every stored weight.': 'इकाई बदलने पर सभी सहेजे गए वज़न बदलने का विकल्प मिलता है।',}diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex 7dfaba5b5..c2da363b8 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -319,7 +319,6 @@ export default {'Week starts on': 'A hét kezdőnapja','Rest timer': 'Pihenő időzítő','Sounds': 'Hangok',- 'Note: switching units only changes the label — logged numbers are not converted.': 'Megjegyzés: a mértékegység váltása csak a feliratot módosítja — a rögzített számok nem lesznek átváltva.','Data': 'Adatok','Export backup (JSON)': 'Biztonsági mentés exportálása (JSON)','Import backup': 'Biztonsági mentés importálása',@@ -1159,4 +1158,9 @@ export default {'Superset buttons in the exercise header': 'Szuperszett gombok a gyakorlat fejlécében','Move, swap and remove buttons below the exercise': 'Mozgatás, csere és eltávolítás gombok a gyakorlat alatt','Everything hidden here stays one tap away: the ⋯ button of an exercise and the number of a set.': 'Minden, amit itt elrejtesz, egy koppintásra marad: a gyakorlat ⋯ gombja és a sorozat száma.',+ 'Convert to {0}?': 'Átváltás {0}-ra?',+ 'Every stored weight — logged sets, working weights, routine targets, body weight, bar weights — is in {0}. Convert the numbers, or keep them and only change the label?': 'Minden tárolt súly — naplózott sorozatok, munkasúlyok, rutincélok, testsúly, rúdsúlyok — {0}-ban van. Átváltsuk a számokat, vagy maradjanak és csak a címke változzon?',+ 'Convert the numbers': 'Számok átváltása',+ 'Keep the numbers, change the label': 'Számok maradnak, csak a címke változik',+ 'Switching the unit offers to convert every stored weight.': 'Mértékegység-váltáskor felajánlja minden tárolt súly átváltását.',}diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 0f622e6a6..497b57553 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -313,7 +313,6 @@ export default {'Rest timer': 'Timer di riposo','Sounds': 'Suoni','Flash screen when timer ends': 'Fai lampeggiare lo schermo alla fine del timer',- 'Note: switching units only changes the label — logged numbers are not converted.': 'Nota: cambiare unità cambia solo l’etichetta — i numeri registrati non vengono convertiti.','Data': 'Dati','Export backup (JSON)': 'Esporta backup (JSON)','Import backup': 'Importa backup',@@ -1156,4 +1155,9 @@ export default {'Superset buttons in the exercise header': 'Pulsanti superset nell’intestazione dell’esercizio','Move, swap and remove buttons below the exercise': 'Pulsanti sposta, sostituisci e rimuovi sotto l’esercizio','Everything hidden here stays one tap away: the ⋯ button of an exercise and the number of a set.': 'Tutto ciò che nascondi qui resta a un tocco: il pulsante ⋯ di un esercizio e il numero di una serie.',+ 'Convert to {0}?': 'Convertire in {0}?',+ 'Every stored weight — logged sets, working weights, routine targets, body weight, bar weights — is in {0}. Convert the numbers, or keep them and only change the label?': 'Ogni peso salvato — serie registrate, pesi di lavoro, obiettivi delle routine, peso corporeo, pesi dei bilancieri — è in {0}. Convertire i numeri o tenerli e cambiare solo l’etichetta?',+ 'Convert the numbers': 'Converti i numeri',+ 'Keep the numbers, change the label': 'Tieni i numeri, cambia l’etichetta',+ 'Switching the unit offers to convert every stored weight.': 'Cambiando unità viene proposto di convertire tutti i pesi salvati.',}diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex 55e6276fd..6b3d8d2c1 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -313,7 +313,6 @@ export default {'Rest timer': '휴식 타이머','Sounds': '소리','Flash screen when timer ends': '타이머 종료 시 화면 깜박임',- 'Note: switching units only changes the label — logged numbers are not converted.': '참고: 단위 변경은 표기만 바꿉니다 — 기록된 숫자는 환산되지 않아요.','Data': '데이터','Export backup (JSON)': '백업 내보내기 (JSON)','Import backup': '백업 가져오기',@@ -1156,4 +1155,9 @@ export default {'Superset buttons in the exercise header': '운동 제목의 슈퍼세트 버튼','Move, swap and remove buttons below the exercise': '운동 아래의 이동·교체·삭제 버튼','Everything hidden here stays one tap away: the ⋯ button of an exercise and the number of a set.': '여기서 숨긴 것은 모두 한 번의 탭으로 열 수 있습니다: 운동의 ⋯ 버튼과 세트 번호.',+ 'Convert to {0}?': '{0}(으)로 변환할까요?',+ 'Every stored weight — logged sets, working weights, routine targets, body weight, bar weights — is in {0}. Convert the numbers, or keep them and only change the label?': '저장된 모든 무게(기록된 세트, 작업 무게, 루틴 목표, 체중, 바 무게)는 {0} 단위입니다. 숫자를 변환할까요, 아니면 숫자는 그대로 두고 표시만 바꿀까요?',+ 'Convert the numbers': '숫자 변환',+ 'Keep the numbers, change the label': '숫자 유지, 표시만 변경',+ 'Switching the unit offers to convert every stored weight.': '단위를 바꾸면 저장된 모든 무게를 변환할지 물어봅니다.',}diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex 1e9773641..1d136a97a 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -313,7 +313,6 @@ export default {'Rest timer': 'Minutnik przerwy','Sounds': 'Dźwięki','Flash screen when timer ends': 'Migaj ekranem po zakończeniu minutnika',- 'Note: switching units only changes the label — logged numbers are not converted.': 'Uwaga: zmiana jednostki zmienia tylko etykietę — zapisane liczby nie są przeliczane.','Data': 'Dane','Export backup (JSON)': 'Eksportuj kopię (JSON)','Import backup': 'Importuj kopię',@@ -1156,4 +1155,9 @@ export default {'Superset buttons in the exercise header': 'Przyciski superserii w nagłówku ćwiczenia','Move, swap and remove buttons below the exercise': 'Przyciski przenieś, zamień i usuń pod ćwiczeniem','Everything hidden here stays one tap away: the ⋯ button of an exercise and the number of a set.': 'Wszystko, co tu ukryjesz, jest o jedno dotknięcie: przycisk ⋯ ćwiczenia i numer serii.',+ 'Convert to {0}?': 'Przeliczyć na {0}?',+ 'Every stored weight — logged sets, working weights, routine targets, body weight, bar weights — is in {0}. Convert the numbers, or keep them and only change the label?': 'Wszystkie zapisane ciężary — serie, ciężary robocze, cele rutyn, masa ciała, ciężary sztang — są w {0}. Przeliczyć liczby, czy zostawić je i zmienić tylko etykietę?',+ 'Convert the numbers': 'Przelicz liczby',+ 'Keep the numbers, change the label': 'Zostaw liczby, zmień etykietę',+ 'Switching the unit offers to convert every stored weight.': 'Zmiana jednostki proponuje przeliczenie wszystkich zapisanych ciężarów.',}diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.jsindex e26afa584..9480788dd 100644--- a/frontend/src/locales/pt-BR.js+++ b/frontend/src/locales/pt-BR.js@@ -107,7 +107,6 @@ export const PT_BR_OVERRIDES = {'synced with your profile': 'sincronizado com seu perfil','The screen stays on while a workout is running, so you don’t have to unlock your phone between sets.': 'A tela permanece ligada durante o treino, para você não precisar desbloquear o celular entre as séries.','Flash screen when timer ends': 'Piscar a tela quando o temporizador terminar',- 'Note: switching units only changes the label — logged numbers are not converted.': 'Observação: trocar a unidade altera somente o rótulo — os valores registrados não são convertidos.','Export backup (JSON)': 'Exportar backup (JSON)','Import backup': 'Importar backup','Reset everything?': 'Redefinir tudo?',@@ -644,7 +643,10 @@ export const PT_BR_OVERRIDES = {'Move, swap and remove buttons below the exercise': 'Botões mover, trocar e remover abaixo do exercício','Everything hidden here stays one tap away: the ⋯ button of an exercise and the number of a set.': 'Tudo o que você esconde aqui fica a um toque: o botão ⋯ de um exercício e o número de uma série.',// effort quick picker — pt-PT uses "toca"/"escreve"; Brazilian uses "toque"/"digite"- 'Tap how many reps you had left, or type an exact {0}.': 'Toque em quantas repetições você ainda tinha, ou digite um {0} exato.'+ 'Tap how many reps you had left, or type an exact {0}.': 'Toque em quantas repetições você ainda tinha, ou digite um {0} exato.',+ 'Every stored weight — logged sets, working weights, routine targets, body weight, bar weights — is in {0}. Convert the numbers, or keep them and only change the label?': 'Todos os pesos salvos — séries registradas, pesos de trabalho, alvos das rotinas, peso corporal, pesos das barras — estão em {0}. Converter os números, ou mantê-los e mudar só o rótulo?',+ 'Keep the numbers, change the label': 'Manter os números, mudar o rótulo',+ 'Switching the unit offers to convert every stored weight.': 'Ao mudar de unidade é oferecido converter todos os pesos salvos.',}export default { ...pt, ...PT_BR_OVERRIDES }diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex 99ca4dff9..b23868852 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -313,7 +313,6 @@ export default {'Rest timer': 'Temporizador de descanso','Sounds': 'Sons','Flash screen when timer ends': 'Piscar o ecrã quando o temporizador terminar',- 'Note: switching units only changes the label — logged numbers are not converted.': 'Nota: mudar a unidade só muda o rótulo — os números registados não são convertidos.','Data': 'Dados','Export backup (JSON)': 'Exportar cópia (JSON)','Import backup': 'Importar cópia',@@ -1156,4 +1155,9 @@ export default {'Superset buttons in the exercise header': 'Botões de superset no cabeçalho do exercício','Move, swap and remove buttons below the exercise': 'Botões mover, trocar e remover por baixo do exercício','Everything hidden here stays one tap away: the ⋯ button of an exercise and the number of a set.': 'Tudo o que escondes aqui fica a um toque: o botão ⋯ de um exercício e o número de uma série.',+ 'Convert to {0}?': 'Converter para {0}?',+ 'Every stored weight — logged sets, working weights, routine targets, body weight, bar weights — is in {0}. Convert the numbers, or keep them and only change the label?': 'Todos os pesos guardados — séries registadas, pesos de trabalho, alvos das rotinas, peso corporal, pesos das barras — estão em {0}. Converter os números, ou mantê-los e mudar só a etiqueta?',+ 'Convert the numbers': 'Converter os números',+ 'Keep the numbers, change the label': 'Manter os números, mudar a etiqueta',+ 'Switching the unit offers to convert every stored weight.': 'Ao mudar de unidade é proposto converter todos os pesos guardados.',}diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex d07463e9a..f05aa66ae 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -313,7 +313,6 @@ export default {'Rest timer': 'Таймер отдыха','Sounds': 'Звуки','Flash screen when timer ends': 'Мигать экраном по окончании таймера',- 'Note: switching units only changes the label — logged numbers are not converted.': 'Примечание: смена единиц меняет только подпись — записанные числа не пересчитываются.','Data': 'Данные','Export backup (JSON)': 'Экспорт резервной копии (JSON)','Import backup': 'Импорт резервной копии',@@ -1156,4 +1155,9 @@ export default {'Superset buttons in the exercise header': 'Кнопки суперсета в заголовке упражнения','Move, swap and remove buttons below the exercise': 'Кнопки переместить, заменить и удалить под упражнением','Everything hidden here stays one tap away: the ⋯ button of an exercise and the number of a set.': 'Всё скрытое здесь остаётся в одном нажатии: кнопка ⋯ упражнения и номер подхода.',+ 'Convert to {0}?': 'Перевести в {0}?',+ 'Every stored weight — logged sets, working weights, routine targets, body weight, bar weights — is in {0}. Convert the numbers, or keep them and only change the label?': 'Все сохранённые веса — подходы, рабочие веса, цели программ, вес тела, вес грифов — записаны в {0}. Пересчитать числа или оставить их и сменить только подпись?',+ 'Convert the numbers': 'Пересчитать числа',+ 'Keep the numbers, change the label': 'Оставить числа, сменить подпись',+ 'Switching the unit offers to convert every stored weight.': 'При смене единицы предлагается пересчитать все сохранённые веса.',}diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex 6fd61ff2b..e6fb2e12a 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -319,7 +319,6 @@ export default {'Week starts on': 'สัปดาห์เริ่มวัน','Rest timer': 'ตัวจับเวลาพัก','Sounds': 'เสียง',- 'Note: switching units only changes the label — logged numbers are not converted.': 'หมายเหตุ: การเปลี่ยนหน่วยจะเปลี่ยนแค่ป้ายกำกับ — ตัวเลขที่บันทึกไว้จะไม่ถูกแปลง','Data': 'ข้อมูล','Export backup (JSON)': 'ส่งออกข้อมูลสำรอง (JSON)','Import backup': 'นำเข้าข้อมูลสำรอง',@@ -1167,4 +1166,9 @@ export default {'Superset buttons in the exercise header': 'ปุ่มซูเปอร์เซ็ตในหัวข้อท่า','Move, swap and remove buttons below the exercise': 'ปุ่มย้าย สลับ และลบใต้ท่าออกกำลังกาย','Everything hidden here stays one tap away: the ⋯ button of an exercise and the number of a set.': 'ทุกอย่างที่ซ่อนไว้ยังอยู่ห่างแค่แตะเดียว: ปุ่ม ⋯ ของท่าและหมายเลขเซ็ต',+ 'Convert to {0}?': 'แปลงเป็น {0} ไหม?',+ 'Every stored weight — logged sets, working weights, routine targets, body weight, bar weights — is in {0}. Convert the numbers, or keep them and only change the label?': 'น้ำหนักที่บันทึกไว้ทั้งหมด — เซ็ตที่บันทึก น้ำหนักทำงาน เป้าหมายของรูทีน น้ำหนักตัว น้ำหนักบาร์ — เป็นหน่วย {0} จะแปลงตัวเลข หรือคงตัวเลขไว้และเปลี่ยนแค่ป้ายหน่วย?',+ 'Convert the numbers': 'แปลงตัวเลข',+ 'Keep the numbers, change the label': 'คงตัวเลขไว้ เปลี่ยนแค่ป้าย',+ 'Switching the unit offers to convert every stored weight.': 'เมื่อเปลี่ยนหน่วยจะมีตัวเลือกให้แปลงน้ำหนักที่บันทึกไว้ทั้งหมด',}diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex a1d5dbde1..a3d5fb91f 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -313,7 +313,6 @@ export default {'Rest timer': 'Dinlenme sayacı','Sounds': 'Sesler','Flash screen when timer ends': 'Zamanlayıcı bitince ekranı yanıp söndür',- 'Note: switching units only changes the label — logged numbers are not converted.': 'Not: birim değiştirmek sadece etiketi değiştirir — kayıtlı sayılar dönüştürülmez.','Data': 'Veriler','Export backup (JSON)': 'Yedeği dışa aktar (JSON)','Import backup': 'Yedeği içe aktar',@@ -1156,4 +1155,9 @@ export default {'Superset buttons in the exercise header': 'Egzersiz başlığında süperset düğmeleri','Move, swap and remove buttons below the exercise': 'Egzersizin altında taşı, değiştir ve kaldır düğmeleri','Everything hidden here stays one tap away: the ⋯ button of an exercise and the number of a set.': 'Burada gizlenen her şey bir dokunuş uzakta kalır: egzersizin ⋯ düğmesi ve setin numarası.',+ 'Convert to {0}?': '{0} birimine çevrilsin mi?',+ 'Every stored weight — logged sets, working weights, routine targets, body weight, bar weights — is in {0}. Convert the numbers, or keep them and only change the label?': 'Kayıtlı tüm ağırlıklar — setler, çalışma ağırlıkları, rutin hedefleri, vücut ağırlığı, bar ağırlıkları — {0} cinsinden. Sayılar çevrilsin mi, yoksa sayılar kalıp yalnızca etiket mi değişsin?',+ 'Convert the numbers': 'Sayıları çevir',+ 'Keep the numbers, change the label': 'Sayıları koru, etiketi değiştir',+ 'Switching the unit offers to convert every stored weight.': 'Birim değiştirilince tüm kayıtlı ağırlıkları çevirme seçeneği sunulur.',}diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex 07ef3c311..911e3d242 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -313,7 +313,6 @@ export default {'Rest timer': '休息计时','Sounds': '声音','Flash screen when timer ends': '计时结束时闪烁屏幕',- 'Note: switching units only changes the label — logged numbers are not converted.': '注意:切换单位只改变标签——已记录的数字不会换算。','Data': '数据','Export backup (JSON)': '导出备份(JSON)','Import backup': '导入备份',@@ -1156,4 +1155,9 @@ export default {'Superset buttons in the exercise header': '动作标题中的超级组按钮','Move, swap and remove buttons below the exercise': '动作下方的移动、替换和删除按钮','Everything hidden here stays one tap away: the ⋯ button of an exercise and the number of a set.': '这里隐藏的一切都只需一次点按:动作的 ⋯ 按钮和组号。',+ 'Convert to {0}?': '换算为 {0}?',+ 'Every stored weight — logged sets, working weights, routine targets, body weight, bar weights — is in {0}. Convert the numbers, or keep them and only change the label?': '所有已保存的重量(记录的组、工作重量、计划目标、体重、杠铃杆重量)目前以 {0} 计。是换算数值,还是保留数值只更改单位标签?',+ 'Convert the numbers': '换算数值',+ 'Keep the numbers, change the label': '保留数值,只改标签',+ 'Switching the unit offers to convert every stored weight.': '切换单位时会提示换算所有已保存的重量。',}diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsxindex 392940119..9c795f120 100644--- a/frontend/src/sheets.jsx+++ b/frontend/src/sheets.jsx@@ -111,11 +111,14 @@ const dayList = days => new Intl.ListFormat(dateLocale()).format(days.map(d => tfunction StarterPlanChooser({ close }) {const week = useStore(s => s.S.week)+ const routines = useStore(s => s.S.routines)const choose = (id, name) => {const days = starterPlanDays(id)close()- // A confirmation is only worth showing when one of those days is actually occupied.- if (!days.some(day => week[day])) { loadStarterPlan(id); return }+ // A confirmation is only worth showing when one of those days is actually occupied — by a+ // routine that still exists, not by a stale id the Plan already shows as "Rest".+ const taken = day => week[day] && routines.some(r => r.id === week[day])+ if (!days.some(taken)) { loadStarterPlan(id); return }confirmSheet({title: t('Load {0}?', name),message: t('The new plan will be scheduled on {0}. Existing routines are kept — only those days of the weekly plan change.', dayList(days)),@@ -866,7 +869,10 @@ export function swapActiveWorkoutExercise(index) {const active = S().activeif (!active?.entries?.[index]) return- const picker = exercisePicker(ex => exConfigSheet(ex, null, cfg => {+ // The "+" on a picker row commits with the default config, exactly as it does in the add+ // flows; tapping the row still opens the config sheet first.+ const picker = exercisePicker((ex, quick) => quick ? swapTo(ex, defaultConfig(ex.id)) : exConfigSheet(ex, null, cfg => swapTo(ex, cfg), null, null))+ function swapTo(ex, cfg) {// The picker is a chooser here, not a stack you keep adding from: one swap, then back to// the workout. (The add flow deliberately leaves it open.)picker.close()@@ -920,7 +926,7 @@ export function swapActiveWorkoutExercise(index) {confirmText: t('Continue'),onConfirm: () => apply({ loggedConfirmed: true })})- }))+ }}/* ============================ equipment profiles ============================ */diff --git a/frontend/src/views/CoachSetup.jsx b/frontend/src/views/CoachSetup.jsxindex e5f81413a..878d266ac 100644--- a/frontend/src/views/CoachSetup.jsx+++ b/frontend/src/views/CoachSetup.jsx@@ -87,10 +87,15 @@ export default function CoachSetup() {if (!chosen) return toast(t('Pick a model'))setBusy(true)try {- if (key.trim()) { await setApiKey(key.trim()); setHasKey(true); setKey('') }+ // The mode first, the key second: the settings file is the cheap, reliable write, the+ // key goes through the platform's secure store, which is the step that can misbehave.+ // Either way the user hears what happened instead of watching a greyed-out button (#42).await setCoachLocal({ mode: 'byok', provider, model: chosen, baseUrl: meta.baseUrl ? (validateBaseUrl(baseUrl).value || null) : null })+ if (key.trim()) { await setApiKey(key.trim()); setHasKey(true); setKey('') }toast(t('The Coach is on'))nav('/coach')+ } catch (e) {+ toast(e?.message || t('Could not connect'))} finally { setBusy(false) }}diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsxindex 36c1e49cd..1949e34d6 100644--- a/frontend/src/views/Settings.jsx+++ b/frontend/src/views/Settings.jsx@@ -2,6 +2,7 @@ import { useEffect, useRef, useState } from 'react'import { useNavigate } from 'react-router-dom'import { useStore, DEF, hasData } from '../store/useStore.js'import { workoutControls } from '../lib/workout-controls.js'+import { convertStateUnit } from '../lib/units.js'import { useUI } from '../store/useUI.js'import { ACCENTS, todayISO, localTZ, weekStartOf, MONDAY, SUNDAY } from '../lib/format.js'import { effortOf } from '../lib/history.js'@@ -12,7 +13,7 @@ import { t, LANGS, INSTR_LANGS } from '../lib/i18n.js'import { DEMO, REPO } from '../lib/demo.js'import { MOBILE, shareExport, syncReminder } from '../lib/mobile.js'import { ConnectSheet } from './MobileOnboarding.jsx'-import { starterPlanSheet, confirmSheet, importFromApp, importFromHevy, equipmentProfileSheet } from '../sheets.jsx'+import { starterPlanSheet, confirmSheet, importFromApp, importFromHevy, equipmentProfileSheet, menuSheet } from '../sheets.jsx'import Icon from '../components/Icon.jsx'import { Section, Row, SelectRow, Switch, Segmented, Button, TextField } from '../components/ui.jsx'@@ -27,6 +28,21 @@ export default function Settings() {const importRef = useRef(null)const wakeOK = wakeLockSupported()+ // Two honest choices on a unit switch (issue #22): convert the numbers, or keep them and only+ // change the label — the old behaviour, still right for someone who logged in lb all along+ // under a kg label. Closing the sheet leaves the unit as it was.+ const switchUnit = v => {+ if (v === S.unit) return+ menuSheet({+ title: t('Convert to {0}?', v),+ subtitle: t('Every stored weight — logged sets, working weights, routine targets, body weight, bar weights — is in {0}. Convert the numbers, or keep them and only change the label?', S.unit),+ items: [+ { icon: 'shuffle', label: t('Convert the numbers'), onClick: () => replaceState(convertStateUnit(useStore.getState().S, v)) },+ { icon: 'pencil', label: t('Keep the numbers, change the label'), onClick: () => update(s => { s.unit = v }) },+ ],+ })+ }+const doExport = async () => {const json = JSON.stringify(S, null, 2)const name = 'opengym-backup-' + todayISO() + '.json'@@ -120,7 +136,7 @@ export default function Settings() {</Section>}{/* ---------- general ---------- */}- <Section title={t('General')} footer={t('Note: switching units only changes the label — logged numbers are not converted.')}>+ <Section title={t('General')} footer={t('Switching the unit offers to convert every stored weight.')}><SelectRowicon="globe" iconTint="var(--blue)" title={t('Language')}value={S.lang || 'en'} onChange={v => update(s => { s.lang = v })}@@ -132,7 +148,7 @@ export default function Settings() {<Row icon="scale" iconTint="var(--teal)" title={t('Weight unit')}><Segmented className="seg-inline"options={[{ value: 'kg', label: 'kg' }, { value: 'lb', label: 'lb' }]}- value={S.unit} onChange={v => update(s => { s.unit = v })} />+ value={S.unit} onChange={v => switchUnit(v)} /></Row>{/* Monday or Sunday — the Plan list, the Home strip, the calendar grid and every"this week" total follow it. Stored as a getDay() index (see lib/format.js). */}