diff --git a/static/boot.js b/static/boot.js index 2d8cbf1a0b..2049db4e57 100644 --- a/static/boot.js +++ b/static/boot.js @@ -1,6 +1,6 @@ async function cancelStream(){ const streamId = S.activeStreamId; - if(!streamId){if(typeof _abortPendingChatStart==='function')_abortPendingChatStart();if(S.busy)setBusy(false);return;} + if(!streamId){window._abortPendingChatStart?.();if(S.busy){setBusy(false);if(typeof removeThinking==='function')removeThinking();}return;} try{ await fetch(new URL(`api/chat/cancel?stream_id=${encodeURIComponent(streamId)}`,document.baseURI||location.href).href,{credentials:'include'}); }catch(e){/* cancel request failed - cleanup below still runs */} diff --git a/static/ui.js b/static/ui.js index 3142111b5b..3552b78a49 100644 --- a/static/ui.js +++ b/static/ui.js @@ -6334,11 +6334,8 @@ function finalizeThinkingCard(){ } } function appendThinking(text=''){ - // Guard: ignore if session was switched during an async SSE stream. - // The old stream's reasoning events can still fire after switch; - // without this check they would pollute the new session's DOM. + // Guard: ignore if no active session (e.g. switched away before stream start). if(!S.session) return; - if(!S.activeStreamId) return; $('emptyState').style.display='none'; let turn=$('liveAssistantTurn'); if(!turn){