diff --git a/ui/desktop/src/components/ChatSessionsContainer.tsx b/ui/desktop/src/components/ChatSessionsContainer.tsx index d7d34566..f429e2f4 100644 --- a/ui/desktop/src/components/ChatSessionsContainer.tsx +++ b/ui/desktop/src/components/ChatSessionsContainer.tsx @@ -23,17 +23,18 @@ export default function ChatSessionsContainer({ const [searchParams] = useSearchParams(); const currentSessionId = searchParams.get('resumeSessionId') ?? undefined; - if (!currentSessionId) { + // Always render active sessions to keep SSE connections alive, even when not on /pair route + if (!currentSessionId && activeSessions.length === 0) { return null; } - const isActiveSession = activeSessions.some((s) => s.sessionId === currentSessionId); - - // If the current session isn't in active sessions, we need to render it anyway - // (handles page refresh case) - const sessionsToRender = isActiveSession - ? activeSessions - : [...activeSessions, { sessionId: currentSessionId }]; + // Build the list of sessions to render + let sessionsToRender = activeSessions; + + // If we have a currentSessionId that's not in activeSessions, add it (handles page refresh) + if (currentSessionId && !activeSessions.some((s) => s.sessionId === currentSessionId)) { + sessionsToRender = [...activeSessions, { sessionId: currentSessionId }]; + } return (