Skip to content

Optimize command palette open rerenders#3048

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

Optimize command palette open rerenders#3048
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/component-performance-optimization-3c66

Conversation

@cursor

@cursor cursor Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • Moved command-palette open-state subscriptions into small controller/dialog components so opening the palette no longer re-renders the app shell children.
  • Replaced the sidebar search CommandDialogTrigger with a stable command-palette store action, keeping the Search button behavior while removing the dialog context render event from the sidebar.
  • Moved touched useEffect usages into named hooks (useCommandPaletteKeyboardShortcut, useCloseCommandPaletteOnUnmount, usePrefetchBrowseParent).

Why

React Doctor surfaced broad React Compiler/performance backlog in the web app, and a manual React Scan pass showed command-palette opening as a repeatable hot interaction. The previous structure put the app shell inside the command dialog root and used a dialog trigger in the sidebar, causing the sidebar trigger to rerender when opening the palette. The new structure keeps dialog updates local to the palette dialog.

React Scan onRender measurement for clicking the sidebar Search button:

  • Before: 181 render events, including DialogTrigger x2 and SidebarMenuButton x2.
  • After: 176 render events, with sidebarRelated: [] for the same interaction.

UI Changes

React Scan recordings captured with the toolbar enabled:

  • Before: react_scan_before_command_palette_rerenders.mp4
  • After: react_scan_after_command_palette_rerenders.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:

  • react-doctor performance/maintainability scan run (remaining non-zero findings are existing broader backlog items in Sidebar/ChatView/MessagesTimeline/etc.)
  • vp check passed (0 errors, 11 existing warnings)
  • vp run typecheck passed
Open in Web View Automation 

Note

Optimize command palette re-renders by isolating dialog and keyboard shortcut state

  • Splits CommandPalette into focused sub-components: CommandPaletteKeyboardShortcutController (keyboard handling), CommandPaletteDialogRoot (dialog rendering), and useCommandPaletteKeyboardShortcut (stable keydown listener via useEffectEvent).
  • CommandPaletteDialogRoot only mounts dialog contents when open, reducing unnecessary renders when the palette is closed.
  • Extracts browse-parent prefetching into a usePrefetchBrowseParent hook in CommandPalette.tsx.
  • The sidebar Search button in Sidebar.tsx now opens the palette by writing directly to the store instead of using CommandDialogTrigger.
  • Behavioral Change: CommandDialog no longer wraps sidebar children; it renders independently, so any code relying on child context from CommandDialog may be affected.

Macroscope summarized af1bebb.

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 Jun 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Expo continuous deployment is ready!

  • Project → t3-code
  • Platforms → android, ios
  • Scheme → t3code-preview
  🤖 Android 🍎 iOS
Fingerprint ae17d94b35f91f9c608a63dadbc3ddd9f4ba056e 313e506a7f15a9c3f15b01d787d68a12382432bf
Build Details Build Permalink
DetailsDistribution: INTERNAL
Build profile: preview:dev
Runtime version: ae17d94b35f91f9c608a63dadbc3ddd9f4ba056e
App version: 0.1.0
Git commit: 92b344feff64b27cb08a8e565731fb79ec49ba1f
Build Permalink
DetailsDistribution: INTERNAL
Build profile: preview:dev
Runtime version: 313e506a7f15a9c3f15b01d787d68a12382432bf
App version: 0.1.0
Git commit: 92b344feff64b27cb08a8e565731fb79ec49ba1f
Update Details Update Permalink
DetailsBranch: pr-3048
Runtime version: ae17d94b35f91f9c608a63dadbc3ddd9f4ba056e
Git commit: 92b344feff64b27cb08a8e565731fb79ec49ba1f
Update Permalink
DetailsBranch: pr-3048
Runtime version: 313e506a7f15a9c3f15b01d787d68a12382432bf
Git commit: 92b344feff64b27cb08a8e565731fb79ec49ba1f
Update QR

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