From a72ccf6484a078aea5f6565a1b67e6beab9aad8c Mon Sep 17 00:00:00 2001 From: Wes Huber Date: Tue, 2 Jun 2026 21:37:29 -0700 Subject: [PATCH] fix(sessions): await DELETE before reloading sidebar session list (#1699) The sidebar delete handler fired the DELETE API call without awaiting it, then called loadSessions() which re-fetches the session list from the server. If the server hadn't processed the deletion yet, the session reappeared in the sidebar immediately after being removed. Await the DELETE response before reloading so the server-side deletion completes first. Fixes #1358 Co-authored-by: Claude Opus 4.6 (1M context) --- static/js/sessions.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/static/js/sessions.js b/static/js/sessions.js index c89206c..26fa46a 100644 --- a/static/js/sessions.js +++ b/static/js/sessions.js @@ -678,10 +678,11 @@ function createSessionItem(s) { } else { _forceSidebarOpen(); } - // Fire API and reload in background - fetch(`${API_BASE}/api/session/${s.id}`, { method: 'DELETE' }) - .then(() => loadSessions()) - .catch(() => loadSessions()); + // Await API deletion, then reload the authoritative list from the server + try { + await fetch(`${API_BASE}/api/session/${s.id}`, { method: 'DELETE' }); + } catch (e) { /* network error — session may still exist server-side */ } + await loadSessions(); }); archiveItem.addEventListener('click', async () => {