feat(chat): resume in-flight workflow stream on chat mount
AR
6mo ago+160+160+012345678901234567890123456789-32-32-01234567890123456789
Reconnects to a still-running workflow stream when a chat is reopened mid-generation, instead of showing a frozen partial turn.
The GET chat snapshot already reports isStreaming. We now surface it and, when true, reconnect through the AI SDK resume path to GET /api/chat/{chatId}/stream (recoupable/api#596). The transport's headers carry the Privy bearer on the reconnect GET automatically.
getChatSnapshotreplacesgetChatMessages, returning{ messages, isStreaming }useMessageLoaderfiresonActiveStreamonce when the loaded chat is streaming- workflow transport gains
prepareReconnectToStreamRequest→ GET stream route useVercelChatresumes viauseChat'sresumeStream()on that signal
Test plan
- Start a long generation, reload the page mid-stream → chat reattaches and continues streaming to completion.
- Reopen a chat whose run already finished → snapshot
isStreaming: false, no reconnect; persisted messages render. - New/empty chat → no resume attempt.
- Unit:
lib/messages/__tests__/getChatSnapshot.test.ts.
Depends on recoupable/api#596 being live.
Summary by cubic
Reattaches to an in-flight workflow stream when a chat mounts, so reopening mid-generation resumes live instead of showing a frozen partial turn. Also updates getChatSnapshot to throw on failed fetches, so errors surface instead of rendering a blank chat.
-
New Features
- Replaced
getChatMessageswithgetChatSnapshot, returning{ messages, isStreaming }. useMessageLoadersignalsonActiveStreamwhenisStreamingis true;useVercelChatresumes viaresumeStream().- Transport adds
prepareReconnectToStreamRequesttoGET /api/chat/{chatId}/stream(bearer forwarded via headers).
- Replaced
-
Dependencies
- Requires
recoupable/api#596(GET stream route) to be live.
- Requires