From 3efaa9f34e2c69be84b2b0faf3443f8a65c2e92a Mon Sep 17 00:00:00 2001 From: m4 Date: Wed, 12 Aug 2026 13:08:37 +0800 Subject: [PATCH] fix(webui): add getServerSnapshot to running-threads store for SSR useLocalRunningThreadIds is now mounted on a force-dynamic route, so useSyncExternalStore needs a getServerSnapshot to avoid React's "Missing getServerSnapshot" error during server rendering. Use a module-level EMPTY_IDS constant to keep snapshot identity stable. Co-Authored-By: Claude Opus 4.7 --- src/app/hooks/useThreads.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/hooks/useThreads.ts b/src/app/hooks/useThreads.ts index e94a611..6309abc 100644 --- a/src/app/hooks/useThreads.ts +++ b/src/app/hooks/useThreads.ts @@ -99,6 +99,7 @@ export function useBusyThreadIds(): ReadonlySet { const runningThreadIds = new Set(); const runningListeners = new Set<() => void>(); let runningSnapshot: ReadonlySet = runningThreadIds; +const EMPTY_IDS: ReadonlySet = new Set(); export function setThreadRunning(threadId: string, running: boolean): void { const changed = running @@ -122,7 +123,11 @@ export function getRunningThreadIds(): ReadonlySet { } export function useLocalRunningThreadIds(): ReadonlySet { - return useSyncExternalStore(subscribeRunningThreads, getRunningThreadIds); + return useSyncExternalStore( + subscribeRunningThreads, + getRunningThreadIds, + () => EMPTY_IDS + ); } /** Merged view of "this thread has an active run": the zero-latency local