Skip to content

Commit 59e55a5

Browse files
committed
Fix Matrix session SSE stream error
- Skip session fetching in SSE 'Finish' event for Matrix sessions - Add error handling for session data fetching to prevent crashes - Matrix room IDs (starting with '!') don't have backend Goose session data - Resolves 'Error parsing SSE event: Failed to read session: Session not found' Matrix chat continues to work without SSE stream errors when reloading sessions.
1 parent f417d57 commit 59e55a5

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

ui/desktop/src/hooks/useMessageStream.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,24 @@ export function useMessageStream({
340340

341341
const sessionId = (extraMetadataRef.current.body as Record<string, unknown>)
342342
?.session_id as string;
343-
if (sessionId) {
344-
const sessionResponse = await getSession({
345-
path: { session_id: sessionId },
346-
throwOnError: true,
347-
});
348-
349-
if (sessionResponse.data) {
350-
setSession(sessionResponse.data);
343+
344+
// Skip session fetching for Matrix sessions (room IDs start with '!')
345+
// Matrix sessions don't have traditional Goose session data on the backend
346+
const isMatrixSession = sessionId && sessionId.startsWith('!');
347+
348+
if (sessionId && !isMatrixSession) {
349+
try {
350+
const sessionResponse = await getSession({
351+
path: { session_id: sessionId },
352+
throwOnError: true,
353+
});
354+
355+
if (sessionResponse.data) {
356+
setSession(sessionResponse.data);
357+
}
358+
} catch (err) {
359+
console.error('Error fetching session data:', err);
360+
// Don't throw here, just log the error for Matrix sessions
351361
}
352362
}
353363
break;

0 commit comments

Comments
 (0)