Reduce sidebar selection rerenders#2560
Merged
juliusmarminge merged 1 commit intomainfrom May 8, 2026
Merged
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Contributor
ApprovabilityVerdict: Approved This is a mechanical performance optimization that replaces reactive Zustand store subscriptions with imperative You can customize Macroscope's approvability policy. Learn more. |
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
Why
React Doctor and a manual pass pointed to
Sidebar.tsxas a hot component, and React Scan confirmed sidebar selection updates were fanning out through mounted thread rows. Reading selection presence at interaction time keeps behavior the same while avoiding parent/row rerenders driven only by aggregate selection-size changes.React Scan recording for two selection updates on five mounted rows:
sidebarThreadRowDuration: 9.4mssidebarThreadRowDuration: 2.8msUI Changes
No visual UI changes.
Checklist
Validation:
bun fmtbun lintbun typecheckbun x react-doctor@latest . --json --fail-on none --offlinereact-scan/liteharnessNote
Reduce rerenders in sidebar components by reading selection state on demand
Replaces reactive subscriptions to
selectedThreadKeys.sizeandselectedThreadCountinSidebarThreadRow,SidebarProjectItem, and the rootSidebarcomponent with on-demand reads viauseThreadSelectionStore.getState().hasSelection(). This means these components no longer re-render when the selection size changes; instead, they query the current state at the moment of user interaction (right-click, project click, or mousedown).Macroscope summarized 8681a6d.
Note
Low Risk
Low risk performance refactor limited to the sidebar: it changes how selection presence is read (on-demand via
getState()), with minimal chance of behavioral regressions in context-menu/clear-selection interactions.Overview
Reduces sidebar re-renders caused by multi-selection updates by removing subscriptions to aggregate selection size/count in
Sidebar.tsx.Interaction handlers (thread row context menu, project click, and global mousedown clear-selection) now query
useThreadSelectionStore.getState().hasSelection()at event time, keeping behavior while avoiding selection-driven re-render fan-out across mounted rows.Reviewed by Cursor Bugbot for commit 8681a6d. Bugbot is set up for automated code reviews on this repo. Configure here.