Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Pyramid sets: a weight field per set (#445)

Tufail Akram9a561565cfa7
diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.js
index 7247ac061..cbe70a194 100644
--- a/frontend/src/lib/history.js
+++ b/frontend/src/lib/history.js
@@ -18,7 +18,7 @@ const workRowsForMode = (entry = {}, mode = 'reps') => {
// gets dragged along behind it.
import { t } from './i18n-core.js'
import { queueNext, pinState, queueLiveOn } from './queue.js'
-import { isPyramid, pyramidLabel, pyramidTargetAt, PYRAMID_MAX } from './pyramid.js'
+import { isPyramid, pyramidLabel, pyramidTargetAt, pyramidWeightAt, PYRAMID_MAX } from './pyramid.js'
// How an exercise is logged (issue #16). This used to be derived from the body part alone,
// which meant a plank or a farmer's carry could only be timed by filing it under cardio.
@@ -564,6 +564,13 @@ function buildWorkSets(S, cfg, options = {}) {
const seed = usable || (lastRegular && lastRegular.r > 0 ? lastRegular : null)
if (target === PYRAMID_MAX) { row.r = seed ? seed.r : 0; row.max = true }
else row.r = target
+ // Each set's weight is the plan's own for that set, else what that same set lifted last
+ // time. The flat `weight` is no pyramid field the editor shows, so it is only the first
+ // session's fallback — ahead of history it handed every set one hidden number (#445).
+ // Freestyle keeps reproducing what you did (preferLast) once there is something to copy.
+ const planned = pyramidWeightAt(cfg, i)
+ if (planned > 0 && !(preferLast && usable)) row.w = planned
+ else if (useTarget && seed) row.w = seed.w
}
// 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
diff --git a/frontend/src/lib/plan-share.js b/frontend/src/lib/plan-share.js
index 786c3ece6..8439b1e58 100644
--- a/frontend/src/lib/plan-share.js
+++ b/frontend/src/lib/plan-share.js
@@ -12,7 +12,7 @@ import { EXIDX, isBodyweightEq } from './exercises.js'
import { cleanUrl } from './media-refs.js'
import { modeOf, exLine, MAX_PLANNED_WARMUPS } from './history.js'
import { deriveSessionName } from './session-merge.js'
-import { isPyramid, normalizePyramid, normalizePyramidRest } from './pyramid.js'
+import { isPyramid, normalizePyramid, normalizePyramidRest, normalizePyramidWeight } from './pyramid.js'
import { uid, todayISO, DAYN, weekOrder, weekStartOf, exCount } from './format.js'
import { t, exerciseNameFor, exerciseNameClass, getLang, RTL_LANGS } from './i18n-core.js'
import { convertWeight } from './units.js'
@@ -46,6 +46,7 @@ function convertedExercise(e, sourceUnit, destinationUnit) {
if (out.weight != null) out.weight = convertWeight(out.weight, sourceUnit, destinationUnit)
// A timed increment is seconds, not a load. Rep-mode increments are load overrides.
if (modeOf(out) === 'reps' && out.inc > 0) out.inc = convertWeight(out.inc, sourceUnit, destinationUnit)
+ if (Array.isArray(out.pyramidWeight)) out.pyramidWeight = out.pyramidWeight.map(w => (w > 0 ? convertWeight(w, sourceUnit, destinationUnit) : w))
return out
}
@@ -83,6 +84,8 @@ function cleanEx(e) {
o.pyramid = normalizePyramid(e.pyramid)
const rest = normalizePyramidRest(e.pyramidRest, o.pyramid.length)
if (rest.length) o.pyramidRest = rest
+ const weight = normalizePyramidWeight(e.pyramidWeight, o.pyramid.length)
+ if (weight.length) o.pyramidWeight = weight
}
}
// How the exercise is logged travels too (issues #31/#32) — the bodyweight flag only when
@@ -232,8 +235,9 @@ export function parsePlan(raw, destinationUnit = 'kg') {
const warmRest = cleanRestSec(e.warmupRestSec)
const pyramid = normalizePyramid(e.pyramid)
const pyramidRest = pyramid.length ? normalizePyramidRest(e.pyramidRest, pyramid.length) : []
- const { warmupSets, intensifier, restSec, warmupRestSec, pyramid: _pyramid, pyramidRest: _pyramidRest, ...passthrough } = e
- return convertedExercise({ ...passthrough, ...(pyramid.length ? { pyramid } : {}), ...(pyramidRest.length ? { pyramidRest } : {}), ...(warm ? { warmupSets: warm } : {}), ...(intens ? { intensifier: intens } : {}), ...(rest ? { restSec: rest } : {}), ...(warmRest ? { warmupRestSec: warmRest } : {}) }, sourceUnit || destination, destination)
+ const pyramidWeight = pyramid.length ? normalizePyramidWeight(e.pyramidWeight, pyramid.length) : []
+ const { warmupSets, intensifier, restSec, warmupRestSec, pyramid: _pyramid, pyramidRest: _pyramidRest, pyramidWeight: _pyramidWeight, ...passthrough } = e
+ return convertedExercise({ ...passthrough, ...(pyramid.length ? { pyramid } : {}), ...(pyramidRest.length ? { pyramidRest } : {}), ...(pyramidWeight.length ? { pyramidWeight } : {}), ...(warm ? { warmupSets: warm } : {}), ...(intens ? { intensifier: intens } : {}), ...(rest ? { restSec: rest } : {}), ...(warmRest ? { warmupRestSec: warmRest } : {}) }, sourceUnit || destination, destination)
})
}))
return {
diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js
index 8fa4c3706..dc13dca69 100644
--- a/frontend/src/lib/pt-br-locale.test.js
+++ b/frontend/src/lib/pt-br-locale.test.js
@@ -41,7 +41,7 @@ describe('Brazilian Portuguese locale', () => {
// has to be taught is a number nobody reads. What the numbers stood for is asserted above.
// If the hash fails, review the changed keys and wording before accepting a new one. From
// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list
- expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('5304c30895afe32bf14334f32497355b645f481f695c582e3b28161a23cba864')
+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('099bc2e39ef6dd7d07ea9ead592a4c0b9da9e6883e89cc29562308ef128c3bb3')
})
test('does not leak European Portuguese UI terms', () => {
diff --git a/frontend/src/lib/pyramid.js b/frontend/src/lib/pyramid.js
index bbb6bf824..6d497d3f4 100644
--- a/frontend/src/lib/pyramid.js
+++ b/frontend/src/lib/pyramid.js
@@ -1,5 +1,6 @@
// Pyramid sets (CONTEXT.md): one rep target per set, in order — a number, or PYRAMID_MAX for
-// "as many reps as you can". No load is prescribed and the exercise is never progressed.
+// "as many reps as you can". A set may carry its own planned weight (pyramidWeight); the
+// exercise is never progressed.
// Imports nothing from history.js, which imports this module.
import { t } from './i18n-core.js'
import { isWarmupRow } from './workout-model.js'
@@ -66,6 +67,25 @@ export function normalizePyramidRest(rest, length) {
return out.some(v => v > 0) ? out : []
}
+// Each set's own planned weight, beside the targets (`pyramidWeight[i]` for `pyramid[i]`), in
+// the plan's unit. 0 is "no plan": the set starts from what that same set lifted last time.
+// Sized to the list; all zeros is no field at all, like pyramidRest.
+export function normalizePyramidWeight(weights, length) {
+ const src = Array.isArray(weights) ? weights : []
+ const out = Array.from({ length }, (_, i) => {
+ const w = Number(src[i])
+ return Number.isFinite(w) && w > 0 ? Math.round(w * 100) / 100 : 0
+ })
+ return out.some(v => v > 0) ? out : []
+}
+
+/** The weight planned for work set `i` of a pyramid, or 0 when that set has none. An extra set
+ * added mid-session copies the last one's, like its target. */
+export function pyramidWeightAt(cfg, i) {
+ if (!isPyramid(cfg) || !Array.isArray(cfg.pyramidWeight) || !cfg.pyramidWeight.length) return 0
+ return Math.max(0, Number(pyramidTargetAt(cfg.pyramidWeight, i)) || 0)
+}
+
/** The rest a ticked work row of a pyramid earns, or 0 to fall back to the exercise's rest.
* `i` indexes `rows`, warm-ups included; the pyramid counts work sets only. */
export function pyramidRestFor(target, rows, i) {
diff --git a/frontend/src/lib/pyramid.test.js b/frontend/src/lib/pyramid.test.js
index 51b9e7521..12997e7b9 100644
--- a/frontend/src/lib/pyramid.test.js
+++ b/frontend/src/lib/pyramid.test.js
@@ -2,11 +2,12 @@ import { describe, expect, it } from 'vitest'
import {
PYRAMID_MAX, MAX_PYRAMID_SETS, isPyramid, normalizePyramid, pyramidFromFlat,
flatFromPyramid, pyramidLabel, pyramidTargetAt, PYRAMID_PRESETS, normalizePyramidRest, pyramidRestFor,
- maxRecordAt, maxRepsSeries,
+ normalizePyramidWeight, pyramidWeightAt, maxRecordAt, maxRepsSeries,
} from './pyramid.js'
import { buildSets, setsRepsOf } from './history.js'
import { policyFor } from './progression.js'
import { buildPlanBundle, parsePlan } from './plan-share.js'
+import { convertWeight } from './units.js'
// Pyramid sets (CONTEXT.md): one rep target per set, in order, a set's target being a number or
// "max". No load is prescribed and the exercise is never progressed automatically.
@@ -211,6 +212,59 @@ describe('rest per set (pyramidRest)', () => {
})
})
+describe('weight per set (pyramidWeight, #445)', () => {
+ const lastTime = {
+ exWeights: {},
+ workouts: [{ id: 'w1', d: '2026-09-28', entries: [{ id: LIFT, sets: [
+ { w: 60, r: 12, done: true }, { w: 70, r: 8, done: true }, { w: 80, r: 6, done: true },
+ { w: 85, r: 9, done: true, max: true }, { w: 50, r: 12, done: true },
+ ] }] }],
+ }
+ it('normalizePyramidWeight sizes the list, keeps decimals and drops an all-zero one', () => {
+ expect(normalizePyramidWeight([40, 52.5], 4)).toEqual([40, 52.5, 0, 0])
+ expect(normalizePyramidWeight([40, 50, 60, 70], 2)).toEqual([40, 50])
+ expect(normalizePyramidWeight([0, 0], 2)).toEqual([])
+ expect(normalizePyramidWeight(undefined, 3)).toEqual([])
+ expect(normalizePyramidWeight([-5, 'x', 61.256], 3)).toEqual([0, 0, 61.26])
+ })
+ it('pyramidWeightAt is the set’s own weight, the last one past the list, 0 without one', () => {
+ const cfg = pyramidCfg({ pyramidWeight: [40, 50, 60, 0, 40] })
+ expect(pyramidWeightAt(cfg, 1)).toBe(50)
+ expect(pyramidWeightAt(cfg, 3)).toBe(0)
+ expect(pyramidWeightAt(cfg, 7)).toBe(40)
+ expect(pyramidWeightAt(pyramidCfg(), 0)).toBe(0)
+ expect(pyramidWeightAt({ mode: 'reps', sets: 3, reps: 10, pyramidWeight: [40] }, 0)).toBe(0)
+ })
+ it('a first session opens each set at its planned weight', () => {
+ const rows = buildSets({ exWeights: {}, workouts: [] }, pyramidCfg({ pyramidWeight: [40, 50, 60, 70, 40] }))
+ expect(rows.map(r => r.w)).toEqual([40, 50, 60, 70, 40])
+ })
+ it('a planned session uses each set’s planned weight, and last time’s for a set left at 0', () => {
+ const rows = buildSets(lastTime, pyramidCfg({ pyramidWeight: [65, 0, 90, 0, 0] }), { useTarget: true, planReps: true })
+ expect(rows.map(r => r.w)).toEqual([65, 70, 90, 85, 50])
+ })
+ it('a hidden flat weight no longer overrides last time in a planned session', () => {
+ const rows = buildSets(lastTime, pyramidCfg({ weight: 100 }), { useTarget: true, planReps: true })
+ expect(rows.map(r => r.w)).toEqual([60, 70, 80, 85, 50])
+ })
+ it('the flat weight is still the first session’s fallback', () => {
+ const rows = buildSets({ exWeights: {}, workouts: [] }, pyramidCfg({ weight: 40 }), { useTarget: true, planReps: true })
+ expect(rows.map(r => r.w)).toEqual([40, 40, 40, 40, 40])
+ })
+ it('freestyle copies what you lifted, and the plan only when there is nothing to copy', () => {
+ const cfg = pyramidCfg({ pyramidWeight: [65, 75, 90, 95, 55] })
+ expect(buildSets(lastTime, cfg, { preferLast: true }).map(r => r.w)).toEqual([60, 70, 80, 85, 50])
+ expect(buildSets({ exWeights: {}, workouts: [] }, cfg, { preferLast: true }).map(r => r.w)).toEqual([65, 75, 90, 95, 55])
+ })
+ it('travels with a shared plan and converts between kg and lb', () => {
+ const stateWith = ex => ({ unit: 'kg', routines: [{ id: 'r1', name: 'Legs', ex: [ex] }], week: {}, customEx: [] })
+ const bundle = JSON.stringify(buildPlanBundle(stateWith(pyramidCfg({ pyramidWeight: [40, 60, 80, 0, 40] })), 'Plan'))
+ expect(parsePlan(bundle, 'kg').routines[0].ex[0].pyramidWeight).toEqual([40, 60, 80, 0, 40])
+ expect(parsePlan(bundle, 'lb').routines[0].ex[0].pyramidWeight)
+ .toEqual([40, 60, 80, 0, 40].map(w => (w > 0 ? convertWeight(w, 'kg', 'lb') : 0)))
+ })
+})
+
describe('Max set records (Q20, Q21)', () => {
const workouts = [
{ id: 'a', d: '2026-09-01', start: 1, entries: [{ id: LIFT, sets: [{ w: 85, r: 9, done: true, max: true }, { w: 50, r: 12, done: true }] }] },
diff --git a/frontend/src/lib/units.js b/frontend/src/lib/units.js
index 62780d298..5f6c78426 100644
--- a/frontend/src/lib/units.js
+++ b/frontend/src/lib/units.js
@@ -42,6 +42,8 @@ const convTarget = (cfg, from, to) => {
// A per-exercise increment is a load too — 2.5 kg is 5 lb, not 2.5 lb.
if (out.inc > 0 && (out.mode == null || out.mode === 'reps')) out.inc = convertWeight(out.inc, from, to)
if (Array.isArray(out.warmup)) out.warmup = out.warmup.map(w => (w && w.weight != null ? { ...w, weight: convertWeight(w.weight, from, to) } : w))
+ // A pyramid's own weight per set; 0 ("no plan for this set") stays 0.
+ if (Array.isArray(out.pyramidWeight)) out.pyramidWeight = out.pyramidWeight.map(w => (w > 0 ? convertWeight(w, from, to) : w))
return out
}
// A bar is a stamped object, not a number: the 45 lb bar IS the 20 kg bar (44.1 lb), so an
diff --git a/frontend/src/lib/units.test.js b/frontend/src/lib/units.test.js
index a5381596d..0a9146ed5 100644
--- a/frontend/src/lib/units.test.js
+++ b/frontend/src/lib/units.test.js
@@ -51,6 +51,10 @@ describe('convertStateUnit', () => {
it('is a no-op for the unit already in use', () => {
expect(convertStateUnit(S, 'kg')).toBe(S)
})
+ it('converts a pyramid’s weight per set, leaving a set at 0 at 0 (#445)', () => {
+ const state = { ...S, routines: [{ id: 'r', ex: [{ id: '0025', sets: 3, reps: 12, weight: 0, pyramid: [12, 10, 8], pyramidWeight: [60, 0, 80] }] }] }
+ expect(convertStateUnit(state, 'lb').routines[0].ex[0].pyramidWeight).toEqual([132.5, 0, 176.5])
+ })
// History rows, the detail header, the month calendar and the heatmap tooltips read the
// cached `vol` and `bw` off the saved workout rather than summing sets, so a conversion that
// skips them shows kg totals under an lb label (QA C11).
diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.js
index b92f6745e..e1e23aa66 100644
--- a/frontend/src/locales/ar.js
+++ b/frontend/src/locales/ar.js
@@ -1767,6 +1767,7 @@ export default {
'Max reps': 'تكرارات أقصى',
'Most reps in a Max set per workout': 'أكبر عدد تكرارات في مجموعة أقصى لكل تمرين',
'A set left at 0 rest uses the exercise’s rest.': 'المجموعة ذات الراحة 0 تستخدم راحة التمرين.',
+ 'A set left at 0 weight starts from that set’s weight last time.': 'المجموعة ذات الوزن 0 تبدأ من وزن المجموعة نفسها في المرة السابقة.',
// --- update a routine from a running workout ---
'Update routine': 'تحديث الروتين',
'Update “{0}”?': 'تحديث «{0}»؟',
diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js
index 7fdb20e04..5e77c9f1f 100644
--- a/frontend/src/locales/de.js
+++ b/frontend/src/locales/de.js
@@ -1734,6 +1734,7 @@ export default {
'Max reps': 'Max-Wdh.',
'Most reps in a Max set per workout': 'Meiste Wiederholungen in einem Max-Satz pro Training',
'A set left at 0 rest uses the exercise’s rest.': 'Ein Satz mit 0 Pause nutzt die Pause der Übung.',
+ 'A set left at 0 weight starts from that set’s weight last time.': 'Ein Satz mit 0 Gewicht startet mit dem Gewicht dieses Satzes vom letzten Mal.',
// --- update a routine from a running workout ---
'Update routine': 'Routine aktualisieren',
'Update “{0}”?': 'Routine „{0}“ aktualisieren?',
diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js
index 592a333e1..af6c597d8 100644
--- a/frontend/src/locales/es.js
+++ b/frontend/src/locales/es.js
@@ -1714,6 +1714,7 @@ export default {
'Max reps': 'Reps Máx',
'Most reps in a Max set per workout': 'Más repeticiones en una serie Máx por entrenamiento',
'A set left at 0 rest uses the exercise’s rest.': 'Una serie con descanso 0 usa el descanso del ejercicio.',
+ 'A set left at 0 weight starts from that set’s weight last time.': 'Una serie con peso 0 empieza con el peso de esa serie la última vez.',
// --- update a routine from a running workout ---
'Update routine': 'Actualizar rutina',
'Update “{0}”?': '¿Actualizar «{0}»?',
diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js
index a6c2a3d84..ef9cb37e1 100644
--- a/frontend/src/locales/fr.js
+++ b/frontend/src/locales/fr.js
@@ -1714,6 +1714,7 @@ export default {
'Max reps': 'Reps Max',
'Most reps in a Max set per workout': 'Le plus de répétitions sur une série Max par séance',
'A set left at 0 rest uses the exercise’s rest.': 'Une série avec 0 de repos utilise le repos de l’exercice.',
+ 'A set left at 0 weight starts from that set’s weight last time.': 'Une série avec 0 de charge reprend la charge de cette série la dernière fois.',
// --- update a routine from a running workout ---
'Update routine': 'Mettre à jour la routine',
'Update “{0}”?': 'Mettre à jour la routine « {0} » ?',
diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js
index 8c05a4933..90795378d 100644
--- a/frontend/src/locales/hi.js
+++ b/frontend/src/locales/hi.js
@@ -1714,6 +1714,7 @@ export default {
'Max reps': 'मैक्स रेप',
'Most reps in a Max set per workout': 'हर वर्कआउट में मैक्स सेट के सबसे ज़्यादा रेप',
'A set left at 0 rest uses the exercise’s rest.': '0 आराम वाला सेट एक्सरसाइज़ का आराम इस्तेमाल करता है।',
+ 'A set left at 0 weight starts from that set’s weight last time.': '0 वज़न वाला सेट पिछली बार उसी सेट के वज़न से शुरू होता है।',
// --- update a routine from a running workout ---
'Update routine': 'रूटीन अपडेट करें',
'Update “{0}”?': 'रूटीन “{0}” अपडेट करें?',
diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js
index 3b8a3698f..b1a1d599f 100644
--- a/frontend/src/locales/hu.js
+++ b/frontend/src/locales/hu.js
@@ -1717,6 +1717,7 @@ export default {
'Max reps': 'Max ism.',
'Most reps in a Max set per workout': 'A legtöbb ismétlés egy Max sorozatban edzésenként',
'A set left at 0 rest uses the exercise’s rest.': 'A 0 pihenőjű sorozat a gyakorlat pihenőjét használja.',
+ 'A set left at 0 weight starts from that set’s weight last time.': 'A 0 súlyú sorozat az előző alkalommal ugyanennél a sorozatnál használt súlyról indul.',
// --- update a routine from a running workout ---
'Update routine': 'Rutin frissítése',
'Update “{0}”?': 'Frissíted a(z) „{0}” rutint?',
diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js
index 81f392217..bf787b286 100644
--- a/frontend/src/locales/it.js
+++ b/frontend/src/locales/it.js
@@ -1714,6 +1714,7 @@ export default {
'Max reps': 'Rip Max',
'Most reps in a Max set per workout': 'Più ripetizioni in una serie Max per allenamento',
'A set left at 0 rest uses the exercise’s rest.': 'Una serie con riposo 0 usa il riposo dell’esercizio.',
+ 'A set left at 0 weight starts from that set’s weight last time.': 'Una serie con peso 0 parte dal peso di quella serie l’ultima volta.',
// --- update a routine from a running workout ---
'Update routine': 'Aggiorna la routine',
'Update “{0}”?': 'Aggiornare la routine «{0}»?',
diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js
index fc4f356c8..f9e462465 100644
--- a/frontend/src/locales/ko.js
+++ b/frontend/src/locales/ko.js
@@ -1714,6 +1714,7 @@ export default {
'Max reps': '최대 반복',
'Most reps in a Max set per workout': '운동마다 최대 세트의 최다 반복 수',
'A set left at 0 rest uses the exercise’s rest.': '휴식이 0인 세트는 운동의 휴식 시간을 사용합니다.',
+ 'A set left at 0 weight starts from that set’s weight last time.': '무게가 0인 세트는 지난번 같은 세트의 무게로 시작합니다.',
// --- update a routine from a running workout ---
'Update routine': '루틴 업데이트',
'Update “{0}”?': '“{0}” 루틴을 업데이트할까요?',
diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js
index 92579d18f..954bab175 100644
--- a/frontend/src/locales/pl.js
+++ b/frontend/src/locales/pl.js
@@ -1714,6 +1714,7 @@ export default {
'Max reps': 'Powt. Maks',
'Most reps in a Max set per workout': 'Najwięcej powtórzeń w serii Maks na trening',
'A set left at 0 rest uses the exercise’s rest.': 'Seria z przerwą 0 używa przerwy ćwiczenia.',
+ 'A set left at 0 weight starts from that set’s weight last time.': 'Seria z ciężarem 0 zaczyna od ciężaru tej serii z poprzedniego razu.',
// --- update a routine from a running workout ---
'Update routine': 'Zaktualizuj plan',
'Update “{0}”?': 'Zaktualizować plan „{0}”?',
diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js
index ad06595ac..7f83ff03a 100644
--- a/frontend/src/locales/pt.js
+++ b/frontend/src/locales/pt.js
@@ -1714,6 +1714,7 @@ export default {
'Max reps': 'Reps Máx',
'Most reps in a Max set per workout': 'Mais repetições numa série Máx por treino',
'A set left at 0 rest uses the exercise’s rest.': 'Uma série com descanso 0 usa o descanso do exercício.',
+ 'A set left at 0 weight starts from that set’s weight last time.': 'Uma série com peso 0 começa com o peso dessa série da última vez.',
// --- update a routine from a running workout ---
'Update routine': 'Atualizar rotina',
'Update “{0}”?': 'Atualizar «{0}»?',
diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js
index 576e5cbe6..5fd69d8de 100644
--- a/frontend/src/locales/ru.js
+++ b/frontend/src/locales/ru.js
@@ -1718,6 +1718,7 @@ export default {
'Max reps': 'Повт. Макс',
'Most reps in a Max set per workout': 'Больше всего повторов в подходе Макс за тренировку',
'A set left at 0 rest uses the exercise’s rest.': 'Подход с отдыхом 0 использует отдых упражнения.',
+ 'A set left at 0 weight starts from that set’s weight last time.': 'Подход с весом 0 начинается с веса этого подхода в прошлый раз.',
// --- update a routine from a running workout ---
'Update routine': 'Обновить программу',
'Update “{0}”?': 'Обновить программу «{0}»?',
diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js
index 1031f9448..d6a4d2e16 100644
--- a/frontend/src/locales/th.js
+++ b/frontend/src/locales/th.js
@@ -1725,6 +1725,7 @@ export default {
'Max reps': 'ครั้งสูงสุด',
'Most reps in a Max set per workout': 'จำนวนครั้งมากที่สุดในเซ็ตสูงสุดต่อการฝึก',
'A set left at 0 rest uses the exercise’s rest.': 'เซ็ตที่พัก 0 จะใช้เวลาพักของท่านั้น',
+ 'A set left at 0 weight starts from that set’s weight last time.': 'เซ็ตที่น้ำหนัก 0 จะเริ่มจากน้ำหนักของเซ็ตเดียวกันครั้งก่อน',
// --- update a routine from a running workout ---
'Update routine': 'อัปเดตรูทีน',
'Update “{0}”?': 'อัปเดตรูทีน “{0}” ไหม?',
diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js
index d6fa067cf..c372e579d 100644
--- a/frontend/src/locales/tr.js
+++ b/frontend/src/locales/tr.js
@@ -1714,6 +1714,7 @@ export default {
'Max reps': 'Maks tekrar',
'Most reps in a Max set per workout': 'Antrenman başına bir Maks setteki en çok tekrar',
'A set left at 0 rest uses the exercise’s rest.': 'Dinlenmesi 0 olan set, egzersizin dinlenmesini kullanır.',
+ 'A set left at 0 weight starts from that set’s weight last time.': 'Ağırlığı 0 olan set, aynı setin geçen seferki ağırlığıyla başlar.',
// --- update a routine from a running workout ---
'Update routine': 'Rutini güncelle',
'Update “{0}”?': '“{0}” rutini güncellensin mi?',
diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.js
index a4a775ede..95df5810e 100644
--- a/frontend/src/locales/uk.js
+++ b/frontend/src/locales/uk.js
@@ -1711,6 +1711,7 @@ export default {
'Max reps': 'Повт. Макс',
'Most reps in a Max set per workout': 'Найбільше повторів у підході Макс за тренування',
'A set left at 0 rest uses the exercise’s rest.': 'Підхід із відпочинком 0 використовує відпочинок вправи.',
+ 'A set left at 0 weight starts from that set’s weight last time.': 'Підхід із вагою 0 починається з ваги цього підходу минулого разу.',
// --- update a routine from a running workout ---
'Update routine': 'Оновити програму',
'Update “{0}”?': 'Оновити програму «{0}»?',
diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.js
index 0ab17d0bf..7590cb94b 100644
--- a/frontend/src/locales/zh-TW.js
+++ b/frontend/src/locales/zh-TW.js
@@ -1687,6 +1687,7 @@ export default {
'Max reps': '力竭次數',
'Most reps in a Max set per workout': '每次訓練中力竭組的最多次數',
'A set left at 0 rest uses the exercise’s rest.': '休息設為 0 的組會使用該動作的休息時間。',
+ 'A set left at 0 weight starts from that set’s weight last time.': '重量設為 0 的組會從上次同一組的重量開始。',
'Show less': '顯示更少',
'Completed': '已完成',
'Weekly muscle volume': '每週肌肉訓練量',
diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js
index 07765586e..d5775e4ba 100644
--- a/frontend/src/locales/zh.js
+++ b/frontend/src/locales/zh.js
@@ -1714,6 +1714,7 @@ export default {
'Max reps': '力竭次数',
'Most reps in a Max set per workout': '每次训练中力竭组的最多次数',
'A set left at 0 rest uses the exercise’s rest.': '休息为 0 的组使用该动作的休息时间。',
+ 'A set left at 0 weight starts from that set’s weight last time.': '重量为 0 的组从上次同一组的重量开始。',
// --- update a routine from a running workout ---
'Update routine': '更新训练日',
'Update “{0}”?': '更新训练日「{0}」?',
diff --git a/frontend/src/sheets.config-pyramid-weight.test.jsx b/frontend/src/sheets.config-pyramid-weight.test.jsx
new file mode 100644
index 000000000..0c880c39a
--- /dev/null
+++ b/frontend/src/sheets.config-pyramid-weight.test.jsx
@@ -0,0 +1,72 @@
+// @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'
+
+// #445: with Pyramid sets on, the exercise settings had no weight field at all. Each set now has
+// its own, next to its reps and rest.
+const ex = EXDB.find(e => e.id === '0009') // a weighted machine exercise
+const mounted = []
+
+function renderConfig(cfg, exercise = ex) {
+ const onSave = vi.fn()
+ exConfigSheet(exercise, { sets: 3, reps: 10, weight: 0, mode: 'reps', pyramid: [12, 10, 8], ...cfg }, 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))))
+ return { host, onSave }
+}
+const weightFields = host => [...host.querySelectorAll('.stp-w')]
+ .filter(w => w.querySelector('.stp-l')?.textContent === 'Weight (kg)')
+ .map(w => w.querySelector('input.num'))
+function type(el, value) {
+ Object.getOwnPropertyDescriptor(el.constructor.prototype, 'value').set.call(el, value)
+ el.dispatchEvent(new Event('input', { bubbles: true }))
+}
+const leave = el => el.dispatchEvent(new FocusEvent('focusout', { bubbles: true }))
+const save = host => [...host.querySelectorAll('button')].find(b => b.textContent.trim() === 'Save').click()
+
+describe('exercise settings: weight per pyramid set (#445)', () => {
+ 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('shows one weight field per set and saves what was typed', () => {
+ const { host, onSave } = renderConfig()
+ const fields = weightFields(host)
+ expect(fields).toHaveLength(3)
+ act(() => { type(fields[0], '40'); leave(fields[0]) })
+ act(() => { type(fields[2], '60'); leave(fields[2]) })
+ act(() => save(host))
+ expect(onSave.mock.calls[0][0].pyramid).toEqual([12, 10, 8])
+ expect(onSave.mock.calls[0][0].pyramidWeight).toEqual([40, 0, 60])
+ })
+
+ it('opens on the saved weights and writes no field when every set is left at 0', () => {
+ const { host, onSave } = renderConfig({ pyramidWeight: [40, 50, 60] })
+ expect(weightFields(host).map(f => f.value)).toEqual(['40', '50', '60'])
+ const blank = renderConfig()
+ act(() => save(blank.host))
+ expect(blank.onSave.mock.calls[0][0]).not.toHaveProperty('pyramidWeight')
+ act(() => save(host))
+ expect(onSave.mock.calls[0][0].pyramidWeight).toEqual([40, 50, 60])
+ })
+
+ it('keeps bodyweight work on its one Added load', () => {
+ const { host, onSave } = renderConfig({ bodyweight: true, pyramidWeight: [40, 50, 60] })
+ expect(weightFields(host)).toHaveLength(0)
+ act(() => save(host))
+ expect(onSave.mock.calls[0][0]).not.toHaveProperty('pyramidWeight')
+ })
+})
diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx
index e5e4a6928..c50dd9107 100644
--- a/frontend/src/sheets.jsx
+++ b/frontend/src/sheets.jsx
@@ -34,7 +34,7 @@ import { estimate1RM, best1RM, is1RMRecord, REP_CAP } from './lib/onerm.js'
import { exerciseHistory } from './lib/exercise-history.js'
import { policyFor, defaultIncrement, POLICIES_FOR, POLICY_NAME, POLICY_DESC, MAX_BW_SETS, weightIncrement } from './lib/progression.js'
import { normalizeRepRange } from './lib/rep-range.js'
-import { isPyramid, normalizePyramid, normalizePyramidRest, pyramidFromFlat, flatFromPyramid, pyramidLabel, PYRAMID_MAX, MAX_PYRAMID_SETS, PYRAMID_PRESETS } from './lib/pyramid.js'
+import { isPyramid, normalizePyramid, normalizePyramidRest, normalizePyramidWeight, pyramidFromFlat, flatFromPyramid, pyramidLabel, PYRAMID_MAX, MAX_PYRAMID_SETS, PYRAMID_PRESETS } from './lib/pyramid.js'
import { MOBILE, shareExport, printHtml } from './lib/mobile.js'
import { speedUnitOf, toSpeed, fromSpeed } from './lib/speed.js'
import { buildCompletedWorkout, sessionEnd } from './lib/finish-workout.js'
@@ -1544,6 +1544,8 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, i
if (list.length) Object.assign(out, flatFromPyramid(list), { pyramid: list })
const pyramidRest = list.length ? normalizePyramidRest(c.pyramidRest, list.length) : []
if (pyramidRest.length) out.pyramidRest = pyramidRest
+ const pyramidWeight = list.length && !bw ? normalizePyramidWeight(c.pyramidWeight, list.length) : []
+ if (pyramidWeight.length) out.pyramidWeight = pyramidWeight
if (double) out.repsMin = range.repsMin
// A ceiling below the working reps would tell you to add a set on day one.
if (bw && !(out.weight > 0) && c.repsMax > 0) out.repsMax = Math.max(reps, Math.round(c.repsMax))
@@ -1596,13 +1598,14 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, i
{!bw && !pyramid && <Stepper label={t('Weight ({0})', st.unit)} value={c.weight} step={2.5} onChange={v => setC(x => ({ ...x, weight: v }))} />}
</>}
</div>
- {/* Pyramid sets: a row per set, each with its own reps or Max. No weight — that is picked
- set by set while training, seeded from the same set last time (buildSets). */}
+ {/* Pyramid sets: a row per set, each with its own reps or Max, rest and weight. A set left
+ at 0 weight starts from that same set last time (buildSets). */}
{pyramid && <div style={{ marginTop: -10, marginBottom: 18 }}>
- {/* Presets replace the list (and its rests) in one tap; the sheet is not saved until Save. */}
+ {/* Presets replace the list (and its rests and weights) in one tap; the sheet is not saved
+ until Save. */}
<div className="chips" style={{ marginBottom: 10 }}>
{PYRAMID_PRESETS.map((preset, k) => <button key={k} type="button" className="chip"
- onClick={() => setC(x => ({ ...x, pyramid: [...preset], pyramidRest: undefined }))}>{pyramidLabel(preset)}</button>)}
+ onClick={() => setC(x => ({ ...x, pyramid: [...preset], pyramidRest: undefined, pyramidWeight: undefined }))}>{pyramidLabel(preset)}</button>)}
</div>
{c.pyramid.map((p, i) => <div key={i} style={{ marginBottom: 10 }}>
<div className="row cfgrow" style={{ marginBottom: 4 }}>
@@ -1616,11 +1619,20 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, i
return { ...x, pyramidRest: rest }
})} />
</div>
+ {/* Bodyweight work has its one "Added" load below instead. */}
+ {!bw && <div className="row cfgrow" style={{ marginBottom: 4 }}>
+ <Stepper label={t('Weight ({0})', st.unit)} value={(c.pyramidWeight || [])[i] || 0} step={2.5}
+ onChange={v => setC(x => {
+ const weight = Array.from({ length: x.pyramid.length }, (_, j) => (x.pyramidWeight || [])[j] || 0)
+ weight[i] = v
+ return { ...x, pyramidWeight: weight }
+ })} />
+ </div>}
<div className="row" style={{ justifyContent: 'flex-end', gap: 8 }}>
<Button size="sm" variant={p === PYRAMID_MAX ? 'primary' : 'plain'} aria-pressed={p === PYRAMID_MAX}
onClick={() => setPyramidAt(i, p === PYRAMID_MAX ? (c.reps || 10) : PYRAMID_MAX)}>{t('Max')}</Button>
{c.pyramid.length > 1 && <Button size="sm" icon="trash" aria-label={t('Remove set')} title={t('Remove set')}
- onClick={() => setC(x => ({ ...x, pyramid: x.pyramid.filter((_, j) => j !== i), pyramidRest: x.pyramidRest?.filter((_, j) => j !== i) }))} />}
+ onClick={() => setC(x => ({ ...x, pyramid: x.pyramid.filter((_, j) => j !== i), pyramidRest: x.pyramidRest?.filter((_, j) => j !== i), pyramidWeight: x.pyramidWeight?.filter((_, j) => j !== i) }))} />}
</div>
</div>)}
<Button size="sm" icon="plus" disabled={c.pyramid.length >= MAX_PYRAMID_SETS}
@@ -1629,8 +1641,10 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, i
pyramid: [...x.pyramid, x.pyramid[x.pyramid.length - 1]],
// The new set copies the last one's rest too, like its target.
pyramidRest: x.pyramidRest?.length ? [...x.pyramid.map((_, j) => x.pyramidRest[j] || 0), x.pyramidRest[x.pyramid.length - 1] || 0] : x.pyramidRest,
+ pyramidWeight: x.pyramidWeight?.length ? [...x.pyramid.map((_, j) => x.pyramidWeight[j] || 0), x.pyramidWeight[x.pyramid.length - 1] || 0] : x.pyramidWeight,
}))}>{t('Add set')}</Button>
<div className="small dim" style={{ marginTop: 8 }}>{t('A set left at 0 rest uses the exercise’s rest.')}</div>
+ {!bw && <div className="small dim" style={{ marginTop: 4 }}>{t('A set left at 0 weight starts from that set’s weight last time.')}</div>}
</div>}
{c.intensifier?.type === 'restpause' && <div className="small dim" style={{ marginTop: -10, marginBottom: 18 }}>
{t('Rest-pause always trains as one warm-up set at this rep count, then one rest-pause work set. "Sets" isn’t used here.')}