Conversation
## Summary This PR fixes several bugs and improves error handling across multiple files. ## Changes - **ChatMarkdown.tsx**: Add error logging for code highlighting failures - **PlanSidebar.tsx**: Fix timeout cleanup bug that could cause memory leaks - **session-logic.ts**: Fix localeCompare fallthrough bug (|| to ??) - **wsTransport.ts**: Add logging for WebSocket errors ## Bug Fixes - PlanSidebar: The copy timeout was not being cleared when the component unmounted or when the copy button was clicked multiple times, potentially causing memory leaks and incorrect UI state. - session-logic.ts: localeCompare returns 0, -1, or 1, not a boolean. Using || would fall through to the id comparison even when dates were different. Changed to ?? for correct short-circuit behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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.
🔴 Critical
Issue on line in apps/web/src/session-logic.ts:367:
The sort comparator uses ?? to fall back to id comparison, but localeCompare returns 0 when strings are equal — not null or undefined. The expression 0 ?? left.id.localeCompare(right.id) evaluates to 0 instead of the ID comparison, breaking the tie-breaker and producing non-deterministic ordering when multiple plans share the same updatedAt. Consider restoring || so 0 triggers the secondary sort key.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file apps/web/src/session-logic.ts around line 367:
The sort comparator uses `??` to fall back to `id` comparison, but `localeCompare` returns `0` when strings are equal — not `null` or `undefined`. The expression `0 ?? left.id.localeCompare(right.id)` evaluates to `0` instead of the ID comparison, breaking the tie-breaker and producing non-deterministic ordering when multiple plans share the same `updatedAt`. Consider restoring `||` so `0` triggers the secondary sort key.
Evidence trail:
apps/web/src/session-logic.ts lines 376-377 and 392-393 at REVIEWED_COMMIT show the sort comparator: `left.updatedAt.localeCompare(right.updatedAt) ?? left.id.localeCompare(right.id)`. JavaScript `localeCompare` returns `0` for equal strings (MDN documentation). The `??` operator only checks for `null`/`undefined`, not `0` (ECMAScript specification for nullish coalescing).
Summary
This PR fixes several bugs and improves error handling across multiple files.
Changes
Bug Fixes
unmounted or when the copy button was clicked multiple times, potentially
causing memory leaks and incorrect UI state.
Using || would fall through to the id comparison even when dates were
different. Changed to ?? for correct short-circuit behavior.
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com
Note
Fix bugs and improve error handling across WebSocket, plan sorting, and copy state
errorhandler inwsTransport.tsand the Shiki code block catch path inChatMarkdown.tsx, replacing silent failures.PlanSidebar.tsxby storing the 'copied' reset timeout in a ref, clearing any previous timeout before starting a new one, and cancelling on unmount.findLatestProposedPlaninsession-logic.tsnow uses??instead of||in the sort comparator, soidis no longer used as a tiebreaker whenupdatedAtvalues are equal (aslocaleComparereturns0, not a falsy value).📊 Macroscope summarized 6651757. 4 files reviewed, 2 issues evaluated, 0 issues filtered, 1 comment posted
🗂️ Filtered Issues