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(focus): plan line, plate loading and the no-progression switch in the focus view

giulioleuciab265143f632
diff --git a/docs/superpowers/specs/2026-09-14-focus-workout-view-design.md b/docs/superpowers/specs/2026-09-14-focus-workout-view-design.md
deleted file mode 100644
index 9842051ff..000000000
--- a/docs/superpowers/specs/2026-09-14-focus-workout-view-design.md
+++ /dev/null
@@ -1,168 +0,0 @@
-# Design Spec: Focus Workout View Mode
-
-**Date:** 2026-09-14
-**Status:** Approved for Implementation
-**Topic:** Adding "Focus" View Mode to Active Workout and Settings
-**References:** `single_exercise.png`, `superset.png`, `docs/LIST_VIEW.md`
-
----
-
-## 1. Overview & Objective
-
-OpenGym currently provides three layouts for the active workout view:
-1. `cards`: One exercise unit at a time, with Prev/Next buttons and horizontal swipe.
-2. `list`: All exercise units stacked vertically in a scrollable list with compact rows.
-3. `compact`: Dense variant of `list` stripping non-essential media, tags, and guidance lines.
-
-This specification introduces a fourth view option: **`focus`**.
-The Focus view mode displays a **single set at a time** for each exercise with large, tactile inputs (steppers for load and reps, RPE slider, prominent completion button) and intra-exercise set navigation (footer pager with chevrons and pagination dots). In supersets, it presents a round-by-round flow with a dedicated superset header, round indicator, and exercise switchers.
-
-All user-facing strings across the interface, code, and test cases must be in **English**.
-
----
-
-## 2. Architecture & Data Model
-
-### 2.1 Presentational Decoupling
-Like `cards`, `list`, and `compact`, the `focus` view mode is strictly presentational:
-- It relies on the identical `s.active` session model, entries array (`s.active.entries`), and set structure.
-- It operates with the same set mutators, completion logic, sound/haptic feedback, progression system, and rest timers.
-- Mid-workout layout changes (via the workout header `⋮` menu) remain non-destructive and instant.
-
-### 2.2 Store & Persistence
-- **Type signature**: `S.workoutView` and `s.active.workoutView` accept `'cards' | 'list' | 'compact' | 'focus'`.
-- **Default value**: `'cards'`. Unrecognized or absent values safely fall back to `'cards'`.
-- **Settings Screen (`frontend/src/views/Settings.jsx`)**:
- - The `Segmented` control under **Workout view** expands to 4 choices:
- - `{ value: 'cards', label: t('Cards') }`
- - `{ value: 'list', label: t('List') }`
- - `{ value: 'compact', label: t('Compact') }`
- - `{ value: 'focus', label: t('Focus') }`
- - Fallback check updated: `['list', 'compact', 'focus'].includes(S.workoutView) ? S.workoutView : 'cards'`.
-- **Active Workout Header Menu (`frontend/src/views/Workout.jsx`)**:
- - `LAYOUT_LABEL` updated with `focus: t('Focus')`.
- - Layout picker menu includes `{ icon: 'target', label: t('Focus'), on: workoutView === 'focus', onClick: () => setWorkoutView('focus') }`.
-- **Session Snapshotting (`frontend/src/sheets.jsx`)**:
- - `beginWorkout` and `beginBackfill` snapshot `st.workoutView || 'cards'` into `s.active.workoutView`.
-
----
-
-## 3. Interaction & State Management
-
-### 3.1 Active Set State Tracking
-In Focus view, an exercise displays one focused set at a time:
-- **Set Pointer (`curSetIdx`)**:
- - Tracked in local state keyed per entry index (e.g. `Map<number, number>` or local state inside the focus view component).
- - **Default on Mount / Entry Change**: Resolves to the **first incomplete set** (`entry.sets.findIndex(s => !s.done)`). If all sets are completed, defaults to the last set (`entry.sets.length - 1`).
- - **Manual Navigation**: Users can tap the `<` or `>` chevrons or tap any pagination dot to inspect or edit any set.
- - **Auto-Advance on Completion**:
- - Tapping `Complete` executes OpenGym's standard `onToggle(curSetIdx)`.
- - If another set exists in the current exercise, `curSetIdx` increments to `curSetIdx + 1`.
- - If the set was the final incomplete set for that exercise (or round in a superset), standard rest begins and navigation advances to the next exercise / round.
-
-### 3.2 Exercise-Level Navigation
-- Below the focus card, OpenGym's existing **Prev** and **Next** exercise buttons and horizontal swipe surface remain available to navigate between different exercises.
-- Once all sets of an exercise are finished, the workout automatically advances to the next unfinished exercise.
-
----
-
-## 4. UI Components & Visual Design
-
-### 4.1 Single Exercise Layout (Inspiration: `single_exercise.png`)
-
-1. **Card Header**:
- - Exercise name in bold title font.
- - Info button `(i)`: triggers exercise detail sheet.
- - Warm-up indicator: flame icon `🔥` displayed if the active set is a warm-up.
- - Exercise menu `⋮`: triggers standard exercise options (Notes, History, Progression Settings, Swap, Remove).
-2. **Prescription & Target Badges**:
- - Set progress pill: e.g., `1/4` (representing `Set {current} of {total}`).
- - Prescribed Reps chip: e.g., `1–5 Reps` (or target reps).
- - Prescribed Load chip: e.g., `@ 20–25 kg` (when target load is configured).
- - Target RPE chip: e.g., `RPE 7–9` (when configured).
- - Rest target chip: e.g., `Rest 120–180s` (based on configured rest).
- - Tempo chip: e.g., `3010` (when tempo is configured).
-3. **Set Input Steppers**:
- - **Load (kg / lbs)**:
- - Label: `Load (kg)` or `Load (lbs)` based on active unit.
- - Stepper control: `[-]` button, centered editable numeric value, `[+]` button.
- - Increment: uses exercise-specific or default load increment (`weightIncrement`).
- - Tapping the numeric value opens the native numeric input keyboard.
- - **Reps**:
- - Label: `Reps`.
- - Stepper control: `[-]` button, centered editable numeric value, `[+]` button (step size `1`).
- - Direct numeric tap edit.
-4. **RPE Slider**:
- - Label: `RPE`.
- - Horizontal slider ranging from `6` to `10` with `0.5` step increments, with an unrated state `-`.
- - Displays selected RPE score dynamically.
-5. **Primary Action Button**:
- - Full-width high-contrast button: `✓ Complete` (or `✓ Completed` if already ticked).
- - Tapping toggles completion, beeps, vibrates, triggers rest countdown, and advances set.
-6. **Secondary Actions Row**:
- - Set Note icon button: opens set note.
- - `▷| Skip` button: navigates to next set without marking complete.
- - `•••` Set Menu: opens set actions (toggle warm-up, add drop-set, add burst, delete set).
-7. **Footer Set Pager**:
- - Left chevron button `<` (disabled on set 1).
- - Pagination dots (`• • • •`): one dot per set. Active set is highlighted (larger/accented). Tapping any dot selects that set directly.
- - Right chevron button `>` (disabled on last set).
-
----
-
-### 4.2 Superset Layout (Inspiration: `superset.png`)
-
-1. **Outer Superset Container**:
- - Header with superset icon `⟳` and joined exercise names: e.g., `Barbell Curl + French Press`.
- - Subheader bar:
- - `Round X` badge (e.g., `Round 1`).
- - Exercise indicator: `Exercise X of Y` (e.g., `Exercise 2 of 2`).
- - Navigation chevrons `<` `>` to cycle through exercises/rounds within the superset.
-2. **Inner Active Exercise Card**:
- - Renders the active exercise's set for that round using the rich single-set card layout.
-3. **Round-by-Round Progression Flow**:
- - Operates in round order: Exercise A Set 1 → Exercise B Set 1 → Round 2 (Exercise A Set 2 → Exercise B Set 2).
- - Driven by `supersetFlowStep` in `frontend/src/lib/supersetFlow.js`.
-
----
-
-### 4.3 Special Set Types Handling
-
-1. **Unilateral (Per-side L/R) Sets**:
- - Stacked Left (`L`) and Right (`R`) stepper sections inside the card.
- - Each side has its own Load and Reps steppers, alongside side completion ticks or combined completion.
-2. **Timed Sets**:
- - In place of the Reps stepper, renders the hold duration and `▶ Start` timer button.
-3. **Drop-Sets & Bursts**:
- - Displayed beneath the main set stepper as sub-stepper rows, maintaining full inline adjustability.
-
----
-
-## 5. Implementation Structure
-
-1. **`frontend/src/views/FocusView.jsx`**:
- - Core component rendering the focused exercise card, steppers, RPE slider, superset round header, and footer pager.
-2. **`frontend/src/views/FocusView.css`**:
- - Dedicated styling for tactile steppers, RPE slider, pagination dots, and superset headers adhering to OpenGym's CSS variable design tokens.
-3. **`frontend/src/views/Workout.jsx`**:
- - Integrated into `ActiveWorkout`: when `workoutView === 'focus'`, renders `<FocusView ... />` instead of `<ExerciseBlock />` or `.workout-list`.
- - Layout switcher menu includes `'focus'`.
-4. **`frontend/src/views/Settings.jsx`**:
- - Segmented control updated to include `focus`.
-
----
-
-## 6. Testing & Quality Assurance
-
-1. **Settings View Tests (`frontend/src/views/Settings.workoutview.test.jsx`)**:
- - Verify Segmented control renders all 4 choices: Cards, List, Compact, Focus.
- - Verify selecting Focus sets `S.workoutView = 'focus'`.
-2. **Session Snapshot Tests (`frontend/src/sheets.workoutview.test.jsx`)**:
- - Verify `beginWorkout` copies `workoutView: 'focus'` to `s.active.workoutView`.
-3. **Focus View Component Tests (`frontend/src/views/FocusView.test.jsx` / `Workout.test.jsx`)**:
- - Verify rendering of set 1 of N with correct initial target values.
- - Verify `<` / `>` and pagination dots correctly change the active set.
- - Verify `Complete` button marks set done, starts rest, and increments `curSetIdx`.
- - Verify `Skip` button advances to next set without marking it done.
- - Verify superset round-by-round auto-advance and round header display.
- - Verify unilateral set rendering and mutator updates.
diff --git a/frontend/src/views/FocusView.jsx b/frontend/src/views/FocusView.jsx
index 4a141ef03..7d45b9338 100644
--- a/frontend/src/views/FocusView.jsx
+++ b/frontend/src/views/FocusView.jsx
@@ -2,9 +2,9 @@ import { useState } from 'react'
import { useStore } from '../store/useStore.js'
import { exOr } from '../lib/exercises.js'
import { exerciseNameFor, t } from '../lib/i18n.js'
-import { fmtDate, fmtNum } from '../lib/format.js'
+import { fmtDate, fmtNum, fmtPlate } from '../lib/format.js'
import { EFFORT, effortOf, modeOf } from '../lib/history.js'
-import { lastEntryFor, pinnedNoteFor } from '../lib/history.js'
+import { lastEntryFor, pinnedNoteFor, setsRepsOf } from '../lib/history.js'
import { effortColor, rirOf } from '../lib/effort.js'
import { progressionGuidance } from '../lib/progression-copy.js'
import {
@@ -13,7 +13,8 @@ import {
setDropAt, setSideClusterAt, setSideDropAt, setSideField,
} from '../lib/workout-model.js'
import { weightIncrement, stepWeight } from '../lib/progression.js'
-import { effortPickerSheet, exerciseDetailSheet, exerciseHistorySheet, exerciseNoteSheet, menuSheet } from '../sheets.jsx'
+import { effortPickerSheet, exerciseDetailSheet, exerciseHistorySheet, exerciseNoteSheet, menuSheet, barWeightSheet } from '../sheets.jsx'
+import { baseWeightFor, inventoryFor, loadKindFor, rowLoad } from '../lib/plates.js'
import Icon from '../components/Icon.jsx'
import { Button, Stepper } from '../components/ui.jsx'
import './FocusView.css'
@@ -73,10 +74,34 @@ function Prescription({ entry, setIdx, unit, fallbackRest }) {
</div>
}
+function PlanLine({ entry, mode }) {
+ const planned = entry.planned && mode !== 'cardio' ? entry.planned : null
+ if (!planned) return null
+ const today = entry.target || {}
+ const todaySets = today.sets || planned.sets || 1
+ const inPlan = mode === 'time'
+ ? today.sec == null || today.sec === planned.sec
+ : today.reps == null || (planned.repsMin > 0 ? today.reps >= planned.repsMin && today.reps <= planned.reps : today.reps === planned.reps)
+ const note = todaySets !== (planned.sets || 1) || !inPlan
+ ? t('today {0}', setsRepsOf({ mode, sets: todaySets, reps: today.reps, sec: today.sec }))
+ : entry.carried ? t('reps from your last session') : null
+ return <div className="small dim planline">{t('Plan: {0}', setsRepsOf({ ...planned, mode }))}{note ? ' · ' + note : ''}</div>
+}
+
+function PlateLine({ S, entry, set }) {
+ if (modeOf({ ...(entry.target || {}), id: entry.id }) !== 'reps') return null
+ const load = rowLoad(loadKindFor(S, { ...(entry.target || {}), id: entry.id }), set.w, baseWeightFor(S, entry.id), inventoryFor(S))
+ if (!load) return null
+ const stack = load.plates.map(fmtPlate).join(' + ')
+ const text = load.barOnly ? t('Bar only')
+ : load.kind === 'pairs' ? t('{0} per side', stack || '—') : t('Load {0}', stack || '—')
+ return <div className="plateline"><Icon name="plate" /><span>{text}{load.missing > 0 && <> · <span className="short">{t('{0} short', fmtPlate(load.missing) + ' ' + S.unit)}</span></>}</span></div>
+}
+
export default function FocusView({
entryIdx, unit, onToggle, onToggleSide, onField, onMutateSet, onStartTimed,
onAddWarmup, onRemoveSetAt, onProgressionSettings, onSwap, onRemoveExercise,
- busy, onSelectEntry, onAdvanceUnit, onPairPrev, onPairNext, onUnpair, pointerEpoch,
+ onNoProg, busy, onSelectEntry, onAdvanceUnit, onPairPrev, onPairNext, onUnpair, pointerEpoch,
}) {
const S = useStore(state => state.S)
const entry = S.active.entries[entryIdx]
@@ -189,6 +214,8 @@ export default function FocusView({
{ icon: 'info', label: t('Details'), onClick: () => exerciseDetailSheet(exOr(entry.id)) },
{ icon: 'history', label: t('History'), onClick: () => exerciseHistorySheet(entry.id) },
{ icon: 'chartLine', label: t('Progression settings'), onClick: onProgressionSettings },
+ onNoProg && { icon: 'pause', label: t('Don’t count for progression'), sub: t('This exercise, this session only'), on: entry.noProg === true, onClick: () => onNoProg(entry.noProg !== true) },
+ mode === 'reps' && { icon: 'plate', label: t('Plate loading'), onClick: () => barWeightSheet(entry.id, { ...(entry.target || {}), id: entry.id }) },
onPairPrev && { icon: 'link', label: t('Make superset with previous'), onClick: onPairPrev },
onPairNext && { icon: 'link', label: t('Make superset with next'), onClick: onPairNext },
{ icon: 'shuffle', label: t('Swap exercise'), onClick: onSwap, disabled: busy },
@@ -201,7 +228,7 @@ export default function FocusView({
items: [
{ icon: 'flame', label: isWarmupRow(set) ? t('Mark as work set') : t('Mark as warm-up'), onClick: () => onMutateSet(setIdx, toggleWarmup) },
{ icon: 'arrowDown', label: t('Add drop set'), onClick: () => onMutateSet(setIdx, row => addDropTo(row, entry.target)) },
- { icon: 'bolt', label: t('Add burst'), onClick: () => onMutateSet(setIdx, row => addBurstTo(row, S.restPauseSec || 15)) },
+ { icon: 'bolt', label: t('Add burst'), onClick: () => onMutateSet(setIdx, row => addBurstTo(row, entry.target?.intensifier?.type === 'restpause' ? entry.target.intensifier.restSec : (S.restPauseSec || 15))) },
{ icon: 'trash', label: t('Delete set'), danger: true, disabled: entry.sets.length <= 1, onClick: () => onRemoveSetAt(setIdx) },
],
})
@@ -238,6 +265,8 @@ export default function FocusView({
{last && <div className="focus-last">{t('Last time')} · {fmtDate(last.d)}</div>}
{guidance && <button className="focus-guidance" onClick={onProgressionSettings}><Icon name="lightbulb" />{t(guidance.policyLabel)}</button>}
</div>
+ {entry.noProg === true && <div className="noprog"><Icon name="pause" /><span>{t('Not counted for progression')}</span>{onNoProg && <button type="button" className="chip" onClick={() => onNoProg(false)}>{t('Undo')}</button>}</div>}
+ <PlanLine entry={entry} mode={mode} />
<Prescription entry={entry} setIdx={setIdx} unit={S.unit} fallbackRest={S.restSec} />
{locked && <p className="focus-lock-note" role="status">{t('Complete set {0} to edit this one.', firstOpenSet + 1)}</p>}
@@ -280,6 +309,7 @@ export default function FocusView({
style={effortTint ? { color: effortTint, borderColor: effortTint, background: `color-mix(in srgb, ${effortTint} 20%, var(--surface-2))` } : undefined}
aria-label={t(EFFORT[effort].hd)} disabled={readOnly} onClick={openEffort}>{effortValue == null ? t(EFFORT[effort].hd) : fmtNum(effortValue)}</button>}
</div>
+ <PlateLine S={S} entry={entry} set={set} />
<Button variant="primary" icon="check" aria-label={t('Complete set')} onClick={complete}>{set.done ? t('Completed') : t('Complete')}</Button>
<div className="focus-secondary">
diff --git a/frontend/src/views/FocusView.test.jsx b/frontend/src/views/FocusView.test.jsx
new file mode 100644
index 000000000..21ffe3619
--- /dev/null
+++ b/frontend/src/views/FocusView.test.jsx
@@ -0,0 +1,101 @@
+// @vitest-environment happy-dom
+import React, { act } from 'react'
+import { createRoot } from 'react-dom/client'
+import { MemoryRouter } from 'react-router-dom'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import Workout from './Workout.jsx'
+import { DEF, useStore } from '../store/useStore.js'
+import { useUI } from '../store/useUI.js'
+
+vi.mock('../lib/sound.js', () => ({ beep: vi.fn(), vibrate: vi.fn(), unlock: vi.fn() }))
+vi.mock('../lib/api.js', () => ({ api: vi.fn(() => Promise.resolve({})) }))
+
+globalThis.IS_REACT_ACT_ENVIRONMENT = true
+const clone = value => JSON.parse(JSON.stringify(value))
+const SQUAT = '0043'
+
+let root, container, sheetRoot, sheetContainer
+
+function mount(entry) {
+ const S = clone(DEF)
+ S.unit = 'lb'
+ S.active = {
+ id: 'focus-test', d: '2026-09-28', start: Date.now(), routineId: null,
+ name: 'Focus', bw: null, cur: 0, workoutView: 'focus', entries: [entry],
+ }
+ useStore.setState({ S, user: null })
+ container = document.createElement('div')
+ document.body.appendChild(container)
+ root = createRoot(container)
+ act(() => root.render(<MemoryRouter><Workout /></MemoryRouter>))
+}
+
+function openMenu() {
+ act(() => container.querySelector('button[aria-label="More"]').click())
+ const sheet = useUI.getState().sheets.at(-1)
+ sheetContainer = document.createElement('div')
+ document.body.appendChild(sheetContainer)
+ sheetRoot = createRoot(sheetContainer)
+ act(() => sheetRoot.render(sheet.render(() => useUI.getState().closeSheet(sheet.id))))
+ return sheetContainer
+}
+
+beforeEach(() => {
+ useUI.setState({ sheets: [], toastMsg: '', timer: null, work: null })
+})
+
+afterEach(() => {
+ if (sheetRoot) act(() => sheetRoot.unmount())
+ if (sheetContainer) sheetContainer.remove()
+ if (root) act(() => root.unmount())
+ if (container) container.remove()
+ sheetRoot = sheetContainer = root = container = null
+ useUI.getState().stopRest()
+})
+
+describe('Focus workout view', () => {
+ it('keeps the plan and plate guidance visible', () => {
+ mount({
+ id: SQUAT,
+ target: { sets: 1, reps: 5, weight: 95 },
+ planned: { sets: 1, reps: 5, weight: 95 },
+ plan: { kind: 'up' },
+ sets: [{ w: 95, r: 5, done: false }],
+ })
+
+ expect(container.textContent).toContain('Plan: 1 × 5')
+ expect(container.querySelector('.plateline')?.textContent).toContain('25 per side')
+ })
+
+ it('offers the per-exercise progression switch and marks the current exercise', () => {
+ mount({ id: SQUAT, target: { sets: 1, reps: 5, weight: 95 }, sets: [{ w: 95, r: 5, done: false }] })
+
+ const item = [...openMenu().querySelectorAll('.menu-item')]
+ .find(el => el.querySelector('.tt')?.textContent === 'Don’t count for progression')
+ expect(item).toBeTruthy()
+ act(() => item.click())
+
+ expect(useStore.getState().S.active.entries[0].noProg).toBe(true)
+ expect(container.querySelector('.noprog')?.textContent).toContain('Not counted for progression')
+ })
+
+ it('uses the exercise rest-pause duration for a new burst', () => {
+ mount({
+ id: SQUAT,
+ target: { sets: 1, reps: 5, weight: 95, intensifier: { type: 'restpause', restSec: 7 } },
+ sets: [{ w: 95, r: 5, done: false }],
+ })
+
+ act(() => container.querySelector('button[aria-label="Set menu"]').click())
+ const sheet = useUI.getState().sheets.at(-1)
+ sheetContainer = document.createElement('div')
+ document.body.appendChild(sheetContainer)
+ sheetRoot = createRoot(sheetContainer)
+ act(() => sheetRoot.render(sheet.render(() => useUI.getState().closeSheet(sheet.id))))
+ const item = [...sheetContainer.querySelectorAll('.menu-item')]
+ .find(el => el.querySelector('.tt')?.textContent === 'Add burst')
+ act(() => item.click())
+
+ expect(useStore.getState().S.active.entries[0].sets[0].clusters[0].restSec).toBe(7)
+ })
+})
diff --git a/frontend/src/views/Workout.keys.test.jsx b/frontend/src/views/Workout.keys.test.jsx
index 59fefb84e..7718d5f87 100644
--- a/frontend/src/views/Workout.keys.test.jsx
+++ b/frontend/src/views/Workout.keys.test.jsx
@@ -70,6 +70,14 @@ describe('workout keys (issue #133)', () => {
expect(doneOf(0)).toEqual([true, true, true])
})
+ it('Space and Enter tick Focus sets through the same handler', () => {
+ renderWorkout([entry('1001', [false, false])], 0, { workoutView: 'focus' })
+ expect(container.querySelector('[data-testid="focus-view"]')).toBeTruthy()
+ press(' ')
+ press('Enter')
+ expect(doneOf(0)).toEqual([true, true])
+ })
+
it('once the exercise on screen is finished, a press brings up the next one and the next press ticks it', () => {
renderWorkout([entry('1001', [true]), entry('1002', [false, false])])
press(' ')