Optimize chat plan catalog selector#3007
Draft
cursor[bot] wants to merge 3 commits into
Draft
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Contributor
|
🚀 Expo continuous deployment is ready!
|
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 reported that
ChatViewcould not be optimized by React Compiler because the plan-catalog selector mutated cache values inside a hook-created memo closure. Keeping the mutable cache inside the Zustand selector factory avoids the component/hook body pattern and reduces excessive render highlighting observed in the chat composer path.UI Changes
No intentional UI changes.
React Scan before/after recordings captured with a hosted-static draft chat/composer route:
/opt/cursor/artifacts/before_react_scan_chat_composer_renders.mp4/opt/cursor/artifacts/after_react_scan_chat_composer_renders.mp4Checklist
Validation:
bunx react-doctor@latest . --verbose --diff false --offline --blocking none --project @t3tools/web --category performanceno longer lists the plan-catalog selector/call-site diagnostics.vp checkpassed.vp run typecheckpassed.Note
Optimize chat plan catalog selector in
ChatViewby extracting a memoized selector factoryuseThreadPlanCataloginto acreateThreadPlanCatalogSelectorfactory in ChatView.tsx, memoizing previous thread IDs, entries, and results across renders.deriveThreadPlanCatalogThreadIdsto assemble the catalog thread ID list fromactiveThreadIdandsourceProposedPlanThreadId, deduplicating when they are equal.useStore, avoiding unnecessary re-renders from inline selector construction.Macroscope summarized 3b2742e.