Skip to content

perf: SAM UI Performance Program — Make Everything Snappy - #1852

Merged
simple-agent-manager[bot] merged 7 commits into
mainfrom
sam/read-idea-01m09skvnjgjnjy2wgcz6d89xz-using-bmbgfz
Aug 19, 2026
Merged

perf: SAM UI Performance Program — Make Everything Snappy#1852
simple-agent-manager[bot] merged 7 commits into
mainfrom
sam/read-idea-01m09skvnjgjnjy2wgcz6d89xz-using-bmbgfz

Conversation

@simple-agent-manager

@simple-agent-manager simple-agent-manager Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

SAM UI Performance Program

Implements SAM idea 01M09SKVNJGJNJY2WGCZ6D89XZ — 12 optimization items across server and client, coordinated via 7 sub-PRs squash-merged into this integration branch.

Program Tracking

Wave WS Items PR Status Key Metric
1 A #1 auth preamble cache #1848 ✅ MERGED 42→3 D1/req (warm)
1 B #2 route code splitting #1850 ✅ MERGED entry chunk −91%
1 C #5 ensureProjectId + #6 chat state #1851 ✅ MERGED −35-42% DO roundtrips
1 D #8 poll guard + #10 memo + #11 visibility #1849 ✅ MERGED 120→6 req/hr idle
2 E #3 query persister + #7 HTTP headers #1858 ✅ MERGED IndexedDB cache + Cache-Control
2 G #9 chat bound + #12 D1 session index #1859 ✅ MERGED 16 DOM nodes for 968 msgs
3 F #4 TanStack migration #1860 ✅ MERGED 15 hooks, zero dedup
4 V consolidated staging validation task 01M0C2TF4KWTEMQBT1KB0VCFHC ✅ PASS 0 regressions

What changed

Server (apps/api)

  • Auth preamble: platform config resolved once + per-isolate TTL cache (60s default)
  • platform-config.ts split into 6 focused modules (was 800+ lines)
  • ensureProjectId: memoized per (isolate, DO-id) via ensureOncePerIsolate
  • chat-agent-state: independent DO lookups parallelized via Promise.all
  • HTTP Cache-Control headers on 6 endpoints (platform-config, model-catalog, login-providers, etc.)
  • D1 covering index for session summaries (migration 0117)

Client (apps/web)

  • React.lazy for ~90 page routes; entry chunk 3,429 kB → 271 kB (−92%)
  • TanStack Query migration of 15 high-impact data-fetching hooks
  • Shared query-options factories with identity-scoped cache keys
  • Stale-while-revalidate rendering (0 blank frames on return navigation)
  • Request deduplication (credentials 7→2, agent profiles 5→0, etc.)
  • IndexedDB query cache persistence (allowlisted queries only)
  • Session-list poll gated on document.visibilityState (0 requests while hidden)
  • Chat DOM bounded via react-virtuoso (max 16 entries for 968-message session)
  • Context providers memoized (ESLint-enforced)
  • Stale-chunk recovery ladder (retry → guarded reload → ErrorBoundary)

Staging Validation Results

Deploy #32214366482 on integration branch — GREEN

Item Verdict Evidence
A — Auth cache PASS Flat 47ms across 8 calls; security gate stays uncached
B — Code splitting PASS Entry 3,429→271 kB (−92%); lazy chunks load on nav
C — DO roundtrips NOT OBSERVABLE Memo + Promise.all have no HTTP signal
D — Poll gating PASS Visible: 8 polls/40s; Hidden: 0/40s
E — Cache headers PASS All 6 endpoints correct byte-for-byte
E — IndexedDB PASS 1 allowlisted query, identity-scoped
F — Dedup PASS 9 API requests, zero duplicates
F — SWR PASS 0 of 42 frames blank on return nav
G — D1 index PASS Coverage row created, fast path confirmed
G — Chat DOM PASS 968-msg session: max 16 DOM entries

Regression sweep: 15 routes × 2 viewports, 0 new console errors, 0 failed API calls, 0 new overflow.

Specialist Review Evidence

Reviews were performed per-sub-PR by the implementing agents. This integration PR aggregates 7 squash-merged sub-PRs that each passed CI independently.

Reviewer Status Notes
performance-reviewer PASS Validated per-sub-PR
staging-validator (Agent V) PASS Full consolidated validation, 39 screenshots

Agent Preflight

  • Classification: ui-change, business-logic-change, cross-component-change
  • Context gathered: Read idea 01M09SKVNJGJNJY2WGCZ6D89XZ, mapped 12 items to 7 workstreams across 4 waves
  • Assumptions: All 12 items can be implemented independently; TanStack Query is available and configured
  • Impact: Client bundle size, API request count, DOM node count, poll frequency — all reduced
  • Constitution check: All timeouts/limits use DEFAULT_* constants with env overrides

🤖 Generated with Claude Code

… audio handler (#1849)

UI Performance Program Workstream D — items #8, #10, partial #11.

Session poll: 120 req/hr → 6 (connected WS). Markdown re-parses: 45 → 5 per streaming burst.
New shared useVisibilityAwarePoll hook. 5 specialist reviewers, all ADDRESSED. CI green (run 32141548794).
…1850)

UI Performance Program Workstream B — item #2.

React.lazy for ~90 pages, mermaid lazy-loaded on first diagram, stale-chunk recovery ladder,
advancedChunks for vendor-terminal + vendor-react. Entry -91%, eager set -78%.
6 specialist reviewers, all ADDRESSED. CI green (run 32141742855).
…e parallelization (#1851)

UI Performance Program Workstream C — items #5 + #6.

ensureProjectId: memoized per (isolate, DO-id) — 7 DO consumers verified safe.
chat-agent-state: parallelized independent DO lookups. Net -35-42% roundtrips per endpoint.
4 specialist reviewers, all ADDRESSED. CI green (run 32142937870).
@codspeed-hq

codspeed-hq Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 6 untouched benchmarks


Comparing sam/read-idea-01m09skvnjgjnjy2wgcz6d89xz-using-bmbgfz (f66f5d9) with main (1f64efc)

Open in CodSpeed

… (items #1)

Workstream A: per-isolate TTL cache for auth preamble D1 queries (~42→~3 per authenticated request) + platform-config.ts split into 6 modules to pass 800-line CI gate. Part of UI Performance Program (idea 01M09SKVNJGJNJY2WGCZ6D89XZ).
simple-agent-manager Bot and others added 3 commits August 19, 2026 00:41
…1858)

Squash-merge Wave 2 workstream E into integration branch.

Items #3 (query cache persistence with IDB) + #7 (HTTP Cache-Control headers for stable GETs).

All gates green before agent stream-dropped; coordinator created PR from branch.
Tests: 7708 API + 3166 web passing.
#1859)

Squash-merge Wave 2 workstream G into integration branch.

Items #9 (chat DOM bound — timeline drawer virtualized, Virtuoso header stabilized) + #12 (D1 session summary index with delta sync, mutex, circuit breaker).

CI run 32201378354: 12/12 jobs pass. 7708 API + 3202 web + 12 Playwright tests.
4 specialist reviews all ADDRESSED. 3 latent bugs found and fixed during review.
Merge conflict resolved: configuration.md — both agents added env var docs to same table.
…1860)

Squash-merge of workstream F (Wave 3). Migrates 15 hand-rolled
useState/useEffect data-fetching hooks to TanStack Query with shared
query-option factories, stale-while-revalidate rendering, identity-scoped
cache keys, and hidden-tab poll gating.

Key changes:
- New query-options/ directory with domain-grouped factories (agents,
  chats, credentials, infrastructure, notifications, projects, tasks, trial)
- Shared stale times (query-stale-times.ts) and poll config (poll-intervals.ts)
- Dedup wins: listCredentials 7→2, listAgentProfiles 5→0,
  listAgents 5→3, getProviderCatalog 4→2, AppShell 6→3 requests/load
- useSetupStatus shared hook eliminates OnboardingProvider + ChoosePathWizard
  double-fetch (CRITICAL performance reviewer finding)
- All migrated hooks tested for SWR, dedup, identity scoping, and
  hidden-tab pause behavior
- Process rule: "A Green Test Count Is Not A Green Suite" (.claude/rules/02)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@simple-agent-manager
simple-agent-manager Bot marked this pull request as ready for review August 19, 2026 06:23
@simple-agent-manager
simple-agent-manager Bot merged commit e20ea4e into main Aug 19, 2026
29 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant