From df50287eacc3dafc83997ff455e7805cc97f8e64 Mon Sep 17 00:00:00 2001 From: Boris 'B' Kurktchiev Date: Wed, 16 Sep 2026 16:57:47 -0400 Subject: [PATCH] home: a door to the Start screen when a plan already owns today MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On a day with a routine there is no way to start a freestyle session, or to pick one of your other routines. The Start button in the tab bar and Home's today row both go into today's planned session the moment there is one, and only fall through to the Start screen when nothing at all is planned. So the screen that holds "Freestyle workout (pick as you go)" and "Other routines" is reachable on rest days only. There was one other way in — "Choose a different workout" on the weigh-in sheet — and it does not exist when the weigh-in is switched off (Settings → During a workout). With a routine on every weekday and that switch off, the Start screen cannot be reached at all. So Home carries that door: under the today row, hidden while a session is running (that screen resumes one, it does not choose), and it starts nothing by itself. It reuses the weigh-in sheet's own string, so no locale pack moves. The one-tap start is untouched: the row above it and the tab bar's button both still go straight into today's session. Co-Authored-By: Claude Opus 5 --- frontend/src/views/Home.jsx | 11 ++++ frontend/src/views/Home.startdoor.test.jsx | 68 ++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 frontend/src/views/Home.startdoor.test.jsx diff --git a/frontend/src/views/Home.jsx b/frontend/src/views/Home.jsx index 8355c3e..cd515a8 100644 --- a/frontend/src/views/Home.jsx +++ b/frontend/src/views/Home.jsx @@ -97,6 +97,17 @@ export default function Home() { : routine ? {t('Start')} : } + {/* The row above starts today's plan in one tap, and so does the Start button in the tab + bar — which is the whole problem when you want something else. Both jump straight into + the planned session whenever there is one, so the Start screen (a freestyle session, + and your other routines) is only reachable on a day with nothing planned. The one other + way in, "Choose a different workout" on the weigh-in sheet, does not exist when the + weigh-in is switched off. This is that door, and it starts nothing on its own. */} + {!S.active &&
+ +
} {/* Jump to the gym check-in cards (QR membership codes). Shown here as a quick tap on diff --git a/frontend/src/views/Home.startdoor.test.jsx b/frontend/src/views/Home.startdoor.test.jsx new file mode 100644 index 0000000..ee98082 --- /dev/null +++ b/frontend/src/views/Home.startdoor.test.jsx @@ -0,0 +1,68 @@ +// @vitest-environment happy-dom +// The Start button in the tab bar (components/TabBar.jsx) and Home's today row both go straight +// into today's planned session the moment there is one, and only fall through to the Start +// screen when nothing is planned. So on any day with a routine, a freestyle session and the +// "Other routines" list are unreachable — the only other way in, "Choose a different workout" +// on the weigh-in sheet, does not exist with the weigh-in switched off. Home carries that door. +import React, { act } from 'react' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { createRoot } from 'react-dom/client' +import { useStore } from '../store/useStore.js' +import { startFlow } from '../sheets.jsx' +import Home from './Home.jsx' + +const nav = vi.fn() +vi.mock('react-router-dom', () => ({ useNavigate: () => nav })) +vi.mock('../sheets.jsx', () => ({ + starterPlanSheet: vi.fn(), bwSheet: vi.fn(), goalSheet: vi.fn(), dayOverrideSheet: vi.fn(), + calendarSheet: vi.fn(), startFlow: vi.fn(), bwDeltaColor: () => '', +})) + +const routines = [{ id: 'r1', name: 'Push', emoji: null, ex: [{ id: '0025' }] }] + +let host, root +beforeEach(() => { + globalThis.IS_REACT_ACT_ENVIRONMENT = true + nav.mockClear(); startFlow.mockClear() + host = document.createElement('div') + document.body.appendChild(host) + root = createRoot(host) +}) +afterEach(() => { act(() => root.unmount()); host.remove() }) + +// Every weekday points at a routine and the weigh-in is off: today is always planned, and the +// weigh-in sheet's own way through to the Start screen never opens. +const setS = (over = {}) => useStore.setState(s => ({ + S: { + ...s.S, routines, dayPlan: {}, workouts: [], active: null, weighIn: false, + week: { 0: ['r1'], 1: ['r1'], 2: ['r1'], 3: ['r1'], 4: ['r1'], 5: ['r1'], 6: ['r1'] }, ...over, + }, + user: null, +})) +const mount = () => act(() => root.render()) +const door = () => [...host.querySelectorAll('button')].find(b => b.textContent.includes('Choose a different workout')) + +describe('Home — the way to the Start screen when a plan already owns today', () => { + it('offers the door on a planned day, where the Start button would start the plan', () => { + setS(); mount() + expect(door()).toBeTruthy() + }) + + it('opens the Start screen without starting anything', () => { + setS(); mount() + act(() => { door().dispatchEvent(new MouseEvent('click', { bubbles: true })) }) + expect(nav).toHaveBeenCalledWith('/workout') + expect(startFlow).not.toHaveBeenCalled() + }) + + it('is still there on a rest day, where freestyle is the only thing left to start', () => { + setS({ week: {} }); mount() + expect(door()).toBeTruthy() + }) + + it('goes away once a session is running — that screen resumes it, it does not choose', () => { + setS({ active: { id: 'a', name: 'Push', start: Date.now(), cur: 0, entries: [] } }) + mount() + expect(door()).toBeFalsy() + }) +})