authorgravatar for cursoragent@cursor.comCursor Agent <cursoragent@cursor.com> 2026-02-19 00:37:06-08:00
committergravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-02-19 00:37:06-08:00
log24c617d32ef64e4aeceedb4746ef89c3815360c0
treeadb5a67becb92e5f55f9b6834bcf3783968c7863
parent22e1a4cf92e035c11d079e7254334acb4d7e2a35

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.

1 files changed, 9 insertions(+), 2 deletions(-)

apps/web/src/routes/__root.tsx+9-2
......@@ -6,7 +6,6 @@ import { AnchoredToastProvider, ToastProvider } from "../components/ui/toast";
66import { isElectron } from "../env";
77import { useNativeApi } from "../hooks/useNativeApi";
88import { invalidateGitQueries } from "../lib/gitReactQuery";
9import { providerQueryKeys } from "../lib/providerReactQuery";
109import { DEFAULT_MODEL } from "../model-logic";
1110import { useStore } from "../store";
1211import { onServerWelcome } from "../wsNativeApi";
......@@ -59,7 +58,15 @@ function EventRouter() {
5958 void invalidateGitQueries(queryClient);
6059 }
6160 if (event.method === "checkpoint/captured") {
62 void queryClient.invalidateQueries({ queryKey: providerQueryKeys.all });
61 const payload = event.payload as { turnCount?: number } | undefined;
62 const turnCount = payload?.turnCount;
63 void queryClient.invalidateQueries({
64 queryKey: ["providers", "checkpointDiff"] as const,
65 predicate: (query) => {
66 if (typeof turnCount !== "number") return true;
67 return query.queryKey[5] === turnCount;
68 },
69 });
6370 }
6471 if (!activeThreadId) return;
6572 dispatch({