From 24c617d32ef64e4aeceedb4746ef89c3815360c0 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 19 Feb 2026 00:37:06 -0800 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 866da47ebff5a5b5b8adcbf39826af0e8d41d425..bfac06dff13a5ce399d898691c917c9d5f68d3db 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({ -- 2.54.0