Session 49: History calendar #224

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

49 · The History calendar

Phase: UI polish · Branch: session/49-history-calendar · Depends on: 48

History (48) is still a long list of workouts and TSS. With a year or more of riding it stops being navigable: you can't jump to a time, see a hard week, or tell a block from a lull. This session turns it into the same calendar as Plan, so the past and the plan read as one book: Plan's week rows, a year strip to pick the month, and month-by-month paging that loads instantly.

The owner chose these directions without a mockup and will iterate on the built result, so build them cleanly and expect a follow-up round.

Read first

  • src/routes/history.tsx (or wherever 48 put it) and its server function
  • src/components/plan/plan-calendar.tsx (StageStrip, week rows, SessionCard, RiddenCard, WeekTotals) and src/components/plan/workout-profile.tsx
  • How Plan builds a ridden profile (RiddenView.profile in src/server/plan-views.ts): it is the cost to measure here
  • TanStack Router search params and TanStack Query prefetchQuery via Context7 (current docs, not memory)
  • DESIGN.md, .impeccable/surfaces/src-routes-app.md

Goal

  1. One month at a time, in the URL. /history?month=2026-10, defaulting to this month. Back and forward, bookmarks and the ride page's "Back to History" return to the same month.
  2. A server function for a month. getHistoryMonth({ month }) returns that month's days in the athlete's time zone: every ride and strength session, each with its title, time, TSS and ridden profile (rides with power), plus week and month totals. It queries by date range, scoped to the user, and never loads more than the month.
  3. Instant paging. The client preloads the month before and after the one shown, and keeps viewed months cached, so Previous and Next don't wait.
  4. The year strip. Under the cover line: a year select (the years with data), then twelve stage cells, one per month, each with the month's name and TSS. Today's month carries the red rule, the shown month is in ink, and empty months are visibly empty. A cell picks the month; Previous month and Next month sit at the strip's end, as Plan's week steps do. The strip's data is one light query per year (month totals only).
  5. The month. A header line with the month's totals (TSS, hours, rides, strength sessions). Then Plan's week rows: the week's done TSS and hours in the first column, Monday–Sunday beside it, each day's sessions drawn as on Plan (name, ridden profile in ink, time · TSS) and linking to the ride or strength page. Weeks that cross the month edge show their days from both months, the other month's dimmed. Reuse Plan's pieces (extract the shared day and session cells rather than copy them).
  6. From Plan. When Plan's Previous week reaches the plan's first week, it becomes "Earlier weeks: History", landing on the month before the plan started.

Rules

  • Measure before deciding: time getHistoryMonth for a full month on real data (bun run db:pull). If ridden profiles make it slow, store a ride's profile when it's imported and backfill once, and record the numbers in docs/decisions.md.
  • Phones get the same calendar stacked as Plan does (days with something on them); the year strip scrolls sideways.
  • Every control is a standard one: the select is a native select or Base UI's, the strip's cells are buttons with names ("October 2026, 1,240 TSS"), Previous and Next are named.

Tests

  • Unit: month boundaries in a time zone (a ride at 23:30 local on the 31st), week rows that cross months, totals.
  • E2E: /history opens on this month; Previous loads last month without a spinner (preloaded); the strip jumps to a month; a ride opens and "Back to History" returns to that month; Plan's "Earlier weeks: History" lands before the plan. Axe and the keyboard checks pass, desk and phone.

Out of scope

Search and filters (by sport, by workout type): note under Follow-ups if the calendar leaves them wanted.

Done when

A year of riding is navigable in a few clicks, month to month is instant, and the past reads like Plan. Owner check under Follow-ups → Now: does the year strip work as the month picker, or should it be dropdowns? Unit, typecheck, lint, format, audit and e2e pass. End-of-session ritual in CLAUDE.md.

Moved from prompts/49-history-calendar.md on 2026-11-08.

# 49 · The History calendar **Phase:** UI polish · **Branch:** `session/49-history-calendar` · **Depends on:** 48 History (48) is still a long list of workouts and TSS. With a year or more of riding it stops being navigable: you can't jump to a time, see a hard week, or tell a block from a lull. This session turns it into the same calendar as Plan, so the past and the plan read as one book: Plan's week rows, a year strip to pick the month, and month-by-month paging that loads instantly. The owner chose these directions without a mockup and will iterate on the built result, so build them cleanly and expect a follow-up round. ## Read first - `src/routes/history.tsx` (or wherever 48 put it) and its server function - `src/components/plan/plan-calendar.tsx` (`StageStrip`, week rows, `SessionCard`, `RiddenCard`, `WeekTotals`) and `src/components/plan/workout-profile.tsx` - How Plan builds a ridden profile (`RiddenView.profile` in `src/server/plan-views.ts`): it is the cost to measure here - TanStack Router search params and TanStack Query `prefetchQuery` via Context7 (current docs, not memory) - `DESIGN.md`, `.impeccable/surfaces/src-routes-app.md` ## Goal 1. **One month at a time, in the URL.** `/history?month=2026-10`, defaulting to this month. Back and forward, bookmarks and the ride page's "Back to History" return to the same month. 2. **A server function for a month.** `getHistoryMonth({ month })` returns that month's days in the athlete's time zone: every ride and strength session, each with its title, time, TSS and ridden profile (rides with power), plus week and month totals. It queries by date range, scoped to the user, and never loads more than the month. 3. **Instant paging.** The client preloads the month before and after the one shown, and keeps viewed months cached, so Previous and Next don't wait. 4. **The year strip.** Under the cover line: a year select (the years with data), then twelve stage cells, one per month, each with the month's name and TSS. Today's month carries the red rule, the shown month is in ink, and empty months are visibly empty. A cell picks the month; Previous month and Next month sit at the strip's end, as Plan's week steps do. The strip's data is one light query per year (month totals only). 5. **The month.** A header line with the month's totals (TSS, hours, rides, strength sessions). Then Plan's week rows: the week's done TSS and hours in the first column, Monday–Sunday beside it, each day's sessions drawn as on Plan (name, ridden profile in ink, time · TSS) and linking to the ride or strength page. Weeks that cross the month edge show their days from both months, the other month's dimmed. Reuse Plan's pieces (extract the shared day and session cells rather than copy them). 6. **From Plan.** When Plan's Previous week reaches the plan's first week, it becomes "Earlier weeks: History", landing on the month before the plan started. ## Rules - Measure before deciding: time `getHistoryMonth` for a full month on real data (`bun run db:pull`). If ridden profiles make it slow, store a ride's profile when it's imported and backfill once, and record the numbers in `docs/decisions.md`. - Phones get the same calendar stacked as Plan does (days with something on them); the year strip scrolls sideways. - Every control is a standard one: the select is a native select or Base UI's, the strip's cells are buttons with names ("October 2026, 1,240 TSS"), Previous and Next are named. ## Tests - Unit: month boundaries in a time zone (a ride at 23:30 local on the 31st), week rows that cross months, totals. - E2E: `/history` opens on this month; Previous loads last month without a spinner (preloaded); the strip jumps to a month; a ride opens and "Back to History" returns to that month; Plan's "Earlier weeks: History" lands before the plan. Axe and the keyboard checks pass, desk and phone. ## Out of scope Search and filters (by sport, by workout type): note under Follow-ups if the calendar leaves them wanted. ## Done when A year of riding is navigable in a few clicks, month to month is instant, and the past reads like Plan. Owner check under Follow-ups → Now: does the year strip work as the month picker, or should it be dropdowns? Unit, typecheck, lint, format, audit and e2e pass. End-of-session ritual in `CLAUDE.md`. _Moved from `prompts/49-history-calendar.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#224
No description provided.