Optimize command palette open rerenders#3048
Draft
cursor[bot] wants to merge 1 commit into
Draft
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Contributor
|
🚀 Expo continuous deployment is ready!
|
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
CommandDialogTriggerwith a stable command-palette store action, keeping the Search button behavior while removing the dialog context render event from the sidebar.useEffectusages 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
onRendermeasurement for clicking the sidebar Search button:DialogTriggerx2 andSidebarMenuButtonx2.sidebarRelated: []for the same interaction.UI Changes
React Scan recordings captured with the toolbar enabled:
react_scan_before_command_palette_rerenders.mp4react_scan_after_command_palette_rerenders.mp4Checklist
Validation:
react-doctorperformance/maintainability scan run (remaining non-zero findings are existing broader backlog items in Sidebar/ChatView/MessagesTimeline/etc.)vp checkpassed (0 errors, 11 existing warnings)vp run typecheckpassedNote
Optimize command palette re-renders by isolating dialog and keyboard shortcut state
CommandPaletteinto focused sub-components:CommandPaletteKeyboardShortcutController(keyboard handling),CommandPaletteDialogRoot(dialog rendering), anduseCommandPaletteKeyboardShortcut(stable keydown listener viauseEffectEvent).CommandPaletteDialogRootonly mounts dialog contents when open, reducing unnecessary renders when the palette is closed.usePrefetchBrowseParenthook in CommandPalette.tsx.CommandDialogTrigger.CommandDialogno longer wraps sidebar children; it renders independently, so any code relying on child context fromCommandDialogmay be affected.Macroscope summarized af1bebb.