refactor(chat): update chat components to use chatId instead of roomId
Merged
AH
6mo ago+130+130+012345678901234567890123456789-143-143-012345678901234567890123456789
This commit removes the InstantChatRoom component and updates various hooks and components to replace references of roomId with chatId. The changes ensure that chat functionality is aligned with the new session-scoped architecture, improving consistency across the chat system. Additionally, the sessionId is now required in several components to streamline the chat transport process.
Summary by cubic
Refactored chat to use session-scoped chatId routes and require sessionId across the stack. Dropped legacy /chat/:id pages and the legacy /api/chat transport; all traffic goes through workflow.
-
Refactors
- Removed
app/chat/[roomId]/page.tsx; replacedroomIdwithchatIdin hooks/components; sidebar derives the active chat from/sessions/:sessionId/chats/:chatId. sessionIdis now required inChat,useVercelChat,useChatTransport,useMessageLoader, andVercelChatProvider; context exposessessionId.- Transport always posts to
POST /api/chat/workflow, injectingsessionId,chatId, and the bearer token. - Split URL helpers into
lib/chat/getChatPath,lib/chat/getChatUrl, andlib/chat/isActiveChatRoomPathwith tests;isActiveChatRoomPathnow only matches session-scoped paths. Used for URL updates, email CTAs, and route guards. - Replaced
usePathnamewithwindow.location.pathnameand hard-nav viawindow.location.hrefinHeader/ArtistandOrganizationProviderto avoid Next router desync; simplifieduseParamsto{ chatId }. - Recent Chats now parses session-scoped paths; fixed new-chat URL handling by casting
newRoomIdtostringand usinggetChatPath.
- Removed
-
Migration
- Pass
sessionIdandchatIdtoVercelChatProviderandChat. - Rename any
roomIdparams/routes tochatId; use/sessions/[sessionId]/chats/[chatId]. - Use
getChatPath/getChatUrlfor links and history updates; remove any dependency on legacy/api/chat. - Update email CTAs to use
getChatUrl(sessionId, conversationId)and ensuresessionIdis provided.
- Pass
Summary by CodeRabbit
-
Refactor
- Chat routing unified to session-scoped URLs and consistent chat paths.
- Sessions are now required for chat operations and context.
- Chat transport always uses the workflow endpoint with consistent session/chat context.
- URL generation and navigation updated for reliable chat-to-chat and organization switches.
-
Bug Fixes
- Improved detection of active chat routes to prevent stale/incorrect redirects.
-
Other
- Email links now point to the canonical chat URL.