Repository navigation
perf(ui): describe each session once per load - #160148
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 4:35 AM ET / 08:35 UTC (Revision 3). ClawSweeper reviewWhat this changesThe Control UI routes session-detail requests from chat, sidebar, board, desktop, and placement flows through one connection-scoped reader to reduce duplicate Gateway requests. Merge readiness✅ Ready for maintainer review Keep open for normal maintainer review. Current main still has independent session-detail requests, and the PR reports a measured reduction with no source-proven blocking defect. Priority: P2 Review scores
Verification
How this fits togetherThe Control UI asks the Gateway for conversation details and shows them across several panels. Its sessions capability now coordinates those reads before the panels consume the results. flowchart LR
A[Chat and sidebar] --> C[Sessions capability]
B[Board and desktop] --> C
C --> D{Details still current?}
D -->|Yes| E[Shared session details]
D -->|No| F[Gateway session description]
F --> E
G[Session events and refresh] --> D
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +245, Tests +325, Docs +2. Total +572 across 33 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep session-detail reads in the sessions capability with bounded connection-scoped reuse and invalidation for session changes, explicit refreshes, and reconnects. Do we have a high-confidence way to reproduce the issue? Yes for the duplicate-read baseline: the PR reports paired Gateway waterfall runs, and current main retains direct request paths. This read-only review did not run the harness. Is this the best way to solve the issue? Yes. The existing sessions capability is the narrowest shared owner for these reads, while callers retain their own reconciliation and error handling. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 40019980f268. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
|
Pushed
Validation after the fix: every test file importing a migrated caller plus the owner tests (210 files, 4,020 tests), CI's Bun UI shard 3/3 run locally (515 files, 8,192 tests), UI types, touched-file oxlint, and independent P2 review all pass. |
Ten independent describe callers bypassed the session row owner. Component-local pending guards could not collapse overlapping reads or reuse a completed current descriptor during boot and selection changes. Route every caller through the sessions capability. The existing row owner now holds bounded exact-parameter reads, scoped to connection epochs and observed session revisions. Events, explicit refresh, subscription outages and failures retire reusable reads. Keep caller-owned reconciliation and errors, preserve captured-client placement cleanup, and retain the original runtime sample time. Partial roster rows do not stand in for complete descriptors. Five interleaved WATERFALL=1 PARAMS=1 reload/switch pairs, pinned base fb2487a: - Reload describes: before [4,3,3,3,3], after [1,1,1,1,1]. - Switch-7 describes: before [2,2,2,2,2], after [1,1,1,1,1]. - Switch-3 describes: before [2,2,2,2,2], after [1,1,1,1,1]. - Total describes: 36 -> 15 (58.3% fewer); each baseline scenario used identical describe parameters. Every measured candidate scenario issued one request. - Reload visible ms: before [286,545,2753,346,397], after [859,280,266,1244,532]; medians 397 -> 532. - Switch-7 visible ms: before [167,140,137,143,154], after [146,132,148,142,150]; medians 143 -> 146. - Switch-3 visible ms: before [100,99,104,94,97], after [102,92,103,87,96]; medians 99 -> 96. The supplied port 19511 baseline remained unavailable after the prescribed 20-minute wait. Both builds were instead served on owned port 19603 using the same pinned, unchanged Gateway sources and seeded state. The first pair used separate starts; four further pairs reused one ready Gateway, switching matching HTML/service-worker/manifest files and verifying the served entry hash. The shared harness's measured scenarios were unchanged. Gateway shutdown used SIGINT. Host-load variance was substantial; these local results establish fewer RPCs, not a visibility-time improvement or remote-Gateway latency improvement. Validation: 508 focused tests across 21 files passed; UI typecheck, scoped CI oxlint wrapper, formatting and diff checks passed. Codex autoreview is clean through P2 after resolving pending-revision and observer-outage findings. The owner regression fails when sharing is disabled; the updated mounted lineage regression fails against original production code (2 requests vs 1). Changed test file wall costs (one worker, loaded host): - session-describe.test.ts: 10.78s (14 cases). - app-sidebar-session-navigation-logic.test.ts: 37.77s (48 cases). - app-sidebar.lineage-freshness.test.ts: 38.69s (31 cases). - board-document.test.ts: 51.58s (3 cases). - chat-pane-active-resources.test.ts: 119.12s (55 cases). - session-placement-startup.test.ts: 70.54s (42 cases). - session-placement-submit.test.ts: 35.93s (12 cases). Most wall time was transformation/environment overhead. Reported case times for those caller files were 0.071s, 8.174s, 0.275s, 0.498s, 1.434s and 0.043s. No new real timers or sleeps; existing caller fixtures retain their flow checks. UI build passes. Startup gzip is 373301 B, +782 B over the unchanged base's 372519 B. Both exceed the existing 371581 B budget; no budget was changed. Runtime measurement used the documented JavaScript-only build after declaration preparation proved too expensive. No CI dispatch, push, or release was performed.
Incomplete session events invalidated only the named child's describe entry. When a managed list admitted a replacement incarnation, the sidebar retired its lineage walk but the request owner still shared the previous parent's pending read. Ancestors can live outside the held roster and belong to another agent. Retire connection-owned describes when an event cannot certify complete ancestor coverage. Keep exact key/owner invalidation and unrelated reuse for certified trees. No caller exemptions or behavioral assertion changes are needed. Forward describe through the shared sidebar test facade's existing real session capability, preserving captured-client proxy identity. The missing method caused the five out-of-window Home failures before any RPC could run. Supply the required observerError callback in the direct roster observation fixture too. Validation: - Reproduced the reported six failures on b0786b4; all 143 existing cases now pass without changing their assertions. - Import-based caller discovery: rg -l for all ten migrated modules, followed executable production/helper imports and the placement runtime bridge. All 208 discovered files pass: 200 Node files / 3883 tests, six browser files / 74 tests, and two E2E files / 35 tests. - Two owner files pass 28 tests; total targeted proof is 210 files / 4020 tests. Pending/completed and same-agent/cross-agent ancestry cases fail on the old owner (four failures) and preserve reuse after unrelated certified events. - CI-style Bun UI shard 3/3 passes 515 files / 8192 tests through scripts/ci-run-node-test-shard.mts, bun-compatible policy, regenerated PR groups, native --shard=3/3, three workers, and CI reporters. Local macOS Bun 1.4.2 differs from CI's pinned Linux fork; the identical CI binary was not tested. Bun emitted a nonfatal directory-mismatch shutdown diagnostic; the runner exited 0 and every module passed. No remote CI dispatch or push. - UI production types, all UI fixture typecheck shards, CI oxlint wrapper on touched files, formatting, diff checks, and Codex autoreview P2 pass. - One-worker changed-test wall costs: session-describe.test.ts 7.14s (26 tests), session-roster-observations.test.ts 4.79s (2 tests). New cases use deferred promises and fake time; no real timers or sleeps were added.
df47ed4 to
797e570
Compare
|
Merged via squash.
|
* perf(ui): share session descriptor reads Ten independent describe callers bypassed the session row owner. Component-local pending guards could not collapse overlapping reads or reuse a completed current descriptor during boot and selection changes. Route every caller through the sessions capability. The existing row owner now holds bounded exact-parameter reads, scoped to connection epochs and observed session revisions. Events, explicit refresh, subscription outages and failures retire reusable reads. Keep caller-owned reconciliation and errors, preserve captured-client placement cleanup, and retain the original runtime sample time. Partial roster rows do not stand in for complete descriptors. Five interleaved WATERFALL=1 PARAMS=1 reload/switch pairs, pinned base 7fce9df: - Reload describes: before [4,3,3,3,3], after [1,1,1,1,1]. - Switch-7 describes: before [2,2,2,2,2], after [1,1,1,1,1]. - Switch-3 describes: before [2,2,2,2,2], after [1,1,1,1,1]. - Total describes: 36 -> 15 (58.3% fewer); each baseline scenario used identical describe parameters. Every measured candidate scenario issued one request. - Reload visible ms: before [286,545,2753,346,397], after [859,280,266,1244,532]; medians 397 -> 532. - Switch-7 visible ms: before [167,140,137,143,154], after [146,132,148,142,150]; medians 143 -> 146. - Switch-3 visible ms: before [100,99,104,94,97], after [102,92,103,87,96]; medians 99 -> 96. The supplied port 19511 baseline remained unavailable after the prescribed 20-minute wait. Both builds were instead served on owned port 19603 using the same pinned, unchanged Gateway sources and seeded state. The first pair used separate starts; four further pairs reused one ready Gateway, switching matching HTML/service-worker/manifest files and verifying the served entry hash. The shared harness's measured scenarios were unchanged. Gateway shutdown used SIGINT. Host-load variance was substantial; these local results establish fewer RPCs, not a visibility-time improvement or remote-Gateway latency improvement. Validation: 508 focused tests across 21 files passed; UI typecheck, scoped CI oxlint wrapper, formatting and diff checks passed. Codex autoreview is clean through P2 after resolving pending-revision and observer-outage findings. The owner regression fails when sharing is disabled; the updated mounted lineage regression fails against original production code (2 requests vs 1). Changed test file wall costs (one worker, loaded host): - session-describe.test.ts: 10.78s (14 cases). - app-sidebar-session-navigation-logic.test.ts: 37.77s (48 cases). - app-sidebar.lineage-freshness.test.ts: 38.69s (31 cases). - board-document.test.ts: 51.58s (3 cases). - chat-pane-active-resources.test.ts: 119.12s (55 cases). - session-placement-startup.test.ts: 70.54s (42 cases). - session-placement-submit.test.ts: 35.93s (12 cases). Most wall time was transformation/environment overhead. Reported case times for those caller files were 0.071s, 8.174s, 0.275s, 0.498s, 1.434s and 0.043s. No new real timers or sleeps; existing caller fixtures retain their flow checks. UI build passes. Startup gzip is 373301 B, +782 B over the unchanged base's 372519 B. Both exceed the existing 371581 B budget; no budget was changed. Runtime measurement used the documented JavaScript-only build after declaration preparation proved too expensive. No CI dispatch, push, or release was performed. * fix(ui): retire stale ancestor describe requests Incomplete session events invalidated only the named child's describe entry. When a managed list admitted a replacement incarnation, the sidebar retired its lineage walk but the request owner still shared the previous parent's pending read. Ancestors can live outside the held roster and belong to another agent. Retire connection-owned describes when an event cannot certify complete ancestor coverage. Keep exact key/owner invalidation and unrelated reuse for certified trees. No caller exemptions or behavioral assertion changes are needed. Forward describe through the shared sidebar test facade's existing real session capability, preserving captured-client proxy identity. The missing method caused the five out-of-window Home failures before any RPC could run. Supply the required observerError callback in the direct roster observation fixture too. Validation: - Reproduced the reported six failures on b0786b4; all 143 existing cases now pass without changing their assertions. - Import-based caller discovery: rg -l for all ten migrated modules, followed executable production/helper imports and the placement runtime bridge. All 208 discovered files pass: 200 Node files / 3883 tests, six browser files / 74 tests, and two E2E files / 35 tests. - Two owner files pass 28 tests; total targeted proof is 210 files / 4020 tests. Pending/completed and same-agent/cross-agent ancestry cases fail on the old owner (four failures) and preserve reuse after unrelated certified events. - CI-style Bun UI shard 3/3 passes 515 files / 8192 tests through scripts/ci-run-node-test-shard.mts, bun-compatible policy, regenerated PR groups, native --shard=3/3, three workers, and CI reporters. Local macOS Bun 1.4.2 differs from CI's pinned Linux fork; the identical CI binary was not tested. Bun emitted a nonfatal directory-mismatch shutdown diagnostic; the runner exited 0 and every module passed. No remote CI dispatch or push. - UI production types, all UI fixture typecheck shards, CI oxlint wrapper on touched files, formatting, diff checks, and Codex autoreview P2 pass. - One-worker changed-test wall costs: session-describe.test.ts 7.14s (26 tests), session-roster-observations.test.ts 4.79s (2 tests). New cases use deferred promises and fake time; no real timers or sleeps were added.
What Problem This Solves
Fixes: loading or switching a Control UI conversation asked the Gateway to describe the same session several times (3–4
sessions.describerequests per reload, 2 per switch), because ten callers bypassed the sessions capability and requested it directly.User Impact
Each reload and switch now issues exactly one
sessions.describefor the session, down from 3–4 and 2: across five interleaved runs, 36 requests fell to 15 (−58%). That means less Gateway work and fewer round trips over remote connections. Paint timing is unchanged locally: these requests were never on the transcript's critical path, and this PR does not claim a visible speedup.Why This Change Was Made
sessions.describehad ten independent callers (desktop session controller, lineage controller, placement startup/submit, swarm roster, chat pane board and active resources, board document, sidebar child-session data, desktop panel). Each called the Gateway directly, so one reload produced overlapping identical requests at roughly 126, 168, 774, and 862 ms after navigation. AGENTS.md asks for one owner per responsibility; describe reads now have one.ui/src/lib/sessions/session-describe.tsis the read owner behind the sessions capability'sdescribeAPI. Identical in-flight requests (same connection, session key, and parameters) share one request. A completed result is reused only while the held session row still matches the described session (samesessionId, not newerupdatedAt), the connection scope is current, and reuse is allowed. An explicit refresh, a newer row, a different connection epoch, or a matchingsession.changedevent re-fetches. Completed reads are capped at 128 entries.Startup JS grows by 782 bytes gzip. The existing startup budget was already about 1 KiB over before this change (report-only).
Evidence
WATERFALL=1harness against a Gateway with seeded synthetic sessions, five interleaved before/after pairs:sessions.describeper reload 4,3,3,3,3 → 1 each; per switch 2 → 1. Visible medians (ms): reload 397 → 532 (noise-dominated: per-run 286–2,753 before, 266–1,244 after on a heavily loaded host), switch 143 → 146 and 99 → 96.session.changedevent re-fetches; a different connection epoch never reuses a result; the mounted regression fails against the original code.Per-file cost (
--maxWorkers=1, local wall on a heavily loaded host; CI seconds will be added from the first run):session-describe.test.ts10.8 s,app-sidebar-session-navigation-logic.test.ts37.8 s,app-sidebar.lineage-freshness.test.ts38.7 s,board-document.test.ts51.6 s,chat-pane-active-resources.test.ts119.1 s,session-placement-startup.test.ts70.5 s,session-placement-submit.test.ts35.9 s. Most of that is transform and setup on existing files; the new cases are small.