diff --git a/static/ui.js b/static/ui.js index 823a1c31..1ca1d995 100644 --- a/static/ui.js +++ b/static/ui.js @@ -4275,6 +4275,12 @@ function _thinkingMarkup(text=''){ : `
`; } function finalizeThinkingCard(){ + // Guard: only finalize thinking card if we're looking at the session that started it. + // Without this check, switching tabs while a stream is running causes finalizeThinkingCard + // to remove/modify the thinking card DOM of the wrong session — the card belongs to the + // stream that started it, not the session currently displayed. + const _guardTurn = $('liveAssistantTurn'); + if(_guardTurn && S.session && _guardTurn.dataset.sessionId !== S.session.session_id) return; if(!isSimplifiedToolCalling()){ const row=$('thinkingRow'); if(!row) return;