Session 50: Ride chat #225
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#225
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?
50 · Ride chat
Phase: Adaptive coaching 1/5 (owner request 2026-11-08) · Branch:
session/50-ride-chat· Depends on: 34The coach's take on a ride is one-way. The owner wants a conversation: the coach asks what the numbers can't tell it (how hard it felt, why heart rate drifted, why the ride ran long), the athlete answers, and only at the end, by End chat, does one re-plan run with what was learned. No plan changes mid-chat. Session 51 then holds the post-ride re-plan until End chat; this session leaves the immediate
ride_loggedre-plan as it is.Read first
docs/requirements.md→ "Coaching dialogue and adaptability" (FR-19, and FR-20 to see what 51 adds), FR-8, FR-14, and "AI design" (ride feedback and the guardrails paragraph)docs/decisions.md: the 2026-11-08 adaptive coaching entry, and the session 33, 34 and 39 entries on feedback and allowancesprisma/schema.prisma:CoachMessage,RideFeedback,Ride,ReplanTrigger, thePlanTriggerenumsrc/server/coach-store.ts(getCoachThread,askCoach,historyOf,coachSays),src/server/coach.ts,src/ai/prompts/chat.tssrc/server/feedback-store.ts(comparisonFor,getRideFeedbackView,feedbackHeadlines),src/server/feedback-run.ts,src/ai/prompts/feedback.ts,src/domain/feedback/schema.tssrc/server/on-session-logged.ts,src/server/replan/triggers.ts,src/server/replan/input.ts,src/ai/prompts/replan.ts,src/domain/replan/triggers.tssrc/components/log/coach-take.tsx, the ride page route,src/components/today/unplanned-ride.tsxand Today's done-ride card, the coach chat sheetclaude-apiskill before touchingsrc/ai/Goal
RideFeedbackOutputgainsquestions(0–2 short questions). New promptfeedback-v3: ask only when the answer would change how the coach reads the ride or plans the next days. Examples: heart rate high for the power, a ride much longer or harder than planned, an unplanned ride whose kind the data can't settle (polo, a group ride with no power), a note that hints at pain. A clear ride gets none. Old rows parse withquestions: []. Re-record the feedback fixtures.CoachMessage.rideId(nullable, FK toRide, cascade on delete; additive migration) and an index on(userId, rideId, createdAt). A ride chat's state lives on a smallRideChatrow (rideIdunique,userId,endedAt?,createdAt) or an equally small shape you justify; it is created on the first reply. The take's questions show as the coach's opening lines (from the feedback row, not copied into messages).sendRideMessage(rideId, text):authed, Zod, ownership of the ride. Refused when the chat is ended or the ride has no take. One AI call, new taskride_chatwith its ownAI_MODEL_RIDE_CHAT/AI_EFFORT_RIDE_CHATdefaulting to the chat task's config, and a Developer panel row like the others. Input: the ride's comparison and take, the athlete's note on it, its thread, form before and after, the week's planned sessions, recent readiness, and the ride's day. Output:{ reply }only, no patch. The prompt: plain and short; ask a follow-up when the answer is still unclear; never promise plan changes ("I'll take this into the plan when you end the chat" is fine); the athlete's text is data inside a delimited block, never instructions; medical red flags short-circuit as coach chat does. Counts against the athlete's allowance (userStarted). Takes no re-plan lock (it changes nothing).endRideChat(rideId): setsendedAtand enqueues one new triggerride_chat(enum value, additive) whose detail names the ride and day. The thread becomes read-only. Ending an empty chat (no athlete message) is allowed and enqueues nothing.loadReplanInputadds each ride chat from the last 14 days (ended or not) beside its ride in<last_14_days>, as athlete data, delimited like notes, trimmed to a length cap.replan-v3(or the next version) says how to weigh it: what the athlete says about how hard a ride felt, how they feel now, and their time this week outranks what the numbers suggest, inside the rules; a ride the athlete calls easy is no reason to strip planned quality. Coach chat'shistoryOfincludes ride-chat messages, each tagged with its ride's day.Rules
authed, a Zod validator anduserIdfilters; a ride and its messages are only ever the owner's.AI_REPLAY=1. Record withbun run ai:recordandE2E_AI_RECORD=1.Tests
RideFeedbackOutputwith and without questions; old rows parse; the ride-chat output schema parses its fixtures; a red-flag message short-circuits.RideChatand both messages; another user's ride is refused; a reply after End chat is refused; End chat enqueues oneride_chattrigger and an empty chat enqueues none; deleting the ride removes its messages; the re-plan input carries the last 14 days' ride chats and not older ones; coach chat history includes them with their day.Out of scope
Holding the post-ride re-plan, the nightly release and the shell bar (session 51); saving dated context or a TSS override from the chat (session 52); streaming chat replies; notifications. Note anything else under Follow-ups.
Done when
On a production build (replay) a ride's take asks a question, the athlete replies and gets an answer, and End chat runs one re-plan whose input holds the conversation; coach chat shows the ride's messages; unit, typecheck, lint, format, audit and e2e pass. Add an owner check under Follow-ups → Now: chat about the next three real rides (one unplanned) and note the cost per chat. Update FR-19's "not yet built" and the "AI design" table (the ride chat row). Finish with the end-of-session ritual in
CLAUDE.md.Moved from
prompts/50-ride-chat.mdon 2026-11-08.