Avoid rerendering suggested SSH host rows#3556
Draft
cursor[bot] wants to merge 2 commits into
Draft
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
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
onConnectwrapper for discovered SSH hosts with the stable connect handler.memocomparator forDesktopSshHostRowso unchanged discovered host rows are compared by displayed target fields and connection state instead of relying only on object identity.Why
React Doctor flagged
DesktopSshHostRowas a memoized component receiving an inline function prop, which forced every suggested SSH host row to redraw on unrelated parent updates. React Scan confirmed the static suggested host rows rerendered on every Host/Alias keystroke in the Add Environment SSH dialog. Passing a stable handler and comparing row props by value lets these rows skip unrelated parent renders.UI Changes
React Scan recordings captured during local validation:
connections_ssh_rows_react_scan_before.mp4shows devbox/staging/builder rows flashing on each Host/Alias keystroke.connections_ssh_rows_react_scan_after.mp4shows only parent/dialog containers flashing; individual suggested host rows no longer flash.Checklist
Validation:
react-doctor --project @t3tools/web --category performance --verbose --jsonrerun: web performance diagnostics dropped from 134 to 133; warnings dropped from 61 to 60. Remaining failures are pre-existing unrelated diagnostics.vp checkpassed with existing warnings.vp run typecheckpassed.Note
Avoid rerendering
DesktopSshHostRowwhen props are unchangedWraps
DesktopSshHostRowinReact.memowith a custom comparator (areDesktopSshHostRowPropsEqual) that skips re-renders unlessconnectingHostAlias,onConnect, or any oftarget.alias/hostname/username/port/sourcechange. Also replaces the inline arrow function passed asonConnectwith a stablehandleConnectSshHostreference so the comparator can short-circuit on reference equality.Macroscope summarized 0bab680.