Session 51: Held re-plan #226
Labels
No labels
accessibility
area:accounts
area:ai-evals
area:look
area:maps
area:platform
area:rides-progress
area:riding
area:today-plan-coach
area:ui-shell
bot:blocked
bot:failed
bot:pr
bot:waiting
bot:working
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
later
now
owner-check
parked
question
ready
session
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ckreidl/trainer#226
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
51 · The re-plan waits for the conversation
Phase: Adaptive coaching 2/5 (owner request 2026-11-08) · Branch:
session/51-held-replan· Depends on: 50After session 50 a ride re-plans twice: at once when it's logged, and again at End chat. The owner wants one re-plan, after the conversation: the post-ride re-plan is held until End chat, and if the athlete never engages, the nightly cron runs it. A bar in the app shell says a ride is waiting on them.
Read first
docs/requirements.md→ "Coaching dialogue and adaptability" (FR-20) and "Adaptation triggers" under Sports-science foundationsdocs/decisions.md: the 2026-11-08 adaptive coaching entrysrc/server/on-session-logged.ts(onSessionLogged,onRideNotesSaved,onAppOpen),src/server/replan/orchestrator.ts(enqueueTriggers,kickPending,processReplans,claimRun),src/server/replan/triggers.ts(rideTriggers,readinessTriggers,markMissedSessions)src/routes/api/cron/missed-sessions.ts,src/server/cron-auth.ts,vercel.jsonRideChat,endRideChat),src/components/new-build-banner.tsxand where the shell mounts itprisma/schema.prisma:ReplanTrigger,ReplanRunGoal
ReplanTrigger.heldForRideId(nullable, FK toRide, set null on delete; additive migration). A saved ride that will get a take (session 34's minimum riding time, the same teststartRideFeedbackuses) records itsride_loggedandtss_off_targettriggers held for that ride. The orchestrator never consumes a held trigger: the debounce,kickPendingandprocessReplansskip them. Rides that get no take are not held.ride_chatbeside them, so one worker consumes them together (one re-plan). A changed ride note while held stays held (the note is read from the ride); after End chat it re-plans as now. Deleting a held ride drops its held triggers; theride_deletedtrigger runs as now./api/cron/nightlyand updatevercel.json, or keep the path; say which): for each user, release every held trigger, then runmarkMissedSessions, and pass all of them to oneenqueueTriggers, so held rides and a missed session make one re-plan. One user's failure never stops the rest. The release is idempotent (a second run finds nothing held). Session 50's chat stays open after a nightly release; ending it later still runs its ownride_chatre-plan.readinessTriggersreturns none when a ride is logged for that date before the check-in was saved: the check-in was meant for that day's session. The check-in is still saved and read by the next re-plan as today.NewBuildBanner, while any trigger is held: "Saturday's ride is waiting on you. Finish the chat to update your plan." with an Open link to the oldest held ride's chat; for several rides, "2 rides are waiting on you" opening the oldest. It reads from a cheap query (shell data or its own), not a poll faster than the shell already refreshes. It hides on the ride page whose chat it points to, and never shows over the new-build bar.Rules
authed, Zod anduserIdfilters; the cron usescronAuthorised.Tests
ride_chatand one run consumes all three; two held rides released by the cron make one run, and with a missed session still one; the cron run twice releases nothing the second time; a held ride's deletion drops its triggers; an edit while a ride is held runs without consuming the held ones; a check-in after that day's ride raises no trigger, one before it does as now; another user's held triggers are untouched.kickPendingand the debounce ignore held triggers.Out of scope
Dated context and End chat's list (session 52), push notifications, a second cron. Note anything else under Follow-ups.
Done when
On a production build (replay) a logged ride re-plans only at End chat or the nightly job, once, with the bar in between; unit, typecheck, lint, format, audit and e2e pass. Add an owner check under Follow-ups → Now: leave one ride unchatted overnight and check the morning's re-plan line and that only one version was saved. Update FR-20's "not yet built", the "Adaptation triggers" paragraph and the cron line in
docs/PROGRESS.md→ Current state. Finish with the end-of-session ritual inCLAUDE.md.Moved from
prompts/51-held-replan.mdon 2026-11-08.