Session 41: Clearer state #221

Closed
opened 2026-11-08 18:22:05 +00:00 by chris-kreidl · 0 comments
chris-kreidl commented 2026-11-08 18:22:05 +00:00 (Migrated from github.com)

41 · Today and Plan say what state they're in

Phase: UI polish (owner request 2026-11-06) · Branch: session/41-clearer-state · Depends on: 40

The second half of the 2026-11-06 UI review, after session 40's readability fixes. Three places tell the rider something that's out of step with what has happened: the week summary mixes reference frames, pre-ride advice outlives the ride, and plan generation can't be left. Change copy and state only. The look stays as it is.

Read first

  • src/components/today/week-panel.tsx, src/components/plan/week-totals.ts (weekTotals), and wherever weekToDate and weekDays live
  • src/components/today/coach-card.tsx, src/components/today/rest-day.tsx, src/components/today/unplanned-ride.tsx, src/routes/_app/today.tsx
  • src/server/on-session-logged.ts and how Today learns that a re-plan or ride feedback is pending
  • src/routes/_app/plan.tsx (the Generation state and generate()), src/server/plan.ts (generatePlanStream) and the Anthropic call under it
  • Load the claude-api skill before touching src/ai/

Goal

  1. The week summary says one thing per clause. Today, after an unplanned ride on a rest day, week-panel.tsx reads "105 of 0 planned so far · 0 of 3 sessions · 1:30 of 4:00". Split it so each figure has its own reference frame. Logged TSS is one figure. Planned TSS due through today is another, or "nothing scheduled through today" when it's zero. Planned sessions done is "N of M", and unplanned rides are named as such ("+ 1 unplanned ride"). Time is labelled week to date or whole week, but don't mix the two. The arithmetic belongs in a pure function with tests, beside weekTotals or weekToDate. Keep it short enough for a phone, with two short lines rather than one long one. The section's aside total may stay if it still agrees.
  2. Pre-ride advice doesn't outlive the ride. coach-card.tsx labels advice "If you ride anyway" or "How to ride it" from the planned/rest state alone, so after a ride is logged today it still reads as pre-ride advice. Gate that block on there being no ride logged today. Once a ride is logged, either show the advice the coach gave after it, or show a plain "Updating your advice" state while a re-plan or feedback for that ride is pending. Use only state Today already has (or can cheaply load). Don't add polling beyond what exists.
  3. Plan generation has an escape. While generation runs there is no way out. First read how generatePlanStream behaves when the client stops reading. Then add a visible control whose label is honest about what it does. If abandoning the stream stops the server work (an AbortSignal that reaches the Anthropic call), call it "Stop". If the server carries on and saves anyway, call it "Hide" and say so in one line ("The plan keeps generating and will appear here when it's done"). Prefer making "Stop" true if that is a small change. Either way, the current plan stays in force until a new one is saved, as now. Record which one it is in docs/decisions.md.

Rules

  • Plans stay append-only. Neither stopping nor hiding generation ever touches the existing plan version, and a stopped generation saves nothing partial.
  • Every server function changed for item 3 keeps authed, its validator and the ownership checks. A stopped run still writes its AiCall row (cost counts).
  • Replay fixtures for any AI path touched. Tests and e2e run with AI_REPLAY=1.

Tests

  • Domain: the week summary covers a normal mid-week, an unplanned ride on a rest day, a week with nothing scheduled through today, missed sessions, and strength and ride time together.
  • Unit or DB: the advice gate (planned day, rest day, rest day with a logged ride, re-plan pending); a stopped generation leaves the current plan version and saves nothing.
  • E2E (replay): logging an unplanned ride on a rest day removes "If you ride anyway" from Today, and the week summary reads as above. Generation shows the stop or hide control while running, and using it leaves the existing plan in place.

Out of scope

Session 40's items, dark tokens, and wider rewrites of Today's sections (the review noted rest-day choices recur in several places; note it under Follow-ups rather than restructure). Note anything else you find under Follow-ups.

Done when

All three items work on a production build (replay), and unit, typecheck, lint, format, audit and e2e pass. Replay has no recorded re-plan for the rest-day path, so add an owner check under Follow-ups → Now: after a real ride on a rest day, does Today read right once the re-plan lands? Finish with the end-of-session ritual in CLAUDE.md.

Moved from prompts/41-clearer-state.md on 2026-11-08.

# 41 · Today and Plan say what state they're in **Phase:** UI polish (owner request 2026-11-06) · **Branch:** `session/41-clearer-state` · **Depends on:** 40 The second half of the 2026-11-06 UI review, after session 40's readability fixes. Three places tell the rider something that's out of step with what has happened: the week summary mixes reference frames, pre-ride advice outlives the ride, and plan generation can't be left. Change copy and state only. The look stays as it is. ## Read first - `src/components/today/week-panel.tsx`, `src/components/plan/week-totals.ts` (`weekTotals`), and wherever `weekToDate` and `weekDays` live - `src/components/today/coach-card.tsx`, `src/components/today/rest-day.tsx`, `src/components/today/unplanned-ride.tsx`, `src/routes/_app/today.tsx` - `src/server/on-session-logged.ts` and how Today learns that a re-plan or ride feedback is pending - `src/routes/_app/plan.tsx` (the `Generation` state and `generate()`), `src/server/plan.ts` (`generatePlanStream`) and the Anthropic call under it - Load the `claude-api` skill before touching `src/ai/` ## Goal 1. **The week summary says one thing per clause.** Today, after an unplanned ride on a rest day, `week-panel.tsx` reads "105 of 0 planned so far · 0 of 3 sessions · 1:30 of 4:00". Split it so each figure has its own reference frame. Logged TSS is one figure. Planned TSS due through today is another, or "nothing scheduled through today" when it's zero. Planned sessions done is "N of M", and unplanned rides are named as such ("+ 1 unplanned ride"). Time is labelled week to date or whole week, but don't mix the two. The arithmetic belongs in a pure function with tests, beside `weekTotals` or `weekToDate`. Keep it short enough for a phone, with two short lines rather than one long one. The section's `aside` total may stay if it still agrees. 2. **Pre-ride advice doesn't outlive the ride.** `coach-card.tsx` labels advice "If you ride anyway" or "How to ride it" from the planned/rest state alone, so after a ride is logged today it still reads as pre-ride advice. Gate that block on there being no ride logged today. Once a ride is logged, either show the advice the coach gave after it, or show a plain "Updating your advice" state while a re-plan or feedback for that ride is pending. Use only state Today already has (or can cheaply load). Don't add polling beyond what exists. 3. **Plan generation has an escape.** While generation runs there is no way out. First read how `generatePlanStream` behaves when the client stops reading. Then add a visible control whose label is honest about what it does. If abandoning the stream stops the server work (an `AbortSignal` that reaches the Anthropic call), call it "Stop". If the server carries on and saves anyway, call it "Hide" and say so in one line ("The plan keeps generating and will appear here when it's done"). Prefer making "Stop" true if that is a small change. Either way, the current plan stays in force until a new one is saved, as now. Record which one it is in `docs/decisions.md`. ## Rules - Plans stay append-only. Neither stopping nor hiding generation ever touches the existing plan version, and a stopped generation saves nothing partial. - Every server function changed for item 3 keeps `authed`, its validator and the ownership checks. A stopped run still writes its `AiCall` row (cost counts). - Replay fixtures for any AI path touched. Tests and e2e run with `AI_REPLAY=1`. ## Tests - Domain: the week summary covers a normal mid-week, an unplanned ride on a rest day, a week with nothing scheduled through today, missed sessions, and strength and ride time together. - Unit or DB: the advice gate (planned day, rest day, rest day with a logged ride, re-plan pending); a stopped generation leaves the current plan version and saves nothing. - E2E (replay): logging an unplanned ride on a rest day removes "If you ride anyway" from Today, and the week summary reads as above. Generation shows the stop or hide control while running, and using it leaves the existing plan in place. ## Out of scope Session 40's items, dark tokens, and wider rewrites of Today's sections (the review noted rest-day choices recur in several places; note it under Follow-ups rather than restructure). Note anything else you find under Follow-ups. ## Done when All three items work on a production build (replay), and unit, typecheck, lint, format, audit and e2e pass. Replay has no recorded re-plan for the rest-day path, so add an owner check under Follow-ups → Now: after a real ride on a rest day, does Today read right once the re-plan lands? Finish with the end-of-session ritual in `CLAUDE.md`. _Moved from `prompts/41-clearer-state.md` on 2026-11-08._
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ckreidl/trainer#221
No description provided.