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) <noreply@anthropic.com>
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user