Repository navigation
perf(ui): scope live streams and collect Activity only while open - #158574
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: blocked before merge. Reviewed September 26, 2026, 12:38 AM ET / 04:38 UTC (Revision 4). ClawSweeper reviewWhat this changesThe branch makes the Control UI request session-scoped event streams and collect Live Activity only while its page is visible, with updated copy, a Retry action, and browser coverage. Merge readiness⛔ Blocked before merge - 3 items remain Keep this PR open. The earlier delivery finding is resolved, but the branch intentionally removes Activity history that users of the latest release can collect while visiting other pages. That product tradeoff still needs explicit Activity owner acceptance. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway sends session events to Control UI browsers. Browser session subscriptions determine which live events reach a client, and the Activity page turns received tool events into a short visible feed. flowchart LR
A[Gateway session events] --> B[Access and subscription checks]
C[Active sessions roster] --> D[Activity subscriptions]
D --> B
B --> E[Browser event stream]
E --> F[Live Activity feed]
Decision needed
Why: The branch documents and tests the new behavior, but deciding whether the performance gain warrants removing a shipped user workflow requires feature-owner intent. Before merge
Agent review detailsSecurityNone. PR surfaceSource +106, Tests +346, Docs 0. Total +452 across 19 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Ship scoped delivery with the clear live-only Activity explanation if the Activity owner accepts the released-history tradeoff, while retaining the shared subscription and Gateway access guards. Do we have a high-confidence way to reproduce the issue? Not applicable as a bug reproduction. Current source establishes the existing Activity flow, and the PR supplies a scoped fan-out benchmark and browser scenarios for the proposed behavior. Is this the best way to solve the issue? Unclear pending product acceptance. The existing session-scoped capability is a focused way to reduce fan-out, but removing released background Activity capture requires an explicit owner choice. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b458b9f1c6bc. 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 (3 earlier review cycles)
|
369481a to
dce2b5a
Compare
Enable the existing session-scoped event capability and remove the redundant broadcast type alias. This candidate is not ready for a PR: global Activity collection has a tested background-retention contract that requires a maintainer decision before this delivery cutover.
dce2b5a to
f91382c
Compare
|
Merged via squash.
|
…enclaw#158574) * perf(ui): prepare scoped Control UI stream delivery Enable the existing session-scoped event capability and remove the redundant broadcast type alias. This candidate is not ready for a PR: global Activity collection has a tested background-retention contract that requires a maintainer decision before this delivery cutover. * perf(ui): collect scoped activity only while open * fix(ui): retire Activity observers after failed cleanup * test(ui): resolve scoped event fixture lint findings * perf(ui): reuse upstream lazy plugin chunk boundary * perf(ui): preserve opt-in diagnostics for scoped Activity * test(ui): align Activity refresh fixture with scoped collection
What Problem This Solves
A Control UI browser receives other sessions' live streams even when it is only watching one conversation, multiplying Gateway fan-out and browser traffic as concurrent sessions grow.
User Impact
Chat panes and sidebar narration keep their existing subscriptions, while unrelated session streams no longer arrive. Live activity now collects only while its view is open and the browser tab is visible. It watches up to 100 authorized active sessions, starts each Activity-page visit empty, and explains that earlier activity is not shown. Shared leases preserve another pane's subscription when Activity closes; subscription failures offer a visible Retry action.
Why This Change Was Made
The UI now advertises the existing
session-scoped-eventscapability. Activity owns its collector and leases instead of starting a global collector at bootstrap or replaying the diagnostic event log. It preserves opt-in raw diagnostic capture from #158533. No Gateway protocol, configuration, or database schema changes are introduced. The redundantChatEventBroadcastalias is removed.The regenerated boot manifest removes Activity from eager startup.
Evidence
A focused broadcaster benchmark used 100 clients, 50 sessions, and 1,000 chat events containing 10 KiB of text. With two subscribed viewers per session:
This runs the unchanged broadcaster, client registry, and scope guards with the real WebSocket sender and a synthetic UTF-8 sink. Timings are synchronous elapsed time on a shared host. The benchmark excludes network/TLS, storage, and upstream agent work. Actual savings depend on the number of open panes and sidebar subscriptions; Activity intentionally watches a broader bounded roster while open.
The mock Gateway now honors actual handshake capabilities, per-connection subscriptions, deferred acknowledgments, and global-session aliases. Browser proof covers foreground streaming, sidebar narration, split panes, first-turn delivery before the send acknowledgment, mid-run attachment, reconnect, tool and observer events, roster running/unread state, approvals, inactive-agent background outbox sends, retained panes, Activity visibility/unmount cleanup, and unrelated-stream exclusion.
node scripts/run-vitest.mjs ui/src/pages/activity/activity-page.test.ts --maxWorkers=1).node scripts/run-vitest.mjs ui/src/api/gateway.node.test.ts --maxWorkers=1).pnpm ui:build, includingscripts/check-control-ui-performance.mts: passed, 19.96 s wall. Startup JS 370,427 B gzip / 7 requests (371,332 B enforcement limit); startup CSS 50,164 B / 1 request (51,200 B hard limit); largest CSS 50,164 B (53,400 B limit). Limits and baseline are unchanged.attempt-session-replay.test.ts; upstream refactor(test): separate interrupted replay fixtures #158538 repaired it before this rebase, and focused lint on that file now passes. Local findings were fixed and the remaining native checks were resumed. This records the actual staged validation; it does not claim a single uninterrupted wrapper pass.One existing sidebar-outbox case passed its behavior assertion (8.838 s) but exceeded the suite's 180-second cleanup deadline. A bounded standalone reproduction could not start: a read-only Git metadata process stalled and the runner stopped after its 300-second no-output deadline (309.02 s wall). No timeout was raised and no cleanup fix is claimed. Hosted CI remains authoritative for that limitation.
Before: a tool event received while Settings was open appears on the first Activity visit.
After: Activity opens empty and explains its live-only behavior.
Fresh activity still appears while the view is open
All screenshots use inspected synthetic mock-Gateway fixtures.
Landing CI repair
Exact-head CI run 36215317661 failed UI E2E shard 4/9 because
activity-session-refresh.e2e.test.tsstill expected a tool event emitted before opening Live activity to be retained. A focused local replay reproduced the same assertion. The fixture now provides an active roster row, opens Live activity, waits for its subscription, and sends events for that session. The existing refresh, scrolling, and feedback-clipping assertions remain; the latter asserts the active row and exact bounded-roster notice before measuring its bounds. Production behavior and performance budgets are unchanged.The repaired refresh fixture and Activity lifecycle sibling passed 7/7 browser cases (43.50 s wrapper wall time). The required single-worker cost run,
pnpm test ui/src/e2e/activity-session-refresh.e2e.test.ts --maxWorkers=1, passed 5/5 in 40.28 s wrapper wall time (34.41 s Vitest duration, including the shared production-preview setup). This browser boundary is needed to cover route changes, real subscription delivery, virtual-clock refresh pacing, and DOM clipping together. E2E typechecking, focused lint, formatting, andgit diff --checkpassed. CI shard 4/9 spent 381 seconds in its original test step and passed 366/367 cases before this repair; the new head will receive a fresh CI run.Final Codex autoreview of the fixture repair is clean through P2 after adding the explicit row/notice assertions.
The subsequent run 36216631631 passed
control-ui-performancebut failedcheck-test-types-core-1: an unrelated main refactor movedControlUiRootStatewithout updating the retained-assets E2E import. The same TS2459 reproduced on main. Commit da8149b fixes the import; its corrected file is byte-identical to the locally verified repair. All five type graphs from the exact CI check passed, and the retained-assets browser test passed (3.49 s test time; 242.44 s total including cold worker compilation). Main was merged into this branch, preserving its ancestry, to incorporate that repair and obtain fresh CI.After merging repaired main, focused validation passed 115/115 handshake and Activity owner tests plus 9/9 browser cases for Activity refresh/lifecycle and scoped delivery (87.16 s total wrapper wall time). Integration candidate: d2abd2c.