Optimize add provider dialog render flow#3031
Open
cursor[bot] wants to merge 2 commits into
Open
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Contributor
|
🚀 Expo continuous deployment is ready!
|
Contributor
ApprovabilityVerdict: Approved Pure React refactor that consolidates useState hooks into useReducer, extracts sub-components, and optimizes render flow. No behavioral changes - same UI and functionality, just reorganized code structure. You can customize Macroscope's approvability policy. Learn more. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
useEffectchain inAddProviderInstanceDialogthat reset dialog state on open and copied the derived instance ID into state after label/driver changes.Why
react-doctorflagged the old derived-state effect chain as a render-cost issue. Typing in the label field previously caused React to render with the stale instance ID and then render again after the effect copied the derived ID into state. Deriving the ID from current draft state removes that cascading update while preserving the same visible behavior.UI Changes
Before/after React Scan recordings captured for the Add provider instance dialog Identity step:
react_scan_add_provider_before_slow.mp4react_scan_add_provider_after_slow.mp4Caveat: the React Scan counter text is difficult to read in the recordings, but React Scan highlights are visible during the typed interaction and the Instance ID updates to
codex_workbenchin both recordings.react-doctor --diff mainno longer reportsAddProviderInstanceDialog.tsx; remaining diff findings are pre-existing elsewhere on the branch.Checklist
Validation:
corepack pnpm dlx react-doctor@latest . --verbose --project @t3tools/web --diff main --no-telemetry(non-zero due to unrelated existing branch findings; no AddProviderInstanceDialog findings remain)corepack pnpm exec vp checkcorepack pnpm exec vp run typecheckNote
Refactor add provider instance dialog to use reducer-driven state and split into sub-components
useStatehooks inAddProviderInstanceDialogwith a singleuseReducerusing a newaddProviderInstanceDraftReducerandcreateInitialAddProviderInstanceDraftStatefactory.AddProviderInstanceDialogContentcomponent that only mounts when the dialog is open, avoiding unnecessary renders.AddProviderInstanceDialogHeader,AddProviderInstanceDialogPanel,AddProviderInstanceDialogFooter, and step components for driver, identity, and config.WIZARD_STEPSconstant (["Driver", "Identity", "Config"]) and associated TypeScript types to formalize the wizard flow.Macroscope summarized e07e155.
Note
Low Risk
Settings UI refactor only; same validation and
updateSettingssave path, with low regression risk if derived instance ID behavior matches prior effects.Overview
Refactors Add provider instance to cut extra renders when typing on the Identity step (e.g. label → instance ID).
State & lifecycle: Replaces many
useStatehooks anduseEffectchains (open reset + syncing derived instance ID into state) with a singleuseReducerdraft model. Instance ID is derived during render from driver/label until the user edits it (manualInstanceId+instanceIdDirty). Form content mounts only while the dialog is open ({open ? <AddProviderInstanceDialogContent /> : null}), so each open starts fresh without a reset effect.Structure: Splits the monolithic dialog into header, panel, footer, and per-step components (Driver, Identity, Config). Adds
WIZARD_STEPSand explicithtmlFor/ inputids on Identity fields.Behavior and save path are unchanged; the goal is fewer cascading updates and clearer component boundaries.
Reviewed by Cursor Bugbot for commit e07e155. Bugbot is set up for automated code reviews on this repo. Configure here.