Refactor sidebar rerender boundaries anad reduce the re-renders#1890
Refactor sidebar rerender boundaries anad reduce the re-renders#1890justsomelegs wants to merge 10 commits intopingdotgg:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review This is a major architectural refactor of the sidebar component that introduces new state management (Zustand store), new selector patterns with complex memoization, and restructures component boundaries. While the intent is performance optimization, the scope significantly changes shared infrastructure and warrants human review to validate the new patterns work correctly across all sidebar interactions. You can customize Macroscope's approvability policy. Learn more. |
|
is the |
|
yeah it was from the latest version of main, the chat composer was fixed but the sidebar would re-render on every update just cause it was not using the new atomic stores in the best way. |
|
correction it was 3 commits behind but it still does now after pulling those down unless, i could be wrong though let me know :) |
What Changed
Refactored the sidebar to make updates much more atomic and remove broad rerender paths.
before.sidebar.improvements.mp4
after.sidebar.improvements.mp4
Main changes:
Files added/extracted:
apps/web/src/components/sidebar/sidebarConstants.tsapps/web/src/components/sidebar/sidebarControllers.tsxapps/web/src/components/sidebar/sidebarProjectSnapshots.tsapps/web/src/components/sidebar/sidebarSelectors.tsapps/web/src/components/sidebar/sidebarViewStore.tsFiles heavily updated:
apps/web/src/components/Sidebar.tsxapps/web/src/components/Sidebar.logic.tsapps/web/src/logicalProject.tsWhy
The sidebar was still subscribed to broad Zustand state even after the move toward atomic stores. In practice that meant:
Ctrlfor jump hints rerendered more than the affected thread metadataThis change narrows subscriptions and moves derived/volatile state closer to the leaf components that actually need it. The result is a sidebar that is more predictable under load, rerenders less broadly, and is better aligned with the atomic-store direction of the app.
This approach was chosen because it improves performance without introducing new product behavior, and it keeps the refactor focused on existing sidebar ownership/render boundaries rather than expanding scope into chat/composer work.
UI Changes
Sidebar behavior is visually mostly unchanged, but render/update behavior is much narrower.
Checklist
Note
Refactor sidebar to reduce re-renders via selector-driven state and dedicated controllers
Sidebar.tsxwith a new Zustand view store (sidebarViewStore.ts) and a suite of memoized selectors (sidebarSelectors.ts) so each component subscribes only to the data it needs.SidebarKeyboardControllerandSidebarSelectionControllercomponents (sidebarControllers.tsx), removing them from the rootSidebarcomponent.SidebarThreadRowandSidebarProjectIteminto smaller focused components (SidebarThreadMetaCluster,SidebarThreadStatusIndicator,SidebarProjectHeader,SidebarProjectThreadSection) that each derive their own data from selectors.buildSidebarProjectSnapshots(sidebarProjectSnapshots.ts) to compute stable logical-project groupings with cache reuse, replacing ad-hoc inline grouping logic in the root component.resetSidebarViewState) on unmount instead of removing a mousedown listener; thread jump hint delay drops from 100ms to 75ms.Macroscope summarized 6f1805a.