From 8018762f115b4302a4bea8cab05a1d5d41b34be2 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Fri, 12 Dec 2025 01:08:27 -0500 Subject: [PATCH] fix: Update query parameter handling in useChatHelpers - Refactored the logic for determining the query parameter used in fetching messages to prioritize paramId from the URL, falling back to conversationId only if paramId is not available. This change ensures consistency with the ChatView component's expectations. --- client/src/hooks/Chat/useChatHelpers.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/hooks/Chat/useChatHelpers.ts b/client/src/hooks/Chat/useChatHelpers.ts index f52ff1f17e..cea7bcfe17 100644 --- a/client/src/hooks/Chat/useChatHelpers.ts +++ b/client/src/hooks/Chat/useChatHelpers.ts @@ -24,11 +24,13 @@ export default function useChatHelpers(index = 0, paramId?: string) { const { conversation, setConversation } = useCreateConversationAtom(index); const { conversationId, endpoint, endpointType } = conversation ?? {}; - const queryParam = paramId === 'new' ? paramId : (conversationId ?? paramId ?? ''); + /** Use paramId (from URL) as primary source for query key - this must match what ChatView uses + Falling back to conversationId (Recoil) only if paramId is not available */ + const queryParam = paramId === 'new' ? paramId : (paramId ?? conversationId ?? ''); /* Messages: here simply to fetch, don't export and use `getMessages()` instead */ - const { data: _messages } = useGetMessagesByConvoId(conversationId ?? '', { + const { data: _messages } = useGetMessagesByConvoId(queryParam, { enabled: isAuthenticated, });