Stabilize project grouping settings selector#2629
Draft
cursor[bot] wants to merge 2 commits intomainfrom
Draft
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
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
selectProjectGroupingSettingsselector inlogicalProject.ts.artifacts/react-performance/:before-react-scan-project-grouping.webmafter-react-scan-project-grouping.webmWhy
Inline object selectors were creating a new selector function on every render. When large parents like Sidebar or ChatView re-rendered for unrelated state,
useSettingsrecomputed a fresh project grouping object, invalidating downstream memoized project grouping/environment derivations and increasing rerender work. A module-level selector keeps the selector identity stable and lets unrelated parent renders reuse the same selected grouping object.React Doctor was run for a full scan and a diff scan. The remaining diff findings are pre-existing large-component/effect/loop diagnostics in Sidebar/ChatView; the new helper and new-thread call site have no React Doctor diagnostics.
UI Changes
No intentional UI behavior change. React Scan recordings with the same authenticated navigation flow are committed in
artifacts/react-performance/:artifacts/react-performance/before-react-scan-project-grouping.webmartifacts/react-performance/after-react-scan-project-grouping.webmChecklist
Validation:
bun fmtbun lint(passes with existing warnings)bun typechecknpx -y react-doctor@latest . --json --offline --fail-on nonenpx -y react-doctor@latest . --diff main --json --offline --fail-on noneNote
Stabilize project grouping settings selector to prevent unnecessary re-renders
Extracts a shared
selectProjectGroupingSettingsselector function in logicalProject.ts and replaces inline object selectors inChatView,Sidebar,useHandleNewThread, andEventRouter. Inline selectors construct a new object on every render, causing unnecessary re-renders in components that useuseSettings; a stable shared selector avoids this.Macroscope summarized bfc6cd8.