From 0908e983fb974fa3c687f983ddf313dd2198a358 Mon Sep 17 00:00:00 2001 From: gongzhiyong Date: Wed, 15 Apr 2026 01:18:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(ui):=20P0=20=E7=BA=BF=E7=A8=8B=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E6=97=B6=E8=B0=83=E7=94=A8=20switchThread=20=E5=BD=BB?= =?UTF-8?q?=E5=BA=95=E6=B8=85=E9=99=A4=20error=20=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit useStream 的 error 跨线程持久化,切换 threadId 时不自动重置。 useEffect 监听 currentThreadId 变化,调用 thread.switchThread() 清除 error、messages 等所有旧状态,从根本上解决切换线程后 红色错误横幅残留问题。 Co-Authored-By: Claude Sonnet 4.6 --- langgraph/src/main.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/langgraph/src/main.tsx b/langgraph/src/main.tsx index 78d8b81..4e9a398 100644 --- a/langgraph/src/main.tsx +++ b/langgraph/src/main.tsx @@ -95,6 +95,11 @@ function App() { return () => window.removeEventListener("open-canvas", handler); }, []); + // Clear error and stale stream state when thread switches + useEffect(() => { + thread.switchThread(currentThreadId); + }, [currentThreadId]); // eslint-disable-line react-hooks/exhaustive-deps + // Sync concurrent status with thread loading state useEffect(() => { if (!thread.isLoading && concurrentStatus !== "cancelling") {