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
feat(workout): collapsed list shows only what is left (#241, Discord request)
Duarte Santosb16c34027044
diff --git a/frontend/src/index.css b/frontend/src/index.cssindex 5bd506030..e1353df66 100644--- a/frontend/src/index.css+++ b/frontend/src/index.css@@ -1846,6 +1846,8 @@ body.no-tabbar.resting #toast{bottom:calc(100px + var(--sab))}.wl-unit.cur{box-shadow:inset 0 0 0 1.5px var(--acc-line)}.wl-hd{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:10px}.wl-summary{display:grid;gap:8px;padding-bottom:10px}+/* the folded unit is a button (a tap opens it again): full width, text where it always sat */+button.wl-summary{width:100%;padding:0 0 10px;text-align:start;border-radius:var(--r-sm)}/* --- the chip per exercise at the top of a running workout (#323) --- *//* One numbered chip per unit, filled as far as it is done: an outline waiting, half full started,diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.jsindex e5ab9f003..e1325273f 100644--- a/frontend/src/locales/ar.js+++ b/frontend/src/locales/ar.js@@ -2222,4 +2222,8 @@ export default {'Not started yet': 'لم يبدأ بعد','Exercise chips at the top': 'شارات التمارين في الأعلى','A numbered dot per exercise, filled as you go. Tap one to jump there.': 'نقطة مرقّمة لكل تمرين تمتلئ كلما تقدّمت. اضغط على واحدة للانتقال إليه.',+ // --- collapse completed exercises (#241) ---+ 'Fold away': 'اطوِه',+ 'Show the sets': 'اعرض المجموعات',+ 'In List and Compact, a finished exercise folds into one line.': 'في عرض القائمة والمضغوط، يُطوى التمرين المكتمل في سطر واحد.',}diff --git a/frontend/src/locales/bn.js b/frontend/src/locales/bn.jsindex 3f22dfde0..c1c29c50f 100644--- a/frontend/src/locales/bn.js+++ b/frontend/src/locales/bn.js@@ -2246,4 +2246,8 @@ export default {'Not started yet': 'এখনও শুরু হয়নি','Exercise chips at the top': 'উপরে ব্যায়ামের চিপ','A numbered dot per exercise, filled as you go. Tap one to jump there.': 'প্রতিটি ব্যায়ামের জন্য একটি নম্বরওয়ালা বিন্দু, এগোতে এগোতে ভরে ওঠে। ট্যাপ করলেই সেখানে চলে যাবেন।',+ // --- collapse completed exercises (#241) ---+ 'Fold away': 'গুটিয়ে রাখুন',+ 'Show the sets': 'সেটগুলো দেখান',+ 'In List and Compact, a finished exercise folds into one line.': 'তালিকা ও কমপ্যাক্টে শেষ হওয়া ব্যায়াম এক লাইনে গুটিয়ে যায়।',}diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex ab83e8a62..9f38cd476 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -2187,4 +2187,8 @@ export default {'Not started yet': 'Noch nicht angefangen','Exercise chips at the top': 'Übungs-Chips oben','A numbered dot per exercise, filled as you go. Tap one to jump there.': 'Ein nummerierter Punkt pro Übung, der sich beim Trainieren füllt. Tipp einen an und du bist da.',+ // --- collapse completed exercises (#241) ---+ 'Fold away': 'Einklappen',+ 'Show the sets': 'Sätze anzeigen',+ 'In List and Compact, a finished exercise folds into one line.': 'In Liste und Kompakt schrumpft eine fertige Übung auf eine Zeile.',}diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex 0aed55fe1..35230c1d8 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -2167,4 +2167,8 @@ export default {'Not started yet': 'Sin empezar','Exercise chips at the top': 'Chips de ejercicios arriba','A numbered dot per exercise, filled as you go. Tap one to jump there.': 'Un punto numerado por ejercicio que se llena sobre la marcha. Toca uno para saltar ahí.',+ // --- collapse completed exercises (#241) ---+ 'Fold away': 'Plegar',+ 'Show the sets': 'Ver las series',+ 'In List and Compact, a finished exercise folds into one line.': 'En Lista y Compacta, un ejercicio terminado se pliega en una sola línea.',}diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex 6a732a285..33f81ce64 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -2167,4 +2167,8 @@ export default {'Not started yet': 'Pas encore commencé','Exercise chips at the top': 'Pastilles d’exercices en haut','A numbered dot per exercise, filled as you go. Tap one to jump there.': 'Une pastille numérotée par exercice, qui se remplit au fil de la séance. Touchez-en une pour y aller.',+ // --- collapse completed exercises (#241) ---+ 'Fold away': 'Replier',+ 'Show the sets': 'Voir les séries',+ 'In List and Compact, a finished exercise folds into one line.': 'En Liste et Compacte, un exercice terminé se replie sur une seule ligne.',}diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex e025ae804..8da768695 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -2167,4 +2167,8 @@ export default {'Not started yet': 'अभी शुरू नहीं हुआ','Exercise chips at the top': 'ऊपर व्यायाम चिप्स','A numbered dot per exercise, filled as you go. Tap one to jump there.': 'हर व्यायाम के लिए एक नंबर वाला बिंदु, जो आगे बढ़ते हुए भरता है। किसी पर टैप करें और वहीं पहुँच जाएँ।',+ // --- collapse completed exercises (#241) ---+ 'Fold away': 'समेटें',+ 'Show the sets': 'सेट दिखाएँ',+ 'In List and Compact, a finished exercise folds into one line.': 'सूची और संक्षिप्त में पूरा हुआ व्यायाम एक लाइन में सिमट जाता है।',}diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex b00595227..5228765a1 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -2170,4 +2170,8 @@ export default {'Not started yet': 'Még nincs elkezdve','Exercise chips at the top': 'Gyakorlatjelölők felül','A numbered dot per exercise, filled as you go. Tap one to jump there.': 'Minden gyakorlatnak egy számozott pötty, ami menet közben telik meg. Koppints rá, és ott vagy.',+ // --- collapse completed exercises (#241) ---+ 'Fold away': 'Összecsukás',+ 'Show the sets': 'Sorozatok mutatása',+ 'In List and Compact, a finished exercise folds into one line.': 'Lista és Tömör nézetben a befejezett gyakorlat egy sorra csukódik össze.',}diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 3e41b433d..c1b1fc55a 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -2167,4 +2167,8 @@ export default {'Not started yet': 'Non ancora iniziato','Exercise chips at the top': 'Chip degli esercizi in alto','A numbered dot per exercise, filled as you go. Tap one to jump there.': 'Un pallino numerato per esercizio, che si riempie man mano. Toccane uno per andarci.',+ // --- collapse completed exercises (#241) ---+ 'Fold away': 'Comprimi',+ 'Show the sets': 'Mostra le serie',+ 'In List and Compact, a finished exercise folds into one line.': 'In Elenco e Compatta, un esercizio finito si riduce a una riga.',}diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex 2926166d6..e0608901c 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -2167,4 +2167,8 @@ export default {'Not started yet': '아직 시작 안 함','Exercise chips at the top': '위쪽 운동 칩','A numbered dot per exercise, filled as you go. Tap one to jump there.': '운동마다 번호 점이 하나씩 있고, 진행할수록 채워져요. 누르면 바로 그 운동으로 가요.',+ // --- collapse completed exercises (#241) ---+ 'Fold away': '접기',+ 'Show the sets': '세트 보기',+ 'In List and Compact, a finished exercise folds into one line.': '목록과 간략 보기에서 끝낸 운동은 한 줄로 접혀요.',}diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex 96f229b0a..a2665d20d 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -2167,4 +2167,8 @@ export default {'Not started yet': 'Jeszcze nie rozpoczęte','Exercise chips at the top': 'Znaczniki ćwiczeń na górze','A numbered dot per exercise, filled as you go. Tap one to jump there.': 'Ponumerowana kropka dla każdego ćwiczenia, wypełnia się w trakcie. Stuknij jedną, aby tam przejść.',+ // --- collapse completed exercises (#241) ---+ 'Fold away': 'Zwiń',+ 'Show the sets': 'Pokaż serie',+ 'In List and Compact, a finished exercise folds into one line.': 'W widokach Lista i Kompaktowy ukończone ćwiczenie zwija się do jednej linii.',}diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.jsindex c6022f9f0..756d0045c 100644--- a/frontend/src/locales/pt-BR.js+++ b/frontend/src/locales/pt-BR.js@@ -1340,6 +1340,10 @@ export const PT_BR_OVERRIDES = {'Not started yet': 'Ainda não começou','Exercise chips at the top': 'Marcadores de exercícios no topo','A numbered dot per exercise, filled as you go. Tap one to jump there.': 'Um ponto numerado por exercício, que vai enchendo conforme você treina. Toque em um para ir até lá.',+ // --- collapse completed exercises (#241) ---+ 'Fold away': 'Recolher',+ 'Show the sets': 'Mostrar as séries',+ 'In List and Compact, a finished exercise folds into one line.': 'Em Lista e Compacta, um exercício concluído vira uma linha só.',}export default { ...pt, ...PT_BR_OVERRIDES }diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex 9416d4641..542744c2d 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -2167,4 +2167,8 @@ export default {'Not started yet': 'Ainda não começado','Exercise chips at the top': 'Marcadores de exercícios no topo','A numbered dot per exercise, filled as you go. Tap one to jump there.': 'Um ponto numerado por exercício, que se vai enchendo. Toque num para saltar para lá.',+ // --- collapse completed exercises (#241) ---+ 'Fold away': 'Recolher',+ 'Show the sets': 'Mostrar as séries',+ 'In List and Compact, a finished exercise folds into one line.': 'Em Lista e Compacta, um exercício terminado fica numa só linha.',}diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex a5ea47151..aa5ec4ebd 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -2171,4 +2171,8 @@ export default {'Not started yet': 'Ещё не начато','Exercise chips at the top': 'Метки упражнений сверху','A numbered dot per exercise, filled as you go. Tap one to jump there.': 'По пронумерованной точке на каждое упражнение, заполняется по ходу. Нажмите на точку, чтобы перейти к упражнению.',+ // --- collapse completed exercises (#241) ---+ 'Fold away': 'Свернуть',+ 'Show the sets': 'Показать подходы',+ 'In List and Compact, a finished exercise folds into one line.': 'В режимах «Список» и «Компактный» завершённое упражнение сворачивается в одну строку.',}diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex 831643e56..22b28e509 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -2178,4 +2178,8 @@ export default {'Not started yet': 'ยังไม่เริ่ม','Exercise chips at the top': 'ชิปท่าฝึกด้านบน','A numbered dot per exercise, filled as you go. Tap one to jump there.': 'จุดมีหมายเลขหนึ่งจุดต่อท่า เติมเต็มไปเรื่อยๆ ตามที่คุณฝึก แตะเพื่อไปที่ท่านั้นได้เลย',+ // --- collapse completed exercises (#241) ---+ 'Fold away': 'ย่อเก็บ',+ 'Show the sets': 'แสดงเซ็ต',+ 'In List and Compact, a finished exercise folds into one line.': 'ในมุมมองรายการและแบบย่อ ท่าที่เสร็จแล้วจะย่อเหลือบรรทัดเดียว',}diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex 58cb14e66..c6d6ffc26 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -2167,4 +2167,8 @@ export default {'Not started yet': 'Henüz başlanmadı','Exercise chips at the top': 'Üstte egzersiz çipleri','A numbered dot per exercise, filled as you go. Tap one to jump there.': 'Her egzersiz için numaralı bir nokta, ilerledikçe dolar. Birine dokun, oraya atla.',+ // --- collapse completed exercises (#241) ---+ 'Fold away': 'Daralt',+ 'Show the sets': 'Setleri göster',+ 'In List and Compact, a finished exercise folds into one line.': 'Liste ve Kompakt görünümde biten egzersiz tek satıra iner.',}diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.jsindex 937c66b61..b60d4fb8a 100644--- a/frontend/src/locales/uk.js+++ b/frontend/src/locales/uk.js@@ -2164,4 +2164,8 @@ export default {'Not started yet': 'Ще не розпочато','Exercise chips at the top': 'Позначки вправ угорі','A numbered dot per exercise, filled as you go. Tap one to jump there.': 'Пронумерована крапка для кожної вправи, заповнюється по ходу. Торкніться її, щоб перейти до вправи.',+ // --- collapse completed exercises (#241) ---+ 'Fold away': 'Згорнути',+ 'Show the sets': 'Показати підходи',+ 'In List and Compact, a finished exercise folds into one line.': 'У режимах «Список» і «Компактно» виконана вправа згортається в один рядок.',}diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.jsindex ba0e73d88..1ef52b66c 100644--- a/frontend/src/locales/zh-TW.js+++ b/frontend/src/locales/zh-TW.js@@ -2160,4 +2160,8 @@ export default {'Not started yet': '還沒開始','Exercise chips at the top': '頂部動作圓點','A numbered dot per exercise, filled as you go. Tap one to jump there.': '每個動作一個帶編號的圓點,練著練著就填滿了。點一下就能跳過去。',+ // --- collapse completed exercises (#241) ---+ 'Fold away': '收起',+ 'Show the sets': '顯示各組',+ 'In List and Compact, a finished exercise folds into one line.': '在清單模式和緊湊模式中,完成的動作會收合成一行。',}diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex b47cfd849..6ac0ff9b8 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -2167,4 +2167,8 @@ export default {'Not started yet': '还没开始','Exercise chips at the top': '顶部动作圆点','A numbered dot per exercise, filled as you go. Tap one to jump there.': '每个动作一个带编号的圆点,练着练着就填满了。点一下就能跳过去。',+ // --- collapse completed exercises (#241) ---+ 'Fold away': '收起',+ 'Show the sets': '显示各组',+ 'In List and Compact, a finished exercise folds into one line.': '在列表和紧凑视图中,完成的动作会折叠成一行。',}diff --git a/frontend/src/store/useStore.js b/frontend/src/store/useStore.jsindex 0650de78a..49fc91a44 100644--- a/frontend/src/store/useStore.js+++ b/frontend/src/store/useStore.js@@ -110,6 +110,9 @@ export const DEF = {// 'cards' behaviour. beginWorkout copies the value onto s.active, so the header ⋮ menu can// override it for the running session without touching this saved default.workoutView: 'cards',+ // List and Compact fold a finished exercise into one line (Settings → Workout; #241). The+ // workout's Layout menu can flip it for the running session (s.active.collapseCompleted).+ collapseCompleted: false,// How the Library, the exercise picker and the muscle explorer show exercises — 'list' (rows// with a small thumbnail) or 'cards' (a grid of pictures with the name underneath). Switched// by the button in those headers (ExerciseViewToggle); older profiles overlay onto the list.diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsxindex c3e41cc10..d596cf4e0 100644--- a/frontend/src/views/Settings.jsx+++ b/frontend/src/views/Settings.jsx@@ -479,6 +479,14 @@ export default function Settings({ page = null, find = null, via = null }) {options={[{ value: 'cards', label: t('Cards') }, { value: 'list', label: t('List') }, { value: 'compact', label: t('Compact') }, { value: 'focus', label: t('Focus') }]}value={layout} onChange={v => update(s => { s.workoutView = v })} /></Row>+ {/* The saved side of the Layout menu's "Collapse completed exercises" (#241): on here, every+ session starts with it, and the menu still flips it for one session. Setting it here+ also drops a running session's own choice, so the switch does what it says right away. */}+ <Row icon="minimize" iconTint="var(--teal)" title={t('Collapse completed exercises')}+ subtitle={t('In List and Compact, a finished exercise folds into one line.')}>+ <Switch aria-label={t('Collapse completed exercises')} checked={!!S.collapseCompleted}+ onChange={v => update(s => { s.collapseCompleted = v; if (s.active) delete s.active.collapseCompleted })} />+ </Row></Section><Section title={t('Before and during')}>{/* The quick weigh-in that opens on Start (sheets.jsx startFlow, issue #137); off skipsdiff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsxindex 5abdcaa32..2e9c699dc 100644--- a/frontend/src/views/Workout.jsx+++ b/frontend/src/views/Workout.jsx@@ -921,10 +921,25 @@ function ActiveWorkout() {return m.name ? t('{0} · do these back-to-back, rest when done', m.name) : t('Superset · do these back-to-back, rest when done')}// Collapse finished exercises in the list (#241). The current unit stays open, superset- // members included, until you move on; an empty exercise or a half-done warm-up or side does too.- const collapsed = new Set(listMode && A.collapseCompleted ? units.filter(u =>- !u.includes(cur) && u.every(idx => A.entries[idx].sets.length > 0 && A.entries[idx].sets.every(s => s.done)),+ // members included, until you move on (ticking its last set does that, see toggle); an empty+ // exercise or a half-done warm-up or side stays open too.+ // The session's own choice (the Layout menu) wins over the saved one (Settings → Workout), the+ // way the layout itself does, so someone who always wants it switches it on once.+ const collapseOn = listMode && !!(A.collapseCompleted ?? S.collapseCompleted)+ // A finished unit you tapped open again to look at or fix (Discord: "minimize completed exercises+ // so I view only what I have yet to do"). This screen's own memory: a reload folds it back.+ // Keyed by index like the units, so a different number of exercises starts over.+ const [openedState, setOpenedState] = useState(() => ({ len: A.entries.length, keys: new Set() }))+ const opened = openedState.len === A.entries.length ? openedState.keys : new Set()+ const finished = u => u.every(idx => A.entries[idx].sets.length > 0 && A.entries[idx].sets.every(s => s.done))+ const collapsed = new Set(collapseOn ? units.filter(u =>+ !u.includes(cur) && !opened.has(u.join('-')) && finished(u),).map(u => u.join('-')) : [])+ const setUnitOpen = (key, open) => setOpenedState(prev => {+ const keys = new Set(prev.len === A.entries.length ? prev.keys : [])+ if (open) keys.add(key); else keys.delete(key)+ return { len: A.entries.length, keys }+ })const wc = workoutControls(S)// Superset flow: center the actionable row when completing a set moves to the partner or// back to the first exercise of the next round. Entry-bound maps keep repeated exercise IDs@@ -1302,8 +1317,8 @@ function ActiveWorkout() {{ icon: 'compact', label: t('Compact'), on: workoutView === 'compact', onClick: () => setWorkoutView('compact') },{ icon: 'target', label: t('Focus'), on: workoutView === 'focus', onClick: () => setWorkoutView('focus') },listMode && { icon: 'minimize', label: t('Collapse completed exercises'),- sub: t('Keep the current exercise open'), on: !!A.collapseCompleted,- onClick: () => update(s => { if (s.active) s.active.collapseCompleted = !s.active.collapseCompleted }) },+ sub: t('Keep the current exercise open'), on: collapseOn,+ onClick: () => update(s => { if (s.active) s.active.collapseCompleted = !collapseOn }) },],})// Logging a past workout (#284): the sets were done days ago, so one tap ticks them all and@@ -1646,6 +1661,16 @@ function ActiveWorkout() {return}+ // With finished exercises folding away in the list, the one you just finished does too: the+ // marker moves on to what is left, so the open unit is the next thing to do (Discord: "view+ // only what I have yet to do"). The scroll anchor holds what is on screen while it folds,+ // and revealCur brings the next exercise up if it was left low on the screen. Only on new+ // progress, never on a re-tick, and never in the other layouts, where the marker stays put.+ if (collapseOn && freshUnitDone && nextUnit && freshUnit?.includes(fresh.cur)) {+ revealCur.current = true+ update(s => { if (s.active) s.active.cur = nextUnit[0] })+ }+// Between the two sides of one timed per-side set (a side plank's left, then its right):// a short "Switch sides" pause instead of the set's whole rest, which comes once both// sides are held (owner's call). A rest switched Off stays off.@@ -1680,6 +1705,25 @@ function ActiveWorkout() {}}+ // After the finished exercise folded away (toggle, above): the new current one is the next thing+ // to do, so if it now sits under the header or low on the screen with little more than its title+ // showing, it glides up under the header. Where it is already in reach the page stays put. Run+ // after a closing sheet has put the page back (the effort picker ticks the set as it closes).+ const revealCur = useRef(false)+ useEffect(() => {+ if (!revealCur.current) return+ revealCur.current = false+ if (!listMode) return+ return afterScrollRestore(() => {+ const el = listRef.current?.querySelector('.wl-unit.cur')+ if (!el || typeof el.getBoundingClientRect !== 'function') return+ const top = el.getBoundingClientRect().top+ const under = hdrRef.current?.getBoundingClientRect?.().bottom || 0+ const screen = window.innerHeight || 0+ if (!screen || (top >= under && top <= screen * 0.55)) return+ scrollToUnit(el, true)+ })+ }, [cur])// Brings a list unit to the top of the screen, under the pinned header. The header grows when// the name wraps and by the chip row, so the unit's scroll margin (index.css) is fed its height// as it is right now. A jump the eye should follow glides, unless the system asks for less motion.@@ -1696,6 +1740,8 @@ function ActiveWorkout() {// as scrolling there by hand; the frame wait is the one opening the list uses (above).const pickChip = chip => {if (listMode) {+ // A folded unit opens as you jump to it: you tapped it to see it.+ if (collapsed.has(chip.key)) setUnitOpen(chip.key, true)const go = () => scrollToUnit(listRef.current?.querySelector(`.wl-unit[data-unit-key="${chip.key}"]`), true)if (window.requestAnimationFrame) window.requestAnimationFrame(go)else window.setTimeout(go, 0)@@ -1820,7 +1866,7 @@ function ActiveWorkout() {}}, [])- return <WorkoutScrollAnchor enabled={listMode && !!A.collapseCompleted} collapsed={[...collapsed].join(',')}>+ return <WorkoutScrollAnchor enabled={collapseOn} collapsed={[...collapsed].join(',')}>{/* In list mode the whole session scrolls under the header, so the header (name, clock,set counter, discard/finish, progress) stays pinned — the one thing you want in viewwhile you are somewhere in the middle of a long stack. Cards mode never scrolls far. */}@@ -1852,21 +1898,29 @@ function ActiveWorkout() {const multi = u.length > 1const isCur = u.includes(cur)const isCollapsed = collapsed.has(u.join('-'))+ // Finished and tapped open again: it says it can fold back, and does on a tap.+ const reopened = collapseOn && !isCur && !isCollapsed && opened.has(u.join('-')) && finished(u)return <section key={u.join('-')} className={'wl-unit' + (isCur ? ' cur' : '')} data-exidx={u[0]} data-unit-key={u.join('-')}><div className="wl-hd"><span className="muted small">{multi ? t('Superset {0} / {1}', ui + 1, units.length) : t('Exercise {0} / {1}', ui + 1, units.length)}</span>- {isCur- ? <span className="tag acc">{t('Current')}</span>- : <button className="chip" aria-expanded={!isCollapsed} aria-controls={'workout-unit-' + u.join('-')}- onClick={() => focusUnit(u[0])}>{t('Set current')}</button>}+ <span className="row" style={{ gap: 6 }}>+ {reopened && <button className="chip" aria-expanded="true" aria-controls={'workout-unit-' + u.join('-')}+ onClick={() => setUnitOpen(u.join('-'), false)}>{t('Fold away')}</button>}+ {isCur+ ? <span className="tag acc">{t('Current')}</span>+ : <button className="chip" onClick={() => focusUnit(u[0])}>{t('Set current')}</button>}+ </span></div><div id={'workout-unit-' + u.join('-')}>- {isCollapsed ? <div className="wl-summary">- {u.map(idx => <div key={idx} className="row between" style={{ gap: 8 }}>+ {/* One line per exercise, and the line is the way back in: a tap opens the sets again+ to fix a number, without making it the current exercise. */}+ {isCollapsed ? <button type="button" className="wl-summary" aria-expanded="false" title={t('Show the sets')}+ onClick={() => setUnitOpen(u.join('-'), true)}>+ {u.map(idx => <span key={idx} className="row between" style={{ gap: 8 }}><span style={{ fontWeight: 600, textTransform: 'capitalize' }}>{exerciseNameFor(exOr(A.entries[idx].id))}</span><span className="tag acc nocap"><Icon name="check" />{t('{0} sets', A.entries[idx].sets.length)}</span>- </div>)}- </div> : multi ? (+ </span>)}+ </button> : multi ? (<div className="ss-card"><div className="ss-hd" style={{ justifyContent: 'space-between' }}><span className="row" style={{ gap: 5 }}><Icon name="link" />{ssTitle(u)}</span>diff --git a/frontend/src/views/Workout.test.jsx b/frontend/src/views/Workout.test.jsxindex ec69a70ad..6ad5157eb 100644--- a/frontend/src/views/Workout.test.jsx+++ b/frontend/src/views/Workout.test.jsx@@ -2413,25 +2413,65 @@ describe('collapsing completed workout exercises', () => {await rerender()}- it.each(['list', 'compact'])('keeps the finished current exercise open in %s, then collapses it when moving on', async workoutView => {+ it.each(['list', 'compact'])('folds the current exercise in %s the moment its last set is ticked, and opens it again on a tap', async workoutView => {await mount([exercise('bench', [true, false]), exercise('row', [false])], 0,{ workoutView, active: { workoutView, collapseCompleted: true } })+ const loggedBefore = structuredClone(mocks.S.active.entries[0].sets)await toggleSet(1)await rerender()- expect(units()[0].querySelector('.wl-summary')).toBeNull()- const loggedSets = structuredClone(mocks.S.active.entries[0].sets)- await setCurrent(1)+ // the marker moved on to what is left, so the finished one folded+ expect(mocks.S.active.cur).toBe(1)expect(units()[0].querySelector('.wl-summary')).toBeTruthy()expect(units()[0].querySelector('.setrow')).toBeNull()expect(units()[0].querySelector('.exmedia')).toBeNull()- expect(units()[0].querySelector('[aria-expanded="false"]')).toBeTruthy()+ expect(units()[1].classList.contains('cur')).toBe(true)expect(units()[1].querySelector('.setrow')).toBeTruthy()- expect(mocks.S.active.entries[0].sets).toEqual(loggedSets)+ expect(mocks.S.active.entries[0].sets).toEqual([...loggedBefore.slice(0, 1), { ...loggedBefore[1], done: true, at: expect.any(Number) }])+ // a tap on the line opens the sets again, without making it current+ const summary = units()[0].querySelector('button.wl-summary')+ expect(summary.getAttribute('aria-expanded')).toBe('false')+ await click(summary)+ expect(units()[0].querySelectorAll('.setrow').length).toBe(2)+ expect(mocks.S.active.cur).toBe(1)+ const fold = [...units()[0].querySelectorAll('button')].find(b => b.textContent.trim() === 'Fold away')+ expect(fold.getAttribute('aria-expanded')).toBe('true')+ await click(fold)+ expect(units()[0].querySelector('.wl-summary')).toBeTruthy()+ // Set current still brings it back as the one you are onawait setCurrent(0)expect(units()[0].querySelectorAll('.setrow').length).toBe(2)+ // unticking and ticking again is not new progress: the marker stays+ await toggleSet(1)+ await toggleSet(1)+ await rerender()+ expect(mocks.S.active.cur).toBe(0)+ })++ it('keeps the marker where it is when collapsing is off', async () => {+ await mount([exercise('bench', [true, false]), exercise('row', [false])], 0, { active: { workoutView: 'list' } })+ await toggleSet(1)+ await rerender()+ expect(mocks.S.active.cur).toBe(0)+ expect(container.querySelector('.wl-summary')).toBeNull()+ })++ it('leaves the marker alone when the exercise finished last is not the current one', async () => {+ await mount([exercise('bench', [false]), exercise('row', [false]), exercise('squat', [false])], 2,+ { active: { workoutView: 'list', collapseCompleted: true } })await toggleSet(0)- await setCurrent(1)- expect(units()[0].querySelector('.wl-summary')).toBeNull()+ await rerender()+ expect(mocks.S.active.cur).toBe(2)+ expect(units()[0].querySelector('.wl-summary')).toBeTruthy()+ })++ it('stays on the last exercise when nothing is left, and offers the finish', async () => {+ await mount([exercise('bench', [true]), exercise('row', [false])], 1,+ { active: { workoutView: 'list', collapseCompleted: true } })+ await toggleSet(0) // the bench is folded already, so the row's set is the only tick on screen+ await rerender()+ expect(mocks.S.active.cur).toBe(1)+ expect(mocks.workoutCompleteSheet).toHaveBeenCalledOnce()+ expect(units()[1].querySelector('.wl-summary')).toBeNull()})it('leaves completed exercises expanded unless the option is enabled', async () => {@@ -2467,6 +2507,116 @@ describe('collapsing completed workout exercises', () => {})})+// Discord: "I use the list layout... I want to minimize/collapse completed exercises so I view+// only what I have yet to do. Not the same as hiding the exercise image."+describe('list layout: only what is left to do (Discord request, #241)', () => {+ const units = () => [...container.querySelectorAll('.wl-unit')]+ const ticks = () => [...container.querySelectorAll('[role="checkbox"]')]+ const session = () => [+ exercise('bench', [false, false]),+ exercise('fly', [false], { sg: 'pair' }), exercise('row', [false], { sg: 'pair' }),+ exercise('squat', [false]),+ ]+ // linkedom has no layout: the header ends at 120 px, the unit with `key` starts at `top`, and+ // every other unit sits above the screen.+ let realRect = null+ afterEach(() => {+ // linkedom's element classes are shared between windows: put the real one back+ if (realRect) parseHTML('<p></p>').window.Element.prototype.getBoundingClientRect = realRect+ realRect = null+ })+ const layout = (key, top) => {+ realRect ||= dom.Element.prototype.getBoundingClientRect+ dom.innerHeight = 800+ dom.scrollY = 0+ dom.scrollTo = vi.fn()+ dom.Element.prototype.getBoundingClientRect = function () {+ if (this.classList?.contains('whdr')) return { top: 0, bottom: 120 }+ if (this.classList?.contains('wl-unit') && this.dataset.unitKey === key) return { top, bottom: top + 400 }+ return { top: -400, bottom: -100 }+ }+ }++ it('folds every finished exercise to one line as the session goes, superset included, and keeps it after a reload', async () => {+ // switched on once in Settings: the session itself never chose+ await mount(session(), 0, { workoutView: 'list', collapseCompleted: true, active: { workoutView: 'list' } })+ expect(mocks.S.active.collapseCompleted).toBeUndefined()+ await toggleSet(0)+ await toggleSet(1)+ await rerender()+ expect(units()[0].querySelector('.wl-summary')).toBeTruthy()+ expect(units()[1].classList.contains('cur')).toBe(true)+ // the superset: its first member moves the marker to its partner, the second finishes the round+ await toggleSet(0)+ await rerender()+ expect(units()[1].querySelector('.wl-summary')).toBeNull()+ await toggleSet(1)+ await rerender()+ expect(units()[1].querySelectorAll('.wl-summary .tag').length).toBe(2)+ expect(units()[2].classList.contains('cur')).toBe(true)+ // what is left is all that is open+ expect(ticks()).toHaveLength(1)+ expect(container.querySelectorAll('.wl-summary').length).toBe(2)+ // a reload (or Resume) brings the same picture back from the saved session+ const saved = structuredClone(mocks.S)+ await unmount()+ mocks.S = saved+ installDom()+ await act(async () => { root.render(React.createElement(Workout)) })+ expect(container.querySelectorAll('.wl-summary').length).toBe(2)+ expect(ticks()).toHaveLength(1)+ })++ it('brings the next exercise up when it is left low on the screen, and leaves the page alone when it is in reach', async () => {+ await mount(session(), 0, { active: { workoutView: 'list', collapseCompleted: true } })+ await flushFrame() // the list's own open-at-current scroll+ layout('1-2', 700)+ mocks.scrollCalls.length = 0+ await toggleSet(0)+ await toggleSet(1)+ await rerender() // the mocked store does not render by itself+ expect(mocks.scrollCalls).toHaveLength(1)+ expect(mocks.scrollCalls[0].node.dataset.unitKey).toBe('1-2')+ expect(mocks.scrollCalls[0].options).toEqual({ block: 'start', behavior: 'smooth' })++ await unmount()+ await mount(session(), 0, { active: { workoutView: 'list', collapseCompleted: true } })+ await flushFrame()+ layout('1-2', 300)+ mocks.scrollCalls.length = 0+ await toggleSet(0)+ await toggleSet(1)+ await rerender()+ expect(mocks.S.active.cur).toBe(1)+ expect(mocks.scrollCalls).toEqual([])+ })++ it('is one switch in Settings for every session, and the Layout menu still flips it for this one', async () => {+ await mount([exercise('bench', [true]), exercise('row', [false])], 1, { collapseCompleted: true, active: { workoutView: 'list' } })+ expect(container.querySelectorAll('.wl-summary').length).toBe(1)+ await click(container.querySelector('button[aria-label="Workout options"]'))+ await act(async () => { menuItemsOf(mocks.menuSheet.mock.calls.at(-1)[0]).find(it => it.label === 'Layout').onClick() })+ const toggleItem = menuItemsOf(mocks.menuSheet.mock.calls.at(-1)[0]).find(it => it.label === 'Collapse completed exercises')+ expect(toggleItem.on).toBe(true)+ await act(async () => { toggleItem.onClick() })+ await rerender()+ expect(mocks.S.active.collapseCompleted).toBe(false)+ expect(mocks.S.collapseCompleted).toBe(true)+ expect(container.querySelector('.wl-summary')).toBeNull()+ })++ it('opens a folded exercise when its chip at the top is tapped, and scrolls to it', async () => {+ await mount([exercise('bench', [true]), exercise('row', [false])], 1, { active: { workoutView: 'list', collapseCompleted: true } })+ await flushFrame()+ mocks.scrollCalls.length = 0+ await click(container.querySelectorAll('.wchip')[0])+ expect(units()[0].querySelector('.wl-summary')).toBeNull()+ await flushFrame()+ expect(mocks.scrollCalls.at(-1).node.dataset.unitKey).toBe('0')+ expect(mocks.S.active.cur).toBe(1)+ })+})+describe('exercise chips at the top of the workout (#323)', () => {const chips = () => [...container.querySelectorAll('.wchip')]const chip = n => chips()[n - 1]diff --git a/frontend/src/views/settings-pages.js b/frontend/src/views/settings-pages.jsindex accab9372..100aba1e9 100644--- a/frontend/src/views/settings-pages.js+++ b/frontend/src/views/settings-pages.js@@ -56,6 +56,7 @@ export const SEARCH = [{ page: 'workout', title: 'Effort per set', icon: 'gauge', tint: 'var(--purple)', kw: 'rir rpe effort reps in reserve difficulty', opts: ['RIR', 'RPE'] },{ page: 'workout', title: 'Shown under each exercise', icon: 'history', tint: 'var(--blue)', kw: 'last time best set reference previous', opts: ['Last time', 'Best set'] },{ page: 'workout', title: 'Layout', icon: 'layout', tint: 'var(--blue)', kw: 'workout view cards list compact', opts: ['Cards', 'List', 'Compact'] },+ { page: 'workout', title: 'Collapse completed exercises', icon: 'minimize', tint: 'var(--teal)', kw: 'collapse fold minimize hide done finished completed exercises list compact remaining left to do' },{ page: 'workout', title: 'Weigh in before workouts', icon: 'scale', tint: 'var(--green)', kw: 'body weight weigh scale start' },{ page: 'workout', title: 'Keep screen awake', icon: 'phoneScreen', tint: 'var(--yellow)', kw: 'wake lock screen sleep display on', when: c => c.wakeOK || !c.mobile },{ page: 'workout', title: 'Exercise animations', icon: 'image', tint: 'var(--teal)', kw: 'gif animation video media pictures images', opts: ['Full', 'Small', 'Hidden'] },diff --git a/frontend/src/views/settings-pages.test.jsx b/frontend/src/views/settings-pages.test.jsxindex 3a9341943..0d6f8aa1f 100644--- a/frontend/src/views/settings-pages.test.jsx+++ b/frontend/src/views/settings-pages.test.jsx@@ -275,7 +275,7 @@ describe('the pages', () => {mount('workout')expect([...host.querySelectorAll('.sect-t')].map(e => e.textContent)).toEqual(['Rest', 'Logging', 'Before and during'])expect(titles()).toEqual(['Rest timer', 'Rest-pause rest', 'Effort per set', 'Shown under each exercise', 'Layout',- 'Weigh in before workouts', 'Keep screen awake', 'Exercise animations', 'Fine-tuning'])+ 'Collapse completed exercises', 'Weigh in before workouts', 'Keep screen awake', 'Exercise animations', 'Fine-tuning'])// QA 10-05: the "screen stays on" line is the awake row's own subtitle, not a section footer// that read as if it explained the animations above it.expect(rowTitled('Keep screen awake').querySelector('.lrow-s').textContent).toMatch(/^The screen stays on/)@@ -286,6 +286,16 @@ describe('the pages', () => {'Drop and burst shortcuts on every set', 'Swipe actions', 'Exercise chips at the top', 'Superset buttons in the exercise header', 'Move, swap and remove buttons below the exercise'])})+ it('Collapse completed exercises is saved for every session and drops a running session\'s own choice', () => {+ mount('workout')+ mocks.S.active = { collapseCompleted: false, entries: [] }+ const sw = rowTitled('Collapse completed exercises').querySelector('[role="switch"]')+ expect(sw.getAttribute('aria-checked')).toBe('false')+ act(() => sw.click())+ expect(mocks.S.collapseCompleted).toBe(true)+ expect('collapseCompleted' in mocks.S.active).toBe(false)+ })+it('the Fine-tuning switches write S.wc as the old Workout controls sheet did', () => {mount('advanced')act(() => rowTitled('Superset buttons in the exercise header').querySelector('[role="switch"]').click())