fix(P1): load thread state before switching threadId to prevent welcome flash
Trigger auto deployment for soc-langgraph / build-and-deploy (push) Failing after 16s
Deploy LangGraph UI to Azure Static Web Apps / build-and-deploy (push) Failing after 44s

Previously: setHistoricalMessages([]) + setCurrentThreadId() fired together,
causing a render where both thread.messages (cleared by switchThread) and
historicalMessages were empty → welcome screen shown.

Fix: await loadThreadState() first, then set historicalMessages/ui and
currentThreadId atomically. historicalMessages is populated before the
first render after the switch, so the welcome screen never flashes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
gongzhiyong
2026-04-15 02:01:20 +08:00
co-authored by Claude Sonnet 4.6
parent 23527b3bdc
commit 820a40982e
+5 -5
View File
@@ -43,13 +43,13 @@ export function useConversation(
} catch {
setInput("");
}
setHistoricalMessages([]);
setHistoricalUi([]);
// Load state BEFORE switching threadId so historicalMessages is populated
// when the first render after the switch fires — avoids flash of welcome screen.
const state = await loadThreadState(client, threadId);
setHistoricalMessages(state.messages.length ? state.messages : []);
setHistoricalUi(state.ui.length ? (state.ui as UIMsgLocal[]) : []);
setCurrentThreadId(threadId);
setSidebarOpen(false);
const state = await loadThreadState(client, threadId);
if (state.messages.length) setHistoricalMessages(state.messages);
if (state.ui.length) setHistoricalUi(state.ui as UIMsgLocal[]);
}, [currentThreadId, input, client, setInput]);
const handleDeleteThread = useCallback(async (threadId: string) => {