ba37ef8a443131a7cd2adeeaa1a8ffa9a9793998
14
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
ba37ef8a44 |
Deploy path: give the health ingest 32 MB, and stop appending to X-Forwarded-For
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
gym.dploy.lol does not run docker-compose.yml. It runs deploy/compose-build-at-deploy.yml, where nginx is generated inline by the web service from a printf in its command, with a single global `client_max_body_size 5m`. The per-route 32 MB added for the Apple Health ingest lives in web/nginx.conf.template, which belongs to the registry-image path and is never read here — so a first export of more than 5 MB came back as nginx's own 413 HTML before the API saw a byte of it. That path now has a second location for /api/vitals/ingest with 32m; nginx picks the longest matching prefix, so that one route takes the bigger body and everything else keeps matching the API's MAX_BODY. Both limits are spelled out in comment 3 at the top, with a note that the two deployment shapes have to be changed together. Also fixes a smaller thing found while reading it: X-Forwarded-For was $proxy_add_x_forwarded_for, which APPENDS to whatever the client sent, and the API reads the first entry — so a caller could choose the address recorded about it. It is now $remote_addr, which is what web/nginx.conf.template already does and for the same reason documented there. Audit IPs are off by default, so nothing was being recorded; this matters the day somebody sets AUDIT_IP=net. Comment 3 also now records the two things that make a deploy confusing rather than broken: the api service copies the clone into /app at container start, so an api that was not recreated keeps serving the previous revision while web-build serves the new frontend (exactly the 404-on-a-new-route symptom), and web resolves api's IP once at start-up, so recreating api without web leaves nginx pointing at a dead address and every /api call answering 502. |
||
|
|
8d190bb591 |
Salud moves to Home's header: a sixth tab pushed Start off centre
Tests / test (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
The tab bar is a flex row of equal columns with the Start button raised in the middle, so the tab count has to stay odd. Adding Salud as a sixth pushed that disc half a column to the right, and it read immediately as "the button moved" — the app's primary action is the one thing in the bar that must not drift. Salud is now the heart button in Home's header, next to the gear, with the same destination and the same route (/health). It is reachable from Settings → Data as well, which was already there. The tab bar is back to five: Home, Plan, Start, Stats, Exercises. Two tests, because this is the kind of change that regresses silently: TabBar.test.jsx asserts the odd count and that the raised button is the middle child (plus that no tab points at /health), and Home.health-door.test.jsx asserts the heart sits in the same non-shrinking container as the gear and navigates to /health — if that breaks, the screen is only reachable from Settings, where nobody looks for it. Also: the Comments in Home, TabBar, README, CHANGELOG and docs/HEALTH.md now say where Salud is, and one test assertion checks flexGrow/flexShrink rather than the `flex: none` shorthand — the CSSOM rewrites that to `0 0 auto`, which is what the first version of the test tripped over. |
||
|
|
691e664d3f |
Apple Health (Salud): a per-profile ingest endpoint, and a tab that draws it
Tests / test (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
An iOS automation in Health Auto Export POSTs Apple Health to /api/vitals/ingest, and the new Salud tab (next to Plan) draws whatever arrived: steps, heart rate, sleep, weight, oxygen, workouts and every other metric HAE can export, grouped into cards with a trend, a sparkline and a 7/30/90/365-day range. Nothing on that screen is an input, and the watch's workouts stay out of the history on purpose — they carry no sets and no weights, so folding them into progression, PRs and the recovery model would be inventing data. The interesting part is duplicates. A five-minute automation re-sends overlapping windows: with Date Range "Today", appending would count a day of steps again on every run, and with "Since Last Sync", replacing would throw away everything but the last five minutes. So the endpoint decides per payload instead. Datapoints that sit on midnight are HAE's own day grouping, i.e. a *total*, and a day total replaces the day it names — re-sending the same day all afternoon converges on that day's total. Anything else is a real sample, identified by its instant plus its numbers and stored once, which is right for overlapping and disjoint windows alike. Every sync answers with a receipt (received / duplicates / stored), so a misconfigured automation is visible rather than silent, and day keys come from the date the phone wrote — never the server's clock, or every evening's steps would land on tomorrow. Per profile and private by construction. Each profile mints its own ingest key (Salud → ⚙), which is write-only: it can add to that one profile's health file and cannot read a single number back, so a key leaking out of a phone is a nuisance rather than a disclosure. It is its own credential, so rotating it disconnects a phone without signing anybody out anywhere. The data lives in data/vitals-<uid>.json, outside the synced state document, so a year of heart rate never round-trips through localStorage on every device, and it is bounded on write: 400 days per metric, a 72 h dedupe ledger, the newest 300 workouts. Two traps that only exist in production, both fixed here and both of which would have shipped broken. api/Dockerfile copies the modules server.js imports by name, and vitals.js was not on that list — a container that boots straight into ERR_MODULE_NOT_FOUND. And the web container's nginx capped every /api body at 5 MB, which a health export with Summarize Data off exceeds; that one route now gets the API's own 32 MB while every other path keeps 5 MB, with the shared proxy settings hoisted to server level so the two locations cannot drift apart. Coverage: vitals.js (13 tests — overlapping, disjoint, day-grouped, raw, heart rate, sleep, blood pressure, pruning, timezones), the routes against a real server (4 — isolation between profiles, a key that cannot read, ten re-sends changing nothing), the card model (18) and the screen (4). docs/HEALTH.md has the Health Auto Export settings and the merge table; the five endpoints are in api/openapi.yaml under the health tag, and website/api.html is rebuilt from it. |
||
|
|
0819d03efb |
Measure the iOS touch offset on the device that has it
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
Tests / test (push) Canceled after 0s
Press a row on an iPhone and the one above it reacts — but only sometimes, and only after typing. That is the shape of the keyboard displacement the app already fights in lib/viewport-guard.js: iOS slides the *visual* viewport inside the layout one, everything `position:fixed` is painted against the layout viewport, and the app and the finger disagree until something scrolls. The guard stands down while a text field has focus on purpose (touching the page there threw the keyboard back out — issue #242), and that is precisely the window this falls into. Which correction is right depends on numbers that only exist on the phone: visualViewport.offsetTop, innerHeight, the scale, whether the body is pinned. So this adds a readout instead of a guess. Open the app with `vvdebug` anywhere in the URL, type in a field, tap the row that misbehaves, and read what the viewports were at the moment of that tap — plus which element the browser believed was under the finger, which is the other half of the question ("did it hit the row above, or the row it hit is not where it is drawn?"). It renders nothing without the parameter, and removing it is this file plus one line in App.jsx. |
||
|
|
903a435af3 |
Build a routine with AI: the screen the builder was missing
Tests / test (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
"Add exercise" now has a sibling: it asks which muscles, whether the session
starts with cardio, and how hard — then the Coach fills the routine in. Three
taps instead of picking ten exercises one at a time, and it is the only place in
the app that asks what you want to train today.
Why it exists in this shape:
- The Coach's own intake asks about the *person* — goal, days, equipment, limits
— and is answered once. Nothing in it asks which muscles, so a three-day plan
reasonably came back full body; that is what prompted this. The builder asks
only what changes between sessions and reads the rest from the saved profile,
so a second routine costs three taps and not a questionnaire.
- It adds a NEW routine rather than filling the one you opened. The questions are
about a session you are about to build, and replacing the routine somebody
opened would be the wrong guess. It does not touch the week either: nobody was
asked about days.
- The muscle buttons are the catalogue's own body-part words ("back", "waist"),
which the Library and the body map already translate, so a button and the list
behind it cannot drift apart. "Light" and "Hard" are NOT reused for the effort
chips: those keys already mean the light theme and hard sets, and a chip reading
"Claro" for an easy session would be nonsense in Spanish.
The async half: requestPlan only *starts* a job (the server runs it in the
background and the result arrives on a status poll), so `awaitCoachJob` waits for
that job by the id of the last finished one — a proposal left over from an
earlier question can never be mistaken for this answer — and throws with the
job's own error class for jobErrorText to phrase.
Five tests drive the whole thing: the three steps, the exact questions sent (the
muscles as bp/tg selectors with cardio in the library, not only in the sentence),
that what comes back lands as a new routine with the cardios and the modes the app
owns normalised, that a failure is shown in the app's words and can be retried,
and that an answer with no routine is refused rather than added empty.
The 22 new strings exist in Spanish only, by decision. Rather than leave
check-locales.mjs permanently red — a guard nobody reads is not a guard — the
pending set is written down in src/locales/PENDING.md: the check still fails on
anything NEW, and the debt is a list somebody can work through.
|
||
|
|
996797bf00 |
Spanish exercise names for the whole catalogue
Tests / test (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
A Spanish profile now reads the catalogue in Spanish. Only pt-BR and hu had a
name pack, so every other language — Spanish included, which is this fork's
default — showed 1,324 English titles.
The pack is generated the way the pt-BR and hu ones were, with two differences
that matter to a self-hosted instance:
- `scripts/translate-es-exercise-names.mjs` talks to an OpenAI-compatible
endpoint instead of the `claude` CLI, because that is what the instance
already has: the same router the Coach runs on. Point it at one with
COACH_BASE_URL / COACH_MODEL / COACH_API_KEY.
- It is resumable. Ids already in the source file are skipped, so a run that
stops half way continues where it left off and a review only re-translates
what it deletes. With 1,324 rows, a pass that had to start over would never be
repeated.
Three rounds of review went into the file, each one caught by reading the output
rather than by the script succeeding:
1. "chin-up" and "pull-up" came back as English loanwords — the terms the
catalogue itself uses — so the core vocabulary is now pinned in the prompt and
asserted by the test (dominada, sentadilla, peso muerto, zancada, plancha…).
2. 142 rows led with the equipment ("Banda sentadilla", "Mancuerna press"), which
is the English word order. Spanish names the movement first: "Sentadilla con
banda". Those rows were re-translated, and the test now refuses a title that
starts with a piece of equipment — "Peso muerto" is why "Peso" is not on that
list.
3. Four rows dropped their (male) qualifier and four named variations kept an
English head noun ("Hack squat con barra"); both were fixed, the first by hand
since the review is allowed to edit the source.
The pack is honest about its provenance, like the pt-BR one: model-produced,
not reviewed by a native speaker, and the README says so.
|
||
|
|
40959de0a2 |
Forward the COACH_* variables to the api container in the deploy compose
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
The api service lists its environment explicitly, and that list is an allowlist:
a variable set in the host's .env reaches the container only when it is named
there. Everything else in the panel is used solely to substitute ${…} in the
compose file — which is how COACH_PROVIDER can sit in Dokploy looking applied
while the api never sees it, the Coach stays off, and no screen anywhere shows a
button. That is exactly what happened on this instance.
The `:-` defaults keep an instance that sets none of them byte-for-byte as it
was: an empty value reads as unset in coach/config.js.
|
||
|
|
238eb635c5 |
Configure the Coach from the environment
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
An instance can now be pointed at a model entirely from its environment — so a
container is redeployed with the Coach already working, and nobody has to open
an admin screen:
COACH_PROVIDER=compatible
COACH_BASE_URL=https://ai.example.com # WITHOUT /v1 — the adapter adds it
COACH_MODEL=vendor/model-name
COACH_API_KEY=sk-... # or the provider's own variable
Naming a provider is the whole configuration, so it also turns the Coach on: an
instance started this way that then reported itself "off" would be a puzzle with
no clue in it.
Three decisions worth stating:
- The environment is the *base*, the way DEFAULTS is, and the saved file is
layered on top: an admin who picked a provider in the app meant it, and this
only fills what is absent.
- The key is deliberately NOT a field of the config. That object is cached,
written to data/coach.json by any admin action, and included in the backup the
docs tell people to make. envCredentialFor reads it from the process
environment instead, so it is written nowhere and never surfaced by any route
that reports configuration. A pasted credential still outranks it, and a filed
one that fails to decrypt stays a failure rather than quietly falling back to
a key nobody knows is being spent.
- What the environment supplies is stripped before the file is written. A saved
config used to be written back whole, which would have frozen this start-up's
values on disk — and since the file outranks the environment, a later change
to COACH_MODEL would have been silently ignored.
Verified through the server's own path (config → credentialFor → jobEnv →
adapter) against the OpenAI-compatible router this fork runs on: a chest+triceps
request came back as a six-exercise routine with the cardio row first and
correctly marked `mode: cardio`.
|
||
|
|
327aa5211b |
The core of "build a routine with AI": muscles, cardio, intensity
Tests / test (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
The screen that will drive this needs three things underneath it, and all three
are here, tested, with no UI yet.
1. `librarySlice` can be narrowed to the muscles someone picked. A selector is
`{ bp }` or `{ tg }` — the target muscle matters because "biceps" and "triceps"
are both `upper arms`, and asking for one must not hand back the other — and an
exercise is kept when it matches any of them, so "back and biceps" is one list.
`catalogueOnly` drops the person's own exercises, which are the only rows in
the app with no animation; the builder promises every pick can be watched.
Both answers ride in the existing `intake` object rather than a second channel:
the intake is already how "which muscles" reaches the payload, and it travels
the whole way (route → job → build, and local → build) untouched. `cleanGroups`
sanitises it, since it is the one intake field that reaches a filter rather than
the model's reading.
2. `lib/ai-routine.js` — the three questions and what to do with the answer: the
intake the model is asked with, and the routine it hands back, normalised for
this app. Cardio lands in the library and not only in the sentence (a model told
to start with cardio but handed no cardio exercise can only improvise, which is
what it did the first time this was tried), a cardio row becomes one bout
whatever set count came back, and a missing mode is read from the exercise the
same way `modeOf` reads it everywhere else.
3. A validator fix found on the way: the cardio branch set `min` and `speed` but
never `clean.mode = 'cardio'`, unlike the time and reps branches. The app
recovered it from the catalogue, so nothing was visibly broken — but the bundle
did not describe its own prescription, and a model that omitted `mode` (which is
what a model prescribing "8 minutes of cardio" usually does) got "3 × 10 reps"
with a stray `min` nothing reads. Now the mode is stated, and inferred from the
catalogue when it is missing. `time` is deliberately not inferred: nothing in the
catalogue says an exercise is held for seconds.
Verified against the real router behind gym.dploy.lol with the real pipeline: a
back+biceps request produced a 6-exercise routine from an 80/80/22 library slice.
|
||
|
|
ea1af681c2 |
Read an answer that arrives with an SSE terminator glued to it
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
A gateway may answer a request that did not ask for streaming with SSE framing anyway: the whole chat.completion object followed by "\ndata: [DONE]". That body is not JSON, so readJson's strict parse rejected it, `data` came back null, and the job failed with "unexpected response shape: Cannot read properties of null (reading 'choices')" — while the answer it wanted sat in the first few kilobytes. Not hypothetical: the OpenAI-compatible router behind this fork's own instance answers exactly that way, which made every coach job fail against it with a message that says nothing about the real problem. The lenient read takes the first complete JSON value and ignores what follows, counting braces outside of strings so a "}" inside a rationale cannot end the scan early. It cannot paper over a truncated answer — an object that never closes still returns null, which is what the token-limit path depends on — and there are three tests for that: the terminator case, trailing junk after a complete object, and an object that never closes. |
||
|
|
1c201ab6f9 |
Merge #1: rebrand to KuentaGYM, pounds/Spanish defaults, build-at-deploy stack
Tests / test (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
|
||
|
|
1a48efdbcc |
Add deploy/compose-build-at-deploy.yml for hosts that build at deploy time
Tests / test (pull_request) Canceled after 0s
The instance at gym.dploy.lol runs a five-service stack that clones the source and builds it on every deploy, rather than pulling the images docker-compose.yml names. That shape has three requirements nothing in the repository stated, and getting any of them wrong costs a deploy: - web-build has to copy the whole repository and build from frontend/. The frontend imports the Coach's core from ../../../api/coach/core/, so a build stage holding only frontend/ fails with nine UNRESOLVED_IMPORT errors — the reason web/Dockerfile copies api/coach/core/ into its build stage. - The volume names have to be pinned with `name:`. Unpinned, a restyled stack silently creates empty volumes and the profiles and training history look gone. - nginx needs client_max_body_size. Its default request limit is 1 MB while the app PUTs the whole profile to /api/data and the API accepts 5 MB — the sync starts failing with a 413 the UI cannot explain once a history grows past 1 MB. web/nginx.conf.template already sets 5m; this matches it. The file is the shape that instance runs, with its volume names filled in. |
||
|
|
affac4a2a0 |
Add scripts/build-images.sh: build the two images and publish them
The images docker-compose.yml pulls are normally built by
.gitea/workflows/docker-publish.yml, which needs a registered Actions runner
and a PACKAGES_TOKEN secret. Neither exists on this instance's forge yet, so a
host that pulls rather than builds has nothing to pull — and the two builds are
easy to get wrong by hand: api builds from ./api, web from the repository root,
because the web image compiles frontend/ inside its first stage. A wrong context
produces an image that builds fine and then fails at runtime.
One command now does both and pushes them:
GITEA_TOKEN=<token with write:package> ./scripts/build-images.sh
TAG, REGISTRY, OWNER, PLATFORM, PUSH and API_TARGET (default vs coach) are all
overridable, and the tags default to exactly what docker-compose.yml asks for.
|
||
|
|
87bfd6d4c4 |
Rebrand to KuentaGYM, and start a new profile in pounds and Spanish
The app is now KuentaGYM everywhere a user can see it, and a fresh profile no longer starts on upstream's English/kg defaults. Both are this fork's decisions, so both are pinned by tests rather than left to a find-and-replace. Rename (1,270 references, 149 files) - Visible surfaces: the Login/Home/mobile-onboarding wordmark, the Settings version line, the printed plan, the PWA title + manifest, and the 17 branded strings across all 14 locale packs. - Infrastructure: repo links, the container images and the release endpoints now name git.dploy.lol/dsantillan/kuentagym; .gitea/workflows/docker-publish.yml publishes to this forge's registry instead of gitea.com. - The Android/iOS application id stays ch.duartesantos.opengym on purpose: changing it would make the mobile app a different app that could never update an installed copy. Three things the mechanical pass would have broken, fixed here - The update check asked gitlab.com for upstream's releases and would have installed upstream's APK, putting the old name back on the phone. It now reads this fork's Gitea releases API (the assets shape differs), with the tests rewritten to the payload Gitea actually returns. - Renaming the mobile state/pairing files (opengym-state.json, opengym-remote.json) would lose the on-device copy of a history whose WebView storage may have been evicted, and silently unpair the device. Both are read under their old names and written forward under the new ones. - Renaming the exported plan-file marker (openGym_plan) rejected every plan shared before the rename as "not a plan file". Both markers are accepted. Defaults: pounds and Spanish - DEF.unit = 'lb', DEF.lang = 'es', plus every fallback that independently assumed en/kg (the <html lang> attribute, the Settings pickers, the Store, the MCP, the Coach payload). - Server-generated push copy existed only in English and pt-BR, so a Spanish profile would have been notified in English; Spanish added. - The demo seed states unit: 'kg' — its seeded numbers are kilograms, and inheriting the new default would have introduced an 82.4 lb lifter benching 60. - The module-level language in i18n-core stays English: it is the only language whose strings need no pack, so `t()`, dates, numbers and lists agree before a pack loads. Starting there on 'es' formats a Spanish-shaped UI with English strings. Also - api/package.json's test glob missed push-messages.test.js and verify-error.test.js, which sat beside the modules they cover and never ran. - README, docs/, website/ and the issue templates no longer describe upstream's GitLab/GitHub pipeline, Discord, sponsorship or public demo as if they were this fork's; upstream history and attribution are preserved (NOTICE.md). |