Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🪤 fix: Reload Messages When Reopening a Chat from a Non-Chat Route (#13501)

Danny Avila45d85bd907ea
diff --git a/client/src/hooks/Conversations/useNavigateToConvo.tsx b/client/src/hooks/Conversations/useNavigateToConvo.tsx
index c8e7aa0b05..390f5b77d7 100644
--- a/client/src/hooks/Conversations/useNavigateToConvo.tsx
+++ b/client/src/hooks/Conversations/useNavigateToConvo.tsx
@@ -119,6 +119,14 @@ const useNavigateToConvo = (index = 0) => {
clearAllConversations(true);
clearMessagesCache(queryClient, currentConvoId);
if (convo.conversationId !== Constants.NEW_CONVO && convo.conversationId) {
+ /**
+ * Remove (not just invalidate) the target's messages so a freshly-mounted
+ * ChatView refetches them. A prior `clearMessagesCache` can leave this
+ * conversation cached as `[]`, which the messages query's `refetchOnMount: false`
+ * would treat as valid — leaving the chat stuck on an empty cache with no
+ * request when navigating in from a non-chat route (e.g. /projects).
+ */
+ queryClient.removeQueries([QueryKeys.messages, convo.conversationId]);
queryClient.invalidateQueries([QueryKeys.conversation, convo.conversationId]);
fetchFreshData(convo);
} else {