From d0257e8bcfe99c8f54126bf53ab445a0e4ac6422 Mon Sep 17 00:00:00 2001 From: Josh Date: Thu, 30 Apr 2026 22:25:25 +0000 Subject: [PATCH] fix: guard finalizeThinkingCard with session ID check (#1366) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this check, switching browser tabs while a stream is running causes finalizeThinkingCard() to operate on the wrong session's thinking card DOM — the card belongs to the stream that started it, not the session currently displayed in the tab. The guard ensures finalize only runs when the live assistant turn's session matches the current session. Co-authored-by: Josh --- static/ui.js | 6 ++++++ 1 file changed, 6 insertions(+) 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;