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.

Focus mode: Add set and Add warm-up set in the exercise menu (Discord)

Duarte Santos71cb8f41f6a2
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5642fe043..9d42c104f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -94,6 +94,8 @@ you leave it alone. Handy for deciding whether those legs are really ready (than
session opens at it unless last time had a grade of its own, and it travels in shared plans.
- Exercise names on the Lock Screen, in the Dynamic Island, on the Apple Watch and in the widgets
are title-cased like in the app, instead of whispering "barbell bench press".
+- Focus mode: the exercise's ⋯ menu has Add set and Add warm-up set, so one more set no longer
+ means a trip to the Cards layout.
- A weight change too small to show (say 0.03 kg) reads 0 instead of a lonely "-0".
- Admin → AI Coach: the Remove button for the stored key is red now, like every other button
that deletes something for good.
diff --git a/frontend/src/views/FocusView.jsx b/frontend/src/views/FocusView.jsx
index aeedc137c..c1c4eb071 100644
--- a/frontend/src/views/FocusView.jsx
+++ b/frontend/src/views/FocusView.jsx
@@ -108,7 +108,7 @@ function PlateBadge({ S, entry, set }) {
export default function FocusView({
entryIdx, unit, onToggle, onToggleSide, onField, onMutateSet, onStartTimed,
- onAddWarmup, onRemoveSetAt, onProgressionSettings, onSwap, onRemoveExercise,
+ onAddSet, onAddWarmup, onRemoveSetAt, onProgressionSettings, onSwap, onRemoveExercise,
onNoProg, busy, onSelectEntry, onAdvanceUnit, onPairPrev, onPairNext, onUnpair, pointerEpoch,
}) {
const S = useStore(state => state.S)
@@ -219,9 +219,15 @@ export default function FocusView({
const openEffort = () => effortPickerSheet(effort, effortValue, value => onField(setIdx, effortField, value))
+ // One more set, or a warm-up in front, like the Cards layout's buttons (Discord: "how do I add an
+ // extra set?"). The set on screen goes back to the next one to do, which is the new set once the
+ // others are done; a stored pointer would also sit on the wrong row after a warm-up goes in front.
+ const addRow = add => () => { add(); clearPointer(entryIdx) }
const openExerciseMenu = () => menuSheet({
title: exerciseNameFor(exOr(entry.id)),
items: [
+ { icon: 'plus', label: t('Add set'), onClick: addRow(onAddSet) },
+ { icon: 'sunrise', label: t('Add warm-up set'), onClick: addRow(onAddWarmup) },
{ icon: 'pencil', label: entry.note ? t('Edit note') : t('Add note'), onClick: () => exerciseNoteSheet(entryIdx) },
{ icon: 'info', label: t('Details'), onClick: () => exerciseDetailSheet(exOr(entry.id)) },
{ icon: 'history', label: t('History'), onClick: () => exerciseHistorySheet(entry.id) },
diff --git a/frontend/src/views/FocusView.test.jsx b/frontend/src/views/FocusView.test.jsx
index a39bafba2..d8180c3b7 100644
--- a/frontend/src/views/FocusView.test.jsx
+++ b/frontend/src/views/FocusView.test.jsx
@@ -104,6 +104,27 @@ describe('Focus workout view', () => {
expect(container.querySelector('.noprog')).toBeNull()
})
+ // Discord: "In Focus mode, how do I add an extra set?" The ⋯ menu has it now, with the warm-up,
+ // like the Cards layout's buttons; the new set is the one on screen when the others are done.
+ it('adds a set and a warm-up set from the exercise menu', () => {
+ mount({ id: SQUAT, target: { sets: 2, reps: 5, weight: 95 }, sets: [{ w: 95, r: 5, done: true }, { w: 95, r: 5, done: true }] })
+ const pick = label => {
+ const item = [...openMenu().querySelectorAll('.menu-item')].find(el => el.querySelector('.tt')?.textContent === label)
+ expect(item, label).toBeTruthy()
+ act(() => item.click())
+ act(() => sheetRoot.unmount()); sheetContainer.remove(); sheetRoot = sheetContainer = null
+ }
+ pick('Add set')
+ const sets = () => useStore.getState().S.active.entries[0].sets
+ expect(sets()).toHaveLength(3)
+ expect(sets()[2]).toMatchObject({ w: 95, r: 5, done: false })
+ expect(container.querySelectorAll('.focus-dots button')).toHaveLength(3)
+ expect(container.querySelector('.focus-dots button.active').getAttribute('aria-label')).toBe('Set 3')
+ pick('Add warm-up set')
+ expect(sets()).toHaveLength(4)
+ expect(sets().filter(row => row.phase === 'warmup' || row.warmup)).toHaveLength(1)
+ })
+
it('uses the exercise rest-pause duration for a new burst', () => {
mount({
id: SQUAT,