Plan: Replace Session Page with Full-Page SessionView
Goal
Replace the narrow chat card layout at /session/[id] with the full-page three-panel SessionView that has sidebars for partner understanding.
Current State
- SessionView (
/src/components/session/SessionView.tsx) - Full three-panel design, only used in/session-demowith mock data - Conversation (
/src/components/session/conversation.tsx) - Simple card layout, currently used in production - Session page (
/src/app/(app)/session/[id]/page.tsx) - Wraps everything inmax-w-3xl mx-auto, uses<Conversation>
Data Structure Gap
| SessionView Expects | Current Real Data | Adapter Needed |
|---|---|---|
participantA.name |
session.created_by (user ID only) |
Fetch profile |
participantB.name |
session.invited_user_id (user ID only) |
Fetch profile |
message.sender: 'A' | 'B' |
message.sender_id (user ID) |
Map IDs to roles |
ParticipantSummary |
Not stored | Derive from NVC extractions |
currentState: 'A_SPEAKING' |
No turn tracking | Implement based on last message |
Implementation Approach
Phase 1: Create Adapter Hook
File: /src/hooks/use-session-context.ts
Creates a useSessionContext hook that:
- Fetches session data + both participant profiles
- Transforms DB messages to SessionView message format
- Builds
ParticipantSummaryobjects from NVC extractions - Determines current speaker (async mode = alternating turns)
- Subscribes to real-time message updates
- Returns
SessionContextcompatible with SessionView
Phase 2: Update Session Page
File: /src/app/(app)/session/[id]/page.tsx
- Remove
max-w-3xl mx-autowrapper constraint - Replace
<Conversation>with<SessionView>when session is active - Use new
useSessionContexthook for data - Keep onboarding/waiting states as-is (they're already full-width)
Phase 3: Wire Up Actions
File: /src/components/session/SessionView.tsx (or adapter)
Connect SessionView's callbacks to real API:
onSendMessage→/api/message/processonEndTurn→ Update turn stateonSessionUpdate→ Persist state changes
Files to Create
/src/hooks/use-session-context.ts- Adapter hook
Files to Modify
/src/app/(app)/session/[id]/page.tsx- Use SessionView/src/components/session/SessionView.tsx- Minor tweaks if needed
Decisions Made
Free-form messaging - Either person can send anytime (no enforced turns)
- SessionView's turn logic needs adjustment for async mode
- Input always enabled, show "last spoke" indicator instead of strict turns
Derive summaries from NVC extractions - No new DB tables needed
- Parse
nvc_extractionJSON from latest message per user - Build
ParticipantSummarydynamically
- Parse
Placeholder text for empty states - "Their thoughts will appear as they share"
Detailed Implementation Steps
Step 1: Create useSessionContext Hook
File: /src/hooks/use-session-context.ts
// Returns SessionContext compatible with SessionView
// - Fetches session + profiles for both participants
// - Transforms messages: sender_id → 'A' | 'B'
// - Builds summaries from latest NVC extractions
// - Subscribes to real-time updates
// - Handles free-form mode (always canSpeak = true)
Key functions:
fetchSessionWithProfiles(sessionId)- Get session + joined profile datatransformMessages(dbMessages, creatorId)- Map sender_id to 'A'/'B'buildSummary(messages, participantId)- Extract latest NVC as summary- Real-time subscription for new messages
Step 2: Modify SessionView for Free-Form Mode
File: /src/components/session/SessionView.tsx
Changes needed:
- Add
mode: 'async' | 'sync'prop (default: 'async') - In async mode:
canSpeak()always returns true - In async mode: Don't show "waiting for partner" in input area
- Show "Last message from [Name]" instead of turn indicator
Step 3: Update Session Page
File: /src/app/(app)/session/[id]/page.tsx
- Remove the
max-w-3xl mx-autowrapper for active sessions - Import and use
useSessionContexthook - Replace
<Conversation>with<SessionView>whensession.status === 'active' - Keep existing onboarding/waiting UI unchanged (already full-width)
Step 4: Connect API Actions
In the session page or adapter:
- Wire
onSendMessage→ existing/api/message/processflow - Wire
onConfirm/onAdjust→ existing/api/message/confirmflow - Handle reflection display state (may need to integrate with SessionView)
File Changes Summary
| File | Action | Changes |
|---|---|---|
/src/hooks/use-session-context.ts |
CREATE | New adapter hook |
/src/components/session/SessionView.tsx |
MODIFY | Add async mode support |
/src/app/(app)/session/[id]/page.tsx |
MODIFY | Use SessionView, remove narrow wrapper |
Risk Areas
Reflection flow integration - SessionView doesn't have reflection/confirm UI built in
- May need to add reflection state to SessionView
- Or layer ReflectionDisplay component over SessionView
Real-time sync - Need to ensure messages update correctly for both users
- Test with two browser windows
Mobile responsiveness - SessionView has mobile layout, verify it works with real data