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

navigateToConvo now removes the target conversation's cached messages before
fetching, so a freshly-mounted ChatView refetches them. clearMessagesCache
leaves a left conversation cached as [], and the messages query's
refetchOnMount: false treats that empty array as valid — so returning to the
conversation from a route where ChatRoute was unmounted (e.g. /projects) left
the chat stuck on an empty cache with no /api/messages request.
This commit is contained in:
Danny Avila 2026-06-03 23:21:19 -04:00 committed by GitHub
parent 4dce0fd3ab
commit 45d85bd907
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 {