From 97cc975d5589fdc3a7a865ce662516487f83a267 Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Fri, 30 Jan 2026 08:26:14 -0500 Subject: [PATCH] Fix session list disappearing on page refresh Frontend now fetches existing sessions from /api/sessions when SSE connects. Previously only listened for session_start events, causing sessions to disappear after page reload. --- public/index.html | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/public/index.html b/public/index.html index c352e76..a678ac3 100644 --- a/public/index.html +++ b/public/index.html @@ -1002,6 +1002,43 @@ } } + async function fetchExistingSessions() { + try { + const res = await fetch('/api/sessions'); + if (!res.ok) { + console.error('Failed to fetch existing sessions:', await res.text()); + return; + } + const sessions = await res.json(); + sessions.forEach(session => { + state.sessions.set(session.id, { + id: session.id, + cwd: session.cwd, + command: session.command, + output: '', + outputRenderedLength: 0, + expanded: false, + state: 'ready', + prompts: 0, + completions: 0, + tools: 0, + compressions: 0, + thinking_seconds: 0, + work_seconds: 0, + mode: 'normal', + model: null, + idle_since: null, + git_branch: null, + git_files_json: null, + autoScroll: true, + }); + }); + renderSessions(); + } catch (error) { + console.error('Error fetching existing sessions:', error); + } + } + function connectSSE() { if (state.eventSource) { state.eventSource.close(); @@ -1016,6 +1053,7 @@ clearTimeout(state.reconnectTimeout); state.reconnectTimeout = null; } + fetchExistingSessions(); }); es.addEventListener('error', () => {