Process Flow
Complete flow from user interaction to AI response, covering 15 steps across 4 phases.
Pre-Recording Phase
Step 1: User presses record button -> Check internet connectivity
Step 2: Check if user has available credits (weekly OR bank) -> If no credits, show “Credit Limit Reached” dialog
Step 3: Check AI token validity -> If invalid/expiring, request new token from generate_ai_token endpoint. Status: “Authenticating…”
Step 4: Check microphone permission -> Request if needed -> Show settings dialog if permanently denied
Recording Phase
Step 5: Clear any cached previous response -> Start recording (WAV, 44.1kHz, 128kbps). Status: “Listening…”. Timer shown: MM:SS
Step 6: Recording continues until user stops OR max 2 minutes reached
Processing Phase
Step 7: User stops recording -> Save audio file. Status: “Sending…”
Step 8: Collect all data payloads (course progress, journal, user context, conversation, voice)
Step 9: POST to voice-chat endpoint with AI token authentication. Upload progress logged to console.
Step 10: After 7 seconds, start rotating status text every 7 seconds: “Thinking…” -> “Processing…” -> “Analyzing…” -> “Reasoning…” -> “Reflecting…” -> “Contemplating…” -> “Evaluating…” -> “Pondering…”
Response Phase
Step 11: Server responds with audio_url, ai_usage_in_seconds, and conversation
Step 12: Update AI usage credits locally -> Save conversation to file. Status: “Receiving…”
Step 13: Download AI response audio from audio_url. Save to: AppData/AI_Voice_Responses/response_[timestamp].wav
Step 14: Play AI audio response using just_audio. Status: “Replying…”
Step 15: Playback complete -> Mark response as replayable -> Return to idle. Status: “Press record button”. Shows: “or replay response” link
Recording Modes
Tap Mode (Default)
- Tap microphone button to start recording
- Tap again to stop recording and send
- Max duration: 2 minutes
Hold Mode
- Press and hold microphone button for 500ms+ to activate
- Release to stop recording and send immediately
- If permission dialog appears during hold, switches to tap mode after permission granted
Code: _onButtonPress() at line ~2182, _onButtonRelease() at line ~2196
UI States
The AI voice tab has 4 states:
idle
- Status: “Press record button” (online) or “Offline” (offline)
- Microphone button glows
- Replay link shown if previous response available
- Tutorial border animation pulsing
recording
- Status: “Listening…”
- Timer displayed (MM:SS)
- Stop/square icon shown in button
- Buddha orb pulsing
processing
- Status: “Sending…” then rotating thinking words
- Loading dots animation in button
- Buddha orb pulsing
playback
- Status: “Replying…”
- Waveform animation in button
- Buddha orb pulsing
Connectivity States
- Online: Full functionality, status shows “Press record button”
- Offline: Recording blocked, status shows “Offline”, orb appears static