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.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
Set menu: 'Make it a warm-up set' only on plain straight sets
Duarte Santos926e6f8eb36c
diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.jsindex 76b5ef1b8..fad21f113 100644--- a/frontend/src/lib/history.js+++ b/frontend/src/lib/history.js@@ -2,7 +2,7 @@import { todayISO, isoOf, weekKey, weekStartOf, fmtNum } from './format.js'import { fmtSpeed } from './speed.js'import { isCardio, isBodyweightEq, isAssisted, betterWeight } from './exercises.js'-import { phaseForSet, modeForSet, modeForEntry, isWarmupRow, normalizeMode, completedVolumeOf, hasCompletedWork, nextDropWeight, splitBurstReps, makeSideSet, isSideSet, syncSideAggregate, WEIGHT_ORIGIN_MANUAL, dropsOf, clustersOf } from './workout-model.js'+import { phaseForSet, modeForSet, modeForEntry, isWarmupRow, isDropSet, isRestPauseSet, normalizeMode, completedVolumeOf, hasCompletedWork, nextDropWeight, splitBurstReps, makeSideSet, isSideSet, syncSideAggregate, WEIGHT_ORIGIN_MANUAL, dropsOf, clustersOf } 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') => {@@ -921,9 +921,15 @@ export function insertWarmupRow(rows, mode, target, step = 2.5) {// warm-up (its weight, reps and tick kept; drops, bursts, sides and effort dropped, since a// warm-up has none) and moves to the end of the warm-ups, so it is numbered, rested and left out// of progression and records like any other warm-up. A row that is one already is left alone.+// Only a plain straight set: a warm-up is one weight times one rep count, so a drop set would+// lose its drops, a rest-pause row would add its bursts into one inflated rep count, and a+// per-side row would merge both sides with no way back (a per-side warm-up is never made a work+// set again).+export const canBeWarmup = row => !!row && !isWarmupRow(row) && !isSideSet(row) && !isDropSet(row) && !isRestPauseSet(row)+export function makeWarmupAt(rows, i) {const src = rows[i]- if (!src || isWarmupRow(src)) return rows+ if (!canBeWarmup(src)) return rowsconst warm = { w: src.w || 0, r: src.r, done: !!src.done, phase: 'warmup', warmup: true }if (src.at != null) warm.at = src.atreturn placeRow(rows, i, warm)diff --git a/frontend/src/lib/history.test.js b/frontend/src/lib/history.test.jsindex ba4fa7bef..d88fa6f94 100644--- a/frontend/src/lib/history.test.js+++ b/frontend/src/lib/history.test.js@@ -1,5 +1,5 @@import { describe, it, expect } from 'vitest'-import { nextTrainingDay, modeOf, isTimed, fmtSec, setLabel, defaultConfig, buildSets, freestyleConfig, exLine, workoutVolume, bestWeightFor, bestWeightForEntry, completedRepsOf, metricRowsForEntry, effortOf, stepEffort, capEffort, isBw, isPerSide, sideReps, repStep, cascadeWeight, insertWarmupRow, makeWarmupAt, makeWorkAt, removeRowAt, workSetsDone, setsDone, setsDoneActive, setUnits, doneUnits, setUnitsTotal, pairAdjacent, unpairSuperset, supersetUnits, sessionSections, applyIntensifierPlan, pinnedNoteFor, exNoteFor, effectiveRoutineIds, effectiveRoutines, effectiveRoutineId, effectiveRoutine, lastEntryFor, entryExcluded, entryRoutineId, setsRepsOf } from './history.js'+import { nextTrainingDay, modeOf, isTimed, fmtSec, setLabel, defaultConfig, buildSets, freestyleConfig, exLine, workoutVolume, bestWeightFor, bestWeightForEntry, completedRepsOf, metricRowsForEntry, effortOf, stepEffort, capEffort, isBw, isPerSide, sideReps, repStep, cascadeWeight, insertWarmupRow, makeWarmupAt, canBeWarmup, makeWorkAt, removeRowAt, workSetsDone, setsDone, setsDoneActive, setUnits, doneUnits, setUnitsTotal, pairAdjacent, unpairSuperset, supersetUnits, sessionSections, applyIntensifierPlan, pinnedNoteFor, exNoteFor, effectiveRoutineIds, effectiveRoutines, effectiveRoutineId, effectiveRoutine, lastEntryFor, entryExcluded, entryRoutineId, setsRepsOf } from './history.js'import { makeSideSet, setSideField, toggleSide, WEIGHT_ORIGIN_MANUAL } from './workout-model.js'import { EXDB } from './exercises.js'import { todayISO, isoOf } from './format.js'@@ -1538,12 +1538,23 @@ describe('a rotation day and a fixed weekday day are one combined day', () => {describe('switching a row between warm-up and work', () => {it('makeWarmupAt gives the warm-up shape, keeps the numbers and the tick, and moves it in front of the work', () => {const rows = [{ w: 40, r: 8, phase: 'warmup', warmup: true, done: true }, { w: 100, r: 5, done: true, at: 7 }, { w: 100, r: 5, done: false, type: 'dropset', drops: [{ w: 80, r: 4 }], rir: 2 }]- const next = makeWarmupAt(rows, 2)+ const plain = [...rows.slice(0, 2), { w: 100, r: 5, done: false, rir: 2 }]+ const next = makeWarmupAt(plain, 2)expect(next).toEqual([rows[0], { w: 100, r: 5, done: false, phase: 'warmup', warmup: true }, rows[1]])expect(makeWarmupAt(rows, 1)[1]).toEqual({ w: 100, r: 5, done: true, phase: 'warmup', warmup: true, at: 7 })expect(makeWarmupAt(rows, 0)).toBe(rows)})+ it('makeWarmupAt leaves drop, rest-pause and per-side rows as they are', () => {+ const drop = [{ w: 60, r: 8, done: true }, { w: 100, r: 5, done: true, type: 'dropset', drops: [{ w: 80, r: 4 }] }]+ expect(makeWarmupAt(drop, 1)).toBe(drop)+ const rp = [{ w: 60, r: 8, done: true }, { w: 100, r: 12, done: true, type: 'restpause', clusters: [{ r: 4, rest: 15 }] }]+ expect(makeWarmupAt(rp, 1)).toBe(rp)+ const side = [{ w: 30, r: 6, done: true }, { w: 30, r: 11, done: false, sides: { L: { w: 30, r: 5, done: true }, R: { w: 0, r: 6, done: false } } }]+ expect(makeWarmupAt(side, 1)).toBe(side)+ expect([canBeWarmup(drop[1]), canBeWarmup(rp[1]), canBeWarmup(side[1]), canBeWarmup(drop[0])]).toEqual([false, false, false, true])+ })+it('a warm-up made one is left out of the best weight and the work-set count', () => {const e = { id: 'x', sets: makeWarmupAt([{ w: 60, r: 5, done: true }, { w: 120, r: 3, done: true }], 1) }expect(bestWeightForEntry(e)).toBe(60)diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsxindex a0d6431f4..d05a62e5f 100644--- a/frontend/src/views/Workout.jsx+++ b/frontend/src/views/Workout.jsx@@ -7,7 +7,7 @@ import { useUI } from '../store/useUI.js'import { exOr, betterWeight } from '../lib/exercises.js'import { usesBar } from '../lib/bar.js'import { loadKindFor, baseWeightFor, inventoryFor, rowLoad, sameLoad, plateDelta, dropGrid } from '../lib/plates.js'-import { effectiveRoutines, effectiveRoutineIds, lastEntryFor, bestWeightFor, bestWeightForEntry, buildSets, freestyleConfig, defaultConfig, setsDoneActive, setUnitsTotal, supersetUnits, unitOf, setLabel, modeOf, isBw, isPerSide, repStep, EFFORT, effortOf, stepEffort, capEffort, cascadeWeight, insertWarmupRow, makeWarmupAt, makeWorkAt, removeRowAt, pairAdjacent, unpairSuperset, cleanupSg, applyIntensifierPlan, pinnedNoteFor, exNoteFor, setsRepsOf } from '../lib/history.js'+import { effectiveRoutines, effectiveRoutineIds, lastEntryFor, bestWeightFor, bestWeightForEntry, buildSets, freestyleConfig, defaultConfig, setsDoneActive, setUnitsTotal, supersetUnits, unitOf, setLabel, modeOf, isBw, isPerSide, repStep, EFFORT, effortOf, stepEffort, capEffort, cascadeWeight, insertWarmupRow, makeWarmupAt, canBeWarmup, makeWorkAt, removeRowAt, pairAdjacent, unpairSuperset, cleanupSg, applyIntensifierPlan, pinnedNoteFor, exNoteFor, setsRepsOf } from '../lib/history.js'import { fmtNum, fmtPlate, exerciseNameText, fmtDate, fmtDaysAgo, todayISO, exCount, DAYN } from '../lib/format.js'import { speedUnitOf, toSpeed, fromSpeed } from '../lib/speed.js'import { beep, vibrate, unlock } from '../lib/sound.js'@@ -417,7 +417,7 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSi// only, the kind a warm-up is added as; one work set always stays, and a per-side// exercise's work sets keep their sides, so a warm-up there is not made one again.{ items: [- !warm && mode === 'reps' && entry.sets.some((x, j) => j !== i && !isWarmupRow(x)) && { icon: 'sunrise', label: t('Make it a warm-up set'), onClick: () => setPhaseAt(i, true) },+ !warm && mode === 'reps' && canBeWarmup(s) && entry.sets.some((x, j) => j !== i && !isWarmupRow(x)) && { icon: 'sunrise', label: t('Make it a warm-up set'), onClick: () => setPhaseAt(i, true) },warm && mode === 'reps' && !perSide && { icon: 'dumbbell', label: t('Count it as a working set'), onClick: () => setPhaseAt(i, false) },] },{ title: t('Add to this set'), items: [