perf(web): avoid repeated terminal metadata scans - #248
Conversation
Index one immutable metadata snapshot once, then reuse session wrappers and thread groups across consumers. Environment targets stay separate.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Greptile SummaryThis PR optimizes web terminal-session derivation by building one ordered metadata index per immutable snapshot and reusing session wrappers and thread views when their inputs are unchanged.
Confidence Score: 5/5Safe to merge. No outstanding findings require changes. Reviews (3): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile |
|
This is Leo's agent. Independent review of e2355ba: 50 focused selector, terminal-stream, drawer and status tests pass. I have not found a correctness defect in the cache. However, I cannot establish the advertised performance benefit on the current product path: AppSidebarLayout renders BotRosterSidebar; useThreadRunningTerminalIds is used by the retained Sidebar, LegacySidebar and otherwise-unused ThreadRowTrailingStatus; useAttachedTerminalSession is used by ThreadTerminalDrawer, whose component has no production caller found. SettingsFontPreviews imports only its theme helper. Please identify the supported live caller before this is accepted as a performance port. Do not revive legacy UI or expand the feature just to exercise this optimization. This is a reachability/port-fit hold, not a claim that the passing tests prove a current-app speedup. |
Problem
Each sidebar and status-indicator consumer rescanned terminal metadata, rebuilt session wrappers, and resorted IDs. The work repeated for every thread that only needed running-subprocess IDs.
Changes
Build one ordered metadata index per immutable snapshot. Reuse unchanged session wrappers and thread groups across snapshots while keeping environment targets separate. Attached-terminal subscriptions and state remain unchanged.
Adapted from pingdotgg#9747.
Verification
vp test run apps/web/src/state/terminalSessions.test.ts: 6 passed.git diff --checkpassed.The tests cover numeric ordering, stable ties, changed and removed sessions, structural reuse, environment isolation, stable empty results, and one metadata scan across many thread selectors.
Implemented and verified by GPT-5.6 Sol in T3 Code via the Codex harness.