Skip to content

Avoid reconnect countdown rerenders#2763

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/react-component-health-dd5b
Draft

Avoid reconnect countdown rerenders#2763
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/react-component-health-dd5b

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 19, 2026

What Changed

  • Replaced the WebSocket reconnect countdown's ticking React state with a ref-backed named hook that refreshes the existing toast directly.
  • Added React Scan before/after recordings for the reconnect countdown scenario:

Why

react-doctor flagged WebSocketConnectionSurface.tsx because nowMs was updated every second but the coordinator renders null. That caused unnecessary React rerenders solely to update toast text. The new hook keeps the countdown timer outside React render state while preserving the visible reconnect toast countdown.

React Doctor verification:

  • Before: WebSocketConnectionSurface.tsx had 1 rerender-state-only-in-handlers warning for nowMs.
  • After: 0 matching warnings.

UI Changes

No intentional UI behavior changes. The reconnect toast still updates its countdown; React Scan recordings above show the before/after run with React Scan enabled.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Validation:

  • bun fmt
  • bun lint
  • bun typecheck
Open in Web View Automation 

Note

Avoid re-renders during WebSocket reconnect countdown by updating toast directly

  • Extracts a buildReconnectToast helper in WebSocketConnectionSurface.tsx to construct the reconnect toast payload.
  • Adds a useReconnectToastCountdown hook that runs a 1s interval to call toastManager.update directly, keeping the countdown display current without triggering component re-renders.
  • Removes the nowMs state and its associated effect from WebSocketConnectionCoordinator, eliminating per-second re-renders during reconnect waits.

Macroscope summarized 71777a1.

cursoragent and others added 2 commits May 19, 2026 16:14
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant