AI Reflection Screen
Location: apps/mobile/src/app/(main)/ai/index.tsx
The AI Reflection screen is the entry point for starting a new 5-question reflection session. It features an animated "Letter Rain" topic selector and streaming responses.
Screen Structure
TopNav: "AI Reflection"
├─ SessionList (recent sessions, tap to resume)
└─ StartNew section
├─ LetterRain Stage (topic display with drop animation)
├─ Topic Chips (interest slugs as selectable pills)
├─ "Or type your own" collapsible input
└─ "Start reflection" buttonLetter Rain Animation
When a user taps an interest chip:
- The chip bounces with a spring animation (
withSpring). - Other chips dim (
opacity → 0.3). - The topic string is split into individual characters.
- Each
FallingLettercomponent animates in fromtranslateY(-30)→0with:- Spring:
damping=14, stiffness=220, mass=0.7 - Stagger:
index * 55msdelay per character - Fade:
opacity 0→1in 50ms
- Spring:
- The dark ink stage block shows the assembled word.
- Tap the stage × to clear and pick again.
FallingLetter Component
tsx
function FallingLetter({ char, index, color }) {
const ty = useSharedValue(-30);
const op = useSharedValue(0);
// withDelay(index * 55ms, withSpring(...))
}Topic Selection
Interest Chips
Loaded from GET /interests/me — the user's subscribed interests. Shows:
- Interest name
- Accent color background
- Bounce animation on press
Sub-Interest Expansion
After selecting a L1 topic chip, a second row of L2/L3 sub-interest chips appears (children of the selected interest). User can refine to a specific sub-topic.
Free-Form Input
A collapsible TextInput labelled "or type your own". When expanded:
- Dismiss on outside tap.
- Clears chip selection when text is entered.
- Max 60 characters.
Session Flow (from this screen)
- User selects topic (chip or typed) →
topicstring set. - Tap "Start reflection" →
POST /ai/sessions { topic }. - Navigate to
ai/session/[id].tsx. - Display question 1 with streaming response (Anthropic mode) or static text (scripted).
- User types answer →
POST /ai/sessions/:id/answer { answer }. - Next question auto-loads. Repeat for steps 2–5.
- Step 5 answer submitted →
POST /ai/sessions/:id/complete. - Screen shows "Your reflection is ready" with summary.
- Tap "Apply to profile" → map-interests → suggestions → apply flow.
Streaming Responses (Anthropic Mode)
When ANTHROPIC_API_KEY is set, AI responses stream via Server-Sent Events:
- Endpoint:
POST /ai/sessions/:id/answerreturns streaming body. - Mobile uses
fetchwithReadableStreamparsing. - Characters appear progressively as they stream.
- A blinking cursor indicates streaming in progress.
Session History
Recent sessions are shown below the topic selector:
- Status badge:
in_progress(pulsing dot),completed(checkmark),abandoned(grey) - Session topic and start time
- Turn count (e.g., "3 of 5 questions")
- Tap to resume an in-progress session
Loaded via GET /ai/sessions?limit=10.