perf(web): cache thread plan catalog lookups#2
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@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.
Summary
ChatView.logic.ts.Performance audit: 10 candidate improvements
apps/web/src/components/ChatView.tsx- cache thread plan catalog environment lookups instead of scanning every environment per requested thread on render. High impact, low effort. Implemented here.apps/web/src/components/Sidebar.tsx- consolidate per-row git status/project subscriptions to reduce visible-row subscription churn. High impact, medium effort.apps/web/src/components/CommandPalette.tsx- keep a stable global keydown listener via refs/effect-event to avoid rebinding on state changes. Medium impact, low effort.apps/web/src/components/DiffPanel.tsx- memoize parsed patch files by patch/scope so large diffs are not reparsed repeatedly. High impact, low effort.apps/web/src/components/chat/MessagesTimeline.logic.ts- collapse repeated timeline derivation passes into one pass and reuse indexes/sets. High impact, medium effort.apps/web/src/components/chat/chatFind.ts- precompute/cache lowercased searchable row text for find-in-chat. Medium impact, low effort.apps/web/src/components/chat/ModelPickerContent.tsx- preindex favorite/model metadata to reduce repeated filtering and tie-break work. Medium impact, low effort.apps/web/src/components/chat/ChangedFilesTree.tsx- avoid traversing the full directory tree to build the expansion reset key on each files update. Medium impact, low effort.apps/web/src/lib/gitStatusState.ts- centralize git status watch fanout so many consumers do not multiply registry/environment subscriptions. High impact, medium effort.apps/web/src/components/WebSocketConnectionSurface.tsx- replace per-second disconnect countdown render loop with a shared/visible-only scheduler. Low impact, low effort.Validation
cd apps/web && bun run test src/components/ChatView.logic.test.tsbun fmt apps/web/src/components/ChatView.tsx apps/web/src/components/ChatView.logic.ts apps/web/src/components/ChatView.logic.test.tsbun lintbun typecheck