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.

feat(workout): a one-arm or one-leg exercise starts per side

lodepavcec8291692e4
diff --git a/frontend/src/lib/exercises.js b/frontend/src/lib/exercises.js
index 1028160cd..999e687c4 100644
--- a/frontend/src/lib/exercises.js
+++ b/frontend/src/lib/exercises.js
@@ -211,6 +211,18 @@ export const isCardio = idOrEx => exerciseOf(idOrEx)?.bp === 'cardio'
// ever held ("hold": true), so a freshly added one starts as a timed hold rather than as reps.
export const isHold = idOrEx => !!(typeof idOrEx === 'string' ? EXIDX[idOrEx] : idOrEx)?.hd
+// Exercises done one arm or leg at a time, by their catalogue name: "single leg", "one arm",
+// "single-arm", "unilateral". Stretches and rollers are mobility, not sets, and a single-leg
+// push-up or plank is a two-arm exercise with a leg lifted. Like `isBodyweightEq`, this only seeds
+// a fresh config (`side: true`); the flag lives on the config, so either way can be switched.
+const ONE_LIMB = /\b(single|one)[\s-]+(arm|leg|hand)\b|\bunilateral\b/i
+const NOT_ONE_LIMB = /stretch|\broll(er|ball)?\b|two to one|single leg (push|plank)|leg push up/i
+export const isOneLimb = idOrEx => {
+ const ex = typeof idOrEx === 'string' ? EXIDX[idOrEx] : idOrEx
+ if (!ex || ex.custom || ex.bp === 'cardio') return false
+ return ONE_LIMB.test(ex.n || '') && !NOT_ONE_LIMB.test(ex.n || '')
+}
+
// Exercises the dataset already knows carry no external load (issue #32) — a quarter of the
// catalogue. This seeds the `bw` flag on a fresh config so a push-up never asks for a weight
// nobody was going to enter. It is only the default: the flag lives on the config, so a dip
diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.js
index a2a133d6b..ca11b7d9f 100644
--- a/frontend/src/lib/history.js
+++ b/frontend/src/lib/history.js
@@ -3,7 +3,7 @@ import { syncSupersetMeta } from './superset-meta.js'
import { todayISO, isoOf, weekKey, weekStartOf, fmtNum } from './format.js'
import { fmtSpeed } from './speed.js'
import { hasIncline, inclineFrom } from './incline.js'
-import { isCardio, isHold, isBodyweightEq, isAssisted, betterWeight } from './exercises.js'
+import { isCardio, isHold, isOneLimb, isBodyweightEq, isAssisted, betterWeight } from './exercises.js'
import { barWeightFor } from './bar.js'
import { phaseForSet, modeForSet, modeForEntry, isWarmupRow, isFailureSet, isDropSet, isRestPauseSet, normalizeMode, completedVolumeOf, hasCompletedWork, nextDropWeight, splitBurstReps, makeSideSet, isSideSet, syncSideAggregate, WEIGHT_ORIGIN_MANUAL, dropsOf, clustersOf } from './workout-model.js'
import { backoffAt, backoffStepOf, backoffWeights } from './backoff.js'
@@ -215,6 +215,15 @@ export function defaultConfig(id, mode) {
if (m === 'time') return { sets: 3, sec: 45, weight: 0, mode: 'time', ...bw }
return { sets: 3, reps: 10, weight: 0, mode: 'reps', ...bw }
}
+// What an exercise picked from the library starts with: `defaultConfig`, and per side for a
+// one-arm or one-leg exercise, at ten reps a side (per-side reps are both sides' total). Kept out
+// of `defaultConfig` itself, which is also spread under saved targets: a lift switched off per
+// side is stored without the flag, and must not get it back.
+export function newConfig(id, mode) {
+ const cfg = defaultConfig(id, mode)
+ if (!isOneLimb(id) || !('mode' in cfg)) return cfg
+ return { ...cfg, side: true, ...(cfg.mode === 'reps' ? { reps: 20 } : {}) }
+}
// A double-progression range is stored as its top (`reps`) and its bottom (`repsMin`), and
// reads as the range it is: "8–12". Printing the top alone made "Reps from 10, up to 15" read
// as "2 × 15" in the plan and then open at 10. `fmt` formats each bound (a per-side split).
diff --git a/frontend/src/lib/history.test.js b/frontend/src/lib/history.test.js
index a82799687..1232249d4 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, canBeWarmup, makeWorkAt, removeRowAt, removeLastSet, setSpanAt, 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, newConfig, buildSets, freestyleConfig, exLine, workoutVolume, bestWeightFor, bestWeightForEntry, completedRepsOf, metricRowsForEntry, effortOf, stepEffort, capEffort, isBw, isPerSide, sideReps, repStep, cascadeWeight, insertWarmupRow, makeWarmupAt, canBeWarmup, makeWorkAt, removeRowAt, removeLastSet, setSpanAt, 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'
@@ -343,6 +343,24 @@ describe('defaultConfig', () => {
})
})
+describe('newConfig', () => {
+ it('starts a one-arm or one-leg exercise per side, ten reps a side', () => {
+ // 4837 dumbbell single arm bent over row, 1027 assisted single leg press
+ expect(newConfig('4837')).toMatchObject({ mode: 'reps', side: true, reps: 20 })
+ expect(isPerSide(newConfig('1027'))).toBe(true)
+ expect(newConfig('4837', 'time')).toMatchObject({ mode: 'time', side: true, sec: 45 })
+ })
+ it('leaves everything else as defaultConfig has it', () => {
+ expect(newConfig('1801')).toEqual(defaultConfig('1801')) // one arm lat stretch
+ expect(newConfig('0667')).toEqual(defaultConfig('0667')) // raise single leg push up
+ expect(newConfig(LIFT)).toEqual(defaultConfig(LIFT))
+ expect(newConfig(CARDIO)).toEqual(defaultConfig(CARDIO))
+ })
+ it('keeps defaultConfig flat, so a saved target without the flag stays one row a set', () => {
+ expect('side' in defaultConfig('4837')).toBe(false)
+ })
+})
+
/* ---------- bodyweight and per side (issues #31/#32/#33) ---------- */
describe('isBw', () => {
diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx
index fe0e0304d..4a2033dee 100644
--- a/frontend/src/sheets.jsx
+++ b/frontend/src/sheets.jsx
@@ -4,7 +4,7 @@ import { useUI } from './store/useUI.js'
import { EXDB, EXIDX, BODYPARTS, isCardio, isBodyweightEq, allExercises, equipmentOf, byCategory, smOf, searchExercises, similarExercises, exOr, isAssisted, betterWeight, beatsWeight, isCustomEx } from './lib/exercises.js'
import { activeProfile, exAvailable, ALL_EQUIPMENT, newProfile, profileEquipment, ACC_V } from './lib/equipment.js'
import { fmtDate, fmtDateRange, fmtNum, fmtPlate, exerciseNameText, fmtVol, fmtDur, durPart, todayISO, isoOf, uid, exCount, routineCount, setsWorkCount, DAYN, DAYS, weekOrder, weekStartOf, weekDayOffset, MONTHS_LONG, ACCENTS } from './lib/format.js'
-import { lastEntryFor, bestWeightFor, bestWeightForEntry, buildSets, effectiveRoutineIds, workoutDay, workoutVolume, setsDone, setsDoneActive, setUnitsTotal, lastBW, sessionSections, 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, effectiveRoutineIds, workoutDay, workoutVolume, setsDone, setsDoneActive, setUnitsTotal, lastBW, sessionSections, setLabel, defaultConfig, newConfig, cleanupSg, modeOf, effortOf, EFFORT, capEffort, stepEffort, isBw, isPerSide, sideReps, workSetsDone, applyIntensifierPlan, MAX_PLANNED_WARMUPS, NOTE_MAX } from './lib/history.js'
import { usesBar, hasBarOverride, isNoBar, barTypeWeight, ownBarDefault, barPicks, withBarDefault, withStandardBars, defaultBarWeight, BAR_TYPES } from './lib/bar.js'
import { PLATE_SIZES, pairsOf, ownsPlates, withPlatePairs, withStandardPlates, withLoadKind, loadKindFor, baseWeightFor, dropGrid } from './lib/plates.js'
import { toScale, rirOf, EFFORT_PRESETS, effortColor } from './lib/effort.js'
@@ -1492,7 +1492,7 @@ export function swapActiveWorkoutExercise(index) {
// The "+" on a picker row commits with the default config, exactly as it does in the add
// flows; tapping the row still opens the config sheet first.
// Worded for the session, not the routine: a swap changes today's workout only.
- const picker = exercisePicker((ex, quick) => quick ? swapTo(ex, defaultConfig(ex.id)) : exConfigSheet(ex, null, cfg => swapTo(ex, cfg), null, null, null, null, t('Use in this workout')), { title: t('Swap exercise'), like: active.entries[index].id, backups: active.entries[index].target?.subs })
+ const picker = exercisePicker((ex, quick) => quick ? swapTo(ex, newConfig(ex.id)) : exConfigSheet(ex, null, cfg => swapTo(ex, cfg), null, null, null, null, t('Use in this workout')), { title: t('Swap exercise'), like: active.entries[index].id, backups: active.entries[index].target?.subs })
function swapTo(ex, cfg) {
// The picker is a chooser here, not a stack you keep adding from: one swap, then back to
// the workout. (The add flow deliberately leaves it open.)
@@ -1760,7 +1760,7 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, i
// or timed like any other (#678): jumping jacks and burpees are cardio and reps both.
const cardioEx = isCardio(ex.id)
const speedUnit = speedUnitOf(st)
- const seed = existing || initial || defaultConfig(ex.id)
+ const seed = existing || initial || newConfig(ex.id)
const [c, setC] = useState(() => {
const cfg = { ...seed }
// A session's target carries the meaning of its dumbbell weight as a stamp (lib/dumbbells.js);
diff --git a/frontend/src/views/RoutineEdit.jsx b/frontend/src/views/RoutineEdit.jsx
index 2bb058986..a26728a55 100644
--- a/frontend/src/views/RoutineEdit.jsx
+++ b/frontend/src/views/RoutineEdit.jsx
@@ -6,7 +6,7 @@ import { exOr } from '../lib/exercises.js'
import { activeProfile, exAvailable } from '../lib/equipment.js'
import { uid, exerciseNameText } from '../lib/format.js'
import { t, exerciseNameFor, exerciseNameClass } from '../lib/i18n.js'
-import { supersetUnits, moveRoutineEntry, cleanupSg, exLine, defaultConfig } from '../lib/history.js'
+import { supersetUnits, moveRoutineEntry, cleanupSg, exLine, newConfig } from '../lib/history.js'
import { Thumb } from '../components/Media.jsx'
import { glyphPicker, exercisePicker, exConfigSheet, confirmSheet, supersetSheet } from '../sheets.jsx'
import { supersetMeta, setSupersetMeta } from '../lib/superset-meta.js'
@@ -439,7 +439,7 @@ export default function RoutineEdit() {
const addExercise = () => exercisePicker((ex, quick) => {
if (quick) {
- edit(x => x.push({ id: ex.id, ...defaultConfig(ex.id) }))
+ edit(x => x.push({ id: ex.id, ...newConfig(ex.id) }))
toast(t('“{0}” added to {1}', exerciseNameText(ex), r.name))
} else {
exConfigSheet(ex, null, cfg => edit(x => { x.push({ id: ex.id, ...cfg }) }), null, r, null, null, undefined, { backups: true })
diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx
index 0092c49d0..3b3fad7d2 100644
--- a/frontend/src/views/Workout.jsx
+++ b/frontend/src/views/Workout.jsx
@@ -8,7 +8,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, freestyleConfig, defaultConfig, setsDoneActive, setUnitsTotal, supersetUnits, unitOf, setLabel, modeOf, isBw, isPerSide, repStep, EFFORT, effortOf, stepEffort, capEffort, cascadeWeight, insertWarmupRow, barFloor, makeWarmupAt, canBeWarmup, makeWorkAt, removeRowAt, removeLastSet, setSpanAt, copyRowAt, copySpanAt, insertRowAt, pairAdjacent, unpairSuperset, cleanupSg, applyIntensifierPlan, pinnedNoteFor, exNoteFor, setsRepsOf } from '../lib/history.js'
+import { effectiveRoutines, effectiveRoutineIds, lastEntryFor, bestWeightFor, bestWeightForEntry, freestyleConfig, newConfig, setsDoneActive, setUnitsTotal, supersetUnits, unitOf, setLabel, modeOf, isBw, isPerSide, repStep, EFFORT, effortOf, stepEffort, capEffort, cascadeWeight, insertWarmupRow, barFloor, makeWarmupAt, canBeWarmup, makeWorkAt, removeRowAt, removeLastSet, setSpanAt, copyRowAt, copySpanAt, insertRowAt, 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 { clampIncline, hasIncline, inclineFits, inclineFrom, INCLINE_STEP } from '../lib/incline.js'
@@ -1514,7 +1514,7 @@ function ActiveWorkout() {
// Freestyle has no routine prescription to apply: show the last target in the config
// sheet and carry its completed rows forward. A planned session uses its configured
// target when progression is off, while progression-enabled sessions keep their path.
- const seed = freestyle ? freestyleConfig(sessionHistory(S), { id: ex.id, ...defaultConfig(ex.id) }) : null
+ const seed = freestyle ? freestyleConfig(sessionHistory(S), { id: ex.id, ...newConfig(ex.id) }) : null
const commit = cfg => {
if (focusMode) focusPointerEpoch.current++
update(s => {
@@ -1533,7 +1533,7 @@ function ActiveWorkout() {
// button. Quick-add commits with the same default (or, freestyle, last-session) config
// the sheet would have opened with; tapping the row still opens that sheet for anyone
// who wants to set sets/reps first.
- if (quick) { commit(seed || defaultConfig(ex.id)); useUI.getState().toast(t('“{0}” added to {1}', exerciseNameText(ex), routine ? routine.name : t('Freestyle'))) }
+ if (quick) { commit(seed || newConfig(ex.id)); useUI.getState().toast(t('“{0}” added to {1}', exerciseNameText(ex), routine ? routine.name : t('Freestyle'))) }
// The confirm names what it changes: this workout, never the routine behind it.
else exConfigSheet(ex, null, commit, null, routine, seed, null, t('Add to this workout'))
})