From 369237f6a8661e1958f5f8f5a0f09259480f1526 Mon Sep 17 00:00:00 2001 From: chengyongru <2755839590@qq.com> Date: Thu, 11 Jun 2026 23:53:51 +0800 Subject: [PATCH] fix: allow slower webui chat creation --- webui/src/hooks/useSessions.ts | 10 ++++++++-- webui/src/tests/useSessions.test.tsx | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/webui/src/hooks/useSessions.ts b/webui/src/hooks/useSessions.ts index 428b37312..7618b7e17 100644 --- a/webui/src/hooks/useSessions.ts +++ b/webui/src/hooks/useSessions.ts @@ -19,6 +19,7 @@ import type { const EMPTY_MESSAGES: UIMessage[] = []; const INITIAL_HISTORY_PAGE_LIMIT = 160; const OLDER_HISTORY_PAGE_LIMIT = 120; +const CHAT_CREATE_TIMEOUT_MS = 60_000; function persistedMessagesToUi(messages: UIMessage[]): UIMessage[] { return messages.map((m, idx) => ({ @@ -86,7 +87,7 @@ export function useSessions(): { }, [client, refresh]); const createChat = useCallback(async (workspaceScope?: WorkspaceScopePayload | null): Promise => { - const chatId = await client.newChat(5_000, workspaceScope); + const chatId = await client.newChat(CHAT_CREATE_TIMEOUT_MS, workspaceScope); const key = `websocket:${chatId}`; optimisticKeysRef.current.add(key); // Optimistic insert; a subsequent refresh will replace it with the @@ -112,7 +113,12 @@ export function useSessions(): { beforeUserIndex: number, title?: string, ): Promise => { - const chatId = await client.forkChat(sourceChatId, beforeUserIndex, title); + const chatId = await client.forkChat( + sourceChatId, + beforeUserIndex, + title, + CHAT_CREATE_TIMEOUT_MS, + ); const key = `websocket:${chatId}`; optimisticKeysRef.current.add(key); setSessions((prev) => [ diff --git a/webui/src/tests/useSessions.test.tsx b/webui/src/tests/useSessions.test.tsx index 826a862a1..323f67ee7 100644 --- a/webui/src/tests/useSessions.test.tsx +++ b/webui/src/tests/useSessions.test.tsx @@ -219,7 +219,7 @@ describe("useSessions", () => { await result.current.createChat(); }); - expect(client.newChat).toHaveBeenCalledWith(5000, undefined); + expect(client.newChat).toHaveBeenCalledWith(60_000, undefined); expect(result.current.sessions.map((s) => s.key)).toEqual(["websocket:chat-new"]); await act(async () => { @@ -258,7 +258,7 @@ describe("useSessions", () => { await result.current.createChat(workspaceScope); }); - expect(client.newChat).toHaveBeenCalledWith(5000, workspaceScope); + expect(client.newChat).toHaveBeenCalledWith(60_000, workspaceScope); expect(result.current.sessions[0]?.workspaceScope).toEqual(workspaceScope); });