fix: finalize Codex sessions without explicit exitCode#614
fix: finalize Codex sessions without explicit exitCode#614CoderLuii wants to merge 2 commits intositeboon:mainfrom
Conversation
📝 WalkthroughWalkthroughThe Changes
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/components/chat/hooks/useChatRealtimeHandlers.ts`:
- Around line 276-278: The current success detection treats any non-number
exitCode as success (completedSuccessfully = typeof msg.exitCode !== 'number' ||
msg.exitCode === 0), which lets malformed values like "1" or null pass; change
the logic so success is only when exitCode is explicitly absent/undefined or the
numeric value 0—e.g. compute completedSuccessfully by checking (msg.exitCode ===
undefined || (typeof msg.exitCode === 'number' && msg.exitCode === 0)) so that
strings, null, or other malformed payloads do not clear pendingSessionId when
pendingSessionId and !currentSessionId are true.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: aa1b9c80-2a0c-47ff-9123-34d7ef705c4d
📒 Files selected for processing (1)
src/components/chat/hooks/useChatRealtimeHandlers.ts
| const completedSuccessfully = typeof msg.exitCode !== 'number' || msg.exitCode === 0; | ||
|
|
||
| if (pendingSessionId && !currentSessionId && completedSuccessfully) { |
There was a problem hiding this comment.
Tighten success detection to avoid false-positive session finalization
On Line 276, typeof msg.exitCode !== 'number' marks all non-numeric values as success. That includes malformed payloads like "1" or null, which can wrongly clear pendingSessionId on Line 278.
Proposed fix
-const completedSuccessfully = typeof msg.exitCode !== 'number' || msg.exitCode === 0;
+const completedSuccessfully = msg.exitCode === undefined || msg.exitCode === 0;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const completedSuccessfully = typeof msg.exitCode !== 'number' || msg.exitCode === 0; | |
| if (pendingSessionId && !currentSessionId && completedSuccessfully) { | |
| const completedSuccessfully = msg.exitCode === undefined || msg.exitCode === 0; | |
| if (pendingSessionId && !currentSessionId && completedSuccessfully) { |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/components/chat/hooks/useChatRealtimeHandlers.ts` around lines 276 - 278,
The current success detection treats any non-number exitCode as success
(completedSuccessfully = typeof msg.exitCode !== 'number' || msg.exitCode ===
0), which lets malformed values like "1" or null pass; change the logic so
success is only when exitCode is explicitly absent/undefined or the numeric
value 0—e.g. compute completedSuccessfully by checking (msg.exitCode ===
undefined || (typeof msg.exitCode === 'number' && msg.exitCode === 0)) so that
strings, null, or other malformed payloads do not clear pendingSessionId when
pendingSessionId and !currentSessionId are true.
Summary
Testing
Summary by CodeRabbit