Refactor sidebar and chat boundaries to reduce rerenders#1890
Refactor sidebar and chat boundaries to reduce rerenders#1890justsomelegs wants to merge 17 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 Diff is too large for automated approval analysis. A human reviewer should evaluate this PR. 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 :) |
c7c7f99 to
6764399
Compare
# Conflicts: # apps/web/src/components/ChatView.tsx # apps/web/src/components/Sidebar.logic.ts # apps/web/src/components/Sidebar.tsx
What Changed
Refactored both the sidebar and chat surfaces to make updates more atomic, reduce broad rerender paths, and preserve behavior in the diff/timeline flows that were touched along the way.
latest.before.on.main.mp4
new.after.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.tsapps/web/src/components/chat/MessagesTimelineContainer.tsxFiles heavily updated:
apps/web/src/components/Sidebar.tsxapps/web/src/components/Sidebar.logic.tsapps/web/src/components/ChatView.tsxapps/web/src/components/chat/MessagesTimeline.tsxapps/web/src/components/DiffPanel.tsxapps/web/src/storeSelectors.tsapps/web/src/logicalProject.tsapps/web/src/lib/providerReactQuery.tsWhy
The sidebar and chat surfaces were still subscribed to state that was broader than necessary. In practice that meant:
Ctrlfor jump hints rerendered more than the affected thread metadataThis change narrows subscriptions, moves derived and volatile state closer to leaf components, and splits hot chat/timeline state from colder historical state. The result is less work during streaming, thread switching, and sidebar interaction, while keeping end-user behavior consistent.
The follow-up audit fixes are included here because they were caused by this refactor and are part of making the branch PR-ready rather than leaving known correctness regressions behind.
UI Changes
Behavior is visually mostly unchanged. The main user-facing goal is narrower update scope and smoother behavior under load, especially in:
Validation
bun fmtbun lintbun typecheckbun run test -- src/lib/providerReactQuery.test.ts src/lib/gitStatusState.test.ts src/components/chat/MessagesTimeline.test.tsx src/components/ChatView.logic.test.tsNote:
bun lintstill reports the same pre-existing warning inapps/web/src/environments/runtime/catalog.test.ts:98Checklist
Note
Reduce sidebar and chat rerenders by decomposing components and introducing targeted store selectors
MessagesTimelineinto historical and live sections, withMessagesTimelineContainerorchestrating data assembly andChatMessagesPaneencapsulating scroll/optimistic-message logic behind an imperative ref.createThreadBranchToolbarSnapshotSelectorByRef,createThreadBranchActionSnapshotSelectorByRef,createThreadStaticShellSelectorByRef) that return stable minimal objects, limiting rerenders to only the fields each component actually needs.SidebarThreadRowto be self-contained — resolving its own data, navigation, context-menu actions, rename/archive flows, and status indicators via new sidebar selectors and a newsidebarViewStore.SidebarKeyboardControllerandSidebarSelectionController; project snapshots and sorting are now built viabuildSidebarProjectSnapshotsandcreateSidebarSortedProjectKeysSelector.ChatViewtouseEffectEvent-backed functions reading latest snapshots via store getters, reducing stale-closure risk.MessagesTimelinecallers must now supply separatehistoricalTimelineEntriesandliveTimelineEntriesprops;ChatComposerconsumers must supplydraftThreadActivitiesand no longer passactiveThread.Macroscope summarized 5371a21.