Skip to content

perf(ui): scope live streams and collect Activity only while open - #158574

Merged
steipete merged 8 commits into
mainfrom
perf/l01-scoped-control-ui-events
Sep 26, 2026
Merged

steipete merged 8 commits into
mainfrom
perf/l01-scoped-control-ui-events

Conversation

@steipete

@steipete steipete commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

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-events capability. 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 redundant ChatEventBroadcast alias 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:

Measurement Before: unscoped After: scoped
Frames sent 100,000 2,000
Encoded bytes 1.052 GB 21.03 MB
Broadcast and encoding time 629.20 ms 70.97 ms

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.

  • Activity owner: 24/24 tests passed, 11.47 s wall (node scripts/run-vitest.mjs ui/src/pages/activity/activity-page.test.ts --maxWorkers=1).
  • Serialized mock Gateway: 17/17 passed, 53.70 s wall; the repeated-event regression runs in 31 ms using fake timers.
  • Gateway handshake: 91/91 passed, 23.65 s wall (node scripts/run-vitest.mjs ui/src/api/gateway.node.test.ts --maxWorkers=1).
  • Activity browser flows: 4/4 selected cases passed, 143.93 s wall including the production preview build; summaries, answer candidates, and populated inspector layout.
  • Scoped composition: 2/2 passed, 12.840 s file time; inactive-agent outbox: 1/1 passed, 91.862 s file time. Their grouped invocation also contained the teardown limitation below and took 749.50 s wall.
  • Existing streaming/tool/reconnect/sidebar/retained-pane flows: 5/5 passed, 151.88 s wall including build. Startup, observer, and approval flows: 5/5 passed in the earlier grouped run (155.49 s wall, alongside the subsequently corrected outbox fixture).
  • Final pnpm ui:build, including scripts/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.
  • Rebase integration: 7/7 browser cases passed on the final main base, 69.91 s wall, covering scoped split/first-turn delivery, Activity lifecycle/tool summaries, and first-session startup. The subsequent opt-in-diagnostics integration passed 4/4 chat/Activity browser cases in 36.83 s wall. Its no-raw-capture regression was demonstrated failing on the old collector before passing. Fresh changed-file lint, UI/E2E typechecks, format, and line-cap checks passed after integration.
  • Changed-file checks: core/UI types, changed-file typed lint, formatting, UI style checks, i18n, all three unused-export scans, and all remaining native guards passed. The final continuation took 1,057.12 s across 13 stages. The initial full-tree lint stage found a baseline max-lines violation in 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.
  • Deslop: removed obsolete global collection/replay and redundant fixture code. Codex autoreview: clean through P2 on the final branch. Two earlier findings were fixed: rejected Activity releases now retire the current connection, and repeated mock events retain their subscription gate.
  • LOC: production +146/−41, net +105; generated boot manifest +5/−4, net +1; tests and support +749/−424, net +325; docs neutral. Lifecycle-owned leases, visibility cleanup, and visible subscription recovery require the production growth despite removing the global owner and alias.

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.

Before: Activity retained background tool events

After: Activity opens empty and explains its live-only behavior.

After: Activity starts empty with the live-only explanation

Fresh activity still appears while the view is open

After: a fresh tool result appears while Activity 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.ts still 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, and git diff --check passed. 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-performance but failed check-test-types-core-1: an unrelated main refactor moved ControlUiRootState without 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.

@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime size: XL labels Sep 26, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 26, 2026, 12:38 AM ET / 04:38 UTC (Revision 4).

ClawSweeper review

What this changes

The 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
Reviewed head: d2abd2cab1b7b2fac3273ff4dd07ba653f99d2ec
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has focused browser and transport evidence with no remaining code finding; released Activity semantics still need an owner decision.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The maintainer-authored PR is exempt from the contributor proof gate. Supplied screenshots show the Activity state change in a browser with a mock Gateway; browser scenarios exercise subscriptions, and a real WebSocket sender benchmark measures fan-out separately. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from the contributor proof gate. Supplied screenshots show the Activity state change in a browser with a mock Gateway; browser scenarios exercise subscriptions, and a real WebSocket sender benchmark measures fan-out separately. No stored-data contract changes.
Evidence reviewed 7 items Current behavior: Current main documents collection across sessions while visiting other Control UI pages, including before the first Activity visit.
Introduced lifecycle change: The branch moves Activity ownership from application bootstrap to the page and limits subscriptions to visible, connected roster rows.
Released behavior provenance: The merged change titled “keep live activity across page navigation” is an ancestor of the latest release commit, v2026.9.6. Current-main source and documentation still retain that behavior.
Findings None None.
Security None None.

How this fits together

The 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]
Loading

Decision needed

Question Recommendation
Should the off-page Activity capture shipped in v2026.9.6 be retired by default to gain the measured scoped-stream savings? Accept live-only Activity: Ship the scoped collector and its visible explanation, accepting that entries from before the page opened will no longer appear.

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

  • Resolve merge risk (P1) - A user upgrading from v2026.9.6 who relies on Activity collected while visiting other pages will instead open an empty feed, with no way to recover those missed entries; explicit feature-owner acceptance of that change is not recorded.
  • Complete next step (P2) - Record explicit Activity feature-owner acceptance of the released off-page history change before merge.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source +106, Tests +346, Docs 0. Total +452 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 8 151 45 +106
Tests 10 775 429 +346
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 927 475 +452

Review metrics

Metric Value Why it matters
Measured event fan-out 100,000 to 2,000 frames in the supplied synthetic benchmark The measured reduction explains why the compatibility tradeoff is being proposed.
Production and test growth production net +105; tests and support net +325 The PR attributes production growth to page-owned leases, visibility cleanup, and visible recovery.

Merge-risk options

Maintainer options:

  1. Accept the Activity change (recommended)
    The feature owner can explicitly accept the released-history tradeoff in the PR discussion before merge.
  2. Retain off-page collection
    Revise the collector design to preserve background history and show that scoped delivery still saves traffic.

Technical review

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded Control UI performance improvement with a material but localized Activity behavior decision.
  • merge-risk: 🚨 compatibility: Merging changes the Activity capture window that was present in the latest release.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored PR is exempt from the contributor proof gate. Supplied screenshots show the Activity state change in a browser with a mock Gateway; browser scenarios exercise subscriptions, and a real WebSocket sender benchmark measures fan-out separately. No stored-data contract changes.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The maintainer-authored PR is exempt from the contributor proof gate. Supplied screenshots show the Activity state change in a browser with a mock Gateway; browser scenarios exercise subscriptions, and a real WebSocket sender benchmark measures fan-out separately. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • Shakker: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-26T02:23:13.037Z sha 369481a6e22d5149ce688dc2a78842396cf24a1e :: blocked before merge. :: [P1] Match Activity events without the roster-only session ID
  • reviewed 2026-09-26T03:04:56.516Z sha dce2b5a :: blocked before merge. :: none
  • reviewed 2026-09-26T04:11:33.080Z sha 84d6b40 :: blocked before merge. :: none

@steipete
steipete force-pushed the perf/l01-scoped-control-ui-events branch from 369481a to dce2b5a Compare September 26, 2026 02:57
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 26, 2026
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.
@steipete
steipete force-pushed the perf/l01-scoped-control-ui-events branch from dce2b5a to f91382c Compare September 26, 2026 03:31
@steipete
steipete marked this pull request as ready for review September 26, 2026 03:36
@steipete
steipete merged commit 8279835 into main Sep 26, 2026
231 of 232 checks passed
@steipete
steipete deleted the perf/l01-scoped-control-ui-events branch September 26, 2026 05:05
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant