From 7ba2cf23285639b90f32cca24d0f0bb9075c9497 Mon Sep 17 00:00:00 2001 From: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com> Date: Thu, 15 Jan 2026 18:29:55 -0500 Subject: [PATCH] Add session ID filter to SSE error handling --- frontend/src/hooks/useSSE.ts | 5 +++-- frontend/src/pages/SessionDetail.tsx | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/src/hooks/useSSE.ts b/frontend/src/hooks/useSSE.ts index cbfa5c1c..d8999b80 100644 --- a/frontend/src/hooks/useSSE.ts +++ b/frontend/src/hooks/useSSE.ts @@ -39,7 +39,7 @@ const handleRestartServer = async () => { } -export const useSSE = (opcodeUrl: string | null | undefined, directory?: string) => { +export const useSSE = (opcodeUrl: string | null | undefined, directory?: string, currentSessionId?: string) => { const client = useOpenCodeClient(opcodeUrl, directory) const queryClient = useQueryClient() const mountedRef = useRef(true) @@ -292,6 +292,7 @@ export const useSSE = (opcodeUrl: string | null | undefined, directory?: string) case 'session.error': { if (!('error' in event.properties)) break + if ('sessionID' in event.properties && event.properties.sessionID === currentSessionId) break const parsed = parseOpenCodeError(event.properties.error) if (parsed) { @@ -306,7 +307,7 @@ export const useSSE = (opcodeUrl: string | null | undefined, directory?: string) default: break } - }, [queryClient, opcodeUrl, directory, setSessionStatus, setSessionTodos]) + }, [queryClient, opcodeUrl, directory, setSessionStatus, setSessionTodos, currentSessionId]) const fetchInitialData = useCallback(async () => { if (!client || !mountedRef.current) return diff --git a/frontend/src/pages/SessionDetail.tsx b/frontend/src/pages/SessionDetail.tsx index 0a64d3c5..1b97741e 100644 --- a/frontend/src/pages/SessionDetail.tsx +++ b/frontend/src/pages/SessionDetail.tsx @@ -112,7 +112,7 @@ export function SessionDetail() { onScrollStateChange: setShowScrollButton }); - const { isConnected, isReconnecting } = useSSE(opcodeUrl, repoDirectory); + const { isConnected, isReconnecting } = useSSE(opcodeUrl, repoDirectory, sessionId); const abortSession = useAbortSession(opcodeUrl, repoDirectory, sessionId); const updateSession = useUpdateSession(opcodeUrl, repoDirectory); const createSession = useCreateSession(opcodeUrl, repoDirectory);