This commit is contained in:
Duarte Santos committed 2026-08-30 13:30:38 +02:00
commit a65287de0f
24 files changed
+136 -11

No files matched your search

+1
View File
@@ -35,6 +35,7 @@ export function buildCompletedWorkout(active, { end = Date.now(), prs = [], snap
bw: active.bw,
entries,
prs,
...(active.excludeFromProgression === true ? { excludeFromProgression: true } : {}),
...(sessionNote ? { note: sessionNote } : {}),
}
}
+12
View File
@@ -15,6 +15,18 @@ describe('completed workout boundary', () => {
})
})
it('persists progression exclusion only for a marked session', () => {
const active = {
id: 'active-1', d: '2026-08-08', start: 1000, routineId: 'routine-1', name: 'Deload', bw: 80,
excludeFromProgression: true,
entries: [{ id: '0025', sets: [{ done: true, w: 30, r: 8 }], target: { sets: 1, reps: 8 } }],
}
expect(buildCompletedWorkout(active, { end: 2000 }).excludeFromProgression).toBe(true)
const { excludeFromProgression, ...regular } = active
expect(buildCompletedWorkout(regular, { end: 2000 })).not.toHaveProperty('excludeFromProgression')
})
it('persists a muscle snapshot only when the caller supplies one', () => {
const active = {
id: 'active-1', d: '2026-08-08', start: 1000,
+7 -3
View File
@@ -312,9 +312,11 @@ function buildWorkSets(S, cfg, options = {}) {
const n = Math.max(1, cfg.sets || 1)
const mode = modeOf(cfg)
const preferLast = !!options.preferLast
const useTarget = !!options.useTarget
const sets = []
// Last time's set at the same position, falling back to its final set when the plan grew.
const prevAt = i => (last ? (last.sets[i] || last.sets[last.sets.length - 1]) : null)
// A deload routine must use its own prescription instead of carrying regular-session values
// into the workout. Other planned sessions keep the existing history-first behaviour.
const prevAt = i => (!useTarget && last ? (last.sets[i] || last.sets[last.sets.length - 1]) : null)
if (mode === 'cardio') {
for (let i = 0; i < n; i++) {
@@ -339,7 +341,9 @@ function buildWorkSets(S, cfg, options = {}) {
const usable = prev && prev.r > 0 ? prev : null
// Planned sessions may use the confirmed working weight, while freestyle should reproduce
// the load of each matching set when that option is requested.
const w = preferLast && usable ? usable.w : (conf && conf.w > 0 ? conf.w : (usable ? usable.w : cfg.weight))
const w = useTarget
? 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 })
}
return sets
+8
View File
@@ -493,6 +493,14 @@ describe('buildSets', () => {
.toEqual([{ w: 60, r: 10, done: false }, { w: 62.5, r: 8, done: false }])
})
it('can use a deload target without carrying regular-session values into it', () => {
const S = { exWeights: { [LIFT]: { w: 75 } }, workouts: [{ d: '2026-01-01', entries: [{ id: LIFT, sets: [
{ w: 75, r: 10, done: true }, { w: 75, r: 9, done: true }
] }] }] }
expect(buildSets(S, { id: LIFT, sets: 2, reps: 12, weight: 40 }, { useTarget: true }))
.toEqual([{ w: 40, r: 12, done: false }, { w: 40, r: 12, done: false }])
})
})
describe('applyIntensifierPlan', () => {
+5 -1
View File
@@ -79,7 +79,10 @@ function cleanIntensifier(x) {
/** Build the shareable bundle: every routine, the week schedule, referenced customs. */
export function buildPlanBundle(S, name) {
const routines = (S.routines || []).map(r => ({
id: r.id, name: r.name, emoji: r.emoji, ...(r.prog ? { prog: r.prog } : {}), ex: (r.ex || []).map(cleanEx)
id: r.id, name: r.name, emoji: r.emoji,
...(r.prog ? { prog: r.prog } : {}),
...(r.excludeFromProgression === true ? { excludeFromProgression: true } : {}),
ex: (r.ex || []).map(cleanEx)
}))
const usedIds = new Set(routines.flatMap(r => r.ex.map(e => e.id)))
const customEx = (S.customEx || [])
@@ -160,6 +163,7 @@ export function mergePlan(s, bundle, { schedule } = {}) {
name: r.name || t('Shared routine'),
emoji: r.emoji,
...(r.prog ? { prog: r.prog } : {}),
...(r.excludeFromProgression === true ? { excludeFromProgression: true } : {}),
ex: (r.ex || []).map(e => ({ ...e, id: exIdMap[e.id] || e.id }))
})
})
+12 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { buildPlanBundle, parsePlan } from './plan-share.js'
import { buildPlanBundle, mergePlan, parsePlan } from './plan-share.js'
// There was no test file for plan sharing at all, which is how a whole prescription field
// went missing without anyone noticing.
@@ -24,6 +24,17 @@ describe('what survives a shared plan', () => {
expect(roundTrip({ warmupSets: 3 }).warmupSets).toBe(3)
})
it('carries progression exclusion on a routine through export and merge', () => {
const source = stateWith({})
source.routines[0].excludeFromProgression = true
const bundle = parsePlan(buildPlanBundle(source, 'Plan'))
const target = { routines: [], week: {}, customEx: [] }
expect(bundle.routines[0].excludeFromProgression).toBe(true)
mergePlan(target, bundle)
expect(target.routines[0].excludeFromProgression).toBe(true)
})
it('drops an intensifier it does not recognise rather than passing it on', () => {
expect(roundTrip({ intensifier: { type: 'nonsense', count: 3 } }).intensifier).toBeUndefined()
})
+4
View File
@@ -134,6 +134,10 @@ export function readSession(entry, fallback) {
export function sessionsFor(S, exId, fallback) {
const out = []
;(S.workouts || []).forEach(w => {
// A planned deload remains a real workout for history and statistics, but it cannot become
// the baseline for the next regular prescription. The routine flag is copied onto the
// active session, then onto this completed workout, so later routine edits do not rewrite it.
if (w.excludeFromProgression === true) return
const entry = w.entries.find(e => e.id === exId)
if (entry && entry.sets.some(s => s.done && !isWarmupRow(s))) out.push({ d: w.d, ...readSession(entry, fallback) })
})
+19
View File
@@ -374,6 +374,25 @@ describe('sessionsFor', () => {
expect(sessionsFor(S, LIFT).map(s => s.d)).toEqual(['2026-01-01'])
})
it('ignores marked deload workouts when it calculates the next regular target', () => {
const target = { sets: 3, reps: 5, weight: 60 }
const entry = (weight, reps) => ({
id: LIFT,
target: { ...target, weight },
sets: reps.map(r => ({ w: weight, r, done: true }))
})
const S = {
unit: 'kg',
workouts: [
{ d: '2026-01-01', entries: [entry(60, [5, 5, 5])] },
{ d: '2026-01-08', excludeFromProgression: true, entries: [entry(30, [8, 8])] }
]
}
expect(sessionsFor(S, LIFT).map(s => s.d)).toEqual(['2026-01-01'])
expect(nextPrescription(S, { id: LIFT, ...target, prog: 'linear' }).weight).toBe(62.5)
})
it('reads a legacy entry that has no target without crashing', () => {
const S = { unit: 'kg', workouts: [{ d: '2026-01-01', entries: [{ id: LIFT, sets: [{ w: 60, r: 5, done: true }] }] }] }
expect(sessionsFor(S, LIFT)).toHaveLength(1)
+3
View File
@@ -539,6 +539,9 @@ export default {
'Step (seconds)': 'Schritt (Sekunden)',
'Reps from': 'Wdh. ab',
'No automatic progression': 'Keine automatische Progression',
'Exclude from automatic progression': 'Von der automatischen Progression ausschließen',
'Use for planned deloads. Workouts stay in history and statistics.': 'Für geplante Deloads. Workouts bleiben im Verlauf und in den Statistiken.',
'The next regular target continues from the last included workout.': 'Das nächste reguläre Ziel setzt beim letzten einbezogenen Workout fort.',
'Linear progression': 'Lineare Progression',
'Greyskull LP': 'Greyskull LP',
'Double progression': 'Doppelte Progression',
+3
View File
@@ -521,6 +521,9 @@ export default {
'Step (seconds)': 'Incremento (segundos)',
'Reps from': 'Reps desde',
'No automatic progression': 'Sin progresión automática',
'Exclude from automatic progression': 'Excluir de la progresión automática',
'Use for planned deloads. Workouts stay in history and statistics.': 'Úsalo para descargas planificadas. Los entrenamientos permanecen en el historial y las estadísticas.',
'The next regular target continues from the last included workout.': 'El siguiente objetivo normal continúa desde el último entrenamiento incluido.',
'Linear progression': 'Progresión lineal',
'Greyskull LP': 'Greyskull LP',
'Double progression': 'Progresión doble',
+3
View File
@@ -521,6 +521,9 @@ export default {
'Step (seconds)': 'Palier (secondes)',
'Reps from': 'Reps à partir de',
'No automatic progression': 'Pas de progression automatique',
'Exclude from automatic progression': 'Exclure de la progression automatique',
'Use for planned deloads. Workouts stay in history and statistics.': 'À utiliser pour les semaines de décharge planifiées. Les séances restent dans l’historique et les statistiques.',
'The next regular target continues from the last included workout.': 'Le prochain objectif normal continue à partir de la dernière séance incluse.',
'Linear progression': 'Progression linéaire',
'Greyskull LP': 'Greyskull LP',
'Double progression': 'Double progression',
+3
View File
@@ -521,6 +521,9 @@ export default {
'Step (seconds)': 'स्टेप (सेकंड)',
'Reps from': 'रेप्स से',
'No automatic progression': 'कोई स्वचालित प्रोग्रेशन नहीं',
'Exclude from automatic progression': 'स्वचालित प्रोग्रेशन से बाहर रखें',
'Use for planned deloads. Workouts stay in history and statistics.': 'योजनाबद्ध डीलोड के लिए उपयोग करें। वर्कआउट इतिहास और आँकड़ों में रहते हैं।',
'The next regular target continues from the last included workout.': 'अगला सामान्य लक्ष्य अंतिम शामिल वर्कआउट से जारी रहता है।',
'Linear progression': 'रैखिक प्रोग्रेशन',
'Greyskull LP': 'Greyskull LP',
'Double progression': 'डबल प्रोग्रेशन',
+3
View File
@@ -521,6 +521,9 @@ export default {
'Step (seconds)': 'Incremento (secondi)',
'Reps from': 'Rip. da',
'No automatic progression': 'Nessuna progressione automatica',
'Exclude from automatic progression': 'Escludi dalla progressione automatica',
'Use for planned deloads. Workouts stay in history and statistics.': 'Usa per gli scarichi programmati. Gli allenamenti restano nella cronologia e nelle statistiche.',
'The next regular target continues from the last included workout.': 'Il prossimo obiettivo normale continua dall’ultimo allenamento incluso.',
'Linear progression': 'Progressione lineare',
'Greyskull LP': 'Greyskull LP',
'Double progression': 'Doppia progressione',
+3
View File
@@ -521,6 +521,9 @@ export default {
'Step (seconds)': '증가폭 (초)',
'Reps from': '최소 횟수',
'No automatic progression': '자동 증가 없음',
'Exclude from automatic progression': '자동 증가에서 제외',
'Use for planned deloads. Workouts stay in history and statistics.': '계획된 디로딩에 사용합니다. 운동은 기록과 통계에 남습니다.',
'The next regular target continues from the last included workout.': '다음 일반 목표는 마지막으로 포함된 운동에서 이어집니다.',
'Linear progression': '선형 증가',
'Greyskull LP': 'Greyskull LP',
'Double progression': '이중 점증',
+3
View File
@@ -521,6 +521,9 @@ export default {
'Step (seconds)': 'Skok (sekundy)',
'Reps from': 'Powt. od',
'No automatic progression': 'Bez automatycznej progresji',
'Exclude from automatic progression': 'Wyklucz z automatycznej progresji',
'Use for planned deloads. Workouts stay in history and statistics.': 'Użyj dla planowanych deloadów. Treningi pozostają w historii i statystykach.',
'The next regular target continues from the last included workout.': 'Następny zwykły cel bazuje na ostatnim uwzględnionym treningu.',
'Linear progression': 'Progresja liniowa',
'Greyskull LP': 'Greyskull LP',
'Double progression': 'Podwójna progresja',
+3
View File
@@ -59,6 +59,9 @@ export const PT_BR_OVERRIDES = {
'Create one or load the starter plan.': 'Crie uma ou carregue o plano inicial.',
'Load starter plan (Push / Pull / Legs)': 'Carregar plano inicial (Push / Pull / Legs)',
'No exercises yet — add your first one.': 'Ainda não há exercícios — adicione o primeiro.',
'Exclude from automatic progression': 'Excluir da progressão automática',
'Use for planned deloads. Workouts stay in history and statistics.': 'Use para deloads planejados. Os treinos permanecem no histórico e nas estatísticas.',
'The next regular target continues from the last included workout.': 'A próxima meta normal continua a partir do último treino incluído.',
'Tap the link button on an exercise to superset it with the one above — you’ll do them back-to-back.': 'Toque no botão de vínculo de um exercício para combiná-lo em um superset com o exercício acima — eles serão feitos em sequência.',
'Delete routine?': 'Excluir rotina?',
'Delete routine': 'Excluir rotina',
+3
View File
@@ -521,6 +521,9 @@ export default {
'Step (seconds)': 'Incremento (segundos)',
'Reps from': 'Reps a partir de',
'No automatic progression': 'Sem progressão automática',
'Exclude from automatic progression': 'Excluir da progressão automática',
'Use for planned deloads. Workouts stay in history and statistics.': 'Use para deloads planeados. Os treinos permanecem no histórico e nas estatísticas.',
'The next regular target continues from the last included workout.': 'O próximo objetivo normal continua a partir do último treino incluído.',
'Linear progression': 'Progressão linear',
'Greyskull LP': 'Greyskull LP',
'Double progression': 'Progressão dupla',
+3
View File
@@ -521,6 +521,9 @@ export default {
'Step (seconds)': 'Шаг (секунды)',
'Reps from': 'Повт. от',
'No automatic progression': 'Без автопрогрессии',
'Exclude from automatic progression': 'Исключить из автоматической прогрессии',
'Use for planned deloads. Workouts stay in history and statistics.': 'Используйте для плановых разгрузок. Тренировки остаются в истории и статистике.',
'The next regular target continues from the last included workout.': 'Следующая обычная цель продолжает прогрессию от последней учтённой тренировки.',
'Linear progression': 'Линейная прогрессия',
'Greyskull LP': 'Greyskull LP',
'Double progression': 'Двойная прогрессия',
+3
View File
@@ -521,6 +521,9 @@ export default {
'Step (seconds)': 'Artış (saniye)',
'Reps from': 'Tekrar en az',
'No automatic progression': 'Otomatik ilerleme yok',
'Exclude from automatic progression': 'Otomatik ilerlemeden hariç tut',
'Use for planned deloads. Workouts stay in history and statistics.': 'Planlı deloadlar için kullanın. Antrenmanlar geçmişte ve istatistiklerde kalır.',
'The next regular target continues from the last included workout.': 'Sonraki normal hedef, dahil edilen son antrenmandan devam eder.',
'Linear progression': 'Doğrusal ilerleme',
'Greyskull LP': 'Greyskull LP',
'Double progression': 'Çift ilerleme',
+3
View File
@@ -521,6 +521,9 @@ export default {
'Step (seconds)': '加量(秒)',
'Reps from': '次数下限',
'No automatic progression': '不自动进阶',
'Exclude from automatic progression': '不计入自动进阶',
'Use for planned deloads. Workouts stay in history and statistics.': '用于计划性减载。训练仍保留在历史记录和统计中。',
'The next regular target continues from the last included workout.': '下一个常规目标从上一次计入的训练继续。',
'Linear progression': '线性进阶',
'Greyskull LP': 'Greyskull LP',
'Double progression': '双重进阶',
+8 -3
View File
@@ -1053,14 +1053,19 @@ export function beginWorkout(routineId, bw) {
// The prescription is applied as the session is built, so you walk up to the bar with the
// right weight already on the screen instead of being told about it afterwards. `plan` is
// kept on the entry purely so the workout can explain the number it chose.
const excluded = r?.excludeFromProgression === true
const entries = (r ? r.ex : []).map(cfg => {
const plan = nextPrescription(st, cfg, r)
const plan = excluded ? { policy: 'off', kind: 'off' } : nextPrescription(st, cfg, r)
const step = defaultIncrement(cfg.id, st.unit)
const sets = applyIntensifierPlan(applyPrescription(buildSets(st, cfg, { step }), plan, step), cfg)
const sets = applyIntensifierPlan(applyPrescription(buildSets(st, cfg, { step, useTarget: excluded }), plan, step), cfg)
return { id: cfg.id, sg: cfg.sg, target: { ...cfg }, plan, sets }
})
update(s => {
s.active = { id: uid(), d: todayISO(), start: Date.now(), routineId, name: r ? r.name : t('Freestyle'), bw: bw || null, cur: 0, entries }
s.active = {
id: uid(), d: todayISO(), start: Date.now(), routineId,
name: r ? r.name : t('Freestyle'), bw: bw || null, cur: 0, entries,
...(excluded ? { excludeFromProgression: true } : {})
}
})
useUI.getState().stopRest()
nav('/workout')
+12 -2
View File
@@ -10,7 +10,7 @@ import { Thumb } from '../components/Media.jsx'
import { glyphPicker, exercisePicker, exConfigSheet, confirmSheet } from '../sheets.jsx'
import Icon from '../components/Icon.jsx'
import { glyphOf } from '../lib/glyphs.js'
import { Button, SelectRow } from '../components/ui.jsx'
import { Button, Row, SelectRow, Switch } from '../components/ui.jsx'
import { POLICIES_FOR, POLICY_NAME, POLICY_DESC } from '../lib/progression.js'
import BodyMap from '../components/BodyMap.jsx'
import { loadOfRoutine, rankOf, MUSCLE_NAME } from '../lib/muscles.js'
@@ -68,9 +68,19 @@ export default function RoutineEdit() {
<SelectRow icon="chartLine" title={t('Progression')} sheetTitle={t('Progression')}
value={r.prog || 'linear'} onChange={v => update(s => { s.routines.find(x => x.id === id).prog = v })}
options={POLICIES_FOR.reps.map(p => ({ value: p, label: t(POLICY_NAME[p]), subtitle: t(POLICY_DESC[p]) }))} />
<Row icon="pause" iconTint="var(--orange)" title={t('Exclude from automatic progression')}
subtitle={t('Use for planned deloads. Workouts stay in history and statistics.')}>
<Switch checked={r.excludeFromProgression === true} onChange={v => update(s => {
const routine = s.routines.find(x => x.id === id)
if (v) routine.excludeFromProgression = true
else delete routine.excludeFromProgression
})} />
</Row>
</div>
<div className="small dim" style={{ margin: '-10px 2px 16px' }}>
{t('Applies to every exercise in this routine that does not set its own rule.')}
{r.excludeFromProgression
? t('The next regular target continues from the last included workout.')
: t('Applies to every exercise in this routine that does not set its own rule.')}
</div>
{missingCount > 0 && <div className="card" style={{ marginBottom: 16, borderColor: 'var(--orange)' }}>