Skip to content

perf(web): avoid repeated terminal metadata scans - #248

Merged
leoisadev1 merged 3 commits into
mainfrom
perf/web-terminal-metadata-index
Sep 14, 2026
Merged

leoisadev1 merged 3 commits into
mainfrom
perf/web-terminal-metadata-index

Conversation

@leoisadev1

@leoisadev1 leoisadev1 commented Sep 10, 2026

Copy link
Copy Markdown
Member

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.
  • Web typecheck passed.
  • Scoped lint, formatting, and git diff --check passed.

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.

Index one immutable metadata snapshot once, then reuse session wrappers
and thread groups across consumers. Environment targets stay separate.
@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
akeru-bot-landing Skipped Skipped Sep 10, 2026 6:26pm UTC

Request Review

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L labels Sep 10, 2026
@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown

Greptile Summary

This 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.

  • Adds snapshot-, environment-, and thread-aware structural reuse.
  • Reuses the metadata index for attached-session lookup.
  • Memoizes running-subprocess ID derivation.
  • Adds coverage for ordering, changed and removed sessions, environment isolation, stable empty results, and scan count.

Confidence Score: 5/5

Safe to merge.

No outstanding findings require changes.

Reviews (3): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile

@leoisadev1

Copy link
Copy Markdown
Member Author

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.

@leoisadev1
leoisadev1 merged commit 71f58f3 into main Sep 14, 2026
11 checks passed
@leoisadev1
leoisadev1 deleted the perf/web-terminal-metadata-index branch September 14, 2026 03:13
This was referenced Sep 14, 2026
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