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.
This commit is contained in:
Cursor Agent committed 2026-04-01 17:43:11 +00:00
1 parent bbe5e14696
commit 95dd2b671c
2 files changed
+2 -13

No files matched your search

+1 -10
View File
@@ -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(
+1 -3
View File
@@ -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,
});
}