Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix: allow slower webui chat creation
chengyongru369237f6a866
diff --git a/webui/src/hooks/useSessions.ts b/webui/src/hooks/useSessions.tsindex 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<string> => {- 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<string> => {- 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.tsxindex 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);});