Browse Source

fix: SSE auto-reconnect and persistent polling fallback

- SSE: retry connection after 3s when it drops (was one-shot before)
- Polling: keep polling while SSE is disconnected, regardless of mode
  (was stopping at terminal modes, causing stuck 'Agent Thinking')
bobbyunknown 1 month ago
parent
commit
6b77f52059
1 changed files with 3 additions and 7 deletions
  1. 3 7
      src/interview/ui.ts

+ 3 - 7
src/interview/ui.ts

@@ -1982,8 +1982,9 @@ export function renderInterviewPage(
         es.onerror = () => {
           sseConnected = false;
           es.close();
-          // Fallback to polling if SSE drops
+          // Retry SSE after 3s, fall back to polling in the meantime
           if (!pollFallbackTimer) schedulePoll();
+          setTimeout(() => connectSse(), 3000);
         };
       }
 
@@ -1992,14 +1993,9 @@ export function renderInterviewPage(
         if (sseConnected) return;
         pollFallbackTimer = setTimeout(async () => {
           try { await refresh(); } catch (_) {}
-          // Keep polling until SSE reconnects or indefinitely for terminal modes
           pollFallbackTimer = null;
           if (!sseConnected) {
-            const terminalModes = ['abandoned', 'completed', 'session-disconnected'];
-            // For terminal modes, do a few more polls to catch final state, then stop
-            if (!terminalModes.includes(state.data?.mode)) {
-              schedulePoll();
-            }
+            schedulePoll();
           }
         }, 2500);
       }