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 SummaryThe terminal-session derivation changes optimize metadata indexing and memoized environment/thread views while preserving terminal ordering, environment isolation, stable empty results, and structural reuse. Confidence Score: 5/5Safe to merge. There are no outstanding findings. Reviews (2): Last reviewed commit: "Merge branch 'main' into perf/web-termin..." | 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. That repeats for every thread that only needs running-subprocess IDs.
Changes
Build one ordered metadata index per immutable snapshot. Reuse unchanged session wrappers and thread groups, with separate environment targets. Attach subscriptions stay as they were.
Adapted from pingdotgg#9747.
Scope
This PR is terminal metadata indexing only.
Covered here:
Still assigned to this handoff, in later PRs:
Verification
vp test run apps/web/src/state/terminalSessions.test.ts: 6 passed.vp linton the two files: clean.Implemented and verified by Grok 4.6 High in Grok Build via Orca.