Skip to content

perf(web): cache thread plan catalog lookups#2

Merged
ronak-guliani merged 1 commit into
mainfrom
perf/thread-plan-catalog
May 27, 2026
Merged

perf(web): cache thread plan catalog lookups#2
ronak-guliani merged 1 commit into
mainfrom
perf/thread-plan-catalog

Conversation

@ronak-guliani

Copy link
Copy Markdown
Owner

Summary

  • Extracts ChatView thread plan catalog selection into a memoized selector in ChatView.logic.ts.
  • Reuses the previously resolved environment for stable thread IDs, avoiding repeated cross-environment scans on every ChatView store update.
  • Adds a regression test that fails if a stable lookup scans unrelated environments.

Performance audit: 10 candidate improvements

  1. 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.
  2. apps/web/src/components/Sidebar.tsx - consolidate per-row git status/project subscriptions to reduce visible-row subscription churn. High impact, medium effort.
  3. 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.
  4. apps/web/src/components/DiffPanel.tsx - memoize parsed patch files by patch/scope so large diffs are not reparsed repeatedly. High impact, low effort.
  5. apps/web/src/components/chat/MessagesTimeline.logic.ts - collapse repeated timeline derivation passes into one pass and reuse indexes/sets. High impact, medium effort.
  6. apps/web/src/components/chat/chatFind.ts - precompute/cache lowercased searchable row text for find-in-chat. Medium impact, low effort.
  7. apps/web/src/components/chat/ModelPickerContent.tsx - preindex favorite/model metadata to reduce repeated filtering and tie-break work. Medium impact, low effort.
  8. 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.
  9. apps/web/src/lib/gitStatusState.ts - centralize git status watch fanout so many consumers do not multiply registry/environment subscriptions. High impact, medium effort.
  10. 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.ts
  • bun fmt apps/web/src/components/ChatView.tsx apps/web/src/components/ChatView.logic.ts apps/web/src/components/ChatView.logic.test.ts
  • bun lint
  • bun typecheck

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels May 27, 2026
@ronak-guliani ronak-guliani merged commit e786266 into main May 27, 2026
5 of 7 checks passed
@ronak-guliani ronak-guliani deleted the perf/thread-plan-catalog branch May 27, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant