Skip to content

Reduce provider instance dialog rerenders#2675

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

Reduce provider instance dialog rerenders#2675
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/react-component-health-4fc0

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 13, 2026

What Changed

  • Removed the provider instance dialog's derived-state useEffect that re-derived the instance ID after label/driver changes.
  • Derive the instance ID directly inside the label/driver handlers while the ID is still pristine, and track manual ID edits in a ref so dirty-state bookkeeping does not trigger renders.
  • Reset the dialog from close/save handlers instead of a component-body effect.
  • Added react-scan before/after recordings under perf-recordings/react-component-health/.

Why

react-doctor flagged AddProviderInstanceDialog for an effect chain and a state value that existed only to drive handlers. The previous flow rendered once for the label/driver update and then rendered again when the effect synchronized instanceId. Moving that derivation into the originating handlers keeps the update batched and removes the extra effect-driven render.

Manual react-scan/DevTools-hook measurement during label typing:

  • Before: 34 AddProviderInstanceDialog render commits.
  • After: 23 AddProviderInstanceDialog render commits.

UI Changes

No intended visual UI changes.

React-scan recordings with the overlay enabled are included in the branch:

  • perf-recordings/react-component-health/before-provider-dialog.webm
  • perf-recordings/react-component-health/after-provider-dialog.webm

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

Verification:

  • bun fmt
  • bun lint (passes with existing warnings)
  • bun typecheck
  • bunx react-doctor apps/web --json --full --offline --fail-on none
  • react-scan@0.5.6 injected into Vite via Playwright recordings
Open in Web View Automation 

Note

Reduce rerenders in AddProviderInstanceDialog by replacing state with a ref

  • Replaces the instanceIdDirty boolean state with a useRef so toggling it no longer triggers a re-render.
  • Removes the useEffect that auto-derived instanceId on driver/label changes; explicit handlers (updateDriver, updateLabel, updateInstanceId) now handle derivation inline.
  • Extracts resetForm and closeDialog helpers to centralize form cleanup; the dialog resets on close rather than on open.
  • Adds handleDialogOpenChange so form state is cleared only when the dialog is closing, not on every open/close toggle.

Macroscope summarized 95a569a.

cursoragent and others added 2 commits May 13, 2026 16:07
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 size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 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