fix: guard per-chat cancelQueries to prevent 'Chat not found' race (#23714)

This commit is contained in:
Danielle Maywood
2026-03-27 13:08:58 +00:00
committed by GitHub
parent 9b4d15db9b
commit 0ec0f8faaf
+11 -4
View File
@@ -471,10 +471,17 @@ const AgentsPage: FC = () => {
// title generation finished, so its response carries
// the fallback title.
void cancelChatListQueries(queryClient);
void queryClient.cancelQueries({
queryKey: chatKey(updatedChat.id),
exact: true,
});
// Only cancel a per-chat refetch when the cache
// already has data. Cancelling a first-time fetch
// reverts the query to pending/idle with no data
// and no retry, which AgentDetail shows as
// "Chat not found".
if (queryClient.getQueryData(chatKey(updatedChat.id))) {
void queryClient.cancelQueries({
queryKey: chatKey(updatedChat.id),
exact: true,
});
}
// For "created" events, use a cross-page existence
// check and prepend only to the first page.