diff --git a/.env.example b/.env.example
index ac3773c..380e6a0 100644
--- a/.env.example
+++ b/.env.example
@@ -33,6 +33,14 @@ RP_NAME=openGym
# generate the codes from the admin dashboard):
#
# INVITE_ONLY=1
+#
+# Remove the "Continue without account" button, so a profile is the only way in.
+# Guest mode keeps everything in the browser and never touches this server, but
+# on an instance meant for a known set of people it is still the wrong front
+# door. Anyone already inside as a guest is signed out on their next visit; the
+# data they made stays in that browser. Defaults to on (guests allowed):
+#
+# ALLOW_GUEST=0
# ── Session length (optional) ──────────────────────────────────────────────
# How long a sign-in lasts, in days. Default 90 — long enough that people who
diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml
index 602284f..ec6db7d 100644
--- a/.github/workflows/docker-publish.yml
+++ b/.github/workflows/docker-publish.yml
@@ -1,9 +1,14 @@
name: Publish Docker images
+# Images are published from a *published release*, never from a bare tag push.
+# A tag that is later deleted (the versioning rule consolidates unreleased tags)
+# would otherwise leave its image tags behind in GHCR forever, and dependency
+# bots read those as a newer version. See issue #87.
on:
push:
branches: [main]
- tags: ['v*']
+ release:
+ types: [published]
workflow_dispatch:
permissions:
@@ -29,6 +34,19 @@ jobs:
id: repo
run: echo "owner=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
+ - name: Set version metadata
+ id: version_meta
+ run: |
+ # On a release the ref is refs/tags/vX.Y.Z; on a main push it is a branch ref,
+ # which would otherwise label the image "refs/heads/main".
+ case "$GITHUB_REF" in
+ refs/tags/*) VERSION="${GITHUB_REF#refs/tags/}" ;;
+ *) VERSION="main-${GITHUB_SHA::7}" ;;
+ esac
+ echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
+ echo "VCS_REF=${GITHUB_SHA}" >> $GITHUB_OUTPUT
+ echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
+
- uses: docker/setup-qemu-action@v4
- uses: docker/setup-buildx-action@v4
@@ -52,6 +70,10 @@ jobs:
context: ${{ matrix.context }}
file: ${{ matrix.file }}
platforms: linux/amd64,linux/arm64
+ build-args: |
+ VERSION=${{ steps.version_meta.outputs.VERSION }}
+ VCS_REF=${{ steps.version_meta.outputs.VCS_REF }}
+ BUILD_DATE=${{ steps.version_meta.outputs.BUILD_DATE }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 60ad8c4..dd972bb 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -7,13 +7,15 @@ on:
paths:
- 'frontend/**'
- 'api/**'
+ - 'mcp/**'
- 'scripts/build-coach-library.mjs'
- '.github/workflows/test.yml'
push:
- branches: [main]
+ branches: [main, coach]
paths:
- 'frontend/**'
- 'api/**'
+ - 'mcp/**'
- 'scripts/build-coach-library.mjs'
- '.github/workflows/test.yml'
workflow_dispatch:
@@ -45,6 +47,36 @@ jobs:
working-directory: frontend
- run: node scripts/check-locales.mjs
working-directory: frontend
+ # check-locales compares the packs to each other, so a key missing from ALL of them is
+ # invisible to it. This walks src/ instead. Report-only for now: there is a known
+ # backlog of untranslated demo-view strings to clear before it can fail the build.
+ - run: node scripts/check-source-strings.mjs
+ working-directory: frontend
+ # The fatigue model must never read higher after a rest day than before it.
+ # Property probe over ~108k comparisons; too slow for the unit suite, cheap here.
+ - run: npm run test:fatigue-probe
+ working-directory: frontend
+
+
+ mcp:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v7
+ - uses: actions/setup-node@v7
+ with:
+ node-version: 22
+ cache: npm
+ cache-dependency-path: mcp/package-lock.json
+ - run: npm ci
+ working-directory: mcp
+ - run: npm test
+ working-directory: mcp
+ # The one check the vitest suite structurally cannot make. The MCP server is a bare node
+ # process, but vitest runs its tests through Vite — import.meta.glob, .jsx imports and
+ # ?raw all resolve happily there. That is how a Vite-only import reached a shared lib
+ # module with 33 green tests standing over a server that died on startup.
+ - run: npm run check:node-loadable
+ working-directory: mcp
api:
runs-on: ubuntu-latest
diff --git a/.gitignore b/.gitignore
index 12881fa..06bdf38 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,4 @@ frontend/dist/
node_modules/
*.log
.DS_Store
+node_modules
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4f06387..76d8c71 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,171 @@
# Changelog
+## v1.2.6 — 2026-08-11
+
+The muscle map learned to answer a second question — not just where the volume went, but what is
+still recovering from it. Plus: a freestyle session no longer starts from blanks, the rest timer
+can reach you in another app, and a self-hosted instance can insist that everyone using it has an
+account.
+
+### The muscle map, read as recovery (#44)
+
+- 🔥 **A `Balance | Fatigue | Strength` switch on the Stats muscle card.** Balance is the map you
+ already had and is untouched. Fatigue shades each muscle by how much of the recent training it
+ is still carrying; Strength shades it by how long it has been since you trained it at all, with
+ the weeks-since count spelled out underneath.
+- **Fatigue is volume-sensitive and fades smoothly.** A hard twelve-set chest day starts near the
+ top and takes about six days to read ready again; a single set barely registers and is gone in
+ two. It decays continuously on a 36-hour half-life rather than expiring at a window edge, so the
+ map never flips from "fatigued" to "ready" between one look and the next.
+- **Strength holds for two weeks, then decays toward a floor.** A muscle you have not trained in
+ months reads detrained rather than absent, which is the state that actually tells you something.
+- Both views are pure functions over your existing history — no new stored data, no schema change,
+ nothing sent anywhere.
+
+### The rest timer can reach you in another app (#49)
+
+- ⏰ **A system notification when rest is over**, on top of the beep, for when you have switched to
+ another tab or app mid-session. Permission is asked the first time a rest starts, and everything
+ degrades quietly where notifications are unsupported or refused.
+- It goes through the service worker where the browser requires that — which is most phones — and
+ falls back to the direct API elsewhere. No new dependencies; the existing server push path is
+ untouched.
+
+### Rows now strain the rear delts (#51)
+
+- **Four row variations gained rear-deltoid secondaries** — barbell, dumbbell, inverted and cable
+ seated rows — so the muscle map spreads their load the way the lift actually does. The overrides
+ live in a small table that survives a regeneration of the exercise dataset rather than being
+ edited into the generated data.
+
+### An instance can require an account (#42)
+
+- 🔒 **`ALLOW_GUEST=0` removes the "Continue without account" button.** Guest mode keeps everything
+ in the browser and never touches the server — no account, no sync, nothing the admin dashboard
+ can see — so on an instance meant for a known set of people it was a door leading nowhere
+ useful, and until now there was no way to close it.
+- **It also ends guest sessions that already exist.** Guests never authenticate, so there is no
+ request for the server to start refusing; the switch reaches someone already inside on their
+ next visit, when the app checks the config and returns them to the login screen. Their data is
+ not deleted — it stays in that browser, and moves into a real profile if they create one on the
+ same device.
+- **A server it cannot reach is not a server that said no.** The button is only withdrawn on an
+ explicit `allow_guest: false`; a failed config request, or a server too old to send the flag at
+ all, leaves guest mode exactly as it was. An instance that is merely offline for a moment does
+ not lock out everyone who never made an account.
+- **Default is on, so nothing changes for existing instances.** Set it alongside `INVITE_ONLY=1`:
+ invite-only governs who may *create a profile* and says nothing about the guest button, which
+ never creates one.
+
+### Freestyle sessions start where you left off
+
+- 🏋️ **Adding an exercise to an empty workout now prefills it from the last time you trained
+ it** — the same number of sets, with each row's reps and weight carried across by position.
+ Cardio brings its duration and speed, a hold brings its seconds. Until now every row opened on
+ the config-sheet defaults, so the first thing a freestyle session asked of you was to retype
+ what you already did last week.
+- **The config sheet agrees with the rows it is about to create.** It opens on the last target you
+ actually trained rather than the generic default, so the set count you confirm is the set count
+ you get.
+- **Planned sessions are untouched.** A routine-driven workout still runs the progression logic and
+ still applies its prescription; only the freestyle path — which has no prescription to apply —
+ reads from history instead.
+
+Contributed by [@Space-Hermes](https://github.com/Space-Hermes) in
+[#50](https://github.com/DuarteSantos8/openGym/pull/50).
+
+### Pair exercises into a superset mid-session (#64)
+
+- 🔗 **"Make superset with previous / next" on each exercise card.** Two exercises paired in the
+ session collapse into a single *Superset* card — do them back-to-back, rest once at the end —
+ with an **Unpair** button in the header. No planning ahead required; pair them when you decide
+ to, in the workout.
+- **Groups are any size.** Pairing the end of one group to the start of another merges them, and
+ the header wording stays correct past two exercises.
+- **Unpairing cleans up after itself.** A group reduced to one exercise is dissolved rather than
+ left as a superset of one, and the pairing helpers never mutate the running session.
+- Session-only by design: pairings drive the workout, and history stores the sets.
+
+Contributed by [@Space-Hermes](https://github.com/Space-Hermes) in
+[#64](https://github.com/DuarteSantos8/openGym/pull/64).
+
+### The muscle map stops rewriting the catalogue (#67)
+
+- **The curated secondary-muscle additions are now an overlay, not a mutation.** The four row
+ exercises that strain the rear delts used to get that written into the shared exercise dataset
+ at import time, which meant export, print and import saw a catalogue that had been edited
+ underneath them. They are derived at the read points instead, so the dataset stays pristine.
+- The detail sheet's tag row reads through the same overlay, so those muscles still show where
+ they always did.
+
+Contributed by [@Space-Hermes](https://github.com/Space-Hermes) in
+[#67](https://github.com/DuarteSantos8/openGym/pull/67).
+
+### Fixes
+
+- 🖼️ **Exercise images and animations were blank on the routine screen** ([#79]). The media paths
+ were relative, and `/plan/r/:id` is the app's only two-segment route — so the browser asked for
+ `/plan/r/img/…` and got a 404 with nothing in the console to say why. Every other screen was
+ fine, which is what made it look like a one-screen mystery. Reported with the root cause already
+ found, by [@lemi1000](https://github.com/lemi1000).
+- 📥 **Imports mapped more of what other apps export** ([#74]). Treadmill, Goblet Squat, Cycling and
+ Cable Core Pallof Press arrived as *custom* exercises rather than catalogue ones — no word
+ overlap could reach the names openGym stores them under. Those and their neighbours are now in
+ the alias table. Already-imported history stays custom; new imports resolve. Reported by
+ [@KiloOscarSix](https://github.com/KiloOscarSix).
+- **A progression edge case that could loop forever** ([#60]). An entry left with nothing but
+ warm-up rows seeded the set-growth loop from a warm-up, which could never satisfy its own exit
+ condition. It leaves the entry alone instead. Contributed by
+ [@Space-Hermes](https://github.com/Space-Hermes).
+- Documented that `VITE_IMG_BASE` / `VITE_GIF_BASE` are build-time values, so setting them next to
+ `docker compose` does nothing on a prebuilt image.
+
+[#79]: https://github.com/DuarteSantos8/openGym/issues/79
+[#74]: https://github.com/DuarteSantos8/openGym/issues/74
+[#60]: https://github.com/DuarteSantos8/openGym/pull/60
+
+## v1.2.5 — 2026-08-04
+
+Nothing in the app itself changed. This release adds an optional side door: a small server that
+lets an AI assistant you already run — Claude Desktop, Cursor, Cline — answer questions about
+your own training, off the same files your instance already writes. If you don't use one, this
+release is invisible to you.
+
+### Ask an AI about your training, without the data leaving your box (#19)
+
+- 🤖 **An MCP server (`mcp/`)** — opt-in, read-only, and not part of the Docker build. Your LLM
+ client spawns it as a local process, it reads `./data` directly, and it exits when the client
+ disconnects. No new container, no extra auth on the api, no third-party service, nothing over
+ the network. *"What did I bench last week?", "what's my estimated 1RM on deadlift?", "which
+ muscles have I been neglecting?"*
+- **The answers match the Stats screen because they are the same numbers.** The server calls the
+ very functions in `frontend/src/lib/` the app already computes with, rather than reimplementing
+ them. Eight tools: routines, the week plan, workouts, one session in detail, body weight,
+ estimated 1RM and muscle balance.
+- **Read-only on purpose.** Logging a workout from an assistant needs a long-lived token the api
+ does not have yet, plus a lock against the web UI's read-modify-write. Until both exist, the
+ server answers questions and does nothing else. It never reads passkey material, VAPID keys or
+ session state — only the profile it was pointed at.
+- `docker-compose.yml` is untouched and nothing new enters the image, so an instance that ignores
+ this ships exactly what it shipped before. Setup is in [mcp/README.md](mcp/README.md).
+
+### Under the hood
+
+- The pure half of `i18n.js` — the language state, the constants, the readers — moved into
+ `i18n-core.js`, so the helpers under `frontend/src/lib/` can be loaded by a plain Node process
+ and not only by Vite. `i18n.js` keeps the Vite-only parts (the locale-pack loader, the React
+ hook) and re-exports the rest, so nothing that imports it had to change.
+- The shared lib modules that only need `t` now take it from the core directly. A Vite-only
+ import inside a shared module is invisible under vitest, which transforms it, and fatal to the
+ MCP server, which does not — so the shared half stays clear of the bundler half by
+ construction rather than by remembering to.
+- `npm run check:node-loadable` in `mcp/` walks the server's import graph under a bare `node`,
+ which is the one thing the test suite cannot do from inside Vite. CI runs it, alongside the
+ MCP tests — neither had ever run there before.
+
+The MCP server was contributed by [@Pengboi](https://github.com/Pengboi) — the first feature in
+openGym written by someone other than me. Thank you.
+
## v1.2.4 — 2026-08-01
The effort ratings you have been recording since v1.2.3 now answer questions, and bodyweight
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 21ea8d8..a33bc04 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -12,6 +12,9 @@ api/ backend — server.js (Node, no framework), one dependency (@simplewe
web/ multi-stage Dockerfile (builds frontend → nginx) + nginx.conf (serves app, proxies /api).
media/ exercise img/gif (gitignored, fetched at runtime).
docs/ self-hosting guide.
+mcp/ optional Model Context Protocol server — read-only stdio bridge for LLM apps
+ (Claude Desktop, Cursor, …) to query a user's workouts/1RM/muscle balance. Not in
+ the Docker build; only runs when an LLM client spawns it. See mcp/README.md.
```
## Running for development
diff --git a/README.md b/README.md
index 3471e8d..7afbf24 100644
--- a/README.md
+++ b/README.md
@@ -81,6 +81,7 @@ as a home-screen app, passkey sign-in, offline support, sync across your phone a
- 🌍 **12 languages** — full UI translation (EN, DE, ES, FR, IT, PT, PL, TR, RU, ZH, KO, HI); exercise instructions localized in 10 of them, loaded on demand so the app stays fast
- 📥 **Bring your history with you** — import from **FitNotes** (Android and iOS), **Strong** and **Hevy**, or body weight straight out of an **Apple Health** export. Exercise names are matched against the library and anything unrecognised becomes one of your own exercises, so nothing in the file is dropped
- 📦 **Yours to keep** — one-tap JSON export/import, guest mode, **no telemetry**
+- 🤖 **Ask an AI about your training** (optional) — an [MCP server](mcp/README.md) lets a client like Claude Desktop or Cursor read your history in your own words: *"what did I bench last week?"*. Read-only, spawned locally by the client, nothing leaves your box. Not in the Docker build — if you don't use an AI assistant, it isn't there
- 📱 **Standalone Android app** — the whole tracker as a sideloadable APK: no account, no server, data on the phone, native workout reminders ([download](https://opengym.duarte-santos.ch))
## Quick start (self-host)
@@ -151,9 +152,13 @@ All via `.env` (see `.env.example`):
| `RP_ID` | Hostname passkeys are bound to | `localhost` |
| `ORIGIN` | Full URL the app is served from | `http://localhost:8080` |
| `WEB_PORT` | Host port for the web UI | `8080` |
+| `NGINX_PORT` | Internal Nginx port for the web UI | `80` |
+| `BACKEND` | Backend Service service name, so that API calls can be forwarded to | `api` |
+| `PORT` | Port for the api backend Service | `3000` |
| `RP_NAME` | Name shown in the passkey prompt | `openGym` |
| `ADMIN_UIDS` | User ids that get the admin dashboard (comma-separated) | *(none)* |
| `INVITE_ONLY` | Require an invite code to create a profile | *(off)* |
+| `ALLOW_GUEST` | Offer "Continue without account" — set `0` to require a profile | *(on)* |
Push notification keys are generated on first run and saved to `./data/vapid.json` — nothing to set.
@@ -184,6 +189,10 @@ lives in pure functions under `frontend/src/lib/` with tests next to them: `npm
`frontend/`. Vitest is a dev dependency; the app itself ships no runtime dependencies beyond
React, the router and Zustand.
+The same pure helpers power an optional MCP server (`mcp/`) that lets an LLM client like
+Claude Desktop read your data over stdio — see [mcp/README.md](mcp/README.md). Opt-in, not
+in the Docker build.
+
## Community
- **[Q&A](https://github.com/DuarteSantos8/openGym/discussions/categories/q-a)** — self-hosting
diff --git a/api/Dockerfile b/api/Dockerfile
index 72538b8..9bfa024 100644
--- a/api/Dockerfile
+++ b/api/Dockerfile
@@ -12,6 +12,23 @@
# deliberately last and `coach` sits above it.
FROM node:22-alpine AS base
+
+# Declared on the base stage so both targets inherit the labels and the healthcheck.
+ARG VERSION=dev
+ARG VCS_REF=dev
+ARG BUILD_DATE=unknown
+
+LABEL maintainer="Duarte Santos https://github.com/DuarteSantos8" \
+ org.opencontainers.image.title="opengym-api" \
+ org.opencontainers.image.description="Backend for Self-hosted gym & body-weight tracker — plan routines, log workouts (supersets & cardio too), track your weight and progress, passkey login. Your data, your server." \
+ org.opencontainers.image.source="https://github.com/DuarteSantos8/openGym" \
+ org.opencontainers.image.url="https://ghcr.io/duartesantos8/opengym-api" \
+ org.opencontainers.image.documentation="https://github.com/DuarteSantos8/openGym#readme" \
+ org.opencontainers.image.licenses="AGPL-3.0-or-later" \
+ org.opencontainers.image.version=$VERSION \
+ org.opencontainers.image.revision=$VCS_REF \
+ org.opencontainers.image.created=$BUILD_DATE
+
WORKDIR /app
# The unprivileged user Coach jobs drop to. Its uid cannot read /data, which is the control that
@@ -32,9 +49,15 @@ RUN npm ci --omit=dev --omit=optional && npm cache clean --force
COPY server.js ./
COPY coach ./coach
ENV NODE_ENV=production
+ENV PORT=3000
EXPOSE 3000
CMD ["node", "server.js"]
+HEALTHCHECK --interval=5m \
+ --timeout=5s \
+ --retries=3 \
+ CMD wget --spider -q "http://127.0.0.1:${PORT}/api/health" || exit 1
+
# ---------------------------------------------------------------------------------------------
# The opt-in target. Dropping --omit=optional is the whole difference: it pulls in
# @anthropic-ai/claude-agent-sdk together with the one platform runtime this base needs
diff --git a/api/package.json b/api/package.json
index 334909f..5e700b3 100644
--- a/api/package.json
+++ b/api/package.json
@@ -1,6 +1,6 @@
{
"name": "gym-api",
- "version": "1.2.4",
+ "version": "1.2.6",
"private": true,
"type": "module",
"main": "server.js",
diff --git a/api/server.js b/api/server.js
index e2a0b08..de431b6 100644
--- a/api/server.js
+++ b/api/server.js
@@ -23,6 +23,11 @@ const RP_NAME = process.env.RP_NAME || 'openGym';
// code the admin generates. Both default off so a fresh self-hosted instance stays open.
const ADMIN_UIDS = (process.env.ADMIN_UIDS || '').split(',').map(s => s.trim()).filter(Boolean);
const INVITE_ONLY = /^(1|true|yes|on)$/i.test(process.env.INVITE_ONLY || '');
+// Guest mode ("Continue without account") keeps everything in the browser and never touches this
+// server — but on an instance meant for a known set of people, an entrance nobody can walk back
+// out of is still the wrong front door (#42). Default ON, so existing instances are unchanged;
+// the polarity is inverted from INVITE_ONLY because the safe default here is the permissive one.
+const ALLOW_GUEST = !/^(0|false|no|off)$/i.test(process.env.ALLOW_GUEST || '');
// 90 days keeps someone who trains a few times a week permanently signed in without a stolen
// cookie staying good for a year. Overridable because a family instance and one on the open
// internet don't want the same number. Only affects cookies minted from now on — the expiry is
@@ -283,7 +288,7 @@ const routes = {
// the app it was before the feature existed.
'GET /api/config': async (req, res) => {
const coach = coachConfig.publicConfig();
- json(res, 200, { invite_only: INVITE_ONLY, ...(coach ? { coach } : {}) });
+ json(res, 200, { invite_only: INVITE_ONLY, allow_guest: ALLOW_GUEST, ...(coach ? { coach } : {}) });
},
'GET /api/me': async (req, res) => {
diff --git a/docs/SELF_HOSTING.md b/docs/SELF_HOSTING.md
index b254faa..71498f2 100644
--- a/docs/SELF_HOSTING.md
+++ b/docs/SELF_HOSTING.md
@@ -90,11 +90,12 @@ Visit `https://gym.example.com`, create your profile, and add it to your home sc
Anyone who can reach the URL can create their own profile — each gets isolated data. That's the
default: open signup, no admin.
-If you'd rather control who gets in, two optional settings in `.env` turn that around:
+If you'd rather control who gets in, three optional settings in `.env` turn that around:
```bash
ADMIN_UIDS=youruserid # comma-separated; these users get the admin dashboard
INVITE_ONLY=1 # new profiles need an invite code
+ALLOW_GUEST=0 # remove "Continue without account"
```
Register your own passkey profile first, then find your id in `./data/db.json` under `users[].id`
@@ -104,6 +105,16 @@ out and locked out everywhere until you re-enable it), and — with `INVITE_ONLY
revoking invite codes. Existing accounts keep working when you switch invite-only on. Admin access
is gated by your passkey and enforced server-side, so it needs no separate login.
+`INVITE_ONLY=1` and `ALLOW_GUEST=0` answer different questions and are usually set together.
+Invite-only controls who may *create a profile*; it says nothing about the **Continue without
+account** button, which never creates one. Guest mode keeps everything in that browser and never
+talks to the server — there is no account, no sync and nothing for the admin dashboard to show —
+so on an instance meant for a known set of people it is a door that leads nowhere useful. With
+`ALLOW_GUEST=0` the button is gone, and anyone already using the app as a guest is returned to the
+login screen on their next visit. Their data is not deleted: it stays in that browser and comes
+back if you ever switch guests on again, or moves into a real profile if they create one on the
+same device.
+
Prefer to keep the whole thing off the open internet? A VPN or an auth proxy (Authelia, Cloudflare
Access…) in front still works, and composes with the above.
@@ -174,3 +185,14 @@ downloaded media are untouched.
| Day reminder fires at the wrong time | Toggle it off and on in Settings so it re-detects your browser's timezone (also happens automatically on every app load — see section 6). |
| Want to reset a stuck login | Delete the cookie in your browser; sessions are just signed cookies. |
| `docker compose pull` fails with "denied" / "unauthorized" | The prebuilt images aren't published yet, or need to be, or the GHCR package is still private — build from source instead (`docker compose up -d --build`). |
+| Exercise images/GIFs blank when a routine is open | Fixed in current images (issue #79). On an older build, see the note below. |
+
+### `VITE_IMG_BASE` / `VITE_GIF_BASE` are build-time, not run-time
+
+These two are read by Vite when the frontend is **compiled**, so their values are baked into
+the shipped JavaScript bundle. Setting them in the `.env` next to `docker compose` has no
+effect on an already-built image — the bundle has already made up its mind.
+
+They are only useful if you build the frontend yourself (`docker compose up -d --build`, or a
+`npm run build` with the variables exported). If you need to redirect media on a prebuilt
+image, do it in your reverse proxy instead.
diff --git a/frontend/android/app/build.gradle b/frontend/android/app/build.gradle
index ecd76b2..2ac4cc1 100644
--- a/frontend/android/app/build.gradle
+++ b/frontend/android/app/build.gradle
@@ -7,8 +7,8 @@ android {
applicationId "ch.duartesantos.opengym"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
- versionCode 5
- versionName "1.2.4"
+ versionCode 7
+ versionName "1.2.6"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index 4be4005..c693161 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "opengym-frontend",
- "version": "1.2.4",
+ "version": "1.2.6",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "opengym-frontend",
- "version": "1.2.4",
+ "version": "1.2.6",
"license": "AGPL-3.0-or-later",
"dependencies": {
"@capacitor/core": "^7.6.8",
@@ -24,6 +24,8 @@
"@capacitor/cli": "^7.6.8",
"@capacitor/ios": "^7.6.8",
"@vitejs/plugin-react": "^6.0.3",
+ "happy-dom": "^20.11.2",
+ "linkedom": "^0.18.13",
"vite": "^8.1.5",
"vitest": "^4.1.10"
}
@@ -1264,6 +1266,23 @@
"integrity": "sha512-+OpjSaq85gvlZAYINyzKpLeiFkSC4EsC6IIiT6v6TLSU5k5U83fHGj9Lel8oKEXM0HqgrMVCjXPDPVICtxF7EQ==",
"dev": true
},
+ "node_modules/@types/whatwg-mimetype": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/@types/whatwg-mimetype/-/whatwg-mimetype-3.0.2.tgz",
+ "integrity": "sha512-c2AKvDT8ToxLIOUlN51gTiHXflsfIFisS4pO7pDPoKouJCESkhZnEy623gwP9laCy5lnLDAw1vAzu2vM2YLOrA==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/@types/ws": {
+ "version": "8.18.1",
+ "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz",
+ "integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/node": "*"
+ }
+ },
"node_modules/@typescript/typescript-aix-ppc64": {
"version": "7.0.2",
"resolved": "https://registry.npmjs.org/@typescript/typescript-aix-ppc64/-/typescript-aix-ppc64-7.0.2.tgz",
@@ -2070,6 +2089,19 @@
"node": "*"
}
},
+ "node_modules/buffer-image-size": {
+ "version": "0.6.4",
+ "resolved": "https://registry.npmjs.org/buffer-image-size/-/buffer-image-size-0.6.4.tgz",
+ "integrity": "sha512-nEh+kZOPY1w+gcCMobZ6ETUp9WfibndnosbpwB1iJk/8Gt5ZF2bhS6+B6bPYz424KtwsR6Rflc3tCz1/ghX2dQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/node": "*"
+ },
+ "engines": {
+ "node": ">=4.0"
+ }
+ },
"node_modules/camelcase": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
@@ -2594,6 +2626,12 @@
"url": "https://github.com/sponsors/fb55"
}
},
+ "node_modules/cssom": {
+ "version": "0.5.0",
+ "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.5.0.tgz",
+ "integrity": "sha512-iKuQcq+NdHqlAcwUY0o/HL69XQrUaQdMjmStJ8JFmUaiiQErlhrmuigkg/CU4E2J0IyUKUrMAgl36TvN67MqTw==",
+ "dev": true
+ },
"node_modules/dargs": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/dargs/-/dargs-7.0.0.tgz",
@@ -3268,6 +3306,38 @@
"uglify-js": "^3.1.4"
}
},
+ "node_modules/happy-dom": {
+ "version": "20.11.2",
+ "resolved": "https://registry.npmjs.org/happy-dom/-/happy-dom-20.11.2.tgz",
+ "integrity": "sha512-7MB+bJLkxu3SowAfBJbjW+c55kNz5tkR45gu2qzrxznezhLeN5YIlJbwUgSzlGc+qWoZ8Ykg71H5ezz69xixrw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/node": ">=20.0.0",
+ "@types/whatwg-mimetype": "^3.0.2",
+ "@types/ws": "^8.18.1",
+ "buffer-image-size": "^0.6.4",
+ "entities": "^7.0.1",
+ "whatwg-mimetype": "^3.0.0",
+ "ws": "^8.21.0"
+ },
+ "engines": {
+ "node": ">=20.0.0"
+ }
+ },
+ "node_modules/happy-dom/node_modules/entities": {
+ "version": "7.0.1",
+ "resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz",
+ "integrity": "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "engines": {
+ "node": ">=0.12"
+ },
+ "funding": {
+ "url": "https://github.com/fb55/entities?sponsor=1"
+ }
+ },
"node_modules/hard-rejection": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/hard-rejection/-/hard-rejection-2.1.0.tgz",
@@ -3337,6 +3407,98 @@
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
"dev": true
},
+ "node_modules/html-escaper": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-3.0.3.tgz",
+ "integrity": "sha512-RuMffC89BOWQoY0WKGpIhn5gX3iI54O6nRA0yC124NYVtzjmFWBIiFd8M0x+ZdX0P9R4lADg1mgP8C7PxGOWuQ==",
+ "dev": true
+ },
+ "node_modules/htmlparser2": {
+ "version": "10.1.0",
+ "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-10.1.0.tgz",
+ "integrity": "sha512-VTZkM9GWRAtEpveh7MSF6SjjrpNVNNVJfFup7xTY3UpFtm67foy9HDVXneLtFVt4pMz5kZtgNcvCniNFb1hlEQ==",
+ "dev": true,
+ "funding": [
+ "https://github.com/fb55/htmlparser2?sponsor=1",
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/fb55"
+ }
+ ],
+ "dependencies": {
+ "domelementtype": "^2.3.0",
+ "domhandler": "^5.0.3",
+ "domutils": "^3.2.2",
+ "entities": "^7.0.1"
+ }
+ },
+ "node_modules/htmlparser2/node_modules/dom-serializer": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz",
+ "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==",
+ "dev": true,
+ "dependencies": {
+ "domelementtype": "^2.3.0",
+ "domhandler": "^5.0.2",
+ "entities": "^4.2.0"
+ },
+ "funding": {
+ "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1"
+ }
+ },
+ "node_modules/htmlparser2/node_modules/dom-serializer/node_modules/entities": {
+ "version": "4.5.0",
+ "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
+ "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
+ "dev": true,
+ "engines": {
+ "node": ">=0.12"
+ },
+ "funding": {
+ "url": "https://github.com/fb55/entities?sponsor=1"
+ }
+ },
+ "node_modules/htmlparser2/node_modules/domhandler": {
+ "version": "5.0.3",
+ "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz",
+ "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==",
+ "dev": true,
+ "dependencies": {
+ "domelementtype": "^2.3.0"
+ },
+ "engines": {
+ "node": ">= 4"
+ },
+ "funding": {
+ "url": "https://github.com/fb55/domhandler?sponsor=1"
+ }
+ },
+ "node_modules/htmlparser2/node_modules/domutils": {
+ "version": "3.2.2",
+ "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.2.2.tgz",
+ "integrity": "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==",
+ "dev": true,
+ "dependencies": {
+ "dom-serializer": "^2.0.0",
+ "domelementtype": "^2.3.0",
+ "domhandler": "^5.0.3"
+ },
+ "funding": {
+ "url": "https://github.com/fb55/domutils?sponsor=1"
+ }
+ },
+ "node_modules/htmlparser2/node_modules/entities": {
+ "version": "7.0.1",
+ "resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz",
+ "integrity": "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==",
+ "dev": true,
+ "engines": {
+ "node": ">=0.12"
+ },
+ "funding": {
+ "url": "https://github.com/fb55/entities?sponsor=1"
+ }
+ },
"node_modules/ieee754": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
@@ -3826,6 +3988,171 @@
"integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==",
"dev": true
},
+ "node_modules/linkedom": {
+ "version": "0.18.13",
+ "resolved": "https://registry.npmjs.org/linkedom/-/linkedom-0.18.13.tgz",
+ "integrity": "sha512-ES/o9qotMpzpN2MHs+Iq/JcVoOj8Fa5wiQYrTdFpvAnwXL0g66XHHUc9WUMk6nAlBtGsFQ24ne+SYnvnaQ2FSw==",
+ "dev": true,
+ "dependencies": {
+ "css-select": "^7.0.0",
+ "cssom": "^0.5.0",
+ "html-escaper": "^3.0.3",
+ "htmlparser2": "^10.1.0",
+ "uhyphen": "^0.2.0"
+ },
+ "engines": {
+ "node": ">=16"
+ },
+ "peerDependencies": {
+ "canvas": ">= 2"
+ },
+ "peerDependenciesMeta": {
+ "canvas": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/linkedom/node_modules/boolbase": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-2.0.0.tgz",
+ "integrity": "sha512-DkVaaQHymRhpYEYo9x1oo7Q7B0Y6KJUsjm3c9eTyFDby4MHLBTwZ6ZDWBel5zrYxj1WsZgC5oLpiz+93MluXeA==",
+ "dev": true,
+ "engines": {
+ "node": ">=20.19.0"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/fb55"
+ }
+ },
+ "node_modules/linkedom/node_modules/css-select": {
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/css-select/-/css-select-7.0.0.tgz",
+ "integrity": "sha512-snmjEVXy+1LnwXdxhYvTMj1d9tOh4HxkA1YmoayVBeeyR2C14Pum7fcxJIm4SswYspVy866eYNwlH6xC3/VH5g==",
+ "dev": true,
+ "dependencies": {
+ "boolbase": "^2.0.0",
+ "css-what": "^8.0.0",
+ "domhandler": "^6.0.1",
+ "domutils": "^4.0.2",
+ "nth-check": "^3.0.1"
+ },
+ "engines": {
+ "node": ">=20.19.0"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/fb55"
+ }
+ },
+ "node_modules/linkedom/node_modules/css-what": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/css-what/-/css-what-8.0.0.tgz",
+ "integrity": "sha512-DH0Bqq3DNp5tdOReuNyAA+Ev4Y2GS5FMbZpeTLP6C4CDi0h5nL0BmUPChXw3o/qbHLDWHl49sbNqQVY7bMSDdw==",
+ "dev": true,
+ "engines": {
+ "node": ">=20.19.0"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/fb55"
+ }
+ },
+ "node_modules/linkedom/node_modules/dom-serializer": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-3.1.1.tgz",
+ "integrity": "sha512-4MEa38/QexBob6gFNwu+EGdWvhJ1OKuNwdYY3Y3NyeWDQfnGeDYQUDfIRzWu5B5gsv03so2Uxd28YC6zrsx3Lw==",
+ "dev": true,
+ "dependencies": {
+ "domelementtype": "^3.0.0",
+ "domhandler": "^6.0.0",
+ "entities": "^8.0.0"
+ },
+ "engines": {
+ "node": ">=20.19.0"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1"
+ }
+ },
+ "node_modules/linkedom/node_modules/domelementtype": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-3.0.0.tgz",
+ "integrity": "sha512-umCQid3jKbDmVjx8jGaW7uUykm4DEUeyV21hPxNMo2nV955DhUThwqyOIDtreepP31hl84X7G5U9ZfsWvIB3Pg==",
+ "dev": true,
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/fb55"
+ }
+ ],
+ "engines": {
+ "node": ">=20.19.0"
+ }
+ },
+ "node_modules/linkedom/node_modules/domhandler": {
+ "version": "6.0.1",
+ "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-6.0.1.tgz",
+ "integrity": "sha512-gYzvtM72ZtxQO0T048kd6HWSbbGCNOUwcnfQ01cqIJ4X2IYKFFHZ5mKvrQETcFXxsRObZulDaKmy//R7TPtsBg==",
+ "dev": true,
+ "dependencies": {
+ "domelementtype": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=20.19.0"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/fb55/domhandler?sponsor=1"
+ }
+ },
+ "node_modules/linkedom/node_modules/domutils": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/domutils/-/domutils-4.0.2.tgz",
+ "integrity": "sha512-qI4JLRKnSzqFqr7hAlS5xQDusBCjKSEG4t4+7aNrIQMHBcsC2TGEhuyABJdYkgSewL57PNLYEiibY2iPKhKpaA==",
+ "dev": true,
+ "dependencies": {
+ "dom-serializer": "^3.0.0",
+ "domelementtype": "^3.0.0",
+ "domhandler": "^6.0.0"
+ },
+ "engines": {
+ "node": ">=20.19.0"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/fb55/domutils?sponsor=1"
+ }
+ },
+ "node_modules/linkedom/node_modules/entities": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/entities/-/entities-8.0.0.tgz",
+ "integrity": "sha512-zwfzJecQ/Uej6tusMqwAqU/6KL2XaB2VZ2Jg54Je6ahNBGNH6Ek6g3jjNCF0fG9EWQKGZNddNjU5F1ZQn/sBnA==",
+ "dev": true,
+ "engines": {
+ "node": ">=20.19.0"
+ },
+ "funding": {
+ "url": "https://github.com/fb55/entities?sponsor=1"
+ }
+ },
+ "node_modules/linkedom/node_modules/nth-check": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-3.0.1.tgz",
+ "integrity": "sha512-GX0gsdbGVCgnRgbeGaubfjpBXyYRWOOCVeYh08bSQvDZqxz5ndXs1OTfAt/h36G1xvI94YIspsI0sVFqAV9+RQ==",
+ "dev": true,
+ "dependencies": {
+ "boolbase": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=20.19.0"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/fb55/nth-check?sponsor=1"
+ }
+ },
"node_modules/load-json-file": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz",
@@ -5886,6 +6213,12 @@
"node": ">=0.8.0"
}
},
+ "node_modules/uhyphen": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/uhyphen/-/uhyphen-0.2.0.tgz",
+ "integrity": "sha512-qz3o9CHXmJJPGBdqzab7qAYuW8kQGKNEuoHFYrBwV6hWIMcpAmxDLXojcHfFr9US1Pe6zUswEIJIbLI610fuqA==",
+ "dev": true
+ },
"node_modules/undici-types": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.3.0.tgz",
@@ -6129,6 +6462,16 @@
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
"dev": true
},
+ "node_modules/whatwg-mimetype": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz",
+ "integrity": "sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ }
+ },
"node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
@@ -6205,6 +6548,28 @@
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
"dev": true
},
+ "node_modules/ws": {
+ "version": "8.21.3",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.3.tgz",
+ "integrity": "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=10.0.0"
+ },
+ "peerDependencies": {
+ "bufferutil": "^4.0.1",
+ "utf-8-validate": ">=5.0.2"
+ },
+ "peerDependenciesMeta": {
+ "bufferutil": {
+ "optional": true
+ },
+ "utf-8-validate": {
+ "optional": true
+ }
+ }
+ },
"node_modules/xcode": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/xcode/-/xcode-3.0.1.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index 452bd6c..42aa3f9 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -1,7 +1,7 @@
{
"name": "opengym-frontend",
"private": true,
- "version": "1.2.4",
+ "version": "1.2.6",
"type": "module",
"scripts": {
"dev": "vite",
@@ -9,7 +9,8 @@
"build:mobile": "VITE_MOBILE=1 VITE_IMG_BASE=https://cdn.jsdelivr.net/gh/hasaneyldrm/exercises-dataset@7455efae41b330c265e7cd4b78dfa848e7ce5ebd/images/ VITE_GIF_BASE=https://cdn.jsdelivr.net/gh/hasaneyldrm/exercises-dataset@7455efae41b330c265e7cd4b78dfa848e7ce5ebd/videos/ vite build && cap sync",
"preview": "vite preview",
"test": "vitest run",
- "test:watch": "vitest"
+ "test:watch": "vitest",
+ "test:fatigue-probe": "node scripts/fatigue-monotonic-probe.mjs"
},
"license": "AGPL-3.0-or-later",
"dependencies": {
@@ -28,6 +29,8 @@
"@capacitor/cli": "^7.6.8",
"@capacitor/ios": "^7.6.8",
"@vitejs/plugin-react": "^6.0.3",
+ "happy-dom": "^20.11.2",
+ "linkedom": "^0.18.13",
"vite": "^8.1.5",
"vitest": "^4.1.10"
}
diff --git a/frontend/scripts/check-source-strings.mjs b/frontend/scripts/check-source-strings.mjs
new file mode 100644
index 0000000..75202a5
--- /dev/null
+++ b/frontend/scripts/check-source-strings.mjs
@@ -0,0 +1,69 @@
+#!/usr/bin/env node
+// The companion to check-locales.mjs, which compares the locale packs to each other and so
+// cannot see a key that is missing from all of them: that renders English in every language
+// while every check stays green. This walks src/ instead, collects the literals actually
+// passed to t(), and reports the ones no pack defines.
+//
+// node scripts/check-source-strings.mjs # report only, exit 0
+// node scripts/check-source-strings.mjs --strict # exit 1 if anything is missing
+//
+// English is the source language and has no pack, so the key IS the English string.
+// Only literal single-argument calls are collected — t(variable) and template literals are
+// resolved at runtime and are deliberately out of scope.
+
+import { readdirSync, readFileSync, statSync } from 'node:fs'
+import { dirname, join, relative } from 'node:path'
+import { fileURLToPath, pathToFileURL } from 'node:url'
+
+const root = join(dirname(fileURLToPath(import.meta.url)), '..')
+const srcDir = join(root, 'src')
+const localesDir = join(srcDir, 'locales')
+const strict = process.argv.includes('--strict')
+
+function walk(dir, out = []) {
+ for (const name of readdirSync(dir)) {
+ const p = join(dir, name)
+ if (statSync(p).isDirectory()) {
+ if (p === localesDir || name === 'instr' || name === 'node_modules') continue
+ walk(p, out)
+ } else if (/\.(js|jsx)$/.test(name) && !/\.test\.(js|jsx)$/.test(name)) {
+ out.push(p)
+ }
+ }
+ return out
+}
+
+// t('literal') / t("literal") — preceded by a non-identifier char so DateTimeFormat( misses.
+const CALL = /(^|[^A-Za-z0-9_$.])t\(\s*(['"])((?:\\.|(?!\2)[^\\])*)\2/g
+
+const used = new Map()
+for (const file of walk(srcDir)) {
+ const text = readFileSync(file, 'utf8')
+ for (const m of text.matchAll(CALL)) {
+ const key = m[3].replace(/\\(['"\\])/g, '$1')
+ if (!key) continue
+ if (!used.has(key)) used.set(key, new Set())
+ used.get(key).add(relative(root, file))
+ }
+}
+
+const defined = new Set()
+for (const file of readdirSync(localesDir).filter(f => f.endsWith('.js'))) {
+ const pack = (await import(pathToFileURL(join(localesDir, file)).href)).default
+ for (const key of Object.keys(pack)) defined.add(key)
+}
+
+const missing = [...used.keys()].filter(k => !defined.has(k)).sort()
+
+if (!missing.length) {
+ console.log(`${used.size} translated strings in src/, all present in the locale packs.`)
+ process.exit(0)
+}
+
+console.log(`${used.size} translated strings in src/, ${missing.length} defined in no locale pack:\n`)
+for (const key of missing) {
+ console.log(` ${JSON.stringify(key)}`)
+ for (const f of [...used.get(key)].sort()) console.log(` ${f}`)
+}
+console.log(`\nThese render English in all ${readdirSync(localesDir).filter(f => f.endsWith('.js')).length} translated languages.`)
+process.exit(strict ? 1 : 0)
diff --git a/frontend/scripts/fatigue-monotonic-probe.mjs b/frontend/scripts/fatigue-monotonic-probe.mjs
new file mode 100644
index 0000000..89aec62
--- /dev/null
+++ b/frontend/scripts/fatigue-monotonic-probe.mjs
@@ -0,0 +1,100 @@
+import { FATIGUE_SCAN_MS, fatigueOf } from '../src/lib/recovery.js'
+
+const HOUR = 60 * 60 * 1000
+const DAY = 24 * HOUR
+const BASE = Date.UTC(2026, 0, 31, 12)
+const ID = '1254'
+
+const workout = (start, weight, count = 8) => ({
+ d: new Date(start).toISOString(),
+ start,
+ entries: [{
+ id: ID,
+ sets: Array.from({ length: count }, () => ({ done: true, w: weight, r: 8 })),
+ }],
+})
+
+// Deterministic LCG: failures reproduce exactly without an external property-testing dependency.
+let seed = 0x5eed1234
+const random = () => {
+ seed = (Math.imul(seed, 1664525) + 1013904223) >>> 0
+ return seed / 0x100000000
+}
+
+let comparisons = 0
+let deletionComparisons = 0
+let largestIncrease = -Infinity
+for (let historyIndex = 0; historyIndex < 100; historyIndex += 1) {
+ const sessionCount = 3 + Math.floor(random() * 10)
+ const history = Array.from({ length: sessionCount }, () => {
+ const ageHours = Math.floor(random() * 120 * 24)
+ const weight = 40 + Math.floor(random() * 141)
+ const count = 1 + Math.floor(random() * 12)
+ return workout(BASE - ageHours * HOUR, weight, count)
+ })
+
+ let previous = fatigueOf(history, BASE).chest
+ for (let hour = 1; hour <= 1080; hour += 1) {
+ const current = fatigueOf(history, BASE + hour * HOUR).chest
+ const increase = current - previous
+ largestIncrease = Math.max(largestIncrease, increase)
+ if (increase > 1e-12) {
+ throw new Error(
+ `fatigue increased in history ${historyIndex} at hour ${hour}: ${previous} -> ${current}`,
+ )
+ }
+ previous = current
+ comparisons += 1
+ }
+
+ const beforeDeletion = fatigueOf(history, BASE)
+ for (let deleted = 0; deleted < history.length; deleted += 1) {
+ const afterDeletion = fatigueOf(history.filter((_, index) => index !== deleted), BASE)
+ for (const [slug, before] of Object.entries(beforeDeletion)) {
+ if (afterDeletion[slug] > before + Number.EPSILON) {
+ throw new Error(
+ `deleting workout ${deleted} in history ${historyIndex} increased ${slug}: `
+ + `${before} -> ${afterDeletion[slug]}`,
+ )
+ }
+ deletionComparisons += 1
+ }
+ }
+}
+
+if (comparisons !== 108000) throw new Error(`expected 108000 comparisons, got ${comparisons}`)
+
+// Pin the two history-edit invariants alongside the randomized property probes.
+const today = workout(BASE, 100, 5)
+const baseline = fatigueOf([today], BASE).chest
+for (const oldImport of [workout(BASE - 90 * DAY, 140, 10), workout(BASE - 90 * DAY, 100, 20)]) {
+ if (fatigueOf([oldImport, today], BASE).chest !== baseline) {
+ throw new Error('an import older than the scan changed current fatigue')
+ }
+}
+
+const deletionHistory = [
+ workout(BASE - FATIGUE_SCAN_MS - DAY, 100, 15),
+ workout(BASE - 3 * DAY, 100, 8),
+ workout(BASE - 2 * DAY, 100, 8),
+ workout(BASE - DAY, 60, 4),
+ workout(BASE, 120, 10),
+]
+const beforePinnedDeletion = fatigueOf(deletionHistory, BASE)
+for (let deleted = 0; deleted < deletionHistory.length; deleted += 1) {
+ const afterDeletion = fatigueOf(
+ deletionHistory.filter((_, index) => index !== deleted),
+ BASE,
+ )
+ for (const [slug, before] of Object.entries(beforePinnedDeletion)) {
+ if (afterDeletion[slug] > before + Number.EPSILON) {
+ throw new Error(`deleting workout ${deleted} increased ${slug}: ${before} -> ${afterDeletion[slug]}`)
+ }
+ }
+}
+
+console.log(`monotonic probe: ${comparisons} comparisons, largest increase ${largestIncrease}, PASS`)
+console.log(
+ `history-edit probe: out-of-scan imports stable; ${deletionComparisons} randomized `
+ + 'single-workout deletion comparisons non-increasing, PASS',
+)
diff --git a/frontend/src/components/BodyMap.jsx b/frontend/src/components/BodyMap.jsx
index fe71c47..022f180 100644
--- a/frontend/src/components/BodyMap.jsx
+++ b/frontend/src/components/BodyMap.jsx
@@ -47,11 +47,13 @@ function View({ view, levels, onMuscle, selected }) {
/**
*
* `load` is effective sets per muscle (see lib/muscles.js); shading is relative to
- * the hardest-worked muscle in that same load, so it always reads as a balance.
+ * the hardest-worked muscle in that same load, so it always reads as a balance. Pass ordered
+ * `{ at, level, exclusive? }` `thresholds` for a fixed absolute scale (recovery views use this
+ * to keep their semantic bands stable); omitting it preserves the balance behavior.
*/
-export default function BodyMap({ load = {}, body = 'male', onMuscle, selected, className = '' }) {
+export default function BodyMap({ load = {}, thresholds, body = 'male', onMuscle, selected, className = '' }) {
const paths = useBodyPaths()
- const levels = levelsOf(load)
+ const levels = levelsOf(load, thresholds)
const g = paths && (paths[body] || paths.male)
return (
@@ -939,25 +946,22 @@ function doFinishWorkout() {
const prs = []
const e1prs = []
A.entries.forEach(e => {
- const mx = Math.max(0, ...e.sets.filter(s => s.done).map(s => s.w))
+ const mx = Math.max(0, ...e.sets.filter(s => s.done && !isWarmupRow(s)).map(s => s.w))
if (mx > 0 && mx > bestWeightFor(st, e.id)) prs.push(e.id)
// A heavier estimate without a heavier top set is its own kind of progress —
// same weight for more reps. Reported separately so it can't be read as a load PR.
const rec = is1RMRecord(st, e.id, e)
if (rec && !prs.includes(e.id)) e1prs.push({ id: e.id, ...rec })
})
- const w = {
- id: A.id, d: A.d, start: A.start, end: Date.now(), routineId: A.routineId, name: A.name, bw: A.bw,
- // `target` (what the session prescribed) is kept alongside the sets: without it a
- // finished workout cannot say whether it hit its reps, and a timed session reads back
- // as "0 reps". It is what the progression engine works from.
- entries: A.entries.map(e => ({ id: e.id, sets: e.sets, topW: e.topW || null, target: e.target || null })).filter(e => e.sets.some(s => s.done)),
- prs
- }
+ const w = buildCompletedWorkout(A, {
+ end: Date.now(),
+ prs,
+ snapshotFor: e => EXIDX[e.id]?.custom ? exerciseMuscleSnapshot(EXIDX[e.id]) : null,
+ })
w.vol = workoutVolume(w)
update(s => {
w.entries.forEach(e => {
- const mx = Math.max(0, ...e.sets.filter(x => x.done).map(x => x.w || 0), e.topW || 0)
+ const mx = Math.max(0, ...e.sets.filter(x => x.done && !isWarmupRow(x)).map(x => x.w || 0), e.topW || 0)
if (mx > 0) { const cur = s.exWeights[e.id]; if (!cur || mx > cur.w) s.exWeights[e.id] = { w: mx, d: w.d } }
})
s.workouts.push(w)
diff --git a/frontend/src/store/useStore.js b/frontend/src/store/useStore.js
index a6367d4..d64aba1 100644
--- a/frontend/src/store/useStore.js
+++ b/frontend/src/store/useStore.js
@@ -3,6 +3,7 @@ import { api } from '../lib/api.js'
import { localTZ } from '../lib/format.js'
import { registerCustom } from '../lib/exercises.js'
import { DEMO, DEMO_SEEDED } from '../lib/demo.js'
+import { guestAllowed } from '../lib/guest.js'
import { MOBILE, nativeLoad, nativeSave, syncReminder } from '../lib/mobile.js'
const KEY = 'gym_state_v1'
@@ -100,6 +101,16 @@ export const useStore = create((set, get) => {
isGuest: () => localStorage.getItem('gym_guest') === '1',
setGuest(v) { if (v) localStorage.setItem('gym_guest', '1'); else localStorage.removeItem('gym_guest'); set({}) },
+ // Public config from /api/config (invite_only, allow_guest). null until the first successful
+ // fetch — the login screen and boot both read it, so it is fetched once and cached here
+ // rather than by each screen that happens to need it.
+ config: null,
+ async loadConfig() {
+ if (get().config) return get().config
+ try { const c = await api('/api/config'); set({ config: c }); return c }
+ catch { return null }
+ },
+
setUser(u) {
if (u) { localStorage.setItem('gym_user', JSON.stringify(u)); localStorage.removeItem('gym_guest') }
else localStorage.removeItem('gym_user')
@@ -177,9 +188,12 @@ export const useStore = create((set, get) => {
set({ ready: true })
return
}
- // Instance capabilities are public and are needed whether or not anyone is signed in —
- // fetched before /api/me so the first render already knows what this instance offers.
- try { set({ config: await api('/api/config') }) } catch { /* offline — assume nothing extra */ }
+ // Guests never authenticate, so an instance that turned guest mode off has no request to
+ // refuse — the only way the switch reaches someone already inside is here, on their next
+ // boot. Ending the session needs a positive `allow_guest: false`; see lib/guest.js for why
+ // an unreachable server must not be allowed to lock anyone out (#42).
+ const cfg = await get().loadConfig()
+ if (!guestAllowed(cfg)) get().setGuest(false)
try {
const me = await api('/api/me')
get().setUser(me.user)
diff --git a/frontend/src/store/useUI.js b/frontend/src/store/useUI.js
index b4eb439..d1a121a 100644
--- a/frontend/src/store/useUI.js
+++ b/frontend/src/store/useUI.js
@@ -10,6 +10,42 @@ import { useStore } from './useStore.js'
const pushRestTimer = sec => { if (useStore.getState().user) api('/api/push/rest-timer', { method: 'POST', body: JSON.stringify({ seconds: sec }) }).catch(() => {}) }
const cancelPushRestTimer = () => { if (useStore.getState().user) api('/api/push/rest-timer/cancel', { method: 'POST', body: '{}' }).catch(() => {}) }
+const notificationsSupported = () => typeof window !== 'undefined' && 'Notification' in window
+let requestRestNotificationPermissionP = null
+
+const requestRestNotificationPermission = async () => {
+ if (!notificationsSupported()) return false
+ if (Notification.permission === 'granted') return true
+ if (Notification.permission === 'denied') return false
+ if (!requestRestNotificationPermissionP) {
+ requestRestNotificationPermissionP = Notification.requestPermission()
+ .then(perm => perm === 'granted')
+ .catch(() => false)
+ .finally(() => {
+ requestRestNotificationPermissionP = null
+ })
+ }
+ return requestRestNotificationPermissionP
+}
+
+const maybeRestNotification = async () => {
+ if (!notificationsSupported()) return
+ if (!document.hidden && document.visibilityState !== 'hidden') return
+ if (Notification.permission !== 'granted' && !(await requestRestNotificationPermission())) return
+ try {
+ // Android Chrome forbids the Notification constructor (Illegal constructor) - the
+ // service-worker registration path is the one that actually pops there.
+ const reg = await navigator.serviceWorker?.getRegistration?.()
+ if (reg?.showNotification) {
+ reg.showNotification(t('Rest over — next set!'), { body: t('Rest over — next set!') })
+ return
+ }
+ new Notification(t('Rest over — next set!'), { body: t('Rest over — next set!') })
+ } catch {
+ // Intentionally ignore: notification APIs vary by browser and policy in edge cases.
+ }
+}
+
let toastTm = null
let timerInt = null
let timerTick = null
@@ -42,6 +78,7 @@ export const useUI = create((set, get) => ({
get().stopRest()
const endsAt = Date.now() + sec * 1000
set({ timer: { left: sec, total: sec, endsAt } })
+ requestRestNotificationPermission()
pushRestTimer(sec)
timerTick = () => {
const tm = get().timer
@@ -51,7 +88,7 @@ export const useUI = create((set, get) => ({
const snd = useStore.getState().S.sound
if (left <= 0) {
beep(snd, 880, 0.15); beep(snd, 880, 0.15, 0.25); beep(snd, 1320, 0.4, 0.5)
- vibrate([200, 100, 200]); get().toast(t('Rest over — next set!')); get().stopRest(); return
+ vibrate([200, 100, 200]); maybeRestNotification(); get().toast(t('Rest over — next set!')); get().stopRest(); return
}
if (left <= 3) beep(snd, 660, 0.1)
set({ timer: { ...tm, left } })
diff --git a/frontend/src/views/Login.jsx b/frontend/src/views/Login.jsx
index 43fe940..0df9748 100644
--- a/frontend/src/views/Login.jsx
+++ b/frontend/src/views/Login.jsx
@@ -1,21 +1,25 @@
import { useStore } from '../store/useStore.js'
import { useUI } from '../store/useUI.js'
-import { webauthnOK, passkeyLogin, passkeyRegister, api, BIO } from '../lib/api.js'
+import { webauthnOK, passkeyLogin, passkeyRegister, BIO } from '../lib/api.js'
import { hasData } from '../store/useStore.js'
import { t } from '../lib/i18n.js'
import { DEMO, REPO } from '../lib/demo.js'
+import { guestAllowed } from '../lib/guest.js'
import { useState, useRef, useEffect } from 'react'
import Icon from '../components/Icon.jsx'
import { Button } from '../components/ui.jsx'
function RegisterSheet({ close }) {
- const { setUser, pushState, pullState } = useStore()
+ const { setUser, pushState, pullState, loadConfig } = useStore()
+ const config = useStore(s => s.config)
const [name, setName] = useState('')
const [code, setCode] = useState('')
- const [inviteOnly, setInviteOnly] = useState(false)
+ const inviteOnly = !!config?.invite_only
const ref = useRef(null)
useEffect(() => { setTimeout(() => ref.current?.focus(), 250) }, [])
- useEffect(() => { api('/api/config').then(c => setInviteOnly(!!c.invite_only)).catch(() => {}) }, [])
+ // Boot already fetched this; retry here only if that attempt failed, so the invite field still
+ // appears on an instance whose config arrived late rather than never.
+ useEffect(() => { loadConfig() }, [loadConfig])
const go = async () => {
const n = name.trim()
if (!n) { useUI.getState().toast(t('Enter a name')); return }
@@ -44,6 +48,8 @@ function RegisterSheet({ close }) {
export default function Login() {
const { setUser, pullState, setGuest } = useStore()
+ const config = useStore(s => s.config)
+ const canGuest = guestAllowed(config)
const signIn = async () => {
try { const u = await passkeyLogin(); setUser(u); await pullState(); useUI.getState().toast(t('Welcome back, {0}', u.name)) }
catch (e) { if (e.name !== 'NotAllowedError' && e.name !== 'AbortError') useUI.getState().toast(e.message || t('Sign-in failed')) }
@@ -77,9 +83,13 @@ export default function Login() {
-
- > :
{t("This browser doesn't support passkeys — you can still use openGym locally on this device.")}
}
-
+ {canGuest && }
+ > :
{canGuest
+ ? t("This browser doesn't support passkeys — you can still use openGym locally on this device.")
+ // Without passkeys and without the guest entrance there is no way in from this browser,
+ // so say that plainly instead of offering a local profile that cannot be created.
+ : t("This browser doesn't support passkeys, and this instance requires an account. Try a browser or device with passkey support.")}
}
+ {canGuest && }
{t('Passkeys use {0} — no passwords.', BIO)} {t('Each profile keeps its own plan, workouts & body weight.')}
)
diff --git a/frontend/src/views/Stats.jsx b/frontend/src/views/Stats.jsx
index f25b3cd..c16a412 100644
--- a/frontend/src/views/Stats.jsx
+++ b/frontend/src/views/Stats.jsx
@@ -1,8 +1,8 @@
-import { useState } from 'react'
+import { useEffect, useMemo, useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { useStore } from '../store/useStore.js'
import { EXIDX } from '../lib/exercises.js'
-import { lastBW, streakWeeks, setLabel, modeOf, effortOf } from '../lib/history.js'
+import { lastBW, streakWeeks, setLabel, modeOf, effortOf, metricModeForEntry, metricRowsForEntry, bestWeightForEntry } from '../lib/history.js'
import { fmtNum, fmtDate, fmtVol, todayISO, weekKey } from '../lib/format.js'
import { t } from '../lib/i18n.js'
import { bwSheet, goalSheet, calendarSheet, workoutDetailSheet, WorkoutRow, bwDeltaColor } from '../sheets.jsx'
@@ -10,21 +10,117 @@ import LineChart from '../components/LineChart.jsx'
import Heatmap from '../components/Heatmap.jsx'
import Icon from '../components/Icon.jsx'
import BodyMap, { BodyMapLegend } from '../components/BodyMap.jsx'
-import { loadOfWorkouts, rankOf, MUSCLE_NAME } from '../lib/muscles.js'
+import { loadOfWorkouts, rankOf, MUSCLE_NAME, musclesOf } from '../lib/muscles.js'
+import { fatigueOf, strengthOf, STRENGTH_FLOOR, LB_TO_KG } from '../lib/recovery.js'
+import { strengthExerciseRowsForMuscle } from '../lib/strength-exercises.js'
+import { fatigueStateOf } from '../lib/recovery-view.js'
import { e1rmSeries, best1RM } from '../lib/onerm.js'
import {
hasEffort, displayScale, scaleName, toScale, avgRir, effortSummary, effortWeeks,
effortHistogram, isHardSet, HARD_RIR
} from '../lib/effort.js'
import { Button, Segmented, SelectRow } from '../components/ui.jsx'
+import { isWarmupRow } from '../lib/workout-model.js'
// Which muscles the training in a window actually hit — and, the point of the card,
// which ones it keeps missing. Shading is relative within the window (lib/muscles.js).
+function latestMuscleTraining(workouts) {
+ const latest = {}
+ for (const workout of workouts || []) {
+ const timestamp = Number(workout?.start || new Date(workout?.d).getTime())
+ if (!Number.isFinite(timestamp)) continue
+ for (const entry of workout.entries || []) {
+ if (!(entry.sets || []).some(set => set?.done === true && !isWarmupRow(set))) continue
+ const exercise = EXIDX[entry.id] || entry.exercise || entry
+ for (const slug of Object.keys(musclesOf(exercise))) {
+ if (latest[slug] == null || timestamp > latest[slug]) latest[slug] = timestamp
+ }
+ }
+ }
+ return latest
+}
+
+export const FATIGUE_LEVELS = [
+ { at: 0, level: 0 },
+ { at: 0.15, level: 1 },
+ { at: 0.25, level: 2 },
+ { at: 0.4, level: 3 },
+ { at: 0.55, level: 4, exclusive: true },
+]
+
+export const STRENGTH_LEVELS = [
+ { at: STRENGTH_FLOOR, level: 0 },
+ { at: 0.625, level: 1 },
+ { at: 0.75, level: 2 },
+ { at: 0.875, level: 3 },
+ { at: 1, level: 4 },
+]
+
+function useNow() {
+ const [, setTick] = useState(0)
+ useEffect(() => {
+ const iv = setInterval(() => setTick(tick => tick + 1), 60000)
+ return () => clearInterval(iv)
+ }, [])
+ return Date.now()
+}
+
+/**
+ * Return the whole weeks since a completed muscle-training timestamp.
+ *
+ * @param {number} now Current render-time timestamp in milliseconds.
+ * @param {number} lastTrained Timestamp of the latest completed training event.
+ * @returns {number} Non-negative whole weeks, including zero for ages under seven days.
+ */
+export function weeksSinceTraining(now, lastTrained) {
+ return Math.max(0, Math.floor((now - lastTrained) / 86400000 / 7))
+}
+
+function FatigueLegend() {
+ return
{cardio && {t('Cardio')}}
{/* You log the total; this is the split, so the set in front of you is unambiguous
@@ -131,19 +137,33 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov
{/* the header carries the same eff3 sizing as the rows, or the labels drift off their columns */}
- {cell(s, i, col1, 'w')}
- {col2 && cell(s, i, col2, 'r')}
- {col3 && cell(s, i, col3, 'eff')}
- {/* A timed set is started, not typed: the timer counts the hold down and checks the
- set off itself. The checkbox stays for anyone who timed it on their own watch. */}
- {timed && }
- onToggle(i)} />
-
)}
+ {entry.sets.map((s, i) => {
+ const warm = isWarmupRow(s)
+ const warmBefore = i > 0 && isWarmupRow(entry.sets[i - 1])
+ const isFirstWarmup = warm && !warmBefore
+ // Numbering restarts per phase: with two warm-ups the first work set reads 1, not 3.
+ const phaseNum = entry.sets.slice(0, i + 1).filter(x => isWarmupRow(x) === warm).length
+ return
+ {isFirstWarmup &&
{t('Warm-up')}
}
+ {!warm && warmBefore && }
+
+
{phaseNum}
+ {cell(s, i, col1, 'w')}
+ {col2 && cell(s, i, col2, 'r')}
+ {col3 && cell(s, i, col3, 'eff')}
+ {/* A timed set is started, not typed: the timer counts the hold down and checks the
+ set off itself. The checkbox stays for anyone who timed it on their own watch. */}
+ {timed && }
+ {warm && }
+ onToggle(i)} />
+
+
+ })}
-
+
+
@@ -152,17 +172,46 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov
}
/* ---------- active workout ---------- */
+export function removeActiveExercise(idx) {
+ // Clear the work callback before indexes can shift. This also protects a confirmation sheet
+ // that was opened first and confirmed after a timed hold started.
+ useUI.getState().stopWork()
+ useStore.getState().update(s => {
+ if (!s.active || !Array.isArray(s.active.entries)) return
+ if (idx < 0 || idx >= s.active.entries.length) return
+ s.active.entries.splice(idx, 1)
+ cleanupSg(s.active.entries)
+ if (idx < s.active.cur) s.active.cur--
+ if (s.active.cur >= s.active.entries.length) s.active.cur = Math.max(0, s.active.entries.length - 1)
+ }, true)
+}
+
function ActiveWorkout() {
const nav = useNavigate()
const S = useStore(s => s.S)
const update = useStore(s => s.update)
- const { startRest, stopRest } = useUI()
+ const { startRest, stopRest, work } = useUI()
const A = S.active
const units = supersetUnits(A.entries)
const cur = Math.min(A.cur, Math.max(0, A.entries.length - 1))
const unit = A.entries.length ? unitOf(units, cur) : []
const unitIdx = units.findIndex(u => u === unit)
const isSuperset = unit.length > 1
+ // Superset flow: keep the active exercise in view - completing a set scrolls to the
+ // next exercise in the group, then back up to the first exercise of the next round.
+ const exRefs = useRef({})
+ const progressHighWater = useRef(A.entries.map(e => e.sets.filter(s => s.done).length))
+ // The marks are index-keyed, and removing an exercise shifts every index above it down
+ // (removeActiveExercise splices). Re-baseline whenever the list length changes, otherwise a
+ // shifted exercise inherits its predecessor's mark and its real progress reads as a re-check.
+ useEffect(() => {
+ progressHighWater.current = A.entries.map(e => e.sets.filter(s => s.done).length)
+ }, [A.entries.length])
+ useEffect(() => {
+ if (!isSuperset) return
+ const el = exRefs.current[cur]
+ if (el && typeof el.scrollIntoView === 'function') el.scrollIntoView({ behavior: 'smooth', block: 'nearest' })
+ }, [cur, isSuperset, A.entries.length])
const total = A.entries.reduce((n, e) => n + e.sets.length, 0)
const done = setsDoneActive(A)
@@ -172,6 +221,11 @@ function ActiveWorkout() {
// what was actually logged — in the session, in history and in a backup.
const setField = (idx, i, field, v) => mutEntry(idx, e => {
if (v == null) delete e.sets[i][field]; else e.sets[i][field] = v
+ // Changing a weight cascades to the following sets of the same phase, so a
+ // heavier bar carries through the set instead of retyping every row.
+ if (field === 'w') {
+ e.sets = cascadeWeight(e.sets, i, v)
+ }
})
const modeAt = idx => modeOf({ ...(A.entries[idx].target || {}), id: A.entries[idx].id })
const addSet = idx => mutEntry(idx, e => {
@@ -182,6 +236,51 @@ function ActiveWorkout() {
else e.sets.push({ w: l ? l.w : 0, r: l ? l.r : e.target.reps, done: false })
})
const removeSet = idx => mutEntry(idx, e => { if (e.sets.length > 1) e.sets.pop() })
+ const addWarmup = idx => mutEntry(idx, e => {
+ const m = modeOf({ ...(e.target || {}), id: e.id })
+ e.sets = insertWarmupRow(e.sets, m, e.target || {})
+ })
+ const removeSetAt = (idx, i) => mutEntry(idx, e => { e.sets = removeRowAt(e.sets, i) })
+ const pairAt = (first, second) => update(s => {
+ s.active.entries = pairAdjacent(s.active.entries, first, second)
+ })
+ const unpairAt = idx => update(s => {
+ s.active.entries = unpairSuperset(s.active.entries, idx)
+ })
+ const onPairPrev = !isSuperset && cur > 0 ? () => pairAt(cur - 1, cur) : null
+ const onPairNext = !isSuperset && cur < A.entries.length - 1 ? () => pairAt(cur, cur + 1) : null
+
+ // Remove a whole exercise from the session. The confirmation always asks first; in a
+ // superset it asks WHICH exercise of the group to remove.
+ const removeExercise = removeActiveExercise
+ const confirmRemoveExercise = idx => {
+ const e = A.entries[idx]
+ if (!e) return
+ const hasDone = (e.sets || []).some(s => s.done)
+ confirmSheet({
+ title: t('Remove {0}?', exOr(e.id).n),
+ message: hasDone
+ ? t('The sets you logged for this exercise in this session will be lost.')
+ : t('This removes the exercise from your current session.'),
+ confirmText: t('Remove'), danger: true, onConfirm: () => removeExercise(idx)
+ })
+ }
+ const removeExerciseSheet = () => {
+ if (unit.length > 1) {
+ useUI.getState().openSheet(close => (
+
+
{t('Remove exercise')}
+
{t('Which exercise in this superset do you want to remove?')}
+
+ {unit.map(idx =>
{ close(); confirmRemoveExercise(idx) }}>
+
{exOr(A.entries[idx]?.id).n}
+
+
)}
+
+
+ ))
+ } else confirmRemoveExercise(cur)
+ }
// A timed set is held, not typed. The work timer records what was actually held — an early
// finish logs 0:38 of a 0:45 target rather than crediting the full prescription — and then
@@ -199,15 +298,13 @@ function ActiveWorkout() {
const m = modeAt(idx)
const cardioEntry = m === 'cardio'
const isLastUnit = unitIdx >= units.length - 1
- let askTop = false, exJustDone = false, workoutDone = false
+ let askTop = false, exJustDone = false, workoutDone = false, checked = false
mutEntry(idx, e => {
e.sets[i].done = !e.sets[i].done
+ checked = e.sets[i].done
if (e.sets[i].done) {
beep(S.sound, 1040, 0.12); vibrate(30)
- const isLastExInUnit = idx === unit[unit.length - 1]
const unitDone = unit.every(ui => (ui === idx ? e : A.entries[ui]).sets.every(x => x.done))
- if (isLastExInUnit && !unitDone) startRest(S.restSec)
- else if (unitDone) stopRest()
if (unitDone && isLastUnit) workoutDone = true // last exercise's last set → done
// Only loaded reps training has a "working weight" worth confirming — a bodyweight
// plank has nothing to put in that slider, and neither does a set of push-ups
@@ -222,6 +319,43 @@ function ActiveWorkout() {
else if (workoutDone) workoutCompleteSheet()
else if (exJustDone && cardioEntry) useUI.getState().toast(t('Cardio logged'))
else if (exJustDone && m === 'time') useUI.getState().toast(t('Hold logged'))
+
+ // Only progress beyond this exercise's high-water mark may navigate or change rest. This
+ // prevents an uncheck/re-check of finished work from replaying the flow side effects.
+ const fresh = useStore.getState().S.active
+ if (fresh && checked && fresh.entries[idx]) {
+ const progress = setProgressHighWater(fresh.entries[idx], progressHighWater.current[idx] || 0)
+ progressHighWater.current[idx] = progress.highWater
+ if (!progress.isNew) return
+
+ const freshUnits = supersetUnits(fresh.entries)
+ const freshUnit = freshUnits.find(u => u.includes(idx))
+ const freshUnitIdx = freshUnits.indexOf(freshUnit)
+ const freshLastUnit = freshUnitIdx >= freshUnits.length - 1
+ const freshUnitDone = freshUnit?.every(ui => fresh.entries[ui].sets.every(x => x.done))
+
+ // Singleton units are ordinary exercises: preserve their historical between-set rest,
+ // while final sets finish quietly and never enter superset navigation.
+ if (freshUnitDone) stopRest()
+ if (!freshUnit || freshUnit.length <= 1) {
+ if (!freshUnitDone) startRest(S.restSec)
+ return
+ }
+
+ const step = supersetFlowStep(fresh.entries, freshUnit, idx)
+ if (!step) return
+ if (step.unitDone) {
+ if (!freshLastUnit) {
+ const nextUnit = freshUnits[freshUnitIdx + 1]
+ // The top-weight sheet's explicit "Just close" path owns the choice not to advance.
+ if (!askTop && nextUnit?.length) update(s => { if (s.active) s.active.cur = nextUnit[0] })
+ startRest(S.restSec)
+ }
+ } else {
+ if (step.nextIdx != null) update(s => { if (s.active) s.active.cur = step.nextIdx })
+ if (step.roundDone) startRest(S.restSec)
+ }
+ }
}
// Live-presence heartbeat so the admin dashboard can show who's training now. Signed-in only —
@@ -263,15 +397,18 @@ function ActiveWorkout() {