diff --git a/src/components/chat/hooks/useChatRealtimeHandlers.ts b/src/components/chat/hooks/useChatRealtimeHandlers.ts index 6d7347300..d59e0131f 100644 --- a/src/components/chat/hooks/useChatRealtimeHandlers.ts +++ b/src/components/chat/hooks/useChatRealtimeHandlers.ts @@ -273,7 +273,9 @@ export function useChatRealtimeHandlers({ // Clear pending session const pendingSessionId = sessionStorage.getItem('pendingSessionId'); - if (pendingSessionId && !currentSessionId && msg.exitCode === 0) { + const completedSuccessfully = typeof msg.exitCode !== 'number' || msg.exitCode === 0; + + if (pendingSessionId && !currentSessionId && completedSuccessfully) { const actualId = msg.actualSessionId || pendingSessionId; setCurrentSessionId(actualId); if (msg.actualSessionId) {