From 95dd2b671c4e5381fa49fa3a417af17407e85c33 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 1 Apr 2026 17:43:11 +0000 Subject: [PATCH] Fix snapshot sync bypassing recovery coordinator and dead loading state - Remove refreshActiveSnapshot from unarchiveThread: the EventRouter's recovery coordinator already handles thread.unarchived events via fallbackToSnapshotRecovery, which properly updates latestSequence. Calling syncServerReadModel directly left the coordinator stale, causing already-applied events to be re-processed and potentially corrupting streaming message content via double concatenation. - Fix archived threads loading state: placeholderData always returned EMPTY_ARCHIVED_THREADS on first load, making isPending permanently false and the loading UI unreachable. Now only uses previous query data as placeholder, allowing isPending to be true on first fetch. --- apps/web/src/hooks/useThreadActions.ts | 11 +---------- apps/web/src/lib/orchestrationReactQuery.ts | 4 +--- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/apps/web/src/hooks/useThreadActions.ts b/apps/web/src/hooks/useThreadActions.ts index c7444ee18e..535674fd1d 100644 --- a/apps/web/src/hooks/useThreadActions.ts +++ b/apps/web/src/hooks/useThreadActions.ts @@ -18,7 +18,6 @@ import { useSettings } from "./useSettings"; export function useThreadActions() { const appSettings = useSettings(); - const syncServerReadModel = useStore((store) => store.syncServerReadModel); const clearComposerDraftForThread = useComposerDraftStore((store) => store.clearDraftThread); const clearProjectDraftThreadById = useComposerDraftStore( (store) => store.clearProjectDraftThreadById, @@ -33,13 +32,6 @@ export function useThreadActions() { const queryClient = useQueryClient(); const removeWorktreeMutation = useMutation(gitRemoveWorktreeMutationOptions({ queryClient })); - const refreshActiveSnapshot = useCallback(async () => { - const api = readNativeApi(); - if (!api) return; - const snapshot = await api.orchestration.getActiveSnapshot(); - syncServerReadModel(snapshot); - }, [syncServerReadModel]); - const archiveThread = useCallback( async (threadId: ThreadId) => { const api = readNativeApi(); @@ -73,10 +65,9 @@ export function useThreadActions() { commandId: newCommandId(), threadId, }); - await refreshActiveSnapshot(); void queryClient.invalidateQueries({ queryKey: orchestrationQueryKeys.archivedThreads() }); }, - [queryClient, refreshActiveSnapshot], + [queryClient], ); const deleteThread = useCallback( diff --git a/apps/web/src/lib/orchestrationReactQuery.ts b/apps/web/src/lib/orchestrationReactQuery.ts index f746f492d4..86afc49db6 100644 --- a/apps/web/src/lib/orchestrationReactQuery.ts +++ b/apps/web/src/lib/orchestrationReactQuery.ts @@ -1,4 +1,3 @@ -import type { OrchestrationListArchivedThreadsResult } from "@t3tools/contracts"; import { queryOptions } from "@tanstack/react-query"; import { ensureNativeApi } from "~/nativeApi"; @@ -8,7 +7,6 @@ export const orchestrationQueryKeys = { }; const DEFAULT_ARCHIVED_THREADS_STALE_TIME = 15_000; -const EMPTY_ARCHIVED_THREADS: OrchestrationListArchivedThreadsResult = []; export function archivedThreadsQueryOptions() { return queryOptions({ @@ -18,6 +16,6 @@ export function archivedThreadsQueryOptions() { return api.orchestration.listArchivedThreads(); }, staleTime: DEFAULT_ARCHIVED_THREADS_STALE_TIME, - placeholderData: (previous) => previous ?? EMPTY_ARCHIVED_THREADS, + placeholderData: (previous) => previous, }); }