Skip to content

Fix bugs and improve error handling#890

Open
hobostay wants to merge 1 commit intopingdotgg:mainfrom
hobostay:fix/bug-fixes-and-improvements
Open

Fix bugs and improve error handling#890
hobostay wants to merge 1 commit intopingdotgg:mainfrom
hobostay:fix/bug-fixes-and-improvements

Conversation

@hobostay
Copy link

@hobostay hobostay commented Mar 11, 2026

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

Note

Fix bugs and improve error handling across WebSocket, plan sorting, and copy state

  • Adds console warnings to the WebSocket error handler in wsTransport.ts and the Shiki code block catch path in ChatMarkdown.tsx, replacing silent failures.
  • Fixes a timeout leak in PlanSidebar.tsx by storing the 'copied' reset timeout in a ref, clearing any previous timeout before starting a new one, and cancelling on unmount.
  • Behavioral Change: findLatestProposedPlan in session-logic.ts now uses ?? instead of || in the sort comparator, so id is no longer used as a tiebreaker when updatedAt values are equal (as localeCompare returns 0, not a falsy value).
📊 Macroscope summarized 6651757. 4 files reviewed, 2 issues evaluated, 0 issues filtered, 1 comment posted

🗂️ Filtered Issues

## 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>
@coderabbitai
Copy link

coderabbitai bot commented Mar 11, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8417c35e-2c09-450f-8d1e-0754c88fd6fa

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Mar 11, 2026
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant