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.

Settings: the admin Coach row only while the server offers the Coach, Swedish string (#683)

Duarte Santos64d1cb95540b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 18c8832f9..afd011079 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -29,6 +29,9 @@ per muscle. Settings → Workout → Fine-tuning turns it off.
now lists each one in its ⋯ menu during a workout. Tap it and the backup takes over with the
slot's own sets, reps, rest and warm-ups, and the exercise it replaced becomes its backup, so
going back when the bench frees up is one tap too. Your routine stays exactly as it was.
+- **The AI Coach is one tap away for admins** (#683, thanks TheBlackSide243). On a server that
+ offers the Coach, admins now find an AI Coach row in Settings, right next to Look, that opens
+ the admin dashboard straight at the Coach card.
- **Discard means discard, on the Apple Watch too** (#776). Discarding a workout on the phone
while the watch follows it used to save it to Apple Health anyway, calories and all. Now the
watch drops it and Apple Health never hears about it.
diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js
index f85d9cd1b..520b04aa8 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('4cf163160164187ff4422b3360c9db0e2904664a074a8d9236008f49883c8326')
+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('bd12d28e6831c52457fafb4a0839dcd525f1a855a87735c56f7b6eb7bed47684')
})
// pt-PT labelled Unpair 'Desfazer': Undo, in Portuguese (it is pt-BR's Undo), on the button that
diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js
index 73c34b22a..6367f2fe6 100644
--- a/frontend/src/locales/pt-BR.js
+++ b/frontend/src/locales/pt-BR.js
@@ -1627,8 +1627,6 @@ export const PT_BR_OVERRIDES = {
"Gain {0} to {1} a week.": "Ganhar de {0} a {1} por semana.",
"A cut is often 0.5 to 1 % a week, a lean bulk 0.25 to 0.5 %.": "Um cutting costuma ficar em 0,5 a 1 % por semana, um bulking limpo em 0,25 a 0,5 %.",
"Remove range": "Remover faixa",
-
- 'Admin': 'Admin',
}
export default { ...pt, ...PT_BR_OVERRIDES }
diff --git a/frontend/src/locales/sv.js b/frontend/src/locales/sv.js
index 2b5dc3bdb..2bd857a29 100644
--- a/frontend/src/locales/sv.js
+++ b/frontend/src/locales/sv.js
@@ -2570,4 +2570,5 @@ export default {
'Gain {0} to {1} a week.': 'Gå upp {0} till {1} i veckan.',
'A cut is often 0.5 to 1 % a week, a lean bulk 0.25 to 0.5 %.': 'En deff är ofta 0,5 till 1 % i veckan, en lean bulk 0,25 till 0,5 %.',
'Remove range': 'Ta bort intervall',
+ 'Admin': 'Admin',
}
diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsx
index 180cd5317..ef3d70457 100644
--- a/frontend/src/views/Settings.jsx
+++ b/frontend/src/views/Settings.jsx
@@ -37,6 +37,7 @@ import { APK_VARIANT, VARIANT_NAMES } from '../lib/apk-variant.js'
import { BUILTIN_PX } from '../lib/anim-quality.js'
import { selfUpdates } from '../lib/channel.js'
import { forgetCoach } from '../lib/coach-api.js'
+import { coachAvailable } from '../lib/coach.js'
import { REST_MAX, REST_PAUSE_MIN, REST_PAUSE_MAX, fmtRest, fmtDuration } from '../lib/duration.js'
import { starterPlanSheet, confirmSheet, importFromApp, importFromHevy, equipmentProfileSheet, plateInventorySheet, dumbbellInventorySheet, barDefaultsSheet, menuSheet } from '../sheets.jsx'
import Icon from '../components/Icon.jsx'
@@ -1062,7 +1063,10 @@ function SettingsRoot({ ctx, preview, open, user, sync, home, go, entryKey }) {
: { title: t('Guest'), sub: t('Your data lives on this device. Sign in to sync.') }
const initial = user && !DEMO ? String(user.name || '?').trim().charAt(0).toUpperCase() : null
const nav = useNavigate()
- const adminCoach = !MOBILE && !DEMO && !!user?.admin
+ // Only while the server offers the Coach (the flag every Coach screen reads): on a box without
+ // it the admin dashboard has no Coach card to land on.
+ const config = useStore(s => s.config)
+ const adminCoach = !MOBILE && !DEMO && !!user?.admin && coachAvailable(config, user)
return <div className="narrow">
<div className="sp-nav">
<button className="sp-back" data-back="/home" onClick={home} aria-label={t('Home')}><Icon name="chevronLeft" /><span>{t('Home')}</span></button>
diff --git a/frontend/src/views/settings-pages.test.jsx b/frontend/src/views/settings-pages.test.jsx
index 863d90bbe..c9a4d0058 100644
--- a/frontend/src/views/settings-pages.test.jsx
+++ b/frontend/src/views/settings-pages.test.jsx
@@ -11,9 +11,9 @@ import { PAGES, PAGE_IDS, ROOT_GROUPS, SEARCH, pageVisible, searchSettings, page
globalThis.IS_REACT_ACT_ENVIRONMENT = true
const mocks = vi.hoisted(() => {
- const state = { S: null, user: null, sync: null, MOBILE: false, push: false, sheets: [], navs: [], toast: null }
+ const state = { S: null, user: null, sync: null, config: null, MOBILE: false, push: false, sheets: [], navs: [], toast: null }
state.snapshot = () => ({
- S: state.S, user: state.user, coachLocal: null, sync: state.sync, config: null,
+ S: state.S, user: state.user, coachLocal: null, sync: state.sync, config: state.config,
update: mut => { const next = structuredClone(state.S); mut(next); state.S = next },
replaceState: vi.fn(), setUser: vi.fn(), pullState: vi.fn(), pushState: vi.fn(), setUnit: vi.fn(),
resetEverything: vi.fn(), resetDemo: vi.fn(), importBackup: vi.fn(), importConflict: vi.fn(),
@@ -55,6 +55,7 @@ beforeEach(() => {
}
mocks.user = null
mocks.sync = null
+ mocks.config = null
mocks.MOBILE = false
mocks.push = false
mocks.pushOn = false
@@ -150,6 +151,7 @@ describe('the root', () => {
})
it('in a hosted app, an admin gets the Coach row too, straight to the Coach card of the admin dashboard', () => {
+ mocks.config = { coach: { enabled: true } }
mocks.user = { id: 'u1', name: 'Dana' }
mount()
expect(titles()).not.toContain('AI Coach')
@@ -160,6 +162,18 @@ describe('the root', () => {
expect(mocks.navs).toEqual([['/admin', { state: { section: 'coach' } }]])
})
+ it('only while the server offers the Coach, so the row never leads to an admin page without it (#683)', () => {
+ mocks.user = { id: 'u1', name: 'Dana', admin: true }
+ mount()
+ expect(titles()).not.toContain('AI Coach')
+ mocks.config = { coach: null }
+ mount()
+ expect(titles()).not.toContain('AI Coach')
+ mocks.config = { coach: { enabled: true } }
+ mount()
+ expect(titles()).toContain('AI Coach')
+ })
+
it('searches every setting and a hit goes to its page with the row to flash', () => {
mount()
const input = host.querySelector('.sp-search input')