Skip to content

Remove derived state effects from provider dialog#2698

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

Remove derived state effects from provider dialog#2698
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/react-component-health-b58d

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 14, 2026

What Changed

  • Split the add-provider dialog shell from its stateful form content.
  • Removed the direct useEffect reset path by remounting the form content when the dialog open state changes.
  • Removed the chained derived-state useEffect for instance IDs; the ID is now derived during render until the user manually edits it.
  • Added React Scan before/after recordings:
    • Before: artifacts/react-scan/add-provider-dialog-before.webm
    • After: artifacts/react-scan/add-provider-dialog-after.webm

Why

React Doctor flagged AddProviderInstanceDialog for an effect chain and cascading state updates. The previous label/driver flow rendered once for the label/driver update, then rendered again when an effect wrote the derived instance ID. Deriving the ID during render follows React guidance for avoiding unnecessary effects and removes that extra commit path.

Post-fix React Doctor no longer reports no-effect-chain, no-cascading-set-state, or rerender-state-only-in-handlers for this dialog.

UI Changes

No intentional visual changes. The included React Scan recordings show the same add-provider dialog interaction before and after the change.

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@latest apps/web --offline --verbose --json
Open in Web View Automation 

Note

Remove derived state effects from AddProviderInstanceDialog

  • Splits AddProviderInstanceDialog into a thin wrapper and a new AddProviderInstanceDialogContent component; the wrapper keys the content by the open prop to force remounts on open/close transitions, replacing useEffect-based form resets.
  • Replaces instanceId/instanceIdDirty state plus two useEffect hooks with a single derived value: customInstanceId ?? deriveInstanceId(driver, label). The user's typed value is stored as customInstanceId (null means auto-derive).
  • Behavioral Change: all form state now resets on both open and close transitions (previously only reset on open).

Macroscope summarized 785c91c.

cursoragent and others added 2 commits May 14, 2026 16:13
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 14, 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