Commit Graph
815 Commits
Author SHA1 Message Date
Duarte Santos 1574811af0 Wake-lock test: stop assigning to a global Node now owns
The first CI run found this, which is the point of having one. Node 21+ defines
globalThis.navigator itself as a getter with no setter, so `globalThis.navigator
= {...}` throws under ESM strict mode. This box runs Node 20, where the global
does not exist and the assignment is fine — the test has never failed locally
and never would.

Only the first test failed: its afterEach deletes the built-in accessor, so
every later test assigned cleanly against the hole it left. defineProperty works
on both runtimes.

Production images are node:22-alpine (web/Dockerfile, api/Dockerfile), so the
version CI runs is the right one and the test was what needed fixing.
2026-07-31 19:21:03 +02:00
Duarte Santos b45dbca2a6 Demo: rate the sets, so the demo shows the effort stats
The live demo is the shop window, and it was the one place the new Effort card
could not appear — demoSeed fabricated twelve weeks of training with no ratings
at all, so every chart that reads effort rendered empty or absent.

The seed now rates about 82% of finished sets, deterministically as before:
effort tracks position in the session and the block's progression, one deload
week sits well away from failure, the first three weeks are written in RPE as if
imported from another app, and one exercise stays unrated throughout so the
partial-coverage case is visible rather than theoretical. Only reps-mode sets
are rated — a reps-in-reserve number on a cardio set would be nonsense.
2026-07-31 19:12:18 +02:00
Duarte Santos 3a120df205 A security policy, and dependency updates that stay quiet
openGym ships passkeys, a signed session cookie and an admin dashboard, and
people run it on the open internet. Until now someone finding a hole had no
option but a public issue.

SECURITY.md documents the model as it actually is, verified against server.js
rather than described from memory: what the session cookie is and how long it
lasts, that it cannot be revoked individually, that ./data is unencrypted and
its holder can mint a session for any account, that there is no rate limiting,
and what changing RP_ID costs. A self-hoster deciding whether to run this for
other people deserves that list up front.

Dependabot is monthly and grouped one PR per ecosystem — a default setup on a
solo project produces noise that stops being read, which is the opposite of the
point. Android/iOS are left out on purpose: Capacitor pins those to the npm
packages, so bumping them separately breaks the mobile build.

Also: api/ has had two dependencies since notifications landed. CONTRIBUTING
still claimed one.
2026-07-31 19:12:18 +02:00
Duarte Santos 051a37abbf CI: actually run the tests, and hold the locales to one key set
There are 159 unit tests and nothing ran them. Both existing workflows fire on
push to main only, so the two outside pull requests merged so far were reviewed
by eye alone. This runs the suite, the build and a locale check on every pull
request.

The locale check exists because of a bug that shipped last week: a feature added
17 strings to de.js only, and the other ten languages fell back to English
mid-sentence with nothing failing anywhere. The checker compares every locale
against the union of all keys, so a string added to one file flags the other ten
instead of passing unnoticed.
2026-07-31 19:12:18 +02:00
Duarte Santos 8440cf3546 Changelog: the effort stats, under Unreleased
v1.2.3 is published, so this is the start of the next version rather than an
amendment to that one — it stays under Unreleased until there is a release to
fold it into.
2026-07-31 19:00:42 +02:00
Duarte Santos b0d176aba3 Merge branch 'effort-stats': the effort ratings, read back as statistics
Sets have carried an RIR/RPE rating since v1.2.3, but nothing ever read it
back — the number lived in the set label and nowhere else. This is the other
half: a trend per week, the spread across the scale, the share of sets taken
near failure, a hard-sets mode on the muscle map, and the rating riding along
on each exercise's own curve.
2026-07-31 18:49:41 +02:00
Duarte Santos 42ac8c8513 Send questions to Discussions, and put a Sponsor button on the repo
Discussions has been enabled since the start and empty since the start, so
every question arrives as an issue — the tracker is carrying design debates and
"how do I" alongside actual bugs, and the answers end up buried in closed
issues where the next person searching won't find them.

The "New issue" screen now offers Q&A, Ideas and Show-and-tell before the
templates, which is where that traffic gets intercepted; README and CONTRIBUTING
say the same thing in a table.

FUNDING.yml does nothing until the account is enrolled in GitHub Sponsors —
GitHub simply doesn't render the button. Stated plainly next to it: openGym is
AGPL, there is no paid tier and nothing is held back for sponsors. A project
that starts selling access to its maintainer stops being the thing people
starred.
2026-07-31 18:43:15 +02:00
Duarte Santos f232b5ba7e Effort stats: the other ten languages, and drop what nothing calls
The card shipped translated into German only, so every other UI language fell
back to the English source strings mid-sentence — the locale files have been
key-for-key identical until now, and they are again (607 each).

exerciseEffort() had no caller: Stats builds its per-exercise curve from the
points it already has, which are filtered by training mode, so the library
version would have drawn a different set of sessions. Removed with its tests
rather than left as a second answer to the same question.
2026-07-31 16:55:21 +02:00
Duarte Santos caaf61d91e Stats: read the effort back — trend, distribution, hard sets, per exercise
Rating a set only paid off inside the set label until now: Stats never looked at
rir/rpe at all. It reads them now, in four places.

lib/effort.js aggregates everything in RIR and converts back to whichever scale the
profile reads. A history that mixes the two — own logs in RIR, an imported file in
RPE — has to average as one series or every chart draws half the data, and RIR is the
internal unit because its zero is real where RPE's floor of 6 is a convention.

- an Effort card: average and share of sets taken near failure, the week-by-week curve
  with the week's volume in the tooltip, and where the sets land on the scale
- the muscle map gains a hard-sets mode: a muscle can lead on volume and still never
  be trained near failure
- Exercise progress carries effort on the top-set dots and as a curve of its own — the
  same weight with more left in the tank is progress a weight-only line draws flat
- LineChart learns an inverted axis (RIR counts down as it gets harder) and per-point marks

Every number carries how much of the training it speaks for: rating is optional and off
by default, so an unrated set is left out rather than read as failure, and an average
waits for five rated sets before it claims to be one.
2026-07-31 16:17:08 +02:00
Duarte Santos 4c829b6d1f Release v1.2.3: fold in the screen lock, the rest timer and the settings grouping
v1.2.3 was tagged but never published, so everything since v1.2.2 -- the last
published release -- belongs in this one version rather than a new number.

CHANGELOG gets the three new sections, README a feature bullet, SELF_HOSTING a note
that the Wake Lock API wants HTTPS (or localhost) like passkeys do and that iOS
refuses it in Low Power Mode. Website: the APK line said v1.2.2 while the download is
1.2.3, and the feature grid gained the screen-awake card.
v1.2.3
2026-07-31 15:35:36 +02:00
Duarte Santos c5e131f81c Rest timer: take 15 seconds off, not only add them
addRest now accepts a negative step, and taking off more than is left finishes the
rest instead of counting into the negative -- which also kept a negative duration out
of the progress bar and out of the server-side push schedule.

Three controls and the clock do not fit one line on a phone: at 360px the bar was
left with about 30px and stopped saying anything. The rest variant stacks -- clock and
bar on top, controls beneath, -15 and +15 together in number-line order, Skip pushed
to the far edge so the button that ends the rest is not next to the one you tap to buy
more time. Scoped to #timer.rest, so the work timer keeps its single row. Back to one
line at >=1000px, and the card is nearly opaque now -- the set rows underneath were
reading through it.
2026-07-31 15:35:27 +02:00
Duarte Santos 248da53dca Keep the screen awake while a workout is running
Locking and unlocking the phone between every set was the worst part of logging on
one. Settings -> During a workout -> Keep screen awake, on by default; the lock is
held only while S.active exists, so it follows the workout rather than the route and
lets go when you finish.

The browser drops the lock whenever the document stops being visible, which is what
happens the moment you glance at a message, so wakelock.js keeps its own 'wanted'
intent and re-acquires on every visibilitychange. It also releases a sentinel that
arrives after a release landed mid-request, and swallows the rejection iOS gives in
Low Power Mode. Where the API is missing the row shows disabled instead of offering
a switch that does nothing.

Settings is regrouped by what each thing affects while the row needed a home:
General (language, units), During a workout (rest timer, keep awake, sounds, effort),
Notifications, Appearance, Data. Nothing removed, no setting changed meaning.
2026-07-31 15:35:18 +02:00
Duarte Santos 42d3659615 Release v1.2.3: effort per set, and the RPE your old app already had
Everything published since v1.2.2 is one number: the RIR column from #21 and
the RIR/RPE scale choice built on top of it, plus the importer reading the
RPE that Hevy and Strong export.

Changelog, README, roadmap and the website all describe the feature as it
actually shipped — a rating that is optional, keeps its scale per set, and
is deliberately not an input to progression or the 1RM estimate.

Android versionCode 4: it has to increase strictly or the APK will not
install over the v1.2.2 build already out there.
2026-07-31 00:16:43 +02:00
Duarte Santos ca917f0320 Merge branch 'effort-metric': effort per set (RIR / RPE)
Adds an optional per-set effort rating on either of the two scales people
actually use, generalising the RIR column from #21 rather than bolting a
second one next to it, and teaches the importer to read the RPE that Hevy
and Strong already export.
2026-07-31 00:14:51 +02:00
Duarte Santos 54fb14be13 Import: bring the RPE other apps already recorded
Hevy and Strong both write an RPE next to every set and the importer was
dropping the column, so a history imported from either arrived flatter than
the file it came from. It is read now, along with an RIR column if a file
happens to have one.

A blank cell stays unrated rather than becoming 0, and a written-out 0 is
only a rating on the RIR scale — RIR 0 is a set taken to failure, while RPE
runs 1-10, so an app writing 0 there means "nothing here" and reading it as
an effort would stamp one on every unrated set in the file. Ratings above
the scale are capped rather than thrown away, junk is ignored, and effort
only rides along on weighted rep sets — a treadmill row has nowhere to show
it. A file carrying both columns is read as RIR, the precedence setLabel
already reads them back with.

The import summary reports how many sets brought a rating, and says where
to switch the column on when the profile is not logging effort yet —
otherwise the ratings arrive invisibly and look like they were lost.

Export needed no change: the backup is the whole state serialised, so both
fields and the setting travel with it. There is a test pinning that now,
along with 11 for the import paths.
2026-07-30 23:59:01 +02:00
Duarte Santos 6905117352 Effort stepper: count up from the bottom of the scale
The first + on an empty cell jumped straight to a "typical working set"
(RIR 2 / RPE 8), skipping 0 and 1 with no way to see why. A stepper that
lands somewhere other than where counting would take you is just puzzling,
so it now starts at the bottom of the scale and walks up in even steps like
every other stepper in the app: RIR from 0, RPE from 6 — the scale is only
meaningful for working sets and anything lighter is a warm-up nobody rates.

Stepping back off the floor clears the cell again, so a mistap is undoable
instead of sticking at 0 — which on the RIR scale claims the set went to
failure. − on a cell that was never filled in still leaves it empty.

The stepping moved out of the view into stepEffort/capEffort in history.js,
where it can be tested: 16 new cases covering the scale walk, the floor and
ceiling, the clear-on-undershoot, half-step rounding, junk settings values,
the showRir overlay every load path performs, and a session's worth of
logging end to end.

A typed value is still only capped, never floored — clamping up would turn
the "1" of "10" into the floor and fight the input.

The help sheet no longer claims the highlighted row is where + starts; it is
where working sets usually land. Reworded in all 11 language packs.
2026-07-30 23:52:57 +02:00
Duarte Santos 0c6c22c04b Effort help: show the two scales as one table, (i) before the control
The sheet explained RIR and RPE in three paragraphs, which is a bad way to
say "these are the same judgement counted from opposite ends" — you had to
hold both sentences in your head to see the correspondence. A conversion
table shows it in one look: RIR and RPE in fixed tabular columns you can
read straight down, the feel in words next to them, and the row a working
set usually lands on highlighted in the accent.

The table is built from the same parts as the app's grouped lists (surface
fill, inset hairlines) instead of a real <table>, so it inherits the card
look and wraps on a narrow phone.

The (i) moves ahead of the segmented control: you reach the explanation on
the way to the choice rather than past it.

The three paragraph strings are replaced by the table's strings in all 11
language packs.
2026-07-30 23:42:21 +02:00
Duarte Santos 4e27461b7e Effort per set: RIR or RPE, whichever scale you think in
The RIR column becomes a three-way setting (Off / RIR / RPE). Both scales
measure the same judgement from opposite ends — RPE 8 is RIR 2 — so they
share one column and one stepper, but keep their own field on the set.

A set is never silently rewritten into the other scale: switching the
setting changes what new sets ask for, and old sets still read back with
the scale they were logged with.

Profiles carrying the old showRir boolean keep their column (effortOf
falls back to it until the new setting is chosen), so a backup or another
device that still has the flag does not lose the column.

The steppers now know the scale: the first + lands on a typical working
set (RIR 2 / RPE 8) instead of the end of the scale, and typed values are
capped at 10 — there is no RPE 12.
2026-07-30 23:35:47 +02:00
Duarte Santos fa978a1bb4 Merge PR #21: optional RIR column on reps-mode sets
octaviodimarco's RIR (reps in reserve) stepper for reps-mode sets, opt-in under
Settings → Units & timer, plus a fixup for the leftover RIR-0 stamp and the
header alignment.
2026-07-30 19:53:21 +02:00
Duarte Santos c08381e558 RIR: an unlogged RIR stays unlogged, and the header lines up
A set that never had an RIR could still end up carrying one: NumberField mapped an
empty field to 0 and the − button clamped to 0, so one stray tap stamped '(RIR 0)' —
went to failure — on the set for good, in history and in backups, with no way back.
An optional field now clears to null (the key is dropped), and stepping down from
empty leaves it empty. A typed 0 still logs a real 0.

The row's three-stepper sizing also has to reach the header, or the labels sit up
to 5px off the columns they name.
2026-07-30 19:53:14 +02:00
Octavio Di Marco c5172d0633 i18n: add RIR strings to all 11 language packs
t('RIR') and the new Settings toggle label had no entries in
src/locales/ — RIR itself is kept as the acronym across languages
(same treatment as 1RM), only the surrounding label text is translated.
2026-07-30 19:20:00 +02:00
Octavio Di Marco c3929b0a70 Remove RIR auto-check; gate the column behind a setting
Two blockers from review:

- NumberField.commit() fires onChange on every keystroke, so typing
  a decimal RIR (e.g. 1.5) committed the auto-check after the first
  character, before the value was finished — and the same auto-check
  turned a stray tap on an empty field's "−" (or clearing it) into a
  permanent "RIR 0", since 0 is indistinguishable from unset once the
  key exists on the set. Logging RIR is back to a plain field with no
  side effect; the checkbox is the only way to mark a set done, same
  as weight and reps.

- The RIR stepper narrowed every reps-mode row's +/- buttons for
  everyone, including the majority not running an RIR-based program.
  It's now behind a `showRir` setting (Settings → Units & timer,
  default off), so the existing row is untouched unless opted in.
2026-07-30 19:20:00 +02:00
Octavio Di Marco eb582e3c7b Auto-check a set when its RIR is logged
Logging RIR is naturally the last thing you do for a set — by the
time you're rating how many reps you had left, you've already
finished it. Editing the RIR field (typing or the +/- stepper) now
checks the set off itself, same beep/vibrate/rest-timer as tapping
the checkbox by hand, so that's one less tap per set.

Weight and reps are unaffected — those are often set before the set
is performed (pre-filled targets), so editing them shouldn't imply
it's done. Guarded by !s.done so re-editing RIR on an already-done
set (e.g. a correction) doesn't re-fire the toggle side effects.
2026-07-28 22:45:28 +02:00
Octavio Di Marco 6714b16e6a Add optional RIR (reps in reserve) to reps-mode sets
Adds a third stepper column, next to weight and reps, for logging RIR
on strength sets — not shown for cardio or timed holds, where it has
no meaning. RIR is purely a logging/display addition: it never
touches the progression engine (linear/Greyskull/double progression
only ever read weight/reps/seconds), and it round-trips through the
existing whole-object backup export/import with no code changes there.

The set object only gains an `rir` key once the user actually logs a
value (buildSets/addSet don't pre-seed it), matching how missing
fields already read as undefined elsewhere in the store — no schema
version or migration needed for existing logged workouts.

Fitting a third stepper next to weight+reps on narrow phones needed
the same treatment as the exercise-config sheet's three-steppers-in-a-row
(.cfgrow): narrower buttons and a smaller value font just for rows
that show RIR, verified by hand at 360-390px with edge-case values
(2-3 digit weight, double-digit reps, decimal RIR together).

"Last time" summaries now append "(RIR n)" when a set has one logged,
covered by new setLabel tests including the rir: 0 case (0 is a valid
RIR and must not be treated as absent).
2026-07-28 17:10:03 +02:00
Pengboi 6aaf2a3eea Comments: trim to the established cadence
The MCP code came in with 5–8 line file headers, JSDoc on every
one-line wrapper, and inline explanations that referenced the PR
itself ("so the MCP server can reuse it") — none of which matches
api/server.js or frontend/src/lib/, where comments are one-line,
fact-shaped and never mention the change that introduced them.

Trimmed across mcp/src/*.js, i18n-core.js, i18n.js, exercises.js,
format.js, mcp/test/tools.test.js, mcp/vitest.config.js and
mcp/README.md. Tool prefaces lost their numbers; duplicate fs.watch
rationale folded into one; the ASCII import diagram in the README
replaced with a paragraph; the cross-references and self-references
removed. Also fixed two real defects: a corrupted Cyrillic word in a
state.js comment and a missing space in a tools.test.js comment.

No code changes; 92 frontend + 32 MCP tests still pass.
2026-07-26 19:47:52 +01:00
Pengboi 4143ab8676 Tests: Stryker mutation testing on the MCP handlers
Adds Stryker 9.6.1 as a devDep and a .stryker.conf.json scoped to the three MCP-only
modules (src/state.js, src/labels.js, src/tools.js). The reused pure lib in
frontend/src/lib/ is deliberately excluded — it has its own 92-test vitest suite, and
mutating it here would just re-test it under a different label.

Two non-obvious config choices, both learned the hard way:
 · inPlace: true. Stryker's default copies the project to a sandbox, but the MCP test
   file imports "../../frontend/src/lib/*.js" — a relative path that breaks the moment
   the source is moved. inPlace mutates files where they live, keeps a backup in
   .stryker-tmp/backup-*/ during the run, and restores on exit. Verified: after the
   run, `git diff` shows no changes and all 92+32 tests still pass.
 · vitest.related: false. The vitest runner's related-files mode uses static import
   analysis to pick which tests to run per mutant; it can't see the cross-directory
   imports and reported "no tests were found". Disabling it means every mutant runs
   the full suite — slower (~54s for 847 mutants) but accurate.

Baseline first run: 39.32% mutation score (333 killed, 330 survived, 184 no-coverage).
Most of the survivors are zod schema string literals (the unit suite bypasses the SDK's
validation by calling handlers directly), and the bulk of the no-coverage debt lives in
state.js — file watching, multi-user resolution and the mtime fallback paths. The HTML
report at mcp/reports/mutation/mutation.html (gitignored, regenerated per run) shows
each survived mutant inline.

Run with `npm run mutation:test` from mcp/.
2026-07-26 19:34:15 +01:00
Pengboi 92914dea43 MCP: read-only stdio server for LLM apps to query workout history
A Model Context Protocol bridge that lets an external LLM application (Claude Desktop,
Cursor, Cline, Continue, …) read a user's openGym profile directly from ./data — no new
container, no extra auth, no third-party service. The LLM client spawns the server
locally as a stdio process (per the official MCP model); reads the same state-<uid>.json
the api server writes; reuses the pure training helpers from frontend/src/lib/*.js so
the numbers it answers with match what the Stats screen shows exactly.

Eight tools in v1, all read-only:
 · list_routines, get_routine — names + exercise counts + per-exercise targets
 · get_week_plan — Mo/We/Fr assignments and today's routine, accounting for any
   date-specific overrides (a "rest" override cancels the day)
 · list_workouts, get_workout — newest-first session summaries + per-set breakdown
 · get_bodyweight — weigh-ins with the goal line and signed deltas vs goal
 · estimate_1rm — Epley/Brzycki/Lombardi formulas, all-time best + trend per exercise,
   or a PR table across all reps-mode exercises
 · muscle_balance — which muscles are trained vs neglected over a week/month/all window

State is read with fs.watch (mtime fallback for platforms where watchers are flaky) so
the server reflects a session the web UI just finished without a restart. No passkey
material, VAPID keys, or session secrets ever cross the boundary — handlers only ever
serialize fields from the state object plus the user's name from db.json.

The MCP server has exactly one runtime dependency beyond the SDK: none. zod is the SDK's
transitive; vitest and Stryker are devDeps only. Tests run against the demo seed fixture
(demoSeed.js) — 32 cases pinning the JSON shape and the most user-facing edge cases
(empty state, missing routine, rest-day override, zero-workout muscle_balance, three
1RM formulas, superset links, timed/cardio set labels).
2026-07-26 19:34:09 +01:00
Pengboi fadeb17b6c i18n: split the pure core out so the lib is Node-loadable
The pure training helpers (history, progression, onerm, muscles, format, exercises) are
deliberately self-contained — that is what lets them ship with their own vitest suites and
got them reused across the React and mobile builds. They were one Vite-only call away from
being loadable from plain Node too: `import.meta.glob` for the lazy locale packs, run at the
top of i18n.js. Anything that imported `t` or `dateLocale` via the chain (i.e. every helper
in src/lib) inherited the dependency.

Splitting the runtime-agnostic state, constants and readers (t, dateLocale, instrFor, getLang,
LANGS, INSTR_LANGS, DATE_LOCALES) into i18n-core.js lets plain Node require them. i18n.js
keeps the Vite-only bits (the async setLang that lazy-loads locale packs via import.meta.glob
and the React subscription hook useLang) and re-exports everything from core, so none of the
23 existing import sites change.

exercises.js had one direct `import.meta.env` access for IMG_BASE/GIF_BASE — guarded with
`?.` so the module resolves without Vite present. format.js and exercises.js import i18n-core
directly; everything else still imports i18n.js.

No public exports changed. 92/92 vitest tests pass; vite build still code-splits the locale
packs the same way.
2026-07-26 19:34:01 +01:00
Duarte Santos ab0c98ba85 Android: versionCode 3 for the v1.2.2 APK
Same versionName — v1.2.2 was never published, so this is still that release — but the code
has to increase strictly or Android refuses to install over the build already out there.
v1.2.2
2026-07-25 15:05:12 +02:00
Duarte Santos b15f7d9ec4 Release v1.2.2: docs, changelog and website for everything since v1.2.1
v1.2.2 was tagged but never published, so by the versioning rule everything since the last
published release — v1.2.1 — belongs in this one number: the mobile app, the importer, plan
sharing, the QA fix series, and now timed sets, progression rules and estimated 1RM.

The changelog was missing plan sharing and the fix series entirely; both are written up
here rather than left to the git log.
2026-07-25 15:00:43 +02:00
Duarte Santos 5c846b92d5 i18n: the new strings in all 11 language packs
49 keys per pack, 572 in total. The progression rules explain themselves in prose, so most
of these are full sentences rather than labels — a rule you cannot read is one you will
not trust, in any language.
2026-07-25 14:58:48 +02:00
Duarte Santos c248ca3bae The screens for timed sets, progression and estimated 1RM (#16 #17 #18)
Where the three features surface:

 · Routine editor — a progression rule for the whole routine, and per exercise a
   Reps/Time switch, an optional rule of its own and the step it moves in.
 · Workout — timed sets get a start button and the work-timer bar; every exercise says in
   one line why its target is what it is ("every rep last time — 2.5 kg more", "missed
   reps 3 sessions running — reset to 55 kg"). The weights are already right when the
   session opens rather than being suggested afterwards, which is what the old bump-hint
   button did.
 · Stats — the exercise curve switches between top set and estimated 1RM, and names the
   set the estimate came from. Timed exercises chart the longest hold.
 · Exercise detail — an estimated 1RM from your log plus a calculator for a set you have
   not done yet, so the number is reachable before there is any history.
 · Finish summary — a new best estimated 1RM is reported separately from a weight PR.
   Same weight for more reps is progress, but it is not a heavier lift.

Saving an exercise now replaces its config rather than merging into it, so switching back
from time to reps cannot leave a stale duration behind.
2026-07-25 14:58:42 +02:00
Duarte Santos 8e1d3b96a6 Automatic progression: named rules instead of one hard-coded hint (#17)
The old rule was a single line: all reps done, suggest 2.5 kg more. No rep ranges, no
AMRAP, no idea what to do after a bad session. This replaces it with a small set of
policies — linear, Greyskull LP, double progression, and adding time for timed work —
picked per routine and overridable per exercise.

Every function is pure and derives the next target from the log each time it is needed.
Nothing is written back into a finished workout and no counters are stored, so correcting
a mistyped set immediately produces the right next target.

Reading a session honestly is the whole point. Short reps count as a miss even when the
set was checked off; an unchecked set counts as a miss because it was not performed. A
session that fell apart can never advance the load as though it had succeeded.

Two cases the naive version gets badly wrong, both found against real data:

 · Workouts only started recording their prescription in this version. Judged against
   nothing, every past session scores as a miss — the demo history produced "missed reps
   11 sessions running, deload", and every existing user would have been greeted with the
   same on their first session after updating. Targetless history is judged against the
   exercise's current plan instead, which is what the old hint compared against.

 · Bodyweight work has no load to take off. "Reset your push-ups to 2.5 kg" is not advice,
   so with no external weight the rules progress in reps and leave the load alone.
2026-07-25 14:58:31 +02:00
Duarte Santos ec46c7e20d An exercise can be logged by time instead of reps (#16)
Until now the logging model came from the body part alone: cardio meant duration, and
everything else meant weight × reps. A plank, a hang, a wall sit or a loaded carry could
only be timed by filing it under cardio, which then put it in the wrong charts.

A routine entry can now say so itself — reps, time or cardio. Entries without a mode keep
behaving exactly as before, so every existing plan, workout and shared plan file is read
unchanged and nothing needs migrating.

Timed sets get a work timer that counts the set itself, kept deliberately separate from
the rest timer: the two mean opposite things and must never run together. Finishing early
logs the time actually held, not the target, because crediting a full 45 seconds for a
38-second hold would quietly corrupt the log it exists to keep.

Finished workouts now also store what the session prescribed. Without it, history cannot
say whether a session hit its reps, and a timed session reads back as "0 reps".
2026-07-25 14:58:20 +02:00
Duarte Santos a54bad2641 Estimated 1RM: the calculation, and only from sets that can support it (#18)
Working out how strong a set was meant leaving the app. Epley by default, with Brzycki
and Lombardi available and documented.

Two things it deliberately refuses to do:
 · guess above 12 reps, where the formulas disagree by double digits and the answer says
   more about work capacity than about maximal strength;
 · read `topW`, the working weight you confirm after an exercise — it carries no rep
   count, so it cannot produce an estimate at all.

It also knows nothing about the exercise database. An estimate needs a weight AND reps,
and only reps-mode sets carry both, so cardio and timed sets drop out of every scan on
their own rather than through a type check that would need keeping in sync.
2026-07-25 14:58:10 +02:00
Duarte Santos 0818f1b32b Tests: a runner for the pure helpers
The logic that decides what you lift next has no business being verified by hand in a
browser. Vitest is a dev dependency only — the app itself stays dependency-free.
2026-07-25 14:58:01 +02:00
Duarte Santos 62a0b00fbb i18n: the new strings in all 11 language packs
Twelve keys for the plan-import notice, the mixed-unit warning, the
singular counts, the weigh-in button and the error boundary, anchored
next to the strings they belong with. Drops 'Skip today' and
'{0} routines · {1} exercises', which the code no longer uses, and
retunes the German streak line ('13 Wochen in Folge').

All packs stay at the same key count.
2026-07-24 23:45:43 +02:00
Duarte Santos 827c0f8505 UI fixes found while testing the workout flow
· The rest timer floats above the tab bar, so it covered the set rows
  underneath it — during a rest, the next set was behind the bar. The page
  now gets enough bottom padding while a rest runs to scroll clear of it.
· "Skip today", sitting right under "Save & start workout", reads like
  skipping the session rather than the weigh-in. It says "Start without
  weighing in".
· The calendar legend drew "Planned" in blue while planned days have
  always had a grey dot.
· Body weight showed "− 0" when it hadn't moved since the last weigh-in.
· In a superset both exercises are on screen at once, so their animations
  give way: 180px meant scrolling a full screen between two exercises you
  are meant to alternate.
2026-07-24 23:45:36 +02:00
Duarte Santos 43d5495007 Import from other apps: convert weights per row, not per file
The unit was decided once for the whole file: if any row said lb and none
said kg it converted, otherwise it did nothing. FitNotes writes the unit
next to every set, so a history recorded partly in pounds and partly in
kilos hit the 'otherwise' branch — the file was taken over unconverted
and "185 lb" was logged as 185 kg, while the summary claimed the file
does not say which unit it uses.

Each row now carries its own unit through to the conversion (falling back
to the file's, then to the profile's), and a mixed file says so in the
preview.

Also: the "exercises matched" tile counted matched rows, so three
exercises across five sets read as five. It counts distinct exercises
now, which is what the label says.
2026-07-24 23:45:17 +02:00
Duarte Santos 3d5b00cecd A shared plan file can no longer take the app down
Importing a plan whose exercise ids this build doesn't know — a
hand-edited file, an export from a build with a different dataset — put
those ids straight into a routine. The routine editor skipped them
silently (you could neither see nor delete them), and starting the
routine reached for ex.n on undefined: white screen, no tab bar, no way
back. The running workout is persisted, so it came back on every reload.

Three layers, so this class of bug can't reach the screen again:

  · parsePlan() drops ids that resolve to neither the library nor a
    custom exercise carried in the same file, and the import sheet says
    how many were left out.
  · exOr() renders an unresolvable id as a placeholder, so the routine
    editor shows it (and lets you remove it) instead of hiding it, and
    the workout view survives one.
  · an ErrorBoundary around the routes: it keeps the tab bar alive,
    offers a reload, and can discard a running workout that can't be
    drawn. It is keyed on the route, so switching tabs clears it.

Turning the schedule switch on now really replaces Mon–Sun, as the
switch has always claimed. It only wrote the days the shared plan filled,
so days it left empty kept your own routine and you silently ended up
training a mix of two plans.

Also here, because they sit in the same lines: the tags that carry a unit
or a whole sentence opt out of the capitalise rule ("Best: 85 Kg", "Last
Time You Hit All Reps"), and the workout header's "best" now includes the
working weight you confirmed, so it agrees with the sheet that asked for
it.
2026-07-24 23:45:04 +02:00
Duarte Santos c8a68e37e1 Numbers follow the UI language, volume stays in your own unit
fmtNum was pinned to en-CH, so every user in every one of the twelve
languages got Swiss apostrophes: "7'535 kg". It now uses the same locale
as the dates.

fmtVol turned anything over 10 000 into tonnes regardless of the profile's
unit — "18.8t" is meaningless for a pound profile, and inside one history
list "18.8t" next to "7'535 kg" is two numbers you can't compare. Volume
is now always shown in the unit you train in.

The weight slider's ceiling of 300 was a kg number applied to both units;
in pounds it cut off at 136 kg, below plenty of people's body weight and
well below an everyday squat. It now follows the unit.

Also: a shared exCount() so "1 exercises" reads "1 exercise", and
durPart() so imported workouts (which carry no clock) stop claiming
"0 min".
2026-07-24 23:44:20 +02:00
Duarte Santos 238b435c2b i18n: translate plan-sharing strings into all 11 languages
24 new plan-share/PDF strings added to every locale pack (513 keys each),
anchored on each pack's existing terms (routine/exercise/import/week).
2026-07-24 01:22:09 +02:00
Duarte Santos af9289dcd9 Plan sharing: export/import a plan file + printable PDF
New "Share your plan" action in the Plan header (lib/plan-share.js):
- Export plan file: a small JSON with just your routines, the week schedule and any
  custom exercises they use — a friend imports it into their own openGym. Import
  merges (adds routines with fresh ids, dedupes customs by name+body part, optional
  "use this schedule"), so nothing they already have is overwritten.
- Print / Save as PDF: a clean, one-page-per-plan printout rendered in a hidden
  iframe; break-inside:avoid keeps every exercise (and each routine that fits) whole,
  so an exercise never splits across a page.
2026-07-24 01:12:07 +02:00
Duarte Santos 211fb86480 Icons: full-strength glyphs in the routine icon picker
The pickable routine icons were painted at --label-2 (60%), so the whole picker
looked faded when creating/editing a routine. Bring them to full --label; the
selected cell stays accent-on-accent.
2026-07-23 23:28:47 +02:00
Duarte Santos 6f557399b1 Icons: render at full strength everywhere, drop the muted-grey chrome
Follow-up to the opacity removal: the remaining faded icons were muted by colour,
not opacity. Bring list chevrons (.chev) and row icons (.lrow-c) from --label-3 up
to full --label, and lift the empty-state icon to its caption strength (--label-2).
Semantic colours (accent/orange/yellow/green) are left untouched.
2026-07-23 23:23:43 +02:00
Duarte Santos 17c2324f74 Icons: drop the opacity fade on tab-bar and tile icons
The .3/.32 opacity made those icons look washed-out/see-through. Remove it; the
active/inactive tab distinction still reads via colour (label vs accent) and the
heavier stroke on the active tab.
2026-07-23 23:12:49 +02:00
Duarte Santos 41f17934a9 Icons: redraw abs and pullup so strokes stop crossing through each other
The hollow line icons showed overlapping strokes through their transparency:
- abs drew full-width crease lines through a full-height centre line (a see-through #);
  now a six-pack whose centre seam runs the gap between crease pairs, no crossings.
- pullup's head circle sat on the arm-V apex; lifted it clear so the body no longer
  reads as tangled lines behind a transparent head.
2026-07-23 23:08:50 +02:00
Duarte Santos df91727dcf Website: milestones timeline builds itself from published GitHub releases
No more hand-maintained history on the about page — site.js renders one
timeline entry per published release (title, date, first paragraph of
the notes, link). Static entries remain only as an offline fallback.
2026-07-23 15:58:06 +02:00
Duarte Santos ae399cd1dd Website: fix screenshot aspect ratio, embed the live demo, GitHub button in hero
The screenshot img tags carry width/height attributes; with only a CSS
width the height attribute won (240x2532 — stretched). height:auto fixes
it. New #demo section runs the GitHub-Pages demo in a phone frame right
on the page; nav gets a Demo link and the hero a GitHub star button.
2026-07-23 15:54:25 +02:00
Duarte Santos becd2357ff Project website + one icon everywhere
website/ holds the source of opengym.duarte-santos.ch — landing with live
GitHub stats, docs and the story behind the app; no build step. The
native app icons are now generated (capacitor-assets) from the same
blocky dumbbell as the PWA icon, traced into resources/icon.svg, so the
APK, home-screen PWA, and website favicon all match.
2026-07-23 15:49:21 +02:00