fix(P0): 修复发送消息后主区域跳回欢迎屏
This commit is contained in:
@@ -98,7 +98,7 @@ function App() {
|
||||
}, []);
|
||||
|
||||
// Clear error and stale stream state when thread switches.
|
||||
// Skip when doSubmit already called switchThread manually (to avoid clearing mid-stream).
|
||||
// Skip when doSubmit set the flag (new thread created during submit — don't clear mid-stream).
|
||||
useEffect(() => {
|
||||
if (skipNextSwitchRef.current) {
|
||||
skipNextSwitchRef.current = false;
|
||||
@@ -217,12 +217,11 @@ function App() {
|
||||
setConcurrentStatus("idle");
|
||||
return;
|
||||
}
|
||||
// Only need to switchThread manually when a new thread was just created.
|
||||
// For existing threads, currentThreadId didn't change so useEffect won't fire.
|
||||
// Setting the skip flag prevents the useEffect from re-firing and clearing messages.
|
||||
// For a newly created thread, currentThreadId just changed so the useEffect
|
||||
// would call thread.switchThread() which clears thread.messages mid-stream.
|
||||
// Skip it — useStream already uses the updated threadId prop from currentThreadId.
|
||||
if (!currentThreadId) {
|
||||
skipNextSwitchRef.current = true;
|
||||
thread.switchThread(activeThreadId);
|
||||
}
|
||||
|
||||
try { localStorage.removeItem(`draft_${activeThreadId}`); } catch { /* ignore */ }
|
||||
|
||||
Reference in New Issue
Block a user