Refactor web stores into atomic slices ready to split ChatView#1708
Refactor web stores into atomic slices ready to split ChatView#1708justsomelegs wants to merge 19 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 Major refactor of web store architecture from array-based to normalized/atomic slices, restructuring core state management infrastructure across multiple files. The scope and criticality of these internal data structure changes warrant human review to ensure the migration is complete and correct. You can customize Macroscope's approvability policy. Learn more. |
|
fixed CI issues, should now pass :) |
…melegs/t3code into web/atomic-store-refactor
…melegs/t3code into web/atomic-store-refactor
…melegs/t3code into web/atomic-store-refactor
…melegs/t3code into web/atomic-store-refactor
…melegs/t3code into web/atomic-store-refactor
…melegs/t3code into web/atomic-store-refactor
juliusmarminge
left a comment
There was a problem hiding this comment.
Got #1765 stacked on top of this so will merge it as a stack when that one's ready!
What Changed
Refactored the web orchestration store from broad array-based state into a more atomic normalized shape.
Main changes:
projects[]/threads[]as the primary store shape with keyed records and id listsOld Pattern
New Pattern
Why
The old store shape forced many consumers to read broad collections and then search inside them. That made fine-grained subscriptions hard and set us up for unnecessary rerenders once we start breaking large components into smaller ones.
This change establishes the state model we actually want to build on:
Sidebar,ChatView, and other hot UI pathsKeeping this as a store-shape-first PR also keeps the follow-up performance work simpler. Future PRs can focus on splitting components and wiring each subcomponent to only the exact slice it needs.
Checklist
Note
Refactor web store state from arrays to normalized entity maps for projects and threads
projects: Project[]andthreads: Thread[]inAppStatewith normalized maps (projectById,threadShellById,threadSessionById,threadTurnStateById) and id arrays, splitting thread data into immutable shell and volatile turn state slices.selectProjects,selectThreads,createThreadSelector,createProjectSelector, andcreateSidebarThreadSummarySelectorto derive denormalized objects from the new normalized state;createThreadSelectormemoizes by reference equality to avoid unnecessary re-renders.ChatView,BranchToolbar,DiffPanel,Sidebar,GitActionsControl, etc.) and hooks to use selectors or direct map lookups instead of array scans.syncServerReadModelandapplyOrchestrationEventin store.ts to write into normalized slices via newwriteThreadState/removeThreadState/buildThreadStatehelpers.state.projects,state.threads, orstate.sidebarThreadsByIdfields will break; all in-tree callers have been migrated to selectors.Macroscope summarized 025d832.