refactor(streaming): complete rewrite of message streaming architecture
Completely redesigned streaming message accumulation to fix persistent
issues with messages disappearing, flickering, and being replaced during
streaming.
Key changes:
- Simplified streaming state to single accumulating message + completed array
- New message boundary detection: finalize on reasoning_message ID change
- Display both completed and current messages simultaneously (no more "one slot")
- Convert streaming messages to permanent format only after stream completes
- Remove server message fetching - build from stream data only
New architecture:
- currentStreamingMessage: single message being accumulated
- completedStreamingMessages[]: finished messages (stream still active)
- Simple API: accumulateReasoning, accumulateToolCall, accumulateAssistant
This follows the Letta streaming protocol correctly:
- Chunks are DELTAS (incremental, not full text)
- Reasoning + content share same message ID
- New reasoning with different ID = previous message complete
Files changed:
- src/stores/chatStore.ts: New StreamingMessage interface, simple accumulation
- src/hooks/useMessageStream.ts: Dead simple chunk handler with ID-based finalization
- src/hooks/useMessageGroups.ts: Display both completed and current streams
- src/screens/ChatScreen.tsx: Auto-expand reasoning blocks
- STREAMING_ANALYSIS.md: Complete documentation of streaming behavior
This resolves days of streaming issues with a simpler, more correct implementation.