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 <noreply@anthropic.com>
This commit is contained in:
m4
2026-08-12 13:08:37 +08:00
parent b94bcd649a
commit 3efaa9f34e
+6 -1
View File
@@ -99,6 +99,7 @@ export function useBusyThreadIds(): ReadonlySet<string> {
const runningThreadIds = new Set<string>();
const runningListeners = new Set<() => void>();
let runningSnapshot: ReadonlySet<string> = runningThreadIds;
const EMPTY_IDS: ReadonlySet<string> = new Set();
export function setThreadRunning(threadId: string, running: boolean): void {
const changed = running
@@ -122,7 +123,11 @@ export function getRunningThreadIds(): ReadonlySet<string> {
}
export function useLocalRunningThreadIds(): ReadonlySet<string> {
return useSyncExternalStore(subscribeRunningThreads, getRunningThreadIds);
return useSyncExternalStore(
subscribeRunningThreads,
getRunningThreadIds,
() => EMPTY_IDS
);
}
/** Merged view of "this thread has an active run": the zero-latency local