Skip to content

Reduce SSH password prompt rerenders#2731

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

Reduce SSH password prompt rerenders#2731
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/react-component-health-9dbc

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 16, 2026

What Changed

  • Refactored SshPasswordPromptDialog so the outer component only owns the external SSH prompt queue.
  • Moved prompt-specific password/response state into a keyed request dialog so state resets happen through remounting instead of state-setting effects.
  • Derived the expired prompt message during render and moved necessary browser/bridge synchronization into named hooks.
  • Added React Scan recordings:
    • Before: docs/performance/react-scan/ssh-password-prompt-before.webm
    • After: docs/performance/react-scan/ssh-password-prompt-after.webm

Why

react-doctor flagged this component for multiple state updates in an effect and effect-as-event style logic. The previous prompt change path caused an extra post-render state synchronization pass for values that can be owned by the prompt instance or derived during render. Keying the prompt request dialog keeps prompt state local to the active request and removes the cascading reset/expired-message effects.

UI Changes

No intended visual behavior change. The before/after React Scan recordings above capture the same mocked SSH password prompt flow with React Scan enabled.

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:

  • npx -y react-doctor@latest . --verbose --offline --json (baseline scan)
  • npx -y react-doctor@latest . --diff main --verbose --offline --json (fixed state/effect warnings; remaining warnings are unrelated form progressive-enhancement/button-label diagnostics)
  • React Scan before/after recordings committed under docs/performance/react-scan/
  • bun fmt
  • bun lint
  • bun typecheck
Open in Web View Automation 

Note

Reduce rerenders in SshPasswordPromptDialog by splitting into focused subcomponents

  • Extracts queue management, focus/selection, and timer logic into dedicated hooks (useSshPasswordPromptQueue, useSshPasswordPromptFocus, useSshPasswordPromptNow) to isolate state updates.
  • Splits the monolithic component into SshPasswordPromptDialog (queue orchestration) and SshPasswordPromptRequestDialog (single prompt lifecycle), keyed by requestId so React remounts cleanly per request.
  • Replaces a useEffect that set responseError on expiry with a derived displayedError value, removing one source of unnecessary rerenders.
  • SshPasswordPromptDialog now returns null when there is no pending prompt instead of rendering an empty dialog tree.

Macroscope summarized d3fa2a2.

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

Labels

size:L 100-499 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