From e522d33a53866ab62327bb70002930e9509182a2 Mon Sep 17 00:00:00 2001 From: Nige Date: Thu, 12 Mar 2026 22:04:25 +0000 Subject: [PATCH] fix(web): make approval requests appear without page reload (#996) (#1073) * fix(web): show approval requests in realtime without reload * Update src/channels/web/static/app.js Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- src/channels/web/static/app.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/channels/web/static/app.js b/src/channels/web/static/app.js index 6128f05f..5a55051d 100644 --- a/src/channels/web/static/app.js +++ b/src/channels/web/static/app.js @@ -342,8 +342,19 @@ function connectSSE() { eventSource.addEventListener('approval_needed', (e) => { const data = JSON.parse(e.data); - if (!isCurrentThread(data.thread_id)) return; - showApproval(data); + const hasThread = !!data.thread_id; + const forCurrentThread = !hasThread || isCurrentThread(data.thread_id); + + if (forCurrentThread) { + showApproval(data); + } else { + // Keep thread list fresh when approval is requested in a background thread. + unreadThreads.set(data.thread_id, (unreadThreads.get(data.thread_id) || 0) + 1); + debouncedLoadThreads(); + } + + // Extension setup flows can surface approvals while user is on Extensions tab. + if (currentTab === 'extensions') loadExtensions(); }); eventSource.addEventListener('auth_required', (e) => { @@ -991,6 +1002,10 @@ function finalizeActivityGroup() { } function showApproval(data) { + // Avoid duplicate cards on reconnect/history refresh. + const existing = document.querySelector('.approval-card[data-request-id="' + CSS.escape(data.request_id) + '"]'); + if (existing) return; + const container = document.getElementById('chat-messages'); const card = document.createElement('div'); card.className = 'approval-card';