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, and Count it as a working set for the way back
Duarte Santosde35addaea2f
diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.jsindex 5521145c6..76b5ef1b8 100644--- a/frontend/src/lib/history.js+++ b/frontend/src/lib/history.js@@ -917,6 +917,32 @@ export function insertWarmupRow(rows, mode, target, step = 2.5) {return next}+// The set-number menu's "Make it a warm-up set": the row takes the shape insertWarmupRow gives a+// 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.+export function makeWarmupAt(rows, i) {+ const src = rows[i]+ if (!src || isWarmupRow(src)) return rows+ const warm = { w: src.w || 0, r: src.r, done: !!src.done, phase: 'warmup', warmup: true }+ if (src.at != null) warm.at = src.at+ return placeRow(rows, i, warm)+}+// And back: "Count it as a working set" makes it the first work set.+export function makeWorkAt(rows, i) {+ const src = rows[i]+ if (!src || !isWarmupRow(src)) return rows+ const { phase, warmup, ...work } = src+ return placeRow(rows, i, work)+}+// Takes row i out and puts `row` where the work sets begin.+const placeRow = (rows, i, row) => {+ const next = rows.filter((_, j) => j !== i)+ const firstWork = next.findIndex(x => !isWarmupRow(x))+ next.splice(firstWork === -1 ? next.length : firstWork, 0, row)+ return next+}+/** Remove the row at `i`, never emptying the entry below one row. */export function removeRowAt(rows, i) {if (rows.length <= 1) return rows.slice()diff --git a/frontend/src/lib/history.test.js b/frontend/src/lib/history.test.jsindex e0bb26fd7..ba4fa7bef 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, 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, 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'@@ -1534,3 +1534,25 @@ describe('a rotation day and a fixed weekday day are one combined day', () => {expect(effectiveRoutineIds(dup, TODAY, TODAY)).toEqual(['a', 'core'])})})++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)+ 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('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)+ expect(workSetsDone({ entries: [e] })).toBe(1)+ })++ it('makeWorkAt makes it the first work set', () => {+ const rows = [{ w: 40, r: 8, phase: 'warmup', warmup: true }, { w: 60, r: 8, phase: 'warmup', warmup: true, done: true }, { w: 100, r: 5 }]+ expect(makeWorkAt(rows, 0)).toEqual([rows[1], { w: 40, r: 8 }, rows[2]])+ expect(makeWorkAt(rows, 2)).toBe(rows)+ })+})diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.jsindex 19ef73e6d..a2bead1e6 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('367ca8081ab9ad74d99b272118b21ac0f7ccb3398d01f647a071506f156894aa')+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('18a2fce113caf2bb80eecab23a2abb3c6174ab480da3394121d1d55d0c81a329')})test('does not leak European Portuguese UI terms', () => {diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.jsindex c8c4e8fe8..cd892eb76 100644--- a/frontend/src/locales/ar.js+++ b/frontend/src/locales/ar.js@@ -1939,4 +1939,6 @@ export default {'week start': 'بداية الأسبوع','Finish workout?': 'إنهاء التمرين؟','Finish and save': 'إنهاء وحفظ',+ 'Make it a warm-up set': 'اجعلها مجموعة إحماء',+ 'Count it as a working set': 'احسبها مجموعة عمل',}diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex 816736c16..f3f6ebe0a 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -1906,4 +1906,6 @@ export default {'week start': 'Wochenstart','Finish workout?': 'Training beenden?','Finish and save': 'Beenden und speichern',+ 'Make it a warm-up set': 'Zum Aufwärmsatz machen',+ 'Count it as a working set': 'Als Arbeitssatz zählen',}diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex 1a2c25eb6..4c91fb95e 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -1886,4 +1886,6 @@ export default {'week start': 'inicio de semana','Finish workout?': '¿Terminar entrenamiento?','Finish and save': 'Terminar y guardar',+ 'Make it a warm-up set': 'Convertir en serie de calentamiento',+ 'Count it as a working set': 'Contar como serie efectiva',}diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex d9fb384ea..77a64e1be 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -1886,4 +1886,6 @@ export default {'week start': 'début de semaine','Finish workout?': 'Terminer la séance ?','Finish and save': 'Terminer et enregistrer',+ 'Make it a warm-up set': 'En faire une série d’échauffement',+ 'Count it as a working set': 'Compter comme série de travail',}diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex fcdcfbe09..5e8606a3c 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -1886,4 +1886,6 @@ export default {'week start': 'सप्ताह की शुरुआत','Finish workout?': 'वर्कआउट समाप्त करें?','Finish and save': 'समाप्त करें और सहेजें',+ 'Make it a warm-up set': 'इसे वार्म-अप सेट बनाएं',+ 'Count it as a working set': 'इसे वर्किंग सेट गिनें',}diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex 88aa185f5..a05d91504 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -1889,4 +1889,6 @@ export default {'week start': 'hét kezdete','Finish workout?': 'Befejezed az edzést?','Finish and save': 'Befejezés és mentés',+ 'Make it a warm-up set': 'Legyen bemelegítő sorozat',+ 'Count it as a working set': 'Számítson munkasorozatnak',}diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex ba9ee861a..72f5ca998 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -1886,4 +1886,6 @@ export default {'week start': 'inizio settimana','Finish workout?': 'Terminare l’allenamento?','Finish and save': 'Termina e salva',+ 'Make it a warm-up set': 'Rendila serie di riscaldamento',+ 'Count it as a working set': 'Conta come serie allenante',}diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex 98d34ef02..d815dbc50 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -1886,4 +1886,6 @@ export default {'week start': '주 시작','Finish workout?': '운동을 마칠까요?','Finish and save': '마치고 저장',+ 'Make it a warm-up set': '워밍업 세트로 바꾸기',+ 'Count it as a working set': '본 세트로 세기',}diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex b8605de98..1c62e3636 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -1886,4 +1886,6 @@ export default {'week start': 'początek tygodnia','Finish workout?': 'Zakończyć trening?','Finish and save': 'Zakończ i zapisz',+ 'Make it a warm-up set': 'Zamień na serię rozgrzewkową',+ 'Count it as a working set': 'Licz jako serię roboczą',}diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex 56134a439..d2a0f39a3 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -1886,4 +1886,6 @@ export default {'week start': 'início da semana','Finish workout?': 'Terminar o treino?','Finish and save': 'Terminar e guardar',+ 'Make it a warm-up set': 'Tornar série de aquecimento',+ 'Count it as a working set': 'Contar como série de trabalho',}diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex 093ddd94b..a49117e6b 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -1890,4 +1890,6 @@ export default {'week start': 'начало недели','Finish workout?': 'Завершить тренировку?','Finish and save': 'Завершить и сохранить',+ 'Make it a warm-up set': 'Сделать разминочным подходом',+ 'Count it as a working set': 'Считать рабочим подходом',}diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex 7f9586fa1..b71814eb3 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -1897,4 +1897,6 @@ export default {'week start': 'วันเริ่มสัปดาห์','Finish workout?': 'จบการออกกำลังกายไหม?','Finish and save': 'จบและบันทึก',+ 'Make it a warm-up set': 'เปลี่ยนเป็นเซ็ตวอร์มอัพ',+ 'Count it as a working set': 'นับเป็นเซ็ตจริง',}diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex 882991023..36f053602 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -1886,4 +1886,6 @@ export default {'week start': 'hafta başlangıcı','Finish workout?': 'Antrenman bitirilsin mi?','Finish and save': 'Bitir ve kaydet',+ 'Make it a warm-up set': 'Isınma setine çevir',+ 'Count it as a working set': 'Çalışma seti say',}diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.jsindex 4cb74f562..92681728d 100644--- a/frontend/src/locales/uk.js+++ b/frontend/src/locales/uk.js@@ -1883,4 +1883,6 @@ export default {'week start': 'початок тижня','Finish workout?': 'Завершити тренування?','Finish and save': 'Завершити й зберегти',+ 'Make it a warm-up set': 'Зробити розминковим підходом',+ 'Count it as a working set': 'Рахувати робочим підходом',}diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.jsindex 833c6e7fd..8213250a0 100644--- a/frontend/src/locales/zh-TW.js+++ b/frontend/src/locales/zh-TW.js@@ -1879,4 +1879,6 @@ export default {'week start': '每週開始','Finish workout?': '結束訓練?','Finish and save': '結束並儲存',+ 'Make it a warm-up set': '改為熱身組',+ 'Count it as a working set': '算作正式組',}diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex e4f789a5b..97ad9bce0 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -1886,4 +1886,6 @@ export default {'week start': '每周开始','Finish workout?': '结束训练?','Finish and save': '结束并保存',+ 'Make it a warm-up set': '改为热身组',+ 'Count it as a working set': '算作正式组',}diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsxindex b0491a1f6..a0d6431f4 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, 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, 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'@@ -105,6 +105,11 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSi// A planned exercise (see the exercise's "Intensifier" config) arrives with these already// filled in by applyIntensifierPlan; these only add/edit/remove entries live from here on.const mutSet = (i, fn) => update(s => { const row = s.active.entries[entryIdx].sets[i]; s.active.entries[entryIdx].sets[i] = fn(row) }, true)+ // Warm-up or work is the row's phase; switching it moves the row to the edge of the warm-ups.+ const setPhaseAt = (i, warm) => update(s => {+ const e = s.active.entries[entryIdx]+ e.sets = warm ? makeWarmupAt(e.sets, i) : makeWorkAt(e.sets, i)+ }, true)const addDropRow = i => mutSet(i, row => {// A unilateral set drops per side (issue #60): addSideDrop seeds each side from its own weight.if (isSideSet(row)) {@@ -408,6 +413,13 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSititle: warm ? t('Warm-up') : sideTag ? t('Set {0} ({1})', setNumOf(s, i), sideTag) : t('Set {0}', setNumOf(s, i)),subtitle: setLabel(entry.id, s, entry.target, speedUnit),sections: [+ // A warm-up logged as a work set (or the other way round) changes phase here. Reps sets+ // 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' && !perSide && { icon: 'dumbbell', label: t('Count it as a working set'), onClick: () => setPhaseAt(i, false) },+ ] },{ title: t('Add to this set'), 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) },diff --git a/frontend/src/views/Workout.test.jsx b/frontend/src/views/Workout.test.jsxindex f7d0c26d2..e52af29cc 100644--- a/frontend/src/views/Workout.test.jsx+++ b/frontend/src/views/Workout.test.jsx@@ -1769,7 +1769,8 @@ describe('workout controls: the more menu and the set menu', () => {it('opens a per-set menu from the set number with drop, burst and remove', async () => {await mount([exercise('plain-bench', [false, false])])await act(async () => { container.querySelector('button[aria-label="Set 2"]').dispatchEvent(new dom.Event('click', { bubbles: true })) })- expect(menuItemsOf(lastMenu()).map(it => it.label)).toEqual(['Drop set', 'Rest-pause burst', 'Remove this set'])+ expect(menuItemsOf(lastMenu()).map(it => it.label)).toEqual(['Make it a warm-up set', 'Drop set', 'Rest-pause burst', 'Remove this set'])+ expect(item('Make it a warm-up set').icon).toBe('sunrise')await act(async () => { item('Drop set').onClick() })expect(mocks.S.active.entries[0].sets[1].drops?.length).toBe(1)@@ -1779,6 +1780,28 @@ describe('workout controls: the more menu and the set menu', () => {expect(mocks.S.active.entries[0].sets.length).toBe(1)})+ it('makes a work set a warm-up and back, and keeps one work set', async () => {+ await mount([exercise('plain-bench', [true, false])])+ // a warm-up's number button is "Set 1" too, so rows are picked by position+ const openSet = async k => { await act(async () => { container.querySelectorAll('button.n')[k].dispatchEvent(new dom.Event('click', { bubbles: true })) }) }+ await openSet(1)+ await act(async () => { item('Make it a warm-up set').onClick() })+ const sets = () => mocks.S.active.entries[0].sets+ // moved in front of the work sets, in the shape Add warm-up set gives one+ expect(sets()[0]).toEqual({ w: 60, r: 5, done: false, phase: 'warmup', warmup: true })+ expect(isWarmupRow(sets()[1])).toBe(false)+ // the last work set cannot become one too+ await rerender()+ await openSet(1)+ expect(item('Make it a warm-up set')).toBeUndefined()+ // and a warm-up counts as a working set again+ await openSet(0)+ expect(lastMenu().title).toBe('Warm-up')+ await act(async () => { item('Count it as a working set').onClick() })+ expect(sets().every(x => !isWarmupRow(x))).toBe(true)+ expect(sets()[0]).toEqual({ w: 60, r: 5, done: false })+ })+it('brings the legacy button rows back per switch', async () => {await mount([exercise('plain-bench', [false]), exercise('plain-row', [false])], 0, {wc: { setShortcuts: true, pairButtons: true, exerciseButtons: true },@@ -2271,10 +2294,10 @@ describe('the workout screen chrome (v1.3.11)', () => {expect(item('Rest timer')).toBeUndefined()})- it('groups the set menu under a header, with Remove on its own', async () => {+ it('groups the set menu: the warm-up switch, then Add to this set, with Remove on its own', async () => {await mount([exercise('plain-bench', [false, false])])await click(container.querySelector('button[aria-label="Set 1"]'))- expect(lastMenu().sections.map(g => g.title)).toEqual(['Add to this set', undefined])+ expect(lastMenu().sections.map(g => g.title)).toEqual([undefined, 'Add to this set', undefined])})it('shows a thumbnail instead of the animation when animations are Small, and a tap brings it back', async () => {