Skip to content

Avoid discovered SSH row rerenders#3858

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/component-performance-optimization-d7c2
Draft

Avoid discovered SSH row rerenders#3858
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/component-performance-optimization-d7c2

Conversation

@cursor

@cursor cursor Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • Added a stable handleConnectDiscoveredSshHost callback in ConnectionsSettings.
  • Passed that stable callback to memoized DesktopSshHostRow items instead of allocating a new inline function for every discovered SSH host on each parent render.

Why

react-doctor flagged apps/web/src/components/settings/ConnectionsSettings.tsx for Inline prop defeats memo(): the discovered SSH host rows were memoized, but unrelated parent state updates (for example typing in the manual SSH host input) still invalidated every row because onConnect was recreated inline. The stable wrapper keeps row props unchanged unless the underlying connect handler changes.

React Scan evidence from the attached Cursor run artifacts:

  • Before (react_scan_connections_ssh_before_row_renders.mp4): typing abcdef into an unrelated input took the DesktopSshHostRow render counter from 3 to 21 (18 extra row renders), with row highlights on each keystroke.
  • After (react_scan_connections_ssh_after_row_renders.mp4): the same interaction kept the DesktopSshHostRow render counter at 0, and only the input highlighted.

UI Changes

No intentional visual UI changes. Before/after React Scan screen recordings are included as run artifacts:

  • react_scan_connections_ssh_before_row_renders.mp4
  • react_scan_connections_ssh_after_row_renders.mp4

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:

  • vp check passed (pre-existing mobile lint warnings were reported, command exited 0)
  • vp run typecheck passed
  • react-doctor --category performance rerun: the selected ConnectionsSettings.tsx:2498 inline-prop warning is gone; other pre-existing performance findings remain
Open in Web View Automation 

Note

Memoize onConnect callback in ConnectionsSettings to avoid SSH row rerenders

Wraps the inline onConnect handler passed to DesktopSshHostRow in a useCallback, preventing unnecessary rerenders of discovered SSH host rows when the parent component re-renders.

Macroscope summarized 65e5983.

Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
@github-actions github-actions Bot added size:XS 0-9 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 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