feat(checkin): track one-sided exercises per side (L/R)

One-sided (reps-per-side) exercises now log weight, reps, RIR/RPE and done individually per side, shown as two L/R rows per set. The per-side data rides on the set row while its scalar w/r/done/effort stay a correct aggregate, so volume, 1RM, PRs, progression, recovery, history and the coach read it unchanged. Side badges localised for all languages. Closes #60.
This commit is contained in:
Sebastian G committed 2026-09-07 12:23:39 +02:00
1 parent 5c2005e81f
commit af751a718e
21 files changed
+421 -28

No files matched your search

+20
View File
@@ -735,6 +735,26 @@ h4.sec{
.effpick .effpick-free .stp .num::placeholder{color:var(--label-3);font-weight:500}
.setrow.done .n{background:var(--acc);color:var(--on-acc)}
.setrow.done{opacity:.45}
/* one-sided (unilateral) sets (issue #60): the set number sits beside a two-row L/R stack, each
side its own weight/reps/effort + done tick. The two inner rows reuse .setrow so their columns
line up with the header exactly like a straight set — only the leading .n circle is replaced by
a small L/R badge of the same width. */
.setrow-side{display:flex;align-items:center;gap:8px;padding:4px 0;position:relative}
.setrow-side+.setrow-side::before{content:'';position:absolute;left:32px;right:0;top:0;height:var(--hair);background:var(--sep)}
.setrow-side>.n{align-self:center}
.setrow-side .side-rows{flex:1;min-width:0;display:flex;flex-direction:column}
/* inner side rows: no leading number circle (the badge takes its place), no top hairline between
the two sides of the same set — they read as one unit. */
.setrow-side .setrow.side{padding:4px 0}
.setrow-side .setrow.side+.setrow.side::before{display:none}
.sidetag{
width:24px;height:24px;border-radius:8px;background:var(--surface-2);color:var(--label-3);
display:flex;align-items:center;justify-content:center;font-size:11px;font-weight:600;flex:none;
}
.setrow.side.done .sidetag{background:var(--acc);color:var(--on-acc)}
.setrow.side.done{opacity:.45}
/* drop-set drops / rest-pause bursts riding on a work row, editable like the row itself
(issue: drop-sets & rest-pause) */
.subrow{display:flex;align-items:center;gap:6px;padding:3px 0 3px 32px}
+40 -12
View File
@@ -1,7 +1,7 @@
// Pure helpers over the state object S (ported 1:1 from the vanilla app).
import { todayISO, isoOf, weekKey, weekStartOf, fmtNum } from './format.js'
import { isCardio, isBodyweightEq } from './exercises.js'
import { phaseForSet, modeForSet, modeForEntry, isWarmupRow, normalizeMode, extraVolumeOf, nextDropWeight, splitBurstReps } from './workout-model.js'
import { phaseForSet, modeForSet, modeForEntry, isWarmupRow, normalizeMode, extraVolumeOf, nextDropWeight, splitBurstReps, makeSideSet, isSideSet, syncSideAggregate } from './workout-model.js'
const objectOf = value => value && typeof value === 'object' && !Array.isArray(value) ? value : {}
// Completed-state-independent work rows whose authoritative mode matches the requested mode.
const workRowsForMode = (entry = {}, mode = 'reps') => {
@@ -110,16 +110,21 @@ export function setLabel(id, s, cfg) {
const mode = modeOf(c)
if (mode === 'cardio') return `${s.min || 0} min @ ${fmtNum(s.speed || 0)} km/h`
if (mode === 'time') return fmtSec(s.sec) + (s.w > 0 ? ` · ${fmtNum(s.w)}` : '')
const bw = isBw({ ...c, id: c.id ?? id })
// One side's "weight×reps" (or bodyweight "reps" / "+belt × reps"), the same shape a whole
// straight set reads as — reused for each side of a unilateral set below.
const oneSide = side => {
const reps = side.r || 0
return bw ? (side.w > 0 ? `+${fmtNum(side.w)} × ` : '') + reps : `${fmtNum(side.w || 0)}×${reps}`
}
// A unilateral set logged per side (issue #60) reads "L 15×8 · R 15×7" — the asymmetry is the
// whole point, so both sides are shown rather than a single combined total.
if (isSideSet(s)) {
return `${t('L')} ${oneSide(s.sides.L)}${effortTail(s.sides.L)} · ${t('R')} ${oneSide(s.sides.R)}${effortTail(s.sides.R)}`
}
// Bodyweight reads as what you did — "12", or "+10 × 12" once there is a belt involved —
// rather than "0×12", which says a set was performed with no weight and means nothing.
// A per-side set needs no mark here: the number logged is the total, the same as every
// other set in the app.
const reps = s.r || 0
if (isBw({ ...c, id: c.id ?? id })) {
const load = s.w > 0 ? `+${fmtNum(s.w)} × ` : ''
return `${load}${reps}` + effortTail(s)
}
return `${fmtNum(s.w || 0)}×${reps}` + effortTail(s)
return oneSide(s) + effortTail(s)
}
// Default config for a freshly added exercise.
export function defaultConfig(id, mode) {
@@ -372,11 +377,26 @@ function buildWorkSets(S, cfg, options = {}) {
const w = useTarget
? (cfg.weight > 0 ? cfg.weight : (lastRegular && lastRegular.r > 0 ? lastRegular.w : cfg.weight))
: preferLast && usable ? usable.w : (conf && conf.w > 0 ? conf.w : (usable ? usable.w : cfg.weight))
sets.push({ w, r: usable ? usable.r : cfg.reps, done: false })
const row = { w, r: usable ? usable.r : cfg.reps, done: false }
// A unilateral exercise logs each side on its own (issue #60): the row splits into L/R,
// each seeded with half the total reps at the same weight. When "last time" was itself a
// per-side set, carry its two sides over verbatim so an asymmetry you logged persists.
if (isPerSide(cfg)) sets.push(usable && isSideSet(usable) ? seedSideFromLast(row, usable) : makeSideSet(row))
else sets.push(row)
}
return sets
}
// Seed a fresh per-side row from a previous per-side set: same reps/weight each side, nothing
// done, no effort carried (that is logged afresh each session). Falls back to an even split if
// the previous row was not actually per-side.
function seedSideFromLast(row, prev) {
const base = makeSideSet(row)
if (!isSideSet(prev)) return base
const carry = s => ({ w: Number(s?.w) || 0, r: Number(s?.r) || 0, done: false })
return syncSideAggregate({ ...base, sides: { L: carry(prev.sides.L), R: carry(prev.sides.R) } })
}
/**
* Stamp every work row with the exercise's planned intensifier and pre-fill its drops/clusters,
* already computed and editable — the plan designs the set, not a button pressed mid-workout.
@@ -430,14 +450,22 @@ export function workoutVolume(w) {
}))
return v
}
// A unilateral row counts as two toward the "x / y sets" progress — one per side — since each
// side is logged and ticked on its own (issue #60). Every other row counts as one.
export const setUnits = s => (isSideSet(s) ? 2 : 1)
// How many of a row's units are done: both sides independently for a per-side row, else 0/1.
export const doneUnits = s => (isSideSet(s) ? (s.sides.L.done ? 1 : 0) + (s.sides.R.done ? 1 : 0) : (s.done ? 1 : 0))
// Total completion-units across a session's rows (both sides of every unilateral set counted).
export const setUnitsTotal = entries => (entries || []).reduce((n, e) => n + (e.sets || []).reduce((m, s) => m + setUnits(s), 0), 0)
export function setsDone(w) {
let n = 0
w.entries.forEach(e => e.sets.forEach(s => { if (s.done) n++ }))
w.entries.forEach(e => e.sets.forEach(s => { n += doneUnits(s) }))
return n
}
export function setsDoneActive(A) {
let n = 0
if (A) A.entries.forEach(e => e.sets.forEach(s => { if (s.done) n++ }))
if (A) A.entries.forEach(e => e.sets.forEach(s => { n += doneUnits(s) }))
return n
}
export const lastBW = S => (S.bodyweight.length ? S.bodyweight[S.bodyweight.length - 1] : null)
+63 -1
View File
@@ -1,5 +1,6 @@
import { describe, it, expect } from 'vitest'
import { nextTrainingDay, modeOf, isTimed, fmtSec, setLabel, defaultConfig, buildSets, freestyleConfig, exLine, workoutVolume, bestWeightFor, bestWeightForEntry, effortOf, stepEffort, capEffort, isBw, isPerSide, sideReps, repStep, cascadeWeight, insertWarmupRow, removeRowAt, workSetsDone, pairAdjacent, unpairSuperset, supersetUnits, applyIntensifierPlan, pinnedNoteFor, exNoteFor } from './history.js'
import { nextTrainingDay, modeOf, isTimed, fmtSec, setLabel, defaultConfig, buildSets, freestyleConfig, exLine, workoutVolume, bestWeightFor, bestWeightForEntry, effortOf, stepEffort, capEffort, isBw, isPerSide, sideReps, repStep, cascadeWeight, insertWarmupRow, removeRowAt, workSetsDone, setsDone, setsDoneActive, setUnits, doneUnits, setUnitsTotal, pairAdjacent, unpairSuperset, supersetUnits, applyIntensifierPlan, pinnedNoteFor, exNoteFor } from './history.js'
import { makeSideSet, setSideField, toggleSide } from './workout-model.js'
import { EXDB } from './exercises.js'
// Real ids out of the shipped catalogue, so the body-part fallback is exercised for real.
@@ -1019,3 +1020,64 @@ describe('nextTrainingDay', () => {
expect(nextTrainingDay(off, TUE)).toMatchObject({ weekday: 5 })
})
})
/* ---------- one-sided (unilateral) sets, logged per side (issue #60) ---------- */
// A per-side row carries its two sides and a scalar aggregate. These pin that the display shows
// both sides, and — crucially — that every aggregate-reading consumer (volume, best weight, the
// x/y-sets counters) treats the row correctly without knowing sides exist.
describe('setLabel — per side', () => {
it('shows both sides so an asymmetry is visible, not a single combined total', () => {
const s = setSideField(setSideField(makeSideSet({ w: 15, r: 16 }), 'R', 'r', 7), 'L', 'r', 8)
expect(setLabel(LIFT, s, { id: LIFT, side: true })).toBe('L 15×8 · R 15×7')
})
it('keeps each side effort tail and reads bodyweight sides as reps alone', () => {
let s = makeSideSet({ w: 0, r: 16 })
s = setSideField(s, 'L', 'rir', 1)
expect(setLabel(BW, s, { id: BW, side: true })).toBe('L 8 (RIR 1) · R 8')
})
})
describe('per-side aggregate stays readable by existing consumers', () => {
it('workoutVolume counts both sides via the row total, unchanged from a straight set', () => {
// 15×8 per side = 15×16 total = 240, exactly what a straight {w:15,r:16} would score.
const side = { ...makeSideSet({ w: 15, r: 16 }), done: true }
const synced = toggleSide(toggleSide(makeSideSet({ w: 15, r: 16 }), 'L'), 'R') // both done
const w = { entries: [{ id: LIFT, sets: [synced] }] }
expect(synced.done).toBe(true)
expect(workoutVolume(w)).toBe(240)
// and a straight equivalent scores the same
expect(workoutVolume({ entries: [{ id: LIFT, sets: [{ w: 15, r: 16, done: true }] }] })).toBe(240)
})
it('bestWeightForEntry reads the aggregate weight of a completed per-side set', () => {
const s = toggleSide(toggleSide(setSideField(makeSideSet({ w: 15, r: 16 }), 'R', 'w', 17.5), 'L'), 'R')
expect(bestWeightForEntry({ id: LIFT, target: { id: LIFT, side: true }, sets: [s] })).toBe(17.5)
})
})
describe('per-side set counters', () => {
it('setUnits counts a per-side row as two, a straight row as one', () => {
expect(setUnits(makeSideSet({ w: 15, r: 16 }))).toBe(2)
expect(setUnits({ w: 15, r: 16 })).toBe(1)
})
it('doneUnits counts each finished side independently', () => {
const none = makeSideSet({ w: 15, r: 16 })
expect(doneUnits(none)).toBe(0)
expect(doneUnits(toggleSide(none, 'L'))).toBe(1)
expect(doneUnits(toggleSide(toggleSide(none, 'L'), 'R'))).toBe(2)
expect(doneUnits({ w: 15, r: 16, done: true })).toBe(1)
})
it('setUnitsTotal / setsDoneActive account for both sides across the session', () => {
const A = { entries: [
{ id: LIFT, sets: [toggleSide(makeSideSet({ w: 15, r: 16 }), 'L'), makeSideSet({ w: 15, r: 16 })] }, // 2 rows × 2 sides = 4 units, 1 side done
{ id: LIFT, sets: [{ w: 60, r: 8, done: true }] }, // 1 straight, done
] }
expect(setUnitsTotal(A.entries)).toBe(5)
expect(setsDoneActive(A)).toBe(2)
expect(setsDone({ entries: A.entries })).toBe(2)
})
})
+2 -2
View File
@@ -28,10 +28,10 @@ describe('Brazilian Portuguese locale', () => {
const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex')
expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(626)
expect(inherited).toHaveLength(613)
expect(inherited).toHaveLength(615)
// If this fails, review the changed keys and wording before accepting a new hash. From
// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list
expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('81d277306b3029090b7a2ba6cc19108ca207ea65d738487155123260b6e9525d')
expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('1f33b4f41974b95720a8ac936d8fc5e90ae8b705c8dcc039b2d6fe6563ec4355')
})
test('does not leak European Portuguese UI terms', () => {
+79
View File
@@ -128,6 +128,85 @@ export function splitBurstReps(total) {
return bursts
}
// --- one-sided (unilateral) sets (issue #60) -------------------------------------------------
//
// A unilateral exercise (cfg.side, see history.js isPerSide) is trained one limb at a time, and
// asymmetries are the whole point of tracking it — a stronger right that carries a weaker left is
// exactly what a single combined row hides. So a per-side row logs each side on its own: weight,
// reps, effort and its own done tick, held in `sides: { L, R }`.
//
// Like `drops`/`clusters`, this rides on the row while the row's own `w`/`r`/`done`/effort stay a
// correct aggregate of the two sides — so volume, 1RM, PRs, progression, recovery, history and the
// coach keep reading a row's scalar fields and need not know sides exist:
// r = L.r + R.r (the both-sides total, exactly what those readers expect of a per-side set)
// w = max(L.w, R.w) (the heavier side; the two are usually equal)
// done = L.done && R.done (a set counts done only once both sides are)
// effort= the harder side's rating (lower RIR / higher RPE), for the history tail only
// `syncSideAggregate` recomputes those scalars from `sides` after any per-side edit.
export function isSideSet(set) {
const s = objectOf(set)
return !!(s.sides && typeof s.sides === 'object' && s.sides.L && s.sides.R)
}
const sideOf = value => {
const v = objectOf(value)
const out = { w: Number(v.w) || 0, r: Number(v.r) || 0, done: v.done === true }
if (v.rir != null) out.rir = v.rir
if (v.rpe != null) out.rpe = v.rpe
return out
}
// Build a per-side row from a plain row: each side starts as half the row's total reps (a unilateral
// target is always even, so the split is whole) at the same weight, carrying nothing done yet.
export function makeSideSet(row = {}) {
const base = objectOf(row)
const half = Math.round((Number(base.r) || 0) / 2)
const w = Number(base.w) || 0
const side = () => ({ w, r: half, done: false })
const next = { ...base, sides: { L: side(), R: side() } }
// effort/done/reps on the parent become derived — drop any straight-set leftovers so the row
// carries one source of truth, then recompute the aggregate.
delete next.rir; delete next.rpe
return syncSideAggregate(next)
}
// Recompute the row's scalar mirror from its two sides. No-op (returns a shallow copy) for a row
// that is not per-side, so callers can pipe every edit through it unconditionally.
export function syncSideAggregate(row) {
const base = objectOf(row)
if (!isSideSet(base)) return { ...base }
const L = sideOf(base.sides.L)
const R = sideOf(base.sides.R)
const out = { ...base, sides: { L, R }, r: L.r + R.r, w: Math.max(L.w, R.w), done: L.done && R.done }
// The row's effort tail shows the harder side: fewer reps in reserve (lower RIR) or a higher RPE.
// Only one scale is ever in play, matching how a straight row carries rir XOR rpe.
delete out.rir; delete out.rpe
const rirs = [L.rir, R.rir].filter(v => v != null)
const rpes = [L.rpe, R.rpe].filter(v => v != null)
if (rirs.length) out.rir = Math.min(...rirs)
else if (rpes.length) out.rpe = Math.max(...rpes)
return out
}
// Patch one field on one side ('L'|'R'), returning a new row with the aggregate resynced. A null
// value clears an optional field (effort), mirroring how a straight row drops the key.
export function setSideField(row, side, field, value) {
const base = objectOf(row)
if (!isSideSet(base) || (side !== 'L' && side !== 'R')) return { ...base }
const cur = { ...sideOf(base.sides[side]) }
if (value == null && (field === 'rir' || field === 'rpe')) delete cur[field]
else cur[field] = value
return syncSideAggregate({ ...base, sides: { ...base.sides, [side]: cur } })
}
// Flip one side's done tick, resyncing the row's own done (true only when both sides are).
export function toggleSide(row, side) {
const base = objectOf(row)
if (!isSideSet(base) || (side !== 'L' && side !== 'R')) return { ...base }
const cur = { ...sideOf(base.sides[side]), done: !sideOf(base.sides[side]).done }
return syncSideAggregate({ ...base, sides: { ...base.sides, [side]: cur } })
}
export function normalizeMode(value, fallback = 'reps') {
const token = typeof value === 'string' ? value.trim().toLowerCase() : ''
if (MODES.includes(token)) return token
+98
View File
@@ -4,6 +4,7 @@ import {
setType, isDropSet, isRestPauseSet, dropsOf, clustersOf, extraVolumeOf,
addDrop, addCluster, removeDropAt, removeClusterAt, setDropAt, setClusterAt,
nextDropWeight, nextBurstReps, splitBurstReps,
isSideSet, makeSideSet, syncSideAggregate, setSideField, toggleSide,
} from './workout-model.js'
describe('phaseForSet / isWarmupRow', () => {
@@ -179,3 +180,100 @@ describe('modeForSet / modeForEntry stay reps-mode for drop-sets and rest-pause
expect(modeForEntry(entry)).toBe('reps')
})
})
// One-sided (unilateral) sets: each side logged on its own, with the row's scalar w/r/done/effort
// kept as a correct aggregate so every other consumer (volume, 1RM, PRs, progression, counters)
// reads a per-side row exactly as it always read a straight one (issue #60).
describe('isSideSet', () => {
it('is true only for a row carrying both L and R sides', () => {
expect(isSideSet({ sides: { L: { w: 10, r: 8 }, R: { w: 10, r: 8 } } })).toBe(true)
expect(isSideSet({ w: 10, r: 8 })).toBe(false)
expect(isSideSet({ sides: { L: { w: 10, r: 8 } } })).toBe(false)
expect(isSideSet(null)).toBe(false)
})
})
describe('makeSideSet', () => {
it('splits the row total evenly across two sides at the same weight, nothing done', () => {
const s = makeSideSet({ w: 15, r: 16, done: false })
expect(isSideSet(s)).toBe(true)
expect(s.sides.L).toEqual({ w: 15, r: 8, done: false })
expect(s.sides.R).toEqual({ w: 15, r: 8, done: false })
// aggregate mirror: r = both sides, w = the (equal) weight, not done yet
expect(s.r).toBe(16)
expect(s.w).toBe(15)
expect(s.done).toBe(false)
})
it('drops any straight-set effort so the row carries a single source of truth', () => {
const s = makeSideSet({ w: 20, r: 10, rir: 2 })
expect(s.rir).toBeUndefined()
expect(s.rpe).toBeUndefined()
})
})
describe('syncSideAggregate', () => {
it('recomputes r as the sum, w as the heavier side, done only when both sides are', () => {
const row = { sides: { L: { w: 15, r: 8, done: true }, R: { w: 17.5, r: 6, done: false } } }
const s = syncSideAggregate(row)
expect(s.r).toBe(14)
expect(s.w).toBe(17.5)
expect(s.done).toBe(false)
const bothDone = syncSideAggregate({ sides: { L: { w: 15, r: 8, done: true }, R: { w: 15, r: 8, done: true } } })
expect(bothDone.done).toBe(true)
})
it('takes the harder side for the row effort — lower RIR, higher RPE', () => {
const rir = syncSideAggregate({ sides: { L: { w: 15, r: 8, rir: 3 }, R: { w: 15, r: 8, rir: 1 } } })
expect(rir.rir).toBe(1)
expect(rir.rpe).toBeUndefined()
const rpe = syncSideAggregate({ sides: { L: { w: 15, r: 8, rpe: 7 }, R: { w: 15, r: 8, rpe: 9 } } })
expect(rpe.rpe).toBe(9)
expect(rpe.rir).toBeUndefined()
})
it('leaves a non-per-side row alone (returns a copy)', () => {
const s = syncSideAggregate({ w: 20, r: 10, done: true })
expect(s).toEqual({ w: 20, r: 10, done: true })
expect(isSideSet(s)).toBe(false)
})
})
describe('setSideField', () => {
it('patches one side and resyncs the aggregate', () => {
const base = makeSideSet({ w: 15, r: 16 })
const s = setSideField(base, 'R', 'w', 17.5)
expect(s.sides.R.w).toBe(17.5)
expect(s.sides.L.w).toBe(15)
expect(s.w).toBe(17.5) // aggregate = heavier side
})
it('clears an effort field on null, mirroring how a straight row drops the key', () => {
let s = setSideField(makeSideSet({ w: 15, r: 16 }), 'L', 'rir', 2)
expect(s.sides.L.rir).toBe(2)
expect(s.rir).toBe(2)
s = setSideField(s, 'L', 'rir', null)
expect(s.sides.L.rir).toBeUndefined()
expect(s.rir).toBeUndefined()
})
it('ignores an unknown side without throwing', () => {
const base = makeSideSet({ w: 15, r: 16 })
expect(isSideSet(setSideField(base, 'X', 'w', 20))).toBe(true)
})
})
describe('toggleSide', () => {
it('flips one side and marks the row done only once both sides are', () => {
let s = makeSideSet({ w: 15, r: 16 })
expect(s.done).toBe(false)
s = toggleSide(s, 'L')
expect(s.sides.L.done).toBe(true)
expect(s.done).toBe(false) // R still open
s = toggleSide(s, 'R')
expect(s.sides.R.done).toBe(true)
expect(s.done).toBe(true) // both sides done → row done
s = toggleSide(s, 'L')
expect(s.done).toBe(false) // un-tick one side → row no longer done
})
})
+3
View File
@@ -42,6 +42,9 @@ export default {
'rescheduled': 'verschoben',
'Prev': 'Zurück',
'Next': 'Weiter',
// Side badges on a unilateral set's L/R rows (issue #60).
'L': 'L',
'R': 'R',
'Move up': 'Nach oben',
'Move down': 'Nach unten',
// --- days & months ---
+2
View File
@@ -41,6 +41,8 @@ export default {
'rescheduled': 'reprogramado',
'Prev': 'Anterior',
'Next': 'Siguiente',
'L': 'I',
'R': 'D',
'Move up': 'Subir',
'Move down': 'Bajar',
'Sunday': 'Domingo', 'Monday': 'Lunes', 'Tuesday': 'Martes', 'Wednesday': 'Miércoles',
+2
View File
@@ -41,6 +41,8 @@ export default {
'rescheduled': 'reprogrammé',
'Prev': 'Préc.',
'Next': 'Suiv.',
'L': 'G',
'R': 'D',
'Move up': 'Monter',
'Move down': 'Descendre',
'Sunday': 'Dimanche', 'Monday': 'Lundi', 'Tuesday': 'Mardi', 'Wednesday': 'Mercredi',
+2
View File
@@ -41,6 +41,8 @@ export default {
'rescheduled': 'बदला गया',
'Prev': 'पिछला',
'Next': 'अगला',
'L': 'बा',
'R': 'दा',
'Move up': 'ऊपर ले जाएँ',
'Move down': 'नीचे ले जाएँ',
'Sunday': 'रविवार', 'Monday': 'सोमवार', 'Tuesday': 'मंगलवार', 'Wednesday': 'बुधवार',
+2
View File
@@ -43,6 +43,8 @@ export default {
'rescheduled': 'áthelyezve',
'Prev': 'Előző',
'Next': 'Következő',
'L': 'B',
'R': 'J',
// --- days & months ---
'Sunday': 'Vasárnap', 'Monday': 'Hétfő', 'Tuesday': 'Kedd', 'Wednesday': 'Szerda',
'Thursday': 'Csütörtök', 'Friday': 'Péntek', 'Saturday': 'Szombat',
+2
View File
@@ -41,6 +41,8 @@ export default {
'rescheduled': 'riprogrammato',
'Prev': 'Prec.',
'Next': 'Succ.',
'L': 'S',
'R': 'D',
'Move up': 'Sposta su',
'Move down': 'Sposta giù',
'Sunday': 'Domenica', 'Monday': 'Lunedì', 'Tuesday': 'Martedì', 'Wednesday': 'Mercoledì',
+2
View File
@@ -41,6 +41,8 @@ export default {
'rescheduled': '변경됨',
'Prev': '이전',
'Next': '다음',
'L': '좌',
'R': '우',
'Move up': '위로 이동',
'Move down': '아래로 이동',
'Sunday': '일요일', 'Monday': '월요일', 'Tuesday': '화요일', 'Wednesday': '수요일',
+2
View File
@@ -41,6 +41,8 @@ export default {
'rescheduled': 'przełożono',
'Prev': 'Wstecz',
'Next': 'Dalej',
'L': 'L',
'R': 'P',
'Move up': 'Przenieś w górę',
'Move down': 'Przenieś w dół',
'Sunday': 'Niedziela', 'Monday': 'Poniedziałek', 'Tuesday': 'Wtorek', 'Wednesday': 'Środa',
+2
View File
@@ -41,6 +41,8 @@ export default {
'rescheduled': 'reagendado',
'Prev': 'Anterior',
'Next': 'Seguinte',
'L': 'E',
'R': 'D',
'Move up': 'Mover para cima',
'Move down': 'Mover para baixo',
'Sunday': 'Domingo', 'Monday': 'Segunda-feira', 'Tuesday': 'Terça-feira', 'Wednesday': 'Quarta-feira',
+2
View File
@@ -41,6 +41,8 @@ export default {
'rescheduled': 'перенесено',
'Prev': 'Назад',
'Next': 'Далее',
'L': 'Л',
'R': 'П',
'Move up': 'Переместить вверх',
'Move down': 'Переместить вниз',
'Sunday': 'Воскресенье', 'Monday': 'Понедельник', 'Tuesday': 'Вторник', 'Wednesday': 'Среда',
+2
View File
@@ -43,6 +43,8 @@ export default {
'rescheduled': 'เลื่อนแล้ว',
'Prev': 'ก่อนหน้า',
'Next': 'ถัดไป',
'L': 'ซ',
'R': 'ข',
// --- days & months ---
'Sunday': 'วันอาทิตย์', 'Monday': 'วันจันทร์', 'Tuesday': 'วันอังคาร', 'Wednesday': 'วันพุธ',
'Thursday': 'วันพฤหัสบดี', 'Friday': 'วันศุกร์', 'Saturday': 'วันเสาร์',
+2
View File
@@ -41,6 +41,8 @@ export default {
'rescheduled': 'ertelendi',
'Prev': 'Önceki',
'Next': 'Sonraki',
'L': 'L',
'R': 'R',
'Move up': 'Yukarı taşı',
'Move down': 'Aşağı taşı',
'Sunday': 'Pazar', 'Monday': 'Pazartesi', 'Tuesday': 'Salı', 'Wednesday': 'Çarşamba',
+2
View File
@@ -41,6 +41,8 @@ export default {
'rescheduled': '已改期',
'Prev': '上一个',
'Next': '下一个',
'L': '左',
'R': '右',
'Move up': '上移',
'Move down': '下移',
'Sunday': '星期日', 'Monday': '星期一', 'Tuesday': '星期二', 'Wednesday': '星期三',
+2 -2
View File
@@ -4,7 +4,7 @@ import { useUI } from './store/useUI.js'
import { EXDB, EXIDX, BODYPARTS, isCardio, isBodyweightEq, allExercises, equipmentOf, smOf, matchExercise, exOr } from './lib/exercises.js'
import { activeProfile, exAvailable, ALL_EQUIPMENT, newProfile } from './lib/equipment.js'
import { fmtDate, fmtNum, fmtVol, fmtDur, durPart, todayISO, isoOf, uid, exCount, DAYN, DAYS, weekOrder, weekStartOf, weekDayOffset, MONTHS_LONG, ACCENTS } from './lib/format.js'
import { lastEntryFor, bestWeightFor, bestWeightForEntry, buildSets, effectiveRoutineId, workoutVolume, setsDone, setsDoneActive, lastBW, supersetUnits, unitOf, setLabel, defaultConfig, cleanupSg, modeOf, effortOf, EFFORT, capEffort, stepEffort, isBw, isPerSide, sideReps, workSetsDone, applyIntensifierPlan, MAX_PLANNED_WARMUPS, NOTE_MAX } from './lib/history.js'
import { lastEntryFor, bestWeightFor, bestWeightForEntry, buildSets, effectiveRoutineId, workoutVolume, setsDone, setsDoneActive, setUnitsTotal, lastBW, supersetUnits, unitOf, setLabel, defaultConfig, cleanupSg, modeOf, effortOf, EFFORT, capEffort, stepEffort, isBw, isPerSide, sideReps, workSetsDone, applyIntensifierPlan, MAX_PLANNED_WARMUPS, NOTE_MAX } from './lib/history.js'
import { usesBar, barWeightFor, defaultBarWeight, hasBarOverride } from './lib/bar.js'
import { toScale, rirOf, EFFORT_PRESETS, effortColor } from './lib/effort.js'
import { beep, vibrate } from './lib/sound.js'
@@ -1939,7 +1939,7 @@ export function finishWorkout() {
const A = S().active
if (!A) return
const done = setsDoneActive(A)
const total = A.entries.reduce((n, e) => n + e.sets.length, 0)
const total = setUnitsTotal(A.entries)
if (!done) { confirmSheet({ title: t('Nothing logged yet'), message: t('You haven’t checked off any sets. Finish the workout anyway?'), confirmText: t('Finish anyway'), onConfirm: doFinishWorkout }); return }
if (done < total) { confirmSheet({ title: t('Finish early?'), message: t(total - done === 1 ? '{0} set still unchecked. Finish the workout now?' : '{0} sets still unchecked. Finish the workout now?', total - done), confirmText: t('Finish workout'), onConfirm: doFinishWorkout }); return }
doFinishWorkout()
+90 -11
View File
@@ -5,7 +5,7 @@ import { workoutControls } from '../lib/workout-controls.js'
import { useUI } from '../store/useUI.js'
import { exOr } from '../lib/exercises.js'
import { usesBar, barWeightFor, plateSplit } from '../lib/bar.js'
import { effectiveRoutine, lastEntryFor, bestWeightFor, bestWeightForEntry, buildSets, freestyleConfig, defaultConfig, setsDoneActive, supersetUnits, unitOf, setLabel, modeOf, isBw, isPerSide, sideReps, repStep, EFFORT, effortOf, stepEffort, capEffort, cascadeWeight, insertWarmupRow, removeRowAt, pairAdjacent, unpairSuperset, cleanupSg, applyIntensifierPlan, pinnedNoteFor, exNoteFor } from '../lib/history.js'
import { effectiveRoutine, lastEntryFor, bestWeightFor, bestWeightForEntry, buildSets, freestyleConfig, defaultConfig, setsDoneActive, setUnitsTotal, supersetUnits, unitOf, setLabel, modeOf, isBw, isPerSide, sideReps, repStep, EFFORT, effortOf, stepEffort, capEffort, cascadeWeight, insertWarmupRow, removeRowAt, pairAdjacent, unpairSuperset, cleanupSg, applyIntensifierPlan, pinnedNoteFor, exNoteFor } from '../lib/history.js'
import { fmtNum, fmtDate, todayISO, exCount, DAYN } from '../lib/format.js'
import { beep, vibrate } from '../lib/sound.js'
import { t, exerciseNameFor } from '../lib/i18n.js'
@@ -19,7 +19,7 @@ import { Button, Check, NumberField } from '../components/ui.jsx'
import { nextPrescription, applyPrescription, defaultIncrement, weightIncrement, stepWeight } from '../lib/progression.js'
import { progressionGuidance } from '../lib/progression-copy.js'
import { glyphOf } from '../lib/glyphs.js'
import { isWarmupRow, isDropSet, isRestPauseSet, dropsOf, clustersOf, addDrop, addCluster, removeDropAt, removeClusterAt, setDropAt, setClusterAt, nextDropWeight, nextBurstReps } from '../lib/workout-model.js'
import { isWarmupRow, isDropSet, isRestPauseSet, dropsOf, clustersOf, addDrop, addCluster, removeDropAt, removeClusterAt, setDropAt, setClusterAt, nextDropWeight, nextBurstReps, isSideSet, makeSideSet, setSideField, toggleSide } from '../lib/workout-model.js'
import { canMoveActiveWorkoutUnit, moveActiveWorkoutUnit } from '../lib/active-workout-order.js'
const SWIPE_MIN_DISTANCE = 48
@@ -65,7 +65,7 @@ function Elapsed({ start }) {
}
/* ---------- one exercise block (reps: weight×reps · time: a held duration · cardio: duration+speed) ---------- */
function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemoveSet, onAddWarmup, onRemoveSetAt, onStartTimed, onPairPrev, onPairNext, onSetRowRef, onProgressionSettings, onSwap, onMoveUp, onMoveDown, canMoveUp, canMoveDown, onRemoveExercise, busy }) {
function ExerciseBlock({ entryIdx, compact, onToggle, onToggleSide, onField, onAddSet, onRemoveSet, onAddWarmup, onRemoveSetAt, onStartTimed, onPairPrev, onPairNext, onSetRowRef, onProgressionSettings, onSwap, onMoveUp, onMoveDown, canMoveUp, canMoveDown, onRemoveExercise, busy }) {
const S = useStore(s => s.S)
const update = useStore(s => s.update)
const working = useUI(s => s.work)
@@ -90,6 +90,11 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov
const added = nextBurstReps(base)
return { ...addCluster(row, { r: added, restSec }), r: (row.r || 0) + added }
})
// Per-side weight/reps/effort edits (issue #60): patch one side of a unilateral row, keeping
// the row's aggregate (r/w/done/effort) in step via the model helper so every other reader
// stays right. The done tick goes through onToggleSide → toggle() instead, so ticking a side
// still fires the rest timer / auto-advance / workout-complete flow.
const setSide = (i, side, field, v) => mutSet(i, row => setSideField(row, side, field, v))
const removeDrop = (i, di) => mutSet(i, row => removeDropAt(row, di))
const removeCluster = (i, ci) => mutSet(i, row => {
const removed = clustersOf(row)[ci]?.r || 0
@@ -120,6 +125,9 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov
// config brings it back, now labelled as the addition it is.
const cfg = { ...(entry.target || {}), id: entry.id }
const bw = !cardio && isBw(cfg)
// A unilateral exercise logs each side on its own (issue #60): work rows render as an L and an
// R sub-row, each with its own weight/reps/effort and done tick. Warm-ups stay single.
const perSide = mode === 'reps' && isPerSide(cfg)
const added = bw && entry.sets.some(s => s.w > 0)
const loadStep = mode === 'reps' ? weightIncrement(cfg, S.unit) : 2.5
const loadCol = { f: 'w', step: loadStep, dec: true, hd: bw ? t('Added ({0})', S.unit) : t('Weight ({0})', S.unit) }
@@ -203,8 +211,8 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov
title: (warm ? t('Warm-up') : t('Set {0}', entry.sets.slice(0, i + 1).filter(x => isWarmupRow(x) === warm).length)),
subtitle: setLabel(entry.id, s, entry.target),
items: [
!warm && mode === 'reps' && !isRestPauseSet(s) && { icon: 'arrowDown', label: t('Drop set'), sub: t('+ Drop'), onClick: () => addDropRow(i) },
!warm && mode === 'reps' && !isDropSet(s) && { icon: 'bolt', label: t('Rest-pause burst'), sub: t('+ Burst'), onClick: () => addBurstRow(i) },
!warm && mode === 'reps' && !perSide && !isRestPauseSet(s) && { icon: 'arrowDown', label: t('Drop set'), sub: t('+ Drop'), onClick: () => addDropRow(i) },
!warm && mode === 'reps' && !perSide && !isDropSet(s) && { icon: 'bolt', label: t('Rest-pause burst'), sub: t('+ Burst'), onClick: () => addBurstRow(i) },
{ icon: 'trash', label: t('Remove this set'), danger: true, disabled: entry.sets.length <= 1, onClick: () => onRemoveSetAt(i) },
],
})
@@ -232,6 +240,52 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov
</div>
)
}
// Per-side versions of the weight/reps stepper and the effort picker. Same markup and stepping
// rules as the row-level `cell`/`effortCell`, but bound to one side of a unilateral row and
// routed through setSide so the aggregate stays correct. Reads the live side value from the
// store for the same stale-closure reason `bump` does.
const sideBump = (i, side, col, dir) => {
const fresh = useStore.getState().S.active?.entries[entryIdx]?.sets[i]?.sides?.[side]
const cur = fresh ? fresh[col.f] : 0
if (col.f === 'w') return setSide(i, side, col.f, stepWeight(cur, col.step, dir))
setSide(i, side, col.f, Math.max(0, Math.round(((cur || 0) + dir * col.step) * 100) / 100))
}
const sideCell = (sd, i, side, col, cls) => (
<div className={'stp ' + cls + (wc.steppers ? '' : ' plain')}>
{wc.steppers && <button aria-label="Decrease" onClick={() => sideBump(i, side, col, -1)}><Icon name="minus" /></button>}
<span className="val"><NumberField decimal={col.dec} value={sd[col.f] ?? ''}
onChange={v => setSide(i, side, col.f, v)} /></span>
{wc.steppers && <button aria-label="Increase" onClick={() => sideBump(i, side, col, 1)}><Icon name="plus" /></button>}
</div>
)
const sideEffortCell = (sd, i, side, col) => {
const v = sd[col.f] ?? null
const rir = col.eff === 'rpe' ? (v == null ? null : 10 - v) : v
const color = effortColor(rir)
const open = () => effortPickerSheet(col.eff, v, nv => setSide(i, side, col.f, nv))
if (v == null) return <button className="effcell is-empty" aria-label={col.hd} onClick={open}>{col.hd}</button>
const step = dir => setSide(i, side, col.f, stepEffort(col.eff, v, dir))
return (
<div className={'stp effcell-stp' + (wc.steppers ? '' : ' plain')}
style={color ? { color, borderColor: color, background: `color-mix(in srgb, ${color} 20%, var(--surface-2))` } : undefined}>
{wc.steppers && <button aria-label="Decrease" onClick={() => step(-1)}><Icon name="minus" /></button>}
<button className="val" aria-label={col.hd} onClick={open}>{fmtNum(v)}</button>
{wc.steppers && <button aria-label="Increase" onClick={() => step(1)}><Icon name="plus" /></button>}
</div>
)
}
// One side's row: the L or R badge, then the same weight/reps/effort controls as a straight
// row but bound to that side, and the side's own done tick.
const sideRow = (s, i, side, col1, col2, col3) => {
const sd = (s.sides && s.sides[side]) || { w: 0, r: 0, done: false }
return <div className={'setrow side' + (sd.done ? ' done' : '') + (col3 ? ' eff3' : '')}>
<span className="sidetag" aria-hidden="true">{side === 'L' ? t('L') : t('R')}</span>
{sideCell(sd, i, side, col1, 'w')}
{col2 && sideCell(sd, i, side, col2, 'r')}
{col3 && sideEffortCell(sd, i, side, col3)}
<Check checked={sd.done} onChange={() => onToggleSide(i, side)} />
</div>
}
// A smaller stepper for a drop's weight/reps or a burst's reps — editing what the plan (or a
// live "+ Drop"/"+ Burst" tap) already put on the row, not typing into a fresh field.
const miniStepper = (value, step, dec, onChange, snapWeightStep = false) => (
@@ -300,6 +354,17 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov
return <div key={i}>
{isFirstWarmup && <div className="setph">{t('Warm-up')}</div>}
{!warm && warmBefore && <div className="setsep" />}
{perSide && !warm && isSideSet(s) ? (
// Unilateral work set: the number sits beside a two-row L/R stack, each side logged
// and ticked on its own (issue #60).
<div ref={el => onSetRowRef?.(i, el)} className={'setrow-side' + (s.done ? ' done' : '')}>
<button type="button" className="n" aria-label={t('Set {0}', phaseNum)} title={t('More')} onClick={() => openSetMenu(s, i)}>{phaseNum}</button>
<div className="side-rows">
{sideRow(s, i, 'L', col1, col2, col3)}
{sideRow(s, i, 'R', col1, col2, col3)}
</div>
</div>
) : (
<div ref={el => onSetRowRef?.(i, el)} className={'setrow' + (s.done ? ' done' : '') + (col3 ? ' eff3' : '')}>
<button type="button" className="n" aria-label={t('Set {0}', phaseNum)} title={t('More')} onClick={() => openSetMenu(s, i)}>{phaseNum}</button>
{cell(s, i, col1, 'w')}
@@ -311,10 +376,11 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov
onClick={() => onStartTimed(i)}><Icon name="play" /></button>}
<Check checked={s.done} onChange={() => onToggle(i)} />
</div>
)}
{/* Drop-sets and rest-pause bursts extend this same row — no long rest, no new set.
A planned exercise arrives with these already filled in (applyIntensifierPlan);
every value here is just as editable as the main row's own weight/reps. */}
{!warm && mode === 'reps' && <>
{!warm && mode === 'reps' && !perSide && <>
{dropsOf(s).map((d, di) => (
<div className="subrow" key={'d' + di}>
<span className="subn">{t('Drop {0}', di + 1)}</span>
@@ -441,7 +507,7 @@ function ActiveWorkout() {
if (el && typeof el.scrollIntoView === 'function') el.scrollIntoView({ behavior: 'smooth', block: 'center' })
}, [cur, isSuperset, listMode, A.entries.length])
const total = A.entries.reduce((n, e) => n + e.sets.length, 0)
const total = setUnitsTotal(A.entries)
const done = setsDoneActive(A)
const mutEntry = (idx, fn) => update(s => { fn(s.active.entries[idx]) }, true)
@@ -461,7 +527,16 @@ function ActiveWorkout() {
const m = modeOf({ ...(e.target || {}), id: e.id })
if (m === 'cardio') e.sets.push({ min: l ? l.min : (e.target.min || 20), speed: l ? l.speed : (e.target.speed || 8), done: false })
else if (m === 'time') e.sets.push({ sec: l ? l.sec : (e.target.sec || 45), w: l ? (l.w || 0) : (e.target.weight || 0), done: false })
else e.sets.push({ w: l ? l.w : 0, r: l ? l.r : e.target.reps, done: false })
else {
const row = { w: l ? l.w : 0, r: l ? l.r : e.target.reps, done: false }
// A unilateral exercise keeps adding per-side rows (issue #60): seed each side from the
// previous set's own side when it had one, else split the row's total evenly.
e.sets.push(isPerSide({ ...(e.target || {}), id: e.id })
? (l && isSideSet(l)
? makeSideSet({ w: l.sides.L.w, r: (l.sides.L.r || 0) * 2 })
: makeSideSet(row))
: row)
}
})
const removeSet = idx => mutEntry(idx, e => { if (e.sets.length > 1) e.sets.pop() })
const addWarmup = idx => mutEntry(idx, e => {
@@ -510,6 +585,7 @@ function ActiveWorkout() {
onRemoveExercise: () => confirmRemoveExercise(idx),
busy: !!work,
onToggle: i => toggle(idx, i),
onToggleSide: (i, side) => toggle(idx, i, side),
onField: (i, f, v) => setField(idx, i, f, v),
onAddSet: () => addSet(idx),
onRemoveSet: () => removeSet(idx),
@@ -641,13 +717,16 @@ function ActiveWorkout() {
})
}
const toggle = (idx, i) => {
const toggle = (idx, i, side) => {
const m = modeAt(idx)
const cardioEntry = m === 'cardio'
let exJustDone = false, workoutDone = false, checked = false
update(s => {
const e = s.active.entries[idx]
e.sets[i].done = !e.sets[i].done
// A per-side tick flips just that side; the row's own `done` (both sides) is then
// recomputed by toggleSide, so every completion check below still reads a single boolean.
if (side) e.sets[i] = toggleSide(e.sets[i], side)
else e.sets[i].done = !e.sets[i].done
checked = e.sets[i].done
if (e.sets[i].done) {
beep(S.sound, 1040, 0.12); vibrate(30)
@@ -727,7 +806,7 @@ function ActiveWorkout() {
const u = supersetUnits(A2.entries)
const c = Math.min(A2.cur, Math.max(0, A2.entries.length - 1))
const ui = u.findIndex(x => x.includes(c))
const tot = A2.entries.reduce((n, e) => n + e.sets.length, 0)
const tot = setUnitsTotal(A2.entries)
api('/api/activity', { method: 'POST', body: JSON.stringify({
active, name: A2.name, exIdx: ui + 1, exTotal: u.length,
setsDone: setsDoneActive(A2), setsTotal: tot, startedAt: A2.start