From e3ffde0dcf927b45c6e6cb9b29851ca4176e61fb Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 19 Feb 2026 08:27:12 +0000 Subject: [PATCH] Fix broad query invalidation on checkpoint/captured events Scope invalidation to only the checkpoint diff query for the newly captured turn instead of invalidating all provider queries. The checkpoint/captured event carries a turnCount in its payload, so we use a predicate to match only the query whose toTurnCount equals the captured turn. This prevents N unnecessary refetches of immutable diffs for already-completed turns on each new turn completion. --- apps/web/src/routes/__root.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/web/src/routes/__root.tsx b/apps/web/src/routes/__root.tsx index 7564fd5aae..28724d2ce0 100644 --- a/apps/web/src/routes/__root.tsx +++ b/apps/web/src/routes/__root.tsx @@ -6,7 +6,6 @@ import { AnchoredToastProvider, ToastProvider } from "../components/ui/toast"; import { isElectron } from "../env"; import { useNativeApi } from "../hooks/useNativeApi"; import { invalidateGitQueries } from "../lib/gitReactQuery"; -import { providerQueryKeys } from "../lib/providerReactQuery"; import { DEFAULT_MODEL } from "../model-logic"; import { useStore } from "../store"; import { onServerWelcome } from "../wsNativeApi"; @@ -59,7 +58,15 @@ function EventRouter() { void invalidateGitQueries(queryClient); } if (event.method === "checkpoint/captured") { - void queryClient.invalidateQueries({ queryKey: providerQueryKeys.all }); + const payload = event.payload as { turnCount?: number } | undefined; + const turnCount = payload?.turnCount; + void queryClient.invalidateQueries({ + queryKey: ["providers", "checkpointDiff"] as const, + predicate: (query) => { + if (typeof turnCount !== "number") return true; + return query.queryKey[5] === turnCount; + }, + }); } if (!activeThreadId) return; dispatch({