Compare commits

..
33 Commits
Author SHA1 Message Date
Duarte Santos 3ce1a7c055 v1.2.13: hold the save on an empty progression step (!60 follow-up) 2026-08-30 13:17:35 +02:00
Duarte Santos aa42040f55 changelog: !60 also holds the save on an empty step 2026-08-30 13:17:04 +02:00
Duarte Santos 0410ea34be Merge merge request !60 (block empty progression step saves) 2026-08-30 13:16:00 +02:00
Duarte Santos f1c4c66729 v1.2.12: six community fixes for the active workout and exercise settings 2026-08-30 13:14:50 +02:00
Duarte Santos 0e74ad303c Workout: a rest countdown belongs to the exercise that started it; removing another exercise keeps it running 2026-08-30 13:13:45 +02:00
Duarte Santos 0c9e473b68 css: cap the list row's value instead of reserving space for it
!37 diagnosed this correctly — a long value did squeeze the title to nothing.
flex-basis:45% cures that but hands the value 45% of every row, including the
Sets/Rest/Reps rows where the value is two characters and the title is long.
max-width is the same intent at the right lever: measured, it matches !37 on
both long-value cases and keeps the full 328px title on short ones.
2026-08-30 13:13:45 +02:00
Duarte Santos 358d39590a Merge merge request !42 (workout flow after adding an exercise mid-session) 2026-08-30 13:13:01 +02:00
Duarte Santos ce4a30002a Merge merge request !60 (decimal progression steps below one) 2026-08-30 13:13:01 +02:00
Duarte Santos 3026d92cc4 Merge merge request !59 (stop timed-set countdowns when discarding a workout) 2026-08-30 13:13:01 +02:00
Duarte Santos ec258e1367 Merge merge request !58 (deleted custom exercises stay in recovery maps) 2026-08-30 13:13:01 +02:00
Duarte Santos 9006cccb50 Merge merge request !51 (stop the rest timer when removing the exercise it belongs to) 2026-08-30 13:13:01 +02:00
Duarte Santos 3d04dbb1e7 Merge merge request !37 (the routine row's value no longer squashes its title) 2026-08-30 13:13:01 +02:00
Manuel 0ab0f47259 fix: block empty progression step saves 2026-08-29 22:39:15 +00:00
Duarte Santos cb24bf12d7 Merge merge request !44 (a way out of the required weigh-in) 2026-08-29 16:52:07 +02:00
Duarte Santos 3a79a8dd5a css: the Today row's hover follows the file's own formatting
Same rules, house spacing, plus the note on why the guard is there.
2026-08-29 16:45:24 +02:00
Duarte Santos 491132a2b7 Merge merge request !57 (hover and pointer feedback on the Today row) 2026-08-29 16:44:40 +02:00
seals187 d0361b3fe0 home: give the Today row a pointer and a hover state on desktop
The row is a clickable div, so the desktop cursor never changed and nothing
answered the mouse. Both are behind @media (hover: hover) so a tap on a phone
does not leave the row stuck in a hover state. Closes #14.
2026-08-29 16:44:34 +02:00
Duarte Santos 9add360452 Merge merge request !61 (catch the import docs up to the column table) 2026-08-29 16:33:45 +02:00
andi242 19899d0fbd be more specific 2026-08-28 19:28:15 +02:00
andi242 5edfc1e78c update md 2026-08-28 19:26:46 +02:00
Manuel 9216aa2f02 test: assert cleared progression steps are omitted 2026-08-28 17:20:36 +00:00
Manuel dcfc7f15a7 fix: allow decimal progression steps below one 2026-08-28 17:17:02 +00:00
Space_Hermes e47a5418dc fix(workout): stop work timer on discard 2026-08-28 14:34:03 +02:00
Space_Hermes a97ae06c68 fix: use history snapshots in recovery maps 2026-08-28 14:32:56 +02:00
Space_Hermes 03a5bd22ff fix: stop rest timer when removing active exercise 2026-08-27 19:34:08 +02:00
Horus Gonzalez 0eb36abfdb Give the required weigh-in check-in a visible way out
BwSheet opens `locked` when required (starting a workout) — by design,
so a stray swipe doesn't skip your check-in. But locked also disables
backdrop tap, Escape, and (per Modals.jsx's onPop) the Android back
button/gesture, all silently and all identically on iOS and Android.
The only way out was two ghost buttons below the weight slider, easy
to miss since every other sheet in the app can be dismissed on reflex.

Adds a plain X in the header for the required case — close() only, no
onDone, no nav, so it's a true no-op: whatever screen was underneath
(usually Home, after an accidental tap on "Start") is exactly where
you land. The two existing buttons are untouched; they still cover
"start anyway, skip the weigh-in" and "actually I want a different
workout" as distinct, deliberate choices from a true cancel.

No new strings — reuses the existing 'Cancel' key already translated
in all locales.
2026-08-27 09:03:02 -06:00
Space_Hermes b7631dc9a0 fix(workout): skip rest before warmups 2026-08-27 11:52:02 +02:00
Space_Hermes 82f0b84766 fix(workout): continue after added exercise 2026-08-27 09:15:40 +02:00
Moksh 8165e41d8d Fix lrow value overflow 2026-08-26 19:21:16 +05:30
Duarte Santos 5314b342ff website: the feature cards just hold their text now
The dialog is gone. It showed the same paragraph that was already on the card,
only unclamped — so a click bought you nothing, which is a bad trade for making
fourteen cards look like something you have to interact with. The cards are
plain <article>s now and the text is simply on them, no line clamp.

What is left of the click: four cards point into the docs — importing,
self-hosting, the MCP server, backups — where there genuinely is more to read.
Those are ordinary links at the foot of their card rather than a click target
covering the whole box.

Cards are a little wider (250-310px) to carry the full text without turning into
columns of two words, and the rail still snaps and scrolls the same way.

Verified in the browser at 1440 and 390: fourteen cards, no dialog left in the
DOM, no buttons inside the rail, all four docs links present, nothing clipped
(every .fcard-b has scrollHeight == clientHeight), every card the same height,
still flush with the text above, no horizontal overflow, no JS errors.
2026-08-25 22:56:39 +02:00
Duarte Santos 1290db11b5 website: fix the dialog, align the rail, and add a first-visit intro
Tested in a real browser this time, at 1440, 1024, 390 and 360, with touch
emulation and with reduced motion — which is how the first three of these were
found, and none of them were visible from reading the markup.

**The dialog never opened where you could see it.** `* { margin: 0 }` at the top
of this file removes the margin:auto a browser uses to centre a modal <dialog>,
and without a position of its own it resolved to `position: absolute`, so
`inset: 0` centred it inside the document rather than the viewport — near the top
of the page. Opening a card scrolled the whole page up to meet it, showed a
clipped corner on desktop and nothing at all on a phone. It is pinned to the
viewport now, centred on both axes, capped at the screen height and scrollable
inside if the text is long. Measured: centred and fully in frame at all four
sizes, with no scroll jump.

**The rail sat 34px left of everything above it.** Its gutter was half the
leftover width, which lands on the wrap's outer edge, not on the text inside it —
the wrap's own padding was missing from the sum. Cards now line up exactly with
the paragraph above them (measured: 0px). Using 100% instead of 100vw also keeps
the scrollbar out of the arithmetic. The screenshot rail below inherits the same
fix.

**The intro.** The hero settles in on the first load of a visit: a short rise and
fade, staggered eyebrow to headline to lead to buttons to phone. Deliberately the
same movement as the scroll reveals further down, so it reads as one behaviour
rather than an effect. Armed in the inline head script, because site.js is
deferred and would have let the hero paint and then hide it again. Once per tab,
so a reload is not a splash screen. Off entirely for prefers-reduced-motion, and
the animation ends on opacity 1 regardless of whether the cleanup ever runs — the
hero cannot get stuck invisible.

No horizontal overflow at any of the four widths. Arrows confirmed present for a
mouse and absent for touch.
2026-08-25 22:50:28 +02:00
Duarte Santos 57ab683bf6 website: turn the long feature list into a rail, and un-squish the text pages
**"And the rest of it"** was fourteen items as a two-column definition list — the
part of the page nobody finishes reading. It is now a horizontal rail of cards,
one icon each, tapping one opens the full paragraph in a dialog. Four of them
carry a link into the docs, where there is genuinely more to say: importing,
self-hosting, the MCP server and backups. Twelve new icons in the existing
sprite style (24x24, stroke 1.7) to go with it.

The dialog only ever shows text that is already in the card, so nothing is
hidden from a reader without JS: the cards are unclamped and fully readable, the
arrows stay hidden, and there is nothing to open. Arrows are for pointers that
cannot swipe and are dropped on touch.

**The docs and about pages were squished on a phone**, and it was one character:
`.prose` set `padding: <top> 0 0`, and the trailing zeros overwrote the left and
right padding `.wrap` had already set. On a desktop nothing showed, because 720px
of text has room to spare either way; on a phone the text ran into both edges of
the screen. Both pages share that class, which is why both looked wrong.

Two traps in the CSS I added and then found: `.frail-nav` and `.fdlg-go` both set
`display`, which beats the UA's `[hidden] { display: none }`. The arrows would
have shown without JS, and a card with no link would have shown a "read more"
pointing at whatever the previous card linked to. Both now honour the attribute.

Cache busters go to v=6 — the markup needs the new CSS and JS, and a returning
visitor holding v=5 would have got the new page with the old stylesheet.
2026-08-25 22:39:04 +02:00
Duarte Santos 3c985babea website: APK size line matches the 1.2.11 build (4.4 MB, was 4.3) 2026-08-25 22:17:55 +02:00
23 changed files with 959 additions and 94 deletions

No files matched your search

+35
View File
@@ -1,5 +1,40 @@
# Changelog
## v1.2.12 — 2026-08-30
Six small fixes from the community, each read and tried on staging before it went in. All of
them are in the active workout or the exercise settings; nothing changes on the server, so a
self-hosted instance only needs the new web bundle.
### Active workout
- ➕ **Adding an exercise mid-session puts it right after the one you are on**, not at the end
of the list, and the flow carries on from there: "next" takes you to the next *unfinished*
exercise and the finish prompt only appears once nothing is left open. Before, a set added
late could leave you looking at a completion prompt with work still pending.
(Space-Hermes, !42)
- ⏱️ **Removing an exercise no longer leaves a timer behind.** A rest countdown that belonged to
the removed exercise stops with it — but a rest you are in the middle of for a *different*
exercise keeps running and simply follows that exercise. (Space-Hermes, !51, narrowed here)
- ⏹️ **Discarding a workout stops a running timed set.** The countdown used to keep going, and
beep, on a session that no longer existed. Cancelling the confirmation leaves it running.
(Space-Hermes, !59)
- 🗺️ **A custom exercise you delete still counts in recovery.** The muscle map and the recovery
view read the snapshot saved with each finished workout, so deleting the exercise afterwards
no longer blanks the muscles it trained. (Space-Hermes, !58)
### Exercise settings
- 🔢 **Progression steps below one can be typed.** Entering `0.5` used to snap back to the
default halfway through, because the field rejected the intermediate `0`. Leaving the field
empty or at `0` with a progression rule on now marks it red and holds the save, so a step that
cannot progress anything can no longer be stored by accident. (mflova, !60)
- 📐 **Long values in routine rows no longer squash the title.** The value column is capped
instead of reserving space, so a "3 × 12 @ 102.5 kg" row keeps its exercise name readable on a
narrow phone. (MokshManral, !37)
With thanks to Space-Hermes, mflova and MokshManral.
## v1.2.11 — 2026-08-25
A correction release. v1.2.10 landed planned warm-ups and notes, and reviewing that release
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "gym-api",
"version": "1.2.11",
"version": "1.2.13",
"private": true,
"type": "module",
"main": "server.js",
+9 -6
View File
@@ -24,15 +24,18 @@ To import your history from other applications, you'll need an export that is in
The app tries to match the exercise names to link them to the exercises in the database.
> Note: The history is a log of past exercises.
> Because plans change and history does not, it is completely disconnected from routines.
> Because plans change and history does not, it is completely disconnected from routines.
>
> Exercises depend on name matching, so custom exercises might be named differently, as they might be in other apps.
These apps have been tested to work without adjustments:
These apps have been tested to work without adjustments to the column names:
| App | How to export |
|---|---|
| **FitNotes (Android)** | Settings → Backup/Export → **Spreadsheet Export** |
| **FitNotes 2 (iOS)** | Export workouts as CSV; also manual/auto iCloud backups |
| **Strong** | Settings → Export Data |
| **Gravl** | Profile → Export Data |
| **Hevy** | Profile → Settings → Export & Import Data (Workouts or Measurements) |
You can also create your own `CSV` file:
@@ -51,9 +54,9 @@ These field names are supported:
|---|---|
| `exercise` | `exercise`, `exercise name`, `exercise title` |
| `date` | `date`, `workout date` |
| `startTime` | `start time` |
| `startTime` | `start time`, `start date` |
| `endTime` | `end time` |
| `workoutName` | `workout name`, `title` |
| `workoutName` | `workout name`, `title`, `workout` |
| `category` | `category`, `body part`, `muscle group` |
| `weightKg` | `weight kg` |
| `weightLb` | `weight lbs`, `weight lb` |
@@ -65,9 +68,9 @@ These field names are supported:
| `distanceKm` | `distance km` |
| `distance` | `distance` |
| `distanceUnit` | `distance unit` |
| `seconds` | `seconds`, `duration seconds` |
| `seconds` | `seconds`, `duration seconds`, `set duration sec` |
| `time` | `time`, `duration` |
| `setType` | `set type` |
| `note` | `comment`, `comments`, `notes`, `note` |
| `note` | `comment`, `comments`, `notes`, `note`, `workout notes` |
+2 -2
View File
@@ -7,8 +7,8 @@ android {
applicationId "ch.duartesantos.opengym"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 12
versionName "1.2.11"
versionCode 14
versionName "1.2.13"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "opengym-frontend",
"version": "1.2.11",
"version": "1.2.13",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "opengym-frontend",
"version": "1.2.11",
"version": "1.2.13",
"license": "AGPL-3.0-or-later",
"dependencies": {
"@capacitor/app": "^7.1.2",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "opengym-frontend",
"private": true,
"version": "1.2.11",
"version": "1.2.13",
"type": "module",
"scripts": {
"dev": "vite",
+2 -2
View File
@@ -115,13 +115,13 @@ export function Segmented({ options, value, onChange, className = '' }) {
/* ============================ stepper ============================ */
export function Stepper({ value, step = 1, onChange, decimal = true, className = '', label, unit }) {
export function Stepper({ value, step = 1, onChange, decimal = true, className = '', label, unit, invalid = false }) {
const set = v => onChange(Math.max(0, Math.round((v || 0) * 100) / 100))
const inner = (
<div className={'stp ' + className}>
<button onClick={() => set((+value || 0) - step)} aria-label="Decrease"><Icon name="minus" /></button>
<span className="val">
<NumberField value={value} decimal={decimal} onChange={onChange} />
<NumberField value={value} decimal={decimal} onChange={onChange} aria-invalid={invalid ? 'true' : undefined} />
{unit && <i>{unit}</i>}
</span>
<button onClick={() => set((+value || 0) + step)} aria-label="Increase"><Icon name="plus" /></button>
+15 -3
View File
@@ -235,8 +235,12 @@ h4.sec{
.lrow-s{font-size:13px;color:var(--label-2);line-height:1.3}
/* flex:none would let a long value ("Follow the routine (Linear progression)") run straight
through the title next to it, since the title's column is already free to shrink to nothing.
Letting the value shrink and ellipsise instead keeps the two out of each other's way. */
.lrow-v{color:var(--label-2);font-size:17px;letter-spacing:-.012em;flex:0 1 auto;min-width:0;
Letting the value shrink and ellipsise instead keeps the two out of each other's way.
The cap is max-width, not flex-basis: .lrow-m is flex:1, so its basis is 0 and it absorbs
none of the shrink — a long value would otherwise take the whole row and squeeze the title
to 21px. A basis of 45% fixes that but reserves the space even for "3", costing the title
141px on the rows that need it most. A cap does neither. */
.lrow-v{color:var(--label-2);font-size:17px;letter-spacing:-.012em;flex:0 1 auto;max-width:45%;min-width:0;
overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:right}
.lrow-c{color:var(--label);font-size:15px;flex:none;--icon-stroke:2.4}
.lrow-k{color:var(--acc);font-size:17px;flex:none;--icon-stroke:2.4}
@@ -526,6 +530,7 @@ h4.sec{
-moz-appearance:textfield;appearance:textfield;
}
.stp .num::-webkit-inner-spin-button{display:none}
.stp.invalid{box-shadow:inset 0 0 0 1px var(--red)}
/* --- slider --- */
.sld{position:relative;height:32px;display:flex;align-items:center;cursor:pointer;touch-action:none}
@@ -948,7 +953,7 @@ h4.sec{
.today-row{
display:flex;align-items:center;justify-content:space-between;gap:10px;
margin-top:12px;padding:12px 14px;border-radius:var(--r);background:var(--surface-2);
transition:background var(--fast);width:100%;text-align:left;
transition:background var(--fast);width:100%;text-align:left;cursor:pointer;
}
.today-row:active{background:var(--surface-3)}
.today-row .lbl2{font-size:11px;font-weight:500;letter-spacing:.03em;text-transform:uppercase;color:var(--label-3)}
@@ -957,6 +962,13 @@ h4.sec{
letter-spacing:-.012em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:2px;
}
/* Only where a pointer really hovers — on a phone :hover sticks to the row after the tap.
Lighter than :active, which goes all the way to --surface-3, so the two stay distinct. */
@media (hover:hover){
.today-row:hover{background:color-mix(in srgb,var(--surface-2),var(--surface-3) 60%)}
:root[data-theme="light"] .today-row:hover{background:color-mix(in srgb,var(--surface-2),var(--surface-3) 85%)}
}
/* --------------------------------------------------- desktop (≥1000px) --- */
.cols{display:block}
@media (min-width:1000px){
+11 -4
View File
@@ -61,6 +61,12 @@ function emptyMuscleMap(value) {
return Object.fromEntries(MUSCLES.map(slug => [slug, value]))
}
// Current catalogue metadata stays authoritative. Finished entries retain a nested muscle
// snapshot specifically so deleted custom exercises can still contribute to recovery maps.
function exerciseFor(entry) {
return EXIDX[entry?.id] || entry
}
// Epley one-rep-max estimate, matching onerm.js (REP_CAP included so high-rep sets do not
// inflate the estimate). Used only to express a set's intensity relative to the lifter's own
// capacity - the same formula the app already shows for estimated 1RM.
@@ -161,7 +167,7 @@ function loadKgFor(ex, entry, set, workout, opts = {}) {
function session1RMs(workout, opts = {}) {
const best = new Map()
for (const entry of workout?.entries || []) {
const ex = EXIDX[entry.id]
const ex = exerciseFor(entry)
for (const set of entry.sets || []) {
const load = loadKgFor(ex, entry, set, workout, opts)
if (set?.done !== true || !(load > 0) || !(set.r > 0)) continue
@@ -221,10 +227,11 @@ function sessionTonnages(workout, opts = {}) {
const sums = emptyMuscleMap(0)
const oneRms = session1RMs(workout, opts)
for (const entry of workout?.entries || []) {
const weights = musclesOf(EXIDX[entry.id])
const ex = exerciseFor(entry)
const weights = musclesOf(ex)
for (const set of entry.sets || []) {
if (set?.done !== true) continue
const measured = setTonnage(EXIDX[entry.id], entry, set, workout, oneRms.get(entry.id), opts)
const measured = setTonnage(ex, entry, set, workout, oneRms.get(entry.id), opts)
const tonnage = Number.isFinite(measured) && measured > 0 ? measured : ZERO_LOAD_SET_STIMULUS
for (const [slug, weight] of Object.entries(weights)) {
if (Object.prototype.hasOwnProperty.call(MUSCLES_BY_SLUG, slug)) sums[slug] += tonnage * weight
@@ -326,7 +333,7 @@ export function strengthOf(workouts, now, opts = {}) {
if (!Number.isFinite(timestamp)) continue
for (const entry of workout.entries || []) {
if (!(entry.sets || []).some(set => set?.done === true && !isWarmupRow(set))) continue
for (const slug of Object.keys(musclesOf(EXIDX[entry.id]))) {
for (const slug of Object.keys(musclesOf(exerciseFor(entry)))) {
if (Object.prototype.hasOwnProperty.call(MUSCLES_BY_SLUG, slug) && timestamp > latest[slug]) {
latest[slug] = timestamp
}
+37 -1
View File
@@ -17,7 +17,7 @@ import {
strengthOf,
} from './recovery.js'
import { EXDB, registerCustom } from './exercises.js'
import { MUSCLES, musclesOf } from './muscles.js'
import { MUSCLES, exerciseMuscleSnapshot, musclesOf } from './muscles.js'
import { fatigueStateOf } from './recovery-view.js'
const HOUR = 60 * 60 * 1000
@@ -128,6 +128,42 @@ describe('fatigueOf and strengthOf', () => {
expect(fatigueOf(highRep, NOW)[SINGLE_SLUG]).toBeGreaterThan(0.5)
})
it('uses a deleted exercise snapshot for the same bounded primary and secondary fatigue', () => {
const resolved = doneWorkoutAt(WEIGHTED.id, NOW)
const deleted = {
...resolved,
entries: [{
...resolved.entries[0],
id: 'deleted-weighted-exercise',
muscleSnapshot: exerciseMuscleSnapshot(WEIGHTED),
}],
}
expect(fatigueOf([deleted], NOW)).toEqual(fatigueOf([resolved], NOW))
expect(fatigueOf([deleted], NOW)[WEIGHTED_PRIMARY_SLUG]).toBeGreaterThan(0)
expect(fatigueOf([deleted], NOW)[SECONDARY_SLUG]).toBeGreaterThan(0)
})
it('uses a deleted exercise snapshot for strength without changing decay or floor semantics', () => {
const start = NOW - 15 * DAY
const resolved = doneWorkoutAt(WEIGHTED.id, start)
const deleted = {
...resolved,
entries: [{
...resolved.entries[0],
id: 'deleted-weighted-exercise',
muscleSnapshot: exerciseMuscleSnapshot(WEIGHTED),
}],
}
const untouchedSlug = MUSCLES.find(slug => !WEIGHTED_WEIGHTS[slug])
const strength = strengthOf([deleted], NOW)
expect(strength).toEqual(strengthOf([resolved], NOW))
expect(strength[WEIGHTED_PRIMARY_SLUG]).toBeCloseTo(0.5 ** (1 / 28), 10)
expect(strength[SECONDARY_SLUG]).toBeCloseTo(0.5 ** (1 / 28), 10)
expect(strength[untouchedSlug]).toBe(STRENGTH_FLOOR)
})
it('raises starting fatigue with volume, never pins, and fades without a cliff', () => {
const at0 = count => fatigueOf([doneWorkoutAt(SINGLE.id, NOW, count)], NOW)[SINGLE_SLUG]
expect(at0(1)).toBeCloseTo(1 - Math.exp(-V / FATIGUE_REF_VOLUME), 10)
+21
View File
@@ -2,6 +2,27 @@
// the stores makes the uneven-round and re-check rules explicit and directly testable.
const hasWork = (entries, idx) => !!entries[idx]?.sets?.some(set => !set.done)
// Return the first unfinished navigation unit after the current one, wrapping once so a user
// who completed units out of order is never offered workout completion while earlier work remains.
export function nextUnfinishedUnit(entries, units, fromIdx) {
if (!Array.isArray(entries) || !Array.isArray(units) || units.length === 0) return null
const current = units.findIndex(unit => unit.includes(fromIdx))
const ordered = current < 0
? units
: [...units.slice(current + 1), ...units.slice(0, current)]
return ordered.find(unit => unit.some(idx => hasWork(entries, idx))) || null
}
// The current exercise may be one member of a contiguous superset. Insert after that complete
// navigation unit; invalid/empty state safely falls back to the end of the entry list.
export function insertionIndexAfterCurrentUnit(units, currentIndex, entryCount) {
const length = Math.max(0, Number(entryCount) || 0)
if (!Array.isArray(units) || units.length === 0) return length
const unit = units.find(candidate => candidate.includes(currentIndex))
if (!unit?.length) return length
return Math.min(length, Math.max(...unit) + 1)
}
// A completion is new progress only when it takes this exercise beyond the largest number of
// simultaneously completed sets seen in this mounted session. Uncheck/re-check therefore does
// not repeat navigation or rest side effects, while completing an added set still can.
+21 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { setProgressHighWater, supersetFlowStep, restAfterSet, restOnRecheck } from './supersetFlow.js'
import { insertionIndexAfterCurrentUnit, nextUnfinishedUnit, setProgressHighWater, supersetFlowStep, restAfterSet, restOnRecheck } from './supersetFlow.js'
const entry = done => ({ sets: done.map(value => ({ done: value })) })
@@ -52,6 +52,26 @@ describe('supersetFlowStep', () => {
})
})
describe('active workout unit ordering', () => {
it('inserts after the whole current unit', () => {
expect(insertionIndexAfterCurrentUnit([[0, 1], [2]], 0, 3)).toBe(2)
expect(insertionIndexAfterCurrentUnit([[0], [1]], 1, 2)).toBe(2)
expect(insertionIndexAfterCurrentUnit([], 0, 0)).toBe(0)
})
it('finds the next unfinished unit, skips completed units, and wraps once', () => {
const entries = [entry([false]), entry([true]), entry([false]), entry([true])]
const units = [[0], [1], [2, 3]]
expect(nextUnfinishedUnit(entries, units, 0)).toEqual([2, 3])
expect(nextUnfinishedUnit(entries, units, 2)).toEqual([0])
})
it('returns null only when every unit is complete', () => {
const entries = [entry([true]), entry([true])]
expect(nextUnfinishedUnit(entries, [[0], [1]], 1)).toBeNull()
})
})
// Issue #3 has two halves. restAfterSet covers "no break after the LAST set of an exercise";
// this covers "after the first set, sometimes a break doesn't appear" — the uncheck/re-check
// that the high-water rule swallows.
+34 -9
View File
@@ -23,6 +23,7 @@ import { nextPrescription, applyPrescription, policyFor, defaultIncrement, POLIC
import { MOBILE, shareExport } from './lib/mobile.js'
import { buildCompletedWorkout } from './lib/finish-workout.js'
import { isWarmupRow } from './lib/workout-model.js'
import { nextUnfinishedUnit } from './lib/supersetFlow.js'
const S = () => useStore.getState().S
const update = (...a) => useStore.getState().update(...a)
@@ -107,7 +108,18 @@ function BwSheet({ required, onDone, close }) {
const recent = [...st.bodyweight].reverse().slice(0, 3)
const delEntry = d => update(s => { s.bodyweight = s.bodyweight.filter(b => b.d !== d) })
return <>
<h3>{required ? t('Quick check-in') : t('Log body weight')}</h3>
{/* This sheet opens `locked` — swipe/backdrop/Escape/Android-back all no-op on it (see
Modals.jsx) so an accidental tap on "Start" can't be walked back by reflex the way
every other sheet in the app can. The two buttons below already cover leaving it
deliberately; this is the same close a normal sheet gets everywhere else, just
opted back in explicitly instead of by omission. Plain close() — no onDone, no
nav — so it's a true no-op: the screen underneath is exactly where you left it. */}
{required
? <div className="row between" style={{ marginBottom: 14 }}>
<h3 style={{ marginBottom: 0 }}>{t('Quick check-in')}</h3>
<button className="iconbtn" aria-label={t('Cancel')} onClick={() => close()}><Icon name="xmark" /></button>
</div>
: <h3>{t('Log body weight')}</h3>}
<div className="muted small">{required ? t('Slide or tap to set your weight — tracked before every workout so your curve stays honest.') : t('Today') + ', ' + fmtDate(todayISO(), true)}</div>
<WeightInput value={v} setValue={setV} unit={unit} />
<div style={{ height: 14 }} />
@@ -547,12 +559,18 @@ export const equipmentProfileSheet = profile => ui().openSheet(close => <Equipme
// Progression settings for one exercise (issue #17). Shown inside the config sheet because
// "how does this lift go up" belongs next to sets and reps, not in a separate screen. Left
// on "follow the routine" it inherits, so most people never touch it.
const progressionStepOf = (c, mode, ex, unit) =>
c.inc >= 0 ? c.inc : (mode === 'time' ? 5 : defaultIncrement(ex.id, unit))
const progressionStepIsValid = (step, policy) =>
policy === 'off' || (Number.isFinite(step) && step > 0)
function ProgressionFields({ ex, mode, c, setC, routine, unit }) {
const options = POLICIES_FOR[mode] || ['off']
if (options.length < 2) return null
const inherited = policyFor({ id: ex.id }, routine, mode)
const active = policyFor({ ...c, id: ex.id }, routine, mode)
const inc = c.inc > 0 ? c.inc : (mode === 'time' ? 5 : defaultIncrement(ex.id, unit))
const inc = progressionStepOf(c, mode, ex, unit)
const invalid = !progressionStepIsValid(inc, active)
return <>
<h4 className="sec">{t('Progression')}</h4>
<div className="sect-b" style={{ marginBottom: 8 }}>
@@ -563,10 +581,14 @@ function ProgressionFields({ ex, mode, c, setC, routine, unit }) {
<div className="small dim" style={{ marginBottom: active === 'off' ? 18 : 10 }}>{t(POLICY_DESC[active])}</div>
{active !== 'off' && <div className="row cfgrow" style={{ marginBottom: 18 }}>
<Stepper label={mode === 'time' ? t('Step (seconds)') : t('Step ({0})', unit)} value={inc}
step={mode === 'time' ? 5 : 1.25} decimal={mode !== 'time'} onChange={v => setC(x => ({ ...x, inc: v }))} />
step={mode === 'time' ? 5 : 1.25} decimal={mode !== 'time'} invalid={invalid} className={invalid ? 'invalid' : ''}
onChange={v => setC(x => ({ ...x, inc: v }))} />
{active === 'double' && <Stepper label={t('Reps from')} value={c.repsMin || Math.max(1, (c.reps || 10) - 2)}
step={1} decimal={false} onChange={v => setC(x => ({ ...x, repsMin: v }))} />}
</div>}
{invalid && <div className="small" role="alert" style={{ color: 'var(--red)', marginTop: -10, marginBottom: 18 }}>
{t('Enter a positive step to use this progression rule.')}
</div>}
</>
}
@@ -580,9 +602,12 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {
// Both default from the dataset and are then whatever the config says — see isBw.
const bw = !cardio && isBw({ ...c, id: ex.id })
const perSide = isPerSide(c)
const progressionPolicy = policyFor({ ...c, id: ex.id }, routine, mode)
const progressionStepInvalid = !progressionStepIsValid(progressionStepOf(c, mode, ex, st.unit), progressionPolicy)
// Keep whatever the other mode already had (sets, weight) and fill only what is missing.
const setMode = m => setC(x => ({ ...defaultConfig(ex.id, m), ...x, mode: m }))
const save = () => {
if (progressionStepInvalid) return
close()
const sets = Math.max(1, Math.round(c.sets) || (cardio ? 1 : 3))
// Only carry progression settings that differ from the inherited default, so a plan file
@@ -756,7 +781,7 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {
<textarea className="input" rows={3} maxLength={500} style={{ marginBottom: 18 }}
placeholder={t('Note (optional) — loading cues, "bar only then +1 plate/side each set", anything worth remembering here')}
value={c.note || ''} onChange={e => setC(x => ({ ...x, note: e.target.value }))} />
<Button variant="primary" onClick={save}>{existing ? t('Save') : t('Add to routine')}</Button>
<Button variant="primary" disabled={progressionStepInvalid} onClick={save}>{existing ? t('Save') : t('Add to routine')}</Button>
{ex.custom && <><div style={{ height: 8 }} /><Button icon="pencil" onClick={() => { close(); customExSheet(ex) }}>{t('Edit or delete this exercise')}</Button></>}
{onDelete && <><div style={{ height: 8 }} /><Button variant="danger" onClick={() => { close(); onDelete() }}>{t('Remove from routine')}</Button></>}
</>
@@ -1058,8 +1083,8 @@ function TopWeight({ entryIdx, close }) {
const units = supersetUnits(A ? A.entries : [])
const unit = entry ? unitOf(units, entryIdx) : []
const unitDone = !!entry && unit.every(i => A.entries[i].sets.every(s => s.done))
const unitIdx = units.findIndex(u => u === unit)
const isLastUnit = unitIdx === units.length - 1
const nextUnit = unitDone ? nextUnfinishedUnit(A.entries, units, entryIdx) : null
const workoutDone = unitDone && !nextUnit
if (!entry || !ex) return null
const commit = advance => {
@@ -1072,8 +1097,8 @@ function TopWeight({ entryIdx, close }) {
})
close()
if (advance && unitDone) {
if (isLastUnit) workoutCompleteSheet() // whole workout done → finish/continue prompt
else update(s => { s.active.cur = units[unitIdx + 1][0] })
if (workoutDone) workoutCompleteSheet() // no unfinished unit → finish/continue prompt
else update(s => { s.active.cur = nextUnit[0] })
} else toast(t('Tracked — next time starts at {0}', fmtNum(S().exWeights[entry.id].w) + ' ' + st.unit))
}
return <>
@@ -1083,7 +1108,7 @@ function TopWeight({ entryIdx, close }) {
<div style={{ height: 10 }} />
{prevBest > 0 ? <div className="small dim" style={{ textAlign: 'center', marginBottom: 12 }}>{t('Previous best:')} {fmtNum(prevBest)} {st.unit}{maxSet > prevBest && <span style={{ color: 'var(--yellow)' }}> — {t('new record!')}</span>}</div> : <div style={{ height: 4 }} />}
{unitDone ? <>
<Button variant="primary" trailingIcon={isLastUnit ? null : 'chevronRight'} onClick={() => commit(true)}>{isLastUnit ? t('Save') : t('Save & next exercise')}</Button>
<Button variant="primary" trailingIcon={workoutDone ? null : 'chevronRight'} onClick={() => commit(true)}>{workoutDone ? t('Save') : t('Save & next exercise')}</Button>
<div style={{ height: 8 }} /><Button variant="ghost" className="dim" onClick={() => commit(false)}>{t('Just close')}</Button>
</> : <Button variant="primary" onClick={() => commit(false)}>{t('Save weight')}</Button>}
</>
+81
View File
@@ -0,0 +1,81 @@
// @vitest-environment happy-dom
import React, { act } from 'react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { createRoot } from 'react-dom/client'
import { EXDB } from './lib/exercises.js'
import { useStore } from './store/useStore.js'
import { useUI } from './store/useUI.js'
import { exConfigSheet } from './sheets.jsx'
const ex = EXDB.find(e => e.id === '0009')
const mounted = []
function type(el, value) {
Object.getOwnPropertyDescriptor(el.constructor.prototype, 'value').set.call(el, value)
el.dispatchEvent(new Event('input', { bubbles: true }))
}
function renderConfig(onSave = vi.fn()) {
exConfigSheet(ex, { sets: 3, reps: 10, weight: 0, mode: 'reps', prog: 'double' }, onSave)
const sheet = useUI.getState().sheets.at(-1)
const host = document.createElement('div')
document.body.appendChild(host)
const root = createRoot(host)
mounted.push(root)
act(() => root.render(sheet.render(() => useUI.getState().closeSheet(sheet.id))))
const stepper = [...host.querySelectorAll('.stp-w')]
.find(el => el.querySelector('.stp-l')?.textContent.startsWith('Step'))
return { host, step: stepper.querySelector('input'), onSave }
}
describe('exercise configuration progression step', () => {
beforeEach(() => {
globalThis.IS_REACT_ACT_ENVIRONMENT = true
useUI.setState({ sheets: [] })
useStore.setState(s => ({ S: { ...s.S, unit: 'kg' } }))
document.body.innerHTML = ''
})
afterEach(() => {
act(() => { mounted.splice(0).forEach(root => root.unmount()) })
})
it('keeps the draft empty while clearing the default so a sub-one comma decimal can be entered', () => {
const { step } = renderConfig()
expect(step.value).toBe('2.5')
act(() => { type(step, '') })
expect(step.value).toBe('')
act(() => { type(step, '0,5') })
expect(step.value).toBe('0.5')
})
it('blocks saving without a positive progression step but accepts a positive decimal', () => {
const config = renderConfig()
const save = [...config.host.querySelectorAll('button')]
.find(b => /^(save|add to routine)$/i.test(b.textContent.trim()))
act(() => { type(config.step, '') })
expect(config.step.value).toBe('')
expect(config.step.getAttribute('aria-invalid')).toBe('true')
expect(save.disabled).toBe(true)
expect(config.host.textContent).toContain('Enter a positive step to use this progression rule.')
act(() => { save.click() })
expect(config.onSave).not.toHaveBeenCalled()
expect(useUI.getState().sheets).toHaveLength(1)
act(() => { type(config.step, '0') })
expect(save.disabled).toBe(true)
act(() => { type(config.step, '0,5') })
expect(config.step.value).toBe('0.5')
expect(config.step.getAttribute('aria-invalid')).not.toBe('true')
expect(save.disabled).toBe(false)
act(() => { save.click() })
expect(config.onSave).toHaveBeenCalledWith(expect.objectContaining({ inc: 0.5 }))
expect(useUI.getState().sheets).toHaveLength(0)
})
})
+11 -3
View File
@@ -56,7 +56,8 @@ let workDone = null
export const useUI = create((set, get) => ({
sheets: [], // { id, render:(close)=>JSX, kind:'sheet'|'center', locked }
toastMsg: '',
timer: null, // rest countdown between sets — { left, total, endsAt }
timer: null, // rest countdown between sets — { left, total, endsAt, forIdx }
// forIdx: index of the active entry whose set started the rest (undefined when unknown)
work: null, // work countdown DURING a timed set (issue #16) — { left, total, endsAt, label }
openSheet(render, { kind = 'sheet', locked = false } = {}) {
@@ -74,13 +75,13 @@ export const useUI = create((set, get) => ({
toastTm = setTimeout(() => set({ toastMsg: '' }), 2200)
},
startRest(sec) {
startRest(sec, forIdx) {
get().stopRest()
// Rest timer set to Off. Stopping and returning rather than starting a zero-length timer
// keeps every caller honest: the four places that start a rest do not each need to know.
if (!(sec > 0)) return
const endsAt = Date.now() + sec * 1000
set({ timer: { left: sec, total: sec, endsAt } })
set({ timer: { left: sec, total: sec, endsAt, forIdx } })
requestRestNotificationPermission()
pushRestTimer(sec)
timerTick = () => {
@@ -109,6 +110,13 @@ export const useUI = create((set, get) => ({
set({ timer: { ...tm, left, total: tm.total + sec, endsAt: tm.endsAt + sec * 1000 } })
pushRestTimer(left)
},
// The active list changed shape (an exercise removed or inserted at `at`): keep the rest
// pointing at the same exercise. Returns nothing; the caller decides whether to stop instead.
shiftRestOwner(at, delta) {
const tm = get().timer
if (!tm || !(tm.forIdx >= at)) return
set({ timer: { ...tm, forIdx: tm.forIdx + delta } })
},
stopRest() {
if (timerInt) clearInterval(timerInt); timerInt = null
if (timerTick) document.removeEventListener('visibilitychange', timerTick); timerTick = null
+29 -18
View File
@@ -8,7 +8,7 @@ import { fmtNum, fmtDate, todayISO, exCount, DAYN } from '../lib/format.js'
import { beep, vibrate } from '../lib/sound.js'
import { t, exerciseNameFor } from '../lib/i18n.js'
import { api } from '../lib/api.js'
import { setProgressHighWater, supersetFlowStep, restAfterSet, restOnRecheck } from '../lib/supersetFlow.js'
import { insertionIndexAfterCurrentUnit, nextUnfinishedUnit, setProgressHighWater, supersetFlowStep, restAfterSet, restOnRecheck } from '../lib/supersetFlow.js'
import Media from '../components/Media.jsx'
import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, topWeightSheet, finishWorkout, workoutCompleteSheet, confirmSheet, exerciseNoteSheet, sessionNoteSheet } from '../sheets.jsx'
import Icon from '../components/Icon.jsx'
@@ -261,6 +261,13 @@ 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()
// A rest countdown belongs to the exercise whose set started it (timer.forIdx). Removing that
// exercise ends the rest — there is nothing left to rest for. Removing any other exercise
// keeps the countdown and only re-points it, so a pause you are in the middle of survives
// tidying up the list.
const rest = useUI.getState().timer
if (rest && rest.forIdx === idx) useUI.getState().stopRest()
else useUI.getState().shiftRestOwner(idx + 1, -1)
useStore.getState().update(s => {
if (!s.active || !Array.isArray(s.active.entries)) return
if (idx < 0 || idx >= s.active.entries.length) return
@@ -275,7 +282,7 @@ function ActiveWorkout() {
const nav = useNavigate()
const S = useStore(s => s.S)
const update = useStore(s => s.update)
const { startRest, stopRest, work } = useUI()
const { startRest, stopRest, stopWork, work } = useUI()
const A = S.active
const units = supersetUnits(A.entries)
const cur = Math.min(A.cur, Math.max(0, A.entries.length - 1))
@@ -382,7 +389,6 @@ function ActiveWorkout() {
const toggle = (idx, i) => {
const m = modeAt(idx)
const cardioEntry = m === 'cardio'
const isLastUnit = unitIdx >= units.length - 1
let askTop = false, exJustDone = false, workoutDone = false, checked = false
mutEntry(idx, e => {
e.sets[i].done = !e.sets[i].done
@@ -390,7 +396,7 @@ function ActiveWorkout() {
if (e.sets[i].done) {
beep(S.sound, 1040, 0.12); vibrate(30)
const unitDone = unit.every(ui => (ui === idx ? e : A.entries[ui]).sets.every(x => x.done))
if (unitDone && isLastUnit) workoutDone = true // last exercise's last set → done
if (unitDone) workoutDone = !nextUnfinishedUnit(A.entries, supersetUnits(A.entries), idx)
// 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
// (issue #32: the fewest taps that still record what happened).
@@ -414,38 +420,41 @@ function ActiveWorkout() {
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))
const nextUnit = freshUnitDone ? nextUnfinishedUnit(fresh.entries, freshUnits, idx) : null
const freshWorkoutDone = freshUnitDone && !nextUnit
const restBeforeWarmup = nextUnit?.some(ui =>
fresh.entries[ui].sets.some(set => isWarmupRow(set) && !set.done),
)
// A re-check of finished work must not navigate or reopen a sheet, but it may still owe
// you a rest — see restOnRecheck, and the other half of issue #3.
if (!progress.isNew) {
if (restOnRecheck({ timerRunning: !!useUI.getState().timer, unitDone: freshUnitDone, lastUnit: freshLastUnit })) startRest(S.restSec)
if (!restBeforeWarmup && restOnRecheck({ timerRunning: !!useUI.getState().timer, unitDone: freshUnitDone, lastUnit: freshWorkoutDone })) startRest(S.restSec, idx)
return
}
// Singleton units are ordinary exercises: they rest between sets and after the closing
// one, and never enter superset navigation. stopRest() first so the rest that belongs
// after this set replaces the one that was running, rather than stacking on it.
// one unless the next unit has an unfinished warm-up, and never enter superset navigation.
// stopRest() first so a rest that belongs after this set replaces the one that was running.
if (freshUnitDone) stopRest()
if (!freshUnit || freshUnit.length <= 1) {
if (restAfterSet({ unitDone: freshUnitDone, lastUnit: freshLastUnit })) startRest(S.restSec)
if (freshUnitDone && !askTop && nextUnit?.length) update(s => { if (s.active) s.active.cur = nextUnit[0] })
if (!restBeforeWarmup && restAfterSet({ unitDone: freshUnitDone, lastUnit: freshWorkoutDone })) startRest(S.restSec, idx)
return
}
const step = supersetFlowStep(fresh.entries, freshUnit, idx)
if (!step) return
if (step.unitDone) {
if (!freshLastUnit) {
const nextUnit = freshUnits[freshUnitIdx + 1]
if (nextUnit?.length) {
// 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)
if (!askTop) update(s => { if (s.active) s.active.cur = nextUnit[0] })
if (!restBeforeWarmup) startRest(S.restSec, idx)
}
} else {
if (step.nextIdx != null) update(s => { if (s.active) s.active.cur = step.nextIdx })
if (step.roundDone) startRest(S.restSec)
if (step.roundDone) startRest(S.restSec, idx)
}
}
}
@@ -479,7 +488,7 @@ function ActiveWorkout() {
return <div className="narrow">
<div className="hdr">
<button className="iconbtn" aria-label={t('Discard')} onClick={() => confirmSheet({ title: t('Discard workout?'), message: t('The sets you logged in this session will be lost.'), confirmText: t('Discard'), danger: true, onConfirm: () => { update(s => { s.active = null }); stopRest(); nav('/home') } })}><Icon name="xmark" /></button>
<button className="iconbtn" aria-label={t('Discard')} onClick={() => confirmSheet({ title: t('Discard workout?'), message: t('The sets you logged in this session will be lost.'), confirmText: t('Discard'), danger: true, onConfirm: () => { update(s => { s.active = null }); stopRest(); stopWork(); nav('/home') } })}><Icon name="xmark" /></button>
<div style={{ textAlign: 'center' }}><div style={{ fontWeight: 600 }}>{A.name}</div><div className="sub"><Elapsed start={A.start} /> · {t('{0} sets', done + '/' + total)}</div></div>
<button className="iconbtn" style={{ color: 'var(--acc)' }} aria-label={t('Finish')} onClick={finishWorkout}><Icon name="check" /></button>
</div>
@@ -521,8 +530,10 @@ function ActiveWorkout() {
const plan = freestyle ? null : nextPrescription(s, full, s.routines.find(r => r.id === s.active.routineId))
const sets = buildSets(s, full, { step: defaultIncrement(ex.id, s.unit), ...(freestyle ? { preferLast: true } : {}) })
const progressed = freestyle ? sets : applyPrescription(sets, plan, defaultIncrement(ex.id, s.unit))
s.active.entries.push({ id: ex.id, target: { ...cfg }, plan, sets: applyIntensifierPlan(progressed, full) })
s.active.cur = s.active.entries.length - 1
const insertAt = insertionIndexAfterCurrentUnit(supersetUnits(s.active.entries), s.active.cur, s.active.entries.length)
s.active.entries.splice(insertAt, 0, { id: ex.id, target: { ...cfg }, plan, sets: applyIntensifierPlan(progressed, full) })
s.active.cur = insertAt
useUI.getState().shiftRestOwner(insertAt, 1)
}), null, routine, seed)
})} icon="plus">{t('Add exercise')}</Button>
{A.entries.length > 0 && <>
+116
View File
@@ -21,6 +21,8 @@ const entry = (id, sg) => ({
let root
let container
let sheetRoot
let sheetContainer
function setActive(entries, cur = 0) {
const S = clone(DEF)
@@ -43,6 +45,18 @@ function removeButton() {
return [...container.querySelectorAll('button')].find(button => button.textContent.includes('Remove exercise'))
}
function renderTopSheet() {
if (sheetRoot) act(() => sheetRoot.unmount())
if (sheetContainer) sheetContainer.remove()
const sheet = useUI.getState().sheets.at(-1)
expect(sheet).toBeTruthy()
sheetContainer = document.createElement('div')
document.body.appendChild(sheetContainer)
sheetRoot = createRoot(sheetContainer)
act(() => sheetRoot.render(sheet.render(() => useUI.getState().closeSheet(sheet.id))))
return sheetContainer
}
beforeEach(() => {
vi.useFakeTimers()
localStorage.clear()
@@ -52,9 +66,13 @@ beforeEach(() => {
useStore.setState({ S: clone(DEF), user: null })
root = null
container = null
sheetRoot = null
sheetContainer = null
})
afterEach(() => {
if (sheetRoot) act(() => sheetRoot.unmount())
if (sheetContainer) sheetContainer.remove()
if (root) act(() => root.unmount())
if (container) container.remove()
useUI.getState().stopRest()
@@ -94,6 +112,82 @@ describe('active-session exercise removal', () => {
expect(active.entries[0].sets[0].sec).toBeUndefined()
})
it('cancels a running rest countdown when the exercise it belongs to is removed', () => {
setActive([entry('1001'), entry('1002')], 0)
useUI.getState().startRest(90, 0)
expect(useUI.getState().timer).not.toBeNull()
act(() => { removeActiveExercise(0) })
expect(useUI.getState().timer).toBeNull()
expect(useStore.getState().S.active.entries.map(e => e.id)).toEqual(['1002'])
})
it('keeps a rest countdown that belongs to another exercise, re-pointed at it', () => {
setActive([entry('1001'), entry('1002'), entry('1003')], 1)
useUI.getState().startRest(90, 1)
act(() => { removeActiveExercise(0) })
expect(useUI.getState().timer?.forIdx).toBe(0)
expect(useStore.getState().S.active.entries.map(e => e.id)).toEqual(['1002', '1003'])
act(() => { removeActiveExercise(1) })
expect(useUI.getState().timer?.forIdx).toBe(0)
expect(useStore.getState().S.active.entries.map(e => e.id)).toEqual(['1002'])
act(() => { removeActiveExercise(0) })
expect(useUI.getState().timer).toBeNull()
})
it('leaves a rest countdown without a known owner running', () => {
setActive([entry('1001'), entry('1002')], 0)
useUI.getState().startRest(90)
act(() => { removeActiveExercise(0) })
expect(useUI.getState().timer).not.toBeNull()
})
it('does not mutate before confirmation, leaves state unchanged on Cancel, and removes on Confirm', () => {
renderWorkout([entry('1001'), entry('1002')])
act(() => removeButton().click())
expect(useStore.getState().S.active.entries.map(e => e.id)).toEqual(['1001', '1002'])
let dialog = renderTopSheet()
const cancel = [...dialog.querySelectorAll('button')].find(button => button.textContent === 'Cancel')
act(() => cancel.click())
expect(useStore.getState().S.active.entries.map(e => e.id)).toEqual(['1001', '1002'])
act(() => removeButton().click())
dialog = renderTopSheet()
const confirm = [...dialog.querySelectorAll('button')].find(button => button.textContent === 'Remove')
act(() => confirm.click())
expect(useStore.getState().S.active.entries.map(e => e.id)).toEqual(['1002'])
})
it('uses the selected superset member occurrence rather than its exercise id', () => {
renderWorkout([entry('1001', 'pair'), entry('1001', 'pair'), entry('1002')])
useStore.getState().update(s => {
s.active.entries[0].target.marker = 'keep-first'
s.active.entries[1].target.marker = 'remove-second'
}, false)
act(() => removeButton().click())
const chooser = renderTopSheet()
const choices = [...chooser.querySelectorAll('.item')]
expect(choices).toHaveLength(2)
act(() => choices[1].click())
const dialog = renderTopSheet()
const confirm = [...dialog.querySelectorAll('button')].find(button => button.textContent === 'Remove')
act(() => confirm.click())
const active = useStore.getState().S.active
expect(active.entries.map(e => e.id)).toEqual(['1001', '1002'])
expect(active.entries[0].target.marker).toBe('keep-first')
expect(active.entries[0].sg).toBeUndefined()
})
it('hides the remove control for an empty freestyle session', () => {
renderWorkout([])
expect(removeButton()).toBeUndefined()
@@ -143,4 +237,26 @@ describe('remove-exercise edge cases', () => {
expect(A.entries.map(e => e.id)).toEqual(['b', 'c'])
expect(A.entries[A.cur].id).toBe('c')
})
it('persists the shortened active session for reload without changing completed history', () => {
const first = entry('same')
first.target.marker = 'keep-first'
const second = entry('same')
second.target.marker = 'remove-second'
setActive([first, second, entry('other')], 1)
const workouts = [{ id: 'completed', d: '2026-08-10', entries: [{ id: 'same', sets: [{ w: 42, r: 5, done: true }] }] }]
useStore.setState(state => ({ S: { ...state.S, workouts: clone(workouts) } }))
act(() => { removeActiveExercise(1) })
const persisted = JSON.parse(localStorage.getItem('gym_state_v1'))
expect(persisted.workouts).toEqual(workouts)
expect(persisted.active.entries.map(e => e.id)).toEqual(['same', 'other'])
expect(persisted.active.entries[0].target.marker).toBe('keep-first')
expect(persisted.active.cur).toBe(1)
useStore.setState({ S: Object.assign(clone(DEF), persisted), user: null })
expect(useStore.getState().S.active.entries.map(e => e.id)).toEqual(['same', 'other'])
expect(useStore.getState().S.workouts).toEqual(workouts)
})
})
+276 -15
View File
@@ -7,21 +7,38 @@ import Workout from './Workout.jsx'
const mocks = vi.hoisted(() => {
const state = {
S: null,
timer: null,
work: null,
startRest: vi.fn(),
stopRest: vi.fn(),
stopRest: null,
stopWork: null,
confirmSheet: vi.fn(),
topWeightSheet: vi.fn(),
workoutCompleteSheet: vi.fn(),
exercisePicker: vi.fn(),
exConfigSheet: vi.fn(),
toast: vi.fn(),
}
state.stopRest = vi.fn(() => { state.timer = null })
state.stopWork = vi.fn(() => { state.work = null })
state.storeSnapshot = () => ({
S: state.S,
user: null,
update: mut => mut(state.S),
update: mut => {
const next = structuredClone(state.S)
mut(next)
state.S = next
},
})
state.uiSnapshot = () => ({
work: null,
timer: state.timer,
work: state.work,
startRest: state.startRest,
stopRest: state.stopRest,
stopWork: state.stopWork,
shiftRestOwner: vi.fn(),
startWork: vi.fn(),
toast: vi.fn(),
toast: state.toast,
})
return state
})
@@ -39,13 +56,13 @@ vi.mock('../store/useUI.js', () => {
vi.mock('react-router-dom', () => ({ useNavigate: () => () => {} }))
vi.mock('../sheets.jsx', () => ({
startFlow: vi.fn(),
exercisePicker: vi.fn(),
exConfigSheet: vi.fn(),
exercisePicker: mocks.exercisePicker,
exConfigSheet: mocks.exConfigSheet,
exerciseDetailSheet: vi.fn(),
topWeightSheet: mocks.topWeightSheet,
finishWorkout: vi.fn(),
workoutCompleteSheet: vi.fn(),
confirmSheet: vi.fn(),
workoutCompleteSheet: mocks.workoutCompleteSheet,
confirmSheet: mocks.confirmSheet,
// Both note sheets belong here even though the tests never open one: Workout.jsx reads
// sessionNoteSheet during render, so a missing export is a render crash, not a no-op.
exerciseNoteSheet: vi.fn(),
@@ -72,11 +89,13 @@ function exercise(id, sets, extra = {}) {
}
}
function workout(entries, cur = 0) {
function workout(entries, cur = 0, overrides = {}) {
const { active: activeOverrides = {}, ...stateOverrides } = overrides
return {
unit: 'kg', restSec: 90, sound: false, effort: 'none', gifSize: 'full',
workouts: [], exWeights: {}, routines: [],
active: { id: 'active', name: 'Test workout', start: Date.now(), cur, entries },
active: { id: 'active', name: 'Test workout', start: Date.now(), cur, entries, ...activeOverrides },
...stateOverrides,
}
}
@@ -92,8 +111,8 @@ function installDom() {
root = createRoot(container)
}
async function mount(entries, cur = 0) {
mocks.S = workout(entries, cur)
async function mount(entries, cur = 0, overrides = {}) {
mocks.S = workout(entries, cur, overrides)
installDom()
await act(async () => { root.render(React.createElement(Workout)) })
}
@@ -112,8 +131,35 @@ async function toggleSet(index) {
await act(async () => { checkbox.dispatchEvent(new dom.Event('click', { bubbles: true })) })
}
async function requestDiscard() {
const button = container.querySelector('button[aria-label="Discard"]')
expect(button).toBeTruthy()
await act(async () => { button.dispatchEvent(new dom.Event('click', { bubbles: true })) })
}
async function rerender() {
await act(async () => { root.render(React.createElement(Workout)) })
}
async function addExerciseThroughSheets(ex = { id: 'added-exercise' }, cfg = { mode: 'reps', sets: 1, reps: 5, weight: 0 }) {
const addButton = [...container.querySelectorAll('button')]
.find(button => button.textContent.trim() === 'Add exercise')
expect(addButton).toBeTruthy()
await act(async () => { addButton.dispatchEvent(new dom.Event('click', { bubbles: true })) })
const pickerCall = mocks.exercisePicker.mock.calls.at(-1)
expect(pickerCall?.[0]).toEqual(expect.any(Function))
await act(async () => { pickerCall[0](ex) })
const configCall = mocks.exConfigSheet.mock.calls.at(-1)
expect(configCall?.[2]).toEqual(expect.any(Function))
await act(async () => { configCall[2](cfg) })
}
beforeEach(() => {
vi.clearAllMocks()
mocks.timer = null
mocks.work = null
})
afterEach(async () => {
@@ -126,7 +172,7 @@ describe('Workout set completion flow', () => {
await toggleSet(0)
expect(mocks.startRest).toHaveBeenCalledOnce()
expect(mocks.startRest).toHaveBeenCalledWith(90)
expect(mocks.startRest).toHaveBeenCalledWith(90, expect.any(Number))
expect(mocks.stopRest).not.toHaveBeenCalled()
await unmount()
@@ -140,6 +186,85 @@ describe('Workout set completion flow', () => {
expect(mocks.startRest).not.toHaveBeenCalled()
})
it.each(['warmup', 'warm-up', 'warm_up'])(
'does not start transition rest before an incomplete %s row in the next ordinary exercise',
async phase => {
await mount([
exercise('current', [false], { asked: true }),
exercise('next', [false, false], {
asked: true,
sets: [
{ w: 30, r: 5, done: false, phase },
{ w: 60, r: 5, done: false },
],
}),
])
await toggleSet(0)
expect(mocks.S.active.cur).toBe(1)
expect(mocks.startRest).not.toHaveBeenCalled()
},
)
it('does not start transition rest when a completed superset advances to an incomplete warm-up', async () => {
await mount([
exercise('superset-a', [true], { sg: 'group', asked: true }),
exercise('superset-b', [false], { sg: 'group', asked: true }),
exercise('next', [false, false], {
asked: true,
sets: [
{ w: 30, r: 5, done: false, phase: 'warmup' },
{ w: 60, r: 5, done: false },
],
}),
], 1)
await toggleSet(1)
expect(mocks.S.active.cur).toBe(2)
expect(mocks.startRest).not.toHaveBeenCalled()
})
it('does not start transition rest before a warm-up while top-weight confirmation owns navigation', async () => {
await mount([
exercise('current-loaded', [false]),
exercise('next', [false, false], {
asked: true,
sets: [
{ w: 30, r: 5, done: false, phase: 'warmup' },
{ w: 60, r: 5, done: false },
],
}),
])
await toggleSet(0)
expect(mocks.topWeightSheet).toHaveBeenCalledWith(0)
expect(mocks.S.active.cur).toBe(0)
expect(mocks.startRest).not.toHaveBeenCalled()
})
it('does not restart transition rest when re-checking a completed unit before an incomplete warm-up', async () => {
await mount([
exercise('current', [true], { asked: true }),
exercise('next', [false, false], {
asked: true,
sets: [
{ w: 30, r: 5, done: false, phase: 'warmup' },
{ w: 60, r: 5, done: false },
],
}),
])
await toggleSet(0)
await rerender()
await toggleSet(0)
expect(mocks.S.active.cur).toBe(0)
expect(mocks.startRest).not.toHaveBeenCalled()
})
it('leaves a completed superset selected while its top-weight sheet owns the advance choice', async () => {
const group = 'superset-1'
await mount([
@@ -151,7 +276,143 @@ describe('Workout set completion flow', () => {
expect(mocks.topWeightSheet).toHaveBeenCalledWith(1)
expect(mocks.S.active.cur).toBe(1)
expect(mocks.startRest).toHaveBeenCalledWith(90)
expect(mocks.startRest).toHaveBeenCalledWith(90, expect.any(Number))
})
it('skips completed intervening units and selects the next unfinished superset as one unit', async () => {
await mount([
exercise('current-hold', [false], { asked: true, target: { mode: 'time', sec: 30, weight: 0 } }),
exercise('already-done', [true], { asked: true }),
exercise('pending-a', [false], { sg: 'pending-group' }),
exercise('pending-b', [false], { sg: 'pending-group' }),
])
await toggleSet(0)
expect(mocks.S.active.cur).toBe(2)
expect(mocks.workoutCompleteSheet).not.toHaveBeenCalled()
expect(mocks.toast).toHaveBeenCalledWith('Hold logged')
expect(mocks.startRest).toHaveBeenCalledWith(90, expect.any(Number))
})
it('wraps to earlier unfinished work instead of showing a false completion prompt', async () => {
await mount([
exercise('pending-earlier', [false], { asked: true }),
exercise('current-hold', [false], { asked: true, target: { mode: 'time', sec: 30, weight: 0 } }),
], 1)
await toggleSet(0)
expect(mocks.S.active.cur).toBe(0)
expect(mocks.workoutCompleteSheet).not.toHaveBeenCalled()
expect(mocks.startRest).toHaveBeenCalledWith(90, expect.any(Number))
})
it('keeps top-weight confirmation in control without declaring completion while work remains', async () => {
await mount([
exercise('current-loaded', [false]),
exercise('pending', [false], { asked: true }),
])
await toggleSet(0)
expect(mocks.topWeightSheet).toHaveBeenCalledWith(0)
expect(mocks.workoutCompleteSheet).not.toHaveBeenCalled()
expect(mocks.S.active.cur).toBe(0)
})
it('shows workout completion only when no unfinished unit remains', async () => {
await mount([
exercise('already-done', [true], { asked: true }),
exercise('final-hold', [false], { asked: true, target: { mode: 'time', sec: 30, weight: 0 } }),
], 1)
await toggleSet(0)
expect(mocks.workoutCompleteSheet).toHaveBeenCalledOnce()
expect(mocks.startRest).not.toHaveBeenCalled()
})
})
describe('Workout add exercise flow', () => {
it.each([
['freestyle', {}],
['planned', {
active: { routineId: 'routine-1' },
routines: [{ id: 'routine-1', ex: [] }],
}],
])('inserts after the current unit and continues to pending work in a %s session', async (_label, overrides) => {
await mount([
exercise('current', [true], { asked: true }),
exercise('pending', [false], { asked: true }),
], 0, overrides)
await addExerciseThroughSheets(
{ id: 'inserted' },
{ mode: 'time', sets: 1, sec: 30, weight: 0 },
)
expect(mocks.S.active.entries.map(entry => entry.id)).toEqual(['current', 'inserted', 'pending'])
expect(mocks.S.active.cur).toBe(1)
await rerender()
await toggleSet(0)
expect(mocks.S.active.entries[1].sets[0].done).toBe(true)
expect(mocks.S.active.cur).toBe(2)
expect(mocks.workoutCompleteSheet).not.toHaveBeenCalled()
})
it('inserts after the complete current superset without splitting the group', async () => {
await mount([
exercise('current-a', [true], { sg: 'current-group', asked: true }),
exercise('current-b', [true], { sg: 'current-group', asked: true }),
exercise('pending', [false], { asked: true }),
])
await addExerciseThroughSheets({ id: 'inserted' })
expect(mocks.S.active.entries.map(entry => entry.id)).toEqual([
'current-a', 'current-b', 'inserted', 'pending',
])
expect(mocks.S.active.entries.slice(0, 2).map(entry => entry.sg)).toEqual([
'current-group', 'current-group',
])
expect(mocks.S.active.cur).toBe(2)
})
})
describe('Workout discard timer lifecycle', () => {
it('preserves active timers while discard is awaiting confirmation', async () => {
const timer = { left: 30, total: 90, endsAt: Date.now() + 30_000 }
const work = { left: 20, total: 45, endsAt: Date.now() + 20_000, label: 'Plank' }
mocks.timer = timer
mocks.work = work
await mount([exercise('timed-plank', [false])])
await requestDiscard()
expect(mocks.confirmSheet).toHaveBeenCalledOnce()
expect(mocks.timer).toBe(timer)
expect(mocks.work).toBe(work)
expect(mocks.stopRest).not.toHaveBeenCalled()
expect(mocks.stopWork).not.toHaveBeenCalled()
expect(mocks.S.active).not.toBeNull()
})
it('clears rest and work timers only after discard is confirmed', async () => {
mocks.timer = { left: 30, total: 90, endsAt: Date.now() + 30_000 }
mocks.work = { left: 20, total: 45, endsAt: Date.now() + 20_000, label: 'Plank' }
await mount([exercise('timed-plank', [false])])
await requestDiscard()
await act(async () => { mocks.confirmSheet.mock.calls[0][0].onConfirm() })
expect(mocks.S.active).toBeNull()
expect(mocks.timer).toBeNull()
expect(mocks.work).toBeNull()
expect(mocks.stopRest).toHaveBeenCalledOnce()
expect(mocks.stopWork).toHaveBeenCalledOnce()
})
})
@@ -184,6 +445,6 @@ describe('superset flow survives an exercise being removed mid-session', () => {
// Partner closes the round (each still has a second set), which is what starts the rest.
await toggleSet(2)
expect(mocks.startRest).toHaveBeenCalledWith(90)
expect(mocks.startRest).toHaveBeenCalledWith(90, expect.any(Number))
})
})
+2 -2
View File
@@ -9,7 +9,7 @@
<link rel="icon" type="image/png" sizes="512x512" href="icon-512.png">
<link rel="icon" type="image/png" sizes="180x180" href="icon-180.png">
<link rel="apple-touch-icon" href="icon-180.png">
<link rel="stylesheet" href="styles.css?v=5">
<link rel="stylesheet" href="styles.css?v=9">
<script>document.documentElement.className += ' js'</script>
<!-- Umami web analytics for opengym.duarte-santos.ch (self-hosted, cookieless). -->
<script defer src="https://stats.duarte-santos.ch/script.js" data-website-id="db36019e-50f4-453c-9c56-d0588aefe233"></script>
@@ -130,6 +130,6 @@
</div>
</div></footer>
<script src="site.js?v=5" defer></script>
<script src="site.js?v=9" defer></script>
</body>
</html>
+2 -2
View File
@@ -9,7 +9,7 @@
<link rel="icon" type="image/png" sizes="512x512" href="icon-512.png">
<link rel="icon" type="image/png" sizes="180x180" href="icon-180.png">
<link rel="apple-touch-icon" href="icon-180.png">
<link rel="stylesheet" href="styles.css?v=5">
<link rel="stylesheet" href="styles.css?v=9">
<script>document.documentElement.className += ' js'</script>
<!-- Umami web analytics for opengym.duarte-santos.ch (self-hosted, cookieless). -->
<script defer src="https://stats.duarte-santos.ch/script.js" data-website-id="db36019e-50f4-453c-9c56-d0588aefe233"></script>
@@ -209,6 +209,6 @@ docker compose up -d</code></pre>
</div>
</div></footer>
<script src="site.js?v=5" defer></script>
<script src="site.js?v=9" defer></script>
</body>
</html>
+118 -20
View File
@@ -14,10 +14,21 @@
<link rel="icon" type="image/png" sizes="512x512" href="icon-512.png">
<link rel="icon" type="image/png" sizes="180x180" href="icon-180.png">
<link rel="apple-touch-icon" href="icon-180.png">
<link rel="stylesheet" href="styles.css?v=5">
<link rel="stylesheet" href="styles.css?v=9">
<!-- Marks that JS is alive before first paint, so the scroll-reveal styles never
hide content from a browser that will not run them. -->
<script>document.documentElement.className += ' js'</script>
<script>
/* Before first paint: .js arms the scroll reveals, .intro plays the hero entrance once per
tab. Deferred scripts run too late for this — the hero would paint, then vanish and
animate back in. site.js takes .intro off again when the animation ends. */
document.documentElement.className += ' js'
try {
if (!sessionStorage.getItem('og-intro')) {
sessionStorage.setItem('og-intro', '1')
document.documentElement.className += ' intro'
}
} catch (e) { document.documentElement.className += ' intro' }
</script>
<!-- Umami web analytics for opengym.duarte-santos.ch (self-hosted, cookieless). -->
<script defer src="https://stats.duarte-santos.ch/script.js" data-website-id="db36019e-50f4-453c-9c56-d0588aefe233"></script>
<script type="application/ld+json">
@@ -46,6 +57,18 @@
<symbol id="i-gitlab" viewBox="0 0 24 24"><path d="m23.6004 9.5927-.0337-.0862L20.3.9814a.851.851 0 0 0-.3362-.405.8748.8748 0 0 0-.9997.0539.8748.8748 0 0 0-.29.4399l-2.2055 6.748H7.5375l-2.2057-6.748a.8573.8573 0 0 0-.29-.4412.8748.8748 0 0 0-.9997-.0537.8585.8585 0 0 0-.3362.4049L.4332 9.5015l-.0325.0862a6.0657 6.0657 0 0 0 2.0119 7.0105l.0113.0087.03.0213 4.976 3.7264 2.462 1.8633 1.4995 1.1321a1.0085 1.0085 0 0 0 1.2197 0l1.4995-1.1321 2.4619-1.8633 5.006-3.7489.0125-.01a6.0682 6.0682 0 0 0 2.0094-7.003z"/></symbol>
<symbol id="i-github" viewBox="0 0 24 24"><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></symbol>
<symbol id="i-bmc" viewBox="0 0 24 24"><path d="M20.216 6.415l-.132-.666c-.119-.598-.388-1.163-1.001-1.379-.197-.069-.42-.098-.57-.241-.152-.143-.196-.366-.231-.572-.065-.378-.125-.756-.192-1.133-.057-.325-.102-.69-.25-.987-.195-.4-.597-.634-.996-.788a5.723 5.723 0 00-.626-.194c-1-.263-2.05-.36-3.077-.416a25.834 25.834 0 00-3.7.062c-.915.083-1.88.184-2.75.5-.318.116-.646.256-.888.501-.297.302-.393.77-.177 1.146.154.267.415.456.692.58.36.162.737.284 1.123.366 1.075.238 2.189.331 3.287.37 1.218.05 2.437.01 3.65-.118.299-.033.598-.073.896-.119.352-.054.578-.513.474-.834-.124-.383-.457-.531-.834-.473-.466.074-.96.108-1.382.146-1.177.08-2.358.082-3.536.006a22.228 22.228 0 01-1.157-.107c-.086-.01-.18-.025-.258-.036-.243-.036-.484-.08-.724-.13-.111-.027-.111-.185 0-.212h.005c.277-.06.557-.108.838-.147h.002c.131-.009.263-.032.394-.048a25.076 25.076 0 013.426-.12c.674.019 1.347.067 2.017.144l.228.031c.267.04.533.088.798.145.392.085.895.113 1.07.542.055.137.08.288.111.431l.319 1.484a.237.237 0 01-.199.284h-.003c-.037.006-.075.01-.112.015a36.704 36.704 0 01-4.743.295 37.059 37.059 0 01-4.699-.304c-.14-.017-.293-.042-.417-.06-.326-.048-.649-.108-.973-.161-.393-.065-.768-.032-1.123.161-.29.16-.527.404-.675.701-.154.316-.199.66-.267 1-.069.34-.176.707-.135 1.056.087.753.613 1.365 1.37 1.502a39.69 39.69 0 0011.343.376.483.483 0 01.535.53l-.071.697-1.018 9.907c-.041.41-.047.832-.125 1.237-.122.637-.553 1.028-1.182 1.171-.577.131-1.165.2-1.756.205-.656.004-1.31-.025-1.966-.022-.699.004-1.556-.06-2.095-.58-.475-.458-.54-1.174-.605-1.793l-.731-7.013-.322-3.094c-.037-.351-.286-.695-.678-.678-.336.015-.718.3-.678.679l.228 2.185.949 9.112c.147 1.344 1.174 2.068 2.446 2.272.742.12 1.503.144 2.257.156.966.016 1.942.053 2.892-.122 1.408-.258 2.465-1.198 2.616-2.657.34-3.332.683-6.663 1.024-9.995l.215-2.087a.484.484 0 01.39-.426c.402-.078.787-.212 1.074-.518.455-.488.546-1.124.385-1.766zm-1.478.772c-.145.137-.363.201-.578.233-2.416.359-4.866.54-7.308.46-1.748-.06-3.477-.254-5.207-.498-.17-.024-.353-.055-.47-.18-.22-.236-.111-.71-.054-.995.052-.26.152-.609.463-.646.484-.057 1.046.148 1.526.22.577.088 1.156.159 1.737.212 2.48.226 5.002.19 7.472-.14.45-.06.899-.13 1.345-.21.399-.072.84-.206 1.08.206.166.281.188.657.162.974a.544.544 0 01-.169.364zm-6.159 3.9c-.862.37-1.84.788-3.109.788a5.884 5.884 0 01-1.569-.217l.877 9.004c.065.78.717 1.38 1.5 1.38 0 0 1.243.065 1.658.065.447 0 1.786-.065 1.786-.065.783 0 1.434-.6 1.499-1.38l.94-9.95a3.996 3.996 0 00-1.322-.238c-.826 0-1.491.284-2.26.613z"/></symbol>
<symbol id="i-calendar" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><rect x="3.2" y="4.8" width="17.6" height="16" rx="2.4"/><path d="M3.2 9.6h17.6M8.4 3.2v3.2M15.6 3.2v3.2"/></symbol>
<symbol id="i-link" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M10.2 13.8a3.6 3.6 0 0 0 5.4.4l2.6-2.6a3.6 3.6 0 0 0-5.1-5.1l-1.5 1.5"/><path d="M13.8 10.2a3.6 3.6 0 0 0-5.4-.4l-2.6 2.6a3.6 3.6 0 0 0 5.1 5.1l1.5-1.5"/></symbol>
<symbol id="i-timer" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="13.4" r="7.6"/><path d="M12 9.4v4l2.6 1.6M9.4 2.6h5.2"/></symbol>
<symbol id="i-flame" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M12 21.4c3.4 0 6-2.4 6-5.6 0-4-4.2-5.6-3.4-10.4-2 .6-3.6 2.6-3.6 4.8 0 1-.6 1.8-1.4 1.8-.9 0-1.4-.8-1.3-1.9C7 11.4 6 13.2 6 15.8c0 3.2 2.6 5.6 6 5.6z"/></symbol>
<symbol id="i-gauge" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M4.2 17.4a8.6 8.6 0 1 1 15.6 0"/><path d="M12 14.6l3.8-3.8"/><circle cx="12" cy="16.2" r="1.4"/></symbol>
<symbol id="i-share" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3.6v11.2M8.4 7.2L12 3.6l3.6 3.6"/><path d="M5.4 13.2v5.4a1.8 1.8 0 0 0 1.8 1.8h9.6a1.8 1.8 0 0 0 1.8-1.8v-5.4"/></symbol>
<symbol id="i-import" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3.6v11.2M8.4 11.2l3.6 3.6 3.6-3.6"/><path d="M5.4 15.6v3a1.8 1.8 0 0 0 1.8 1.8h9.6a1.8 1.8 0 0 0 1.8-1.8v-3"/></symbol>
<symbol id="i-globe" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="8.6"/><path d="M3.4 12h17.2"/><path d="M12 3.4c2.2 2.4 3.4 5.4 3.4 8.6s-1.2 6.2-3.4 8.6c-2.2-2.4-3.4-5.4-3.4-8.6S9.8 5.8 12 3.4z"/></symbol>
<symbol id="i-key" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><circle cx="7.6" cy="14.4" r="3.8"/><path d="M10.4 11.6l7.4-7.4M15.2 6.8l2.2 2.2M17.8 4.2l2.2 2.2"/></symbol>
<symbol id="i-palette" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3.4a8.6 8.6 0 0 0 0 17.2c1 0 1.8-.8 1.8-1.8 0-.5-.2-.9-.5-1.2-.3-.3-.5-.7-.5-1.2 0-1 .8-1.8 1.8-1.8h2.1a4 4 0 0 0 3.9-4c0-3.9-3.9-7.2-8.6-7.2z"/><circle cx="7.6" cy="11.6" r="1"/><circle cx="10.6" cy="7.4" r="1"/><circle cx="15.4" cy="8.4" r="1"/></symbol>
<symbol id="i-sparkle" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3.2l1.9 4.9 4.9 1.9-4.9 1.9L12 16.8l-1.9-4.9-4.9-1.9 4.9-1.9z"/><path d="M18.6 15.4l.8 2 2 .8-2 .8-.8 2-.8-2-2-.8 2-.8z"/></symbol>
<symbol id="i-archive" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><rect x="3.2" y="4.4" width="17.6" height="4.4" rx="1.6"/><path d="M5 8.8v9.2a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8.8"/><path d="M9.8 12.6h4.4"/></symbol>
</defs></svg>
<nav><div class="wrap nav-in">
@@ -162,22 +185,95 @@
<div class="more rv">
<h3>And the rest of it</h3>
<dl>
<div><dt>Weekly plan</dt><dd>A routine per weekday. Any single day can be moved when life happens, without editing the plan itself.</dd></div>
<div><dt>Supersets and cardio</dt><dd>Plan them, or pair two exercises mid-session and unpair them again. One rest per round, and time-plus-speed logging where weight times reps says nothing.</dd></div>
<div><dt>Timed sets</dt><dd>Planks, hangs and carries are logged by time, with a timer for the set itself. Stop early and it records what you actually held.</dd></div>
<div><dt>Warm-up sets</dt><dd>Mark the ramp-up rows and they stay out of your 1RM, your progression and the fatigue map. Present in the session, absent from the numbers.</dd></div>
<div><dt>Estimated 1RM</dt><dd>Per exercise, from your best eligible set, naming which set it used. It will not guess above 12 reps.</dd></div>
<div><dt>Effort per set</dt><dd>Rate a set as RIR or RPE, whichever scale you already think in. Optional, and each set keeps the scale it was logged with.</dd></div>
<div><dt>Share a plan</dt><dd>Send someone your routines as a small file, or print them as a clean PDF. No workouts, no weigh-ins, and importing merges instead of overwriting.</dd></div>
<div><dt>Bring your history</dt><dd>Import from FitNotes, Strong or Hevy, including the RPE they recorded, or body weight straight out of an Apple Health export.</dd></div>
<div><dt>The screen stays awake</dt><dd>No unlocking the phone between sets. The display stays lit while a workout runs and lets go the moment you finish.</dd></div>
<div><dt>13 languages</dt><dd>The full interface, plus exercise instructions in 11 languages and bilingual Brazilian Portuguese names, all loaded on demand.</dd></div>
<div><dt>Passkeys, not passwords</dt><dd>Self-hosted profiles sign in with Face ID or a fingerprint. Everyone's data stays their own.</dd></div>
<div><dt>Designed, not assembled</dt><dd>Light and dark themes, eight accent colours, a hand-drawn icon set, and the same layout on every phone.</dd></div>
<div><dt>Ask an AI about your training</dt><dd>An optional MCP server lets a client like Claude Desktop read your history in plain language. Read-only, on your machine, and not part of the Docker build.</dd></div>
<div><dt>Yours to keep</dt><dd>One-tap JSON export and import. Your training log is a file you own, not a row in someone's database.</dd></div>
</dl>
<p class="more-hint">Fourteen more things it does.</p>
</div>
</div>
<!-- A rail rather than a wall of text: this is the "and also" list, so it should be
skimmable and skippable. Each card opens the full paragraph in a dialog, and a few
carry a link into the docs. Without JS the cards are plain, fully readable blocks. -->
<div class="bleed rv">
<div class="rail frail">
<article class="fcard">
<span class="fcard-ic"><svg aria-hidden="true"><use href="#i-calendar"/></svg></span>
<b class="fcard-t">Weekly plan</b>
<span class="fcard-b">A routine per weekday. Any single day can be moved when life happens, without editing the plan itself.</span>
</article>
<article class="fcard">
<span class="fcard-ic"><svg aria-hidden="true"><use href="#i-link"/></svg></span>
<b class="fcard-t">Supersets and cardio</b>
<span class="fcard-b">Plan them, or pair two exercises mid-session and unpair them again. One rest per round, and time-plus-speed logging where weight times reps says nothing.</span>
</article>
<article class="fcard">
<span class="fcard-ic"><svg aria-hidden="true"><use href="#i-timer"/></svg></span>
<b class="fcard-t">Timed sets</b>
<span class="fcard-b">Planks, hangs and carries are logged by time, with a timer for the set itself. Stop early and it records what you actually held.</span>
</article>
<article class="fcard">
<span class="fcard-ic"><svg aria-hidden="true"><use href="#i-flame"/></svg></span>
<b class="fcard-t">Warm-up sets</b>
<span class="fcard-b">Mark the ramp-up rows and they stay out of your 1RM, your progression and the fatigue map. Present in the session, absent from the numbers.</span>
</article>
<article class="fcard">
<span class="fcard-ic"><svg aria-hidden="true"><use href="#i-trend"/></svg></span>
<b class="fcard-t">Estimated 1RM</b>
<span class="fcard-b">Per exercise, from your best eligible set, naming which set it used. It will not guess above 12 reps.</span>
</article>
<article class="fcard">
<span class="fcard-ic"><svg aria-hidden="true"><use href="#i-gauge"/></svg></span>
<b class="fcard-t">Effort per set</b>
<span class="fcard-b">Rate a set as RIR or RPE, whichever scale you already think in. Optional, and each set keeps the scale it was logged with.</span>
</article>
<article class="fcard">
<span class="fcard-ic"><svg aria-hidden="true"><use href="#i-share"/></svg></span>
<b class="fcard-t">Share a plan</b>
<span class="fcard-b">Send someone your routines as a small file, or print them as a clean PDF. No workouts, no weigh-ins, and importing merges instead of overwriting.</span>
</article>
<article class="fcard">
<span class="fcard-ic"><svg aria-hidden="true"><use href="#i-import"/></svg></span>
<b class="fcard-t">Bring your history</b>
<span class="fcard-b">Import from FitNotes, Strong or Hevy, including the RPE they recorded, or body weight straight out of an Apple Health export.</span>
<a class="fcard-link" href="docs.html#import">How importing works →</a>
</article>
<article class="fcard">
<span class="fcard-ic"><svg aria-hidden="true"><use href="#i-phone"/></svg></span>
<b class="fcard-t">The screen stays awake</b>
<span class="fcard-b">No unlocking the phone between sets. The display stays lit while a workout runs and lets go the moment you finish.</span>
</article>
<article class="fcard">
<span class="fcard-ic"><svg aria-hidden="true"><use href="#i-globe"/></svg></span>
<b class="fcard-t">13 languages</b>
<span class="fcard-b">The full interface, plus exercise instructions in 11 languages and bilingual Brazilian Portuguese names, all loaded on demand.</span>
</article>
<article class="fcard">
<span class="fcard-ic"><svg aria-hidden="true"><use href="#i-key"/></svg></span>
<b class="fcard-t">Passkeys, not passwords</b>
<span class="fcard-b">Self-hosted profiles sign in with Face ID or a fingerprint. Everyone’s data stays their own.</span>
<a class="fcard-link" href="docs.html#selfhost">Self-hosting guide →</a>
</article>
<article class="fcard">
<span class="fcard-ic"><svg aria-hidden="true"><use href="#i-palette"/></svg></span>
<b class="fcard-t">Designed, not assembled</b>
<span class="fcard-b">Light and dark themes, eight accent colours, a hand-drawn icon set, and the same layout on every phone.</span>
</article>
<article class="fcard">
<span class="fcard-ic"><svg aria-hidden="true"><use href="#i-sparkle"/></svg></span>
<b class="fcard-t">Ask an AI about your training</b>
<span class="fcard-b">An optional MCP server lets a client like Claude Desktop read your history in plain language. Read-only, on your machine, and not part of the Docker build.</span>
<a class="fcard-link" href="docs.html#mcp">Set up the MCP server →</a>
</article>
<article class="fcard">
<span class="fcard-ic"><svg aria-hidden="true"><use href="#i-archive"/></svg></span>
<b class="fcard-t">Yours to keep</b>
<span class="fcard-b">One-tap JSON export and import. Your training log is a file you own, not a row in someone’s database.</span>
<a class="fcard-link" href="docs.html#backup">Backups →</a>
</article>
</div>
</div>
<div class="wrap">
<div class="frail-nav" hidden>
<button class="rnav" type="button" data-dir="-1" aria-label="Previous"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M14.5 5.5L8 12l6.5 6.5"/></svg></button>
<button class="rnav" type="button" data-dir="1" aria-label="Next"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M9.5 5.5L16 12l-6.5 6.5"/></svg></button>
</div>
</div>
</section>
@@ -248,7 +344,7 @@
</ul>
<div class="push">
<a class="btn" href="openGym.apk" download>Download for Android</a>
<p class="meta">v1.2.11 · 4.3 MB · Android 6.0+ · signed APK. Your browser will ask
<p class="meta">v1.2.13 · 4.4 MB · Android 6.0+ · signed APK. Your browser will ask
before installing; that is normal outside the Play Store.</p>
<p class="meta">Every release is also built and signed by CI and attached to the
<a href="https://gitlab.com/DuarteSantos8/opengym/-/releases" rel="noopener">GitLab
@@ -370,6 +466,8 @@
</div>
</section>
<footer><div class="wrap foot">
<span class="c">openGym · AGPL-3.0 · © 2026 <a href="https://duarte-santos.ch" rel="noopener">Duarte Santos</a></span>
<div class="links">
@@ -381,6 +479,6 @@
</div>
</div></footer>
<script src="site.js?v=5" defer></script>
<script src="site.js?v=9" defer></script>
</body>
</html>
+36
View File
@@ -176,3 +176,39 @@ const GL_PROJECT = 'https://gitlab.com/api/v4/projects/DuarteSantos8%2Fopengym'
}
} catch (e) { /* fallback entries stay */ }
})()
/* The "and the rest of it" rail: arrows for pointers that cannot swipe. The cards are plain
reading, so there is nothing to activate on them. */
;(() => {
const rail = document.querySelector('.frail')
if (!rail) return
const nav = document.querySelector('.frail-nav')
if (nav) {
nav.hidden = false
const [prev, next] = nav.querySelectorAll('.rnav')
const step = () => (rail.querySelector('.fcard')?.offsetWidth || 260) + 16
nav.addEventListener('click', e => {
const btn = e.target.closest('.rnav')
if (btn) rail.scrollBy({ left: Number(btn.dataset.dir) * step(), behavior: 'smooth' })
})
const sync = () => {
prev.disabled = rail.scrollLeft < 4
next.disabled = rail.scrollLeft > rail.scrollWidth - rail.clientWidth - 4
}
rail.addEventListener('scroll', sync, { passive: true })
addEventListener('resize', sync)
sync()
}
})()
/* The hero intro is armed in the inline <head> script, before the first paint — a deferred
script would arm it too late and the hero would flash. All this does is take the class off
once the last element has landed, so nothing stays mid-animation. */
;(() => {
const root = document.documentElement
if (!root.classList.contains('intro')) return
const done = () => root.classList.remove('intro')
const last = document.querySelector('.hero-stage') || document.querySelector('.hero .actions')
if (last) last.addEventListener('animationend', done, { once: true })
setTimeout(done, 2400) // if the animation never fires, do not leave the hero hidden
})()
+97 -2
View File
@@ -398,7 +398,10 @@ section { padding: var(--sec) 0 0; }
.rail {
display: flex; gap: clamp(12px, 2.4vw, 22px);
overflow-x: auto; scroll-snap-type: x mandatory;
padding: 4px max(var(--pad), calc((100vw - var(--max)) / 2)) 6px;
/* Line the first card up with the text above it: the gutter is half the leftover width
PLUS the wrap's own padding. Using 100% rather than 100vw keeps the scrollbar out of
the sum, which would otherwise push the rail a few pixels off. */
padding: 4px max(var(--pad), calc((100% - var(--max)) / 2 + var(--pad))) 6px;
scrollbar-width: none;
overscroll-behavior-x: contain;
}
@@ -623,7 +626,10 @@ footer {
/* ------------------------------------------------------------ prose pages */
.prose { max-width: 720px; padding: clamp(44px, 7vw, 72px) 0 0; }
/* Keep .wrap's horizontal padding. The shorthand used to be `… 0 0`, which zeroed the
left and right the .wrap class had set, so on a phone the docs and about pages ran
edge to edge with nothing between the text and the screen. */
.prose { max-width: 720px; padding: clamp(44px, 7vw, 72px) var(--pad) 0; }
.prose h1 { font-size: clamp(36px, 6.5vw, 60px); }
.prose > .lead { max-width: 42ch; margin-bottom: clamp(34px, 5vw, 48px); }
.prose h2 {
@@ -706,3 +712,92 @@ table.cfg td:first-child { white-space: nowrap; width: 1%; padding-right: 26px;
@media (prefers-reduced-motion: reduce) {
.js .rv { opacity: 1; transform: none; transition: none; }
}
/* ------------------------------------------------------- the "rest of it" rail
The long tail of features. It is a rail rather than a two-column list because
this is the "and also" section: worth having, not worth a screenful of reading.
Cards carry their full text in the markup, so a reader without JS gets
everything; with JS the text is clamped and the card opens a dialog. */
.more-hint { color: var(--fg-2); font-size: 15px; margin-top: 12px; }
.frail { align-items: stretch; padding-top: 10px; padding-bottom: 10px; }
.more + .bleed, .bleed:has(.frail) { margin-top: clamp(18px, 2.4vw, 26px); }
/* Not interactive: the card holds its whole text, so there is nothing to open. Only the
four cards that point into the docs carry a link, because that is the only place there is
genuinely more to read. */
.fcard {
flex: 0 0 auto; width: clamp(250px, 78vw, 310px); scroll-snap-align: center;
display: flex; flex-direction: column; text-align: left;
padding: 22px; background: var(--surface);
border: 1px solid var(--hair-soft); border-radius: var(--r-m);
color: var(--fg);
}
.fcard-ic {
width: 40px; height: 40px; border-radius: 12px; margin-bottom: 15px;
display: flex; align-items: center; justify-content: center; flex: none;
background: color-mix(in srgb, var(--acc) 15%, transparent); color: var(--acc);
}
.fcard-ic svg { width: 21px; height: 21px; }
.fcard-t { font-size: 16.5px; font-weight: 600; letter-spacing: -.015em; margin-bottom: 6px; }
.fcard-b { color: var(--fg-2); font-size: 14.5px; line-height: 1.5; }
.fcard-link {
display: block; margin-top: auto; padding-top: 16px;
color: var(--acc); font-size: 13.5px; font-weight: 500;
}
.fcard-link:hover { text-decoration: underline; }
/* `display: flex` here beats the UA's `[hidden] { display: none }`, so the attribute has to
be honoured explicitly — otherwise the arrows show up without JS, where they do nothing. */
.frail-nav { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.frail-nav[hidden] { display: none; }
.rnav {
width: 38px; height: 38px; border-radius: 50%;
display: flex; align-items: center; justify-content: center;
background: var(--surface); border: 1px solid var(--hair-soft); color: var(--fg-2);
cursor: pointer; transition: color .25s var(--ease), border-color .25s var(--ease);
}
.rnav:hover { color: var(--fg); border-color: var(--hair); }
.rnav:disabled { opacity: .3; cursor: default; }
.rnav svg { width: 19px; height: 19px; }
/* Touch scrolls; the arrows are for pointers that cannot swipe. */
@media (hover: none) { .frail-nav { display: none; } }
/* ------------------------------------------------------------ first-visit intro
The hero settles in on the first load of a visit instead of appearing all at once.
Deliberately the same movement as the scroll reveals below the fold (a short rise
and a fade) so it reads as one behaviour rather than an effect. Runs once per tab:
site.js sets .intro, and clears it after the last child has finished. */
.js.intro .hero .eyebrow,
.js.intro .hero h1,
.js.intro .hero .lead,
.js.intro .hero .actions,
.js.intro .hero-stage {
opacity: 0;
animation: introUp .85s var(--ease) forwards;
}
.js.intro .hero .eyebrow { animation-delay: .04s; }
.js.intro .hero h1 { animation-delay: .12s; }
.js.intro .hero .lead { animation-delay: .24s; }
.js.intro .hero .actions { animation-delay: .34s; }
.js.intro .hero-stage { animation-delay: .42s; animation-duration: 1.05s; }
@keyframes introUp {
from { opacity: 0; transform: translateY(18px); }
to { opacity: 1; transform: none; }
}
/* The phone in the hero lifts a little further, so it arrives last and reads as depth. */
.js.intro .hero-stage { animation-name: introRise; }
@keyframes introRise {
from { opacity: 0; transform: translateY(34px) scale(.985); }
to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
.js.intro .hero .eyebrow,
.js.intro .hero h1,
.js.intro .hero .lead,
.js.intro .hero .actions,
.js.intro .hero-stage { opacity: 1; animation: none; }
}