Skip to content

perf(ui): bootstrap session rosters in one request - #130294

Merged
steipete merged 3 commits into
mainfrom
perf/session-bootstrap-rpc
Aug 26, 2026
Merged

steipete merged 3 commits into
mainfrom
perf/session-bootstrap-rpc

Conversation

@steipete

@steipete steipete commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Control UI previously waited on three Gateway requests to load its initial session roster: subscribe, list the signed-in owner's sessions, then list the shared page. Warm session-change refreshes required two lists. This PR reduces each flow to one request while preserving visibility, filters, pagination, and connection lifecycle.

Why This Change Was Made

sessions.subscribe now registers the observer before returning the canonical authorized list projection. ownerFirst uses the authenticated profile to prepend an independent window of at most 60 owned sessions, then deduplicates the normal shared page without advancing its cursor. The UI consumes that bootstrap and uses one canonical list for warm refreshes, removing the two-phase orchestration.

Maintainer review repaired three connected defects: administrator cache keys now include the viewer identity, bootstrap shares the list's startup admission gate, and retained owner windows cannot consume the shared transcript-enrichment budget. The existing involvingMe cache path gets the same identity repair. Swift protocol models and client/protocol documentation were updated.

The related CI fixture race was reproduced at both config writers. Both now use the existing atomic JSON writer so deferred session notifications cannot read a truncated config. Cache-test fixtures were extracted to keep the regression suite below its file-length limit, without suppressions or weakened coverage.

User Impact

Cold roster loading is one sessions.subscribe and no separate list; a warm change is one sessions.list. Older owned sessions remain available alongside shared sessions, and paging retains the shared cursor and previously hydrated preview metadata. Observer errors remain visible and reconnects establish a fresh bootstrap.

No new configuration or environment setting, storage schema change, or protocol-version bump. Empty-parameter subscriptions retain their acknowledgment-only response; subscription requests now receive the same retryable startup admission response as lists while the Gateway warms up. The optional ownerFirst request parameter and non-empty subscribe snapshot response are the only protocol additions.

Evidence

Inspected live video, before/after screenshots, commands, and results.

  • Real built Gateway and served Control UI, isolated state, two authenticated trusted-proxy profiles, 390 sessions: 53/53 checks passed. Verified concurrent administrator projections, bounded owner/shared previews, cold and warm RPC counts, retained paging, reconnect, served asset bytes, and zero browser exceptions. No provider turn or operator credentials were used.
  • Gateway: 147 tests passed, including the original chat test execution order. All four new roster regression cases failed on the incoming code before repair.
  • Full UI unit suite: 10,649 passed, 67 existing skips.
  • Final fixture suite: 5/5 passed; both cases reproduced the original JSON5 EOF before repair. Extracted cache suite: 31/31 passed and targeted lint passed.
  • Focused browser E2Es: 3/3 passed.
  • Full build, UI performance budget, protocol registry/generated Swift/generated Kotlin/since checks, and core/UI/test typechecks passed.
  • Fresh Codex autoreview of the full change and the later fixture extraction: no accepted/actionable findings at the configured default P0 threshold. Maintainer review additionally found and fixed the P2 defects above.
  • Final-head CI passed on 96e5796c7afcdaf4b0b2678a3f02ba6dd71d078a; required openclaw/ci-gate is green.

Production LOC: +154/-118 (net +36). This implements the combined bootstrap and bounded authenticated projection while removing duplicate client orchestration; the maintainer repairs reduce handwritten production code by seven lines relative to the incoming PR. Tests and support: +327/-190 before discounting the pure fixture move; generated Swift: +4; docs: +57/-5.

The latest ClawSweeper review found no actionable patch defect. Its rank-up request is satisfied: final-head CI is green, and GitHub merge ref 5c34be2844a001bce4da32d1a70d7e21b675d1b6 was fetched and compared against the verified PR head on main 26d3b08758fbb0fca0b474b8c4c533cf87ba89e7. All handwritten roster runtime/UI files are unchanged; current-main differences in touched files are unrelated generated approval/portal models and an independent mock-reset ordering change. The earlier rebase-only move remains intentionally skipped because the branch is conflict-free. The reviewer harness stopped after 30 seconds without a completed browser verdict; the completed three-test browser run, full hosted browser shards, and real Gateway/browser evidence above provide the actual results. No persistent-store schema changed.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Aug 26, 2026

steipete commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Maintainer review and live proof

The bootstrap stays at the Gateway owner: register the observer, then reuse the canonical authorized list projection. The repair scopes cached results to the authenticated profile (including administrators), applies the same startup admission to both roster entry points, and retains a separate 60-row owner window without consuming the shared transcript budget. The old duplicate UI request construction is removed. Generated Swift models and protocol/client docs are current.

The four new roster regressions failed on the incoming head for the intended reasons, then passed after repair. I also reproduced the original CI JSON5 failure in both test fixture writers and replaced their truncating writes with the existing atomic JSON writer; the original chat test order passes. No runtime retry, config option, persistent schema change, or protocol-version bump was added.

Real Gateway and browser

The built Gateway and its served Control UI ran against a fresh temporary home/state directory, separate ports, and two synthetic authenticated trusted-proxy profiles. All 53 live checks passed across 390 sessions; the live Gateway and temporary state were removed afterward. No operator Gateway, saved credentials, provider API, or model turn was used.

Observed flow Result
Cold load, each user 1 sessions.subscribe, 0 sessions.list
One metadata event, each user 1 sessions.list, 0 re-subscriptions
Concurrent admin projections Each user's own 60-row window; no cross-profile cache reuse
Retained shared page Cursor 240, independent owner window, bounded transcript hydration
Warm refresh Previously paged shared-tail preview preserved
Reconnect 1 bootstrap request, correct owner rows and authoritative shared cursor
Browser exceptions 0 in either browser

The served entry asset assets/index-D3c4tk6w.js matched the built bytes (SHA-256 a1b4ed2393d7363518924baff8b6dfa30017772d0690c68f140fee6d1b7181d4). The video is accelerated 8×; screenshots show the same shared row before and after its live metadata update. All media contains only synthetic data and was visually inspected.

Verification

  • Gateway: 147 tests passed, including cache, startup, owner/pagination, subscription, fixture publication, and the original chat sequence.
  • Full UI unit suite: 10,649 passed; 67 existing skips.
  • Final atomic-fixture tests: 5/5 passed.
  • Focused browser E2Es: 3/3 passed (bootstrap, warm roster refresh, retained chat pane).
  • Full pnpm build, including Control UI: passed; startup JavaScript 333.2 KiB gzip, within budget.
  • Protocol registry, schema generation, generated Swift/Kotlin, and since checks: passed.
  • Fresh Codex autoreview: no accepted/actionable findings at its default P0 threshold. Maintainer review additionally repaired the P2 findings above.
Commands
pnpm build
node scripts/run-vitest.mjs run src/gateway/server-methods/sessions-read-cache.test.ts src/gateway/server-methods.control-plane-rate-limit.test.ts src/gateway/session-utils.perf.test.ts src/gateway/session-utils-owners.test.ts src/gateway/server-methods/sessions-viewers.test.ts src/gateway/test-helpers.server-env.test.ts src/gateway/server.chat.gateway-server-chat.test.ts ui/src/lib/sessions
node scripts/run-vitest.mjs run src/gateway/test-helpers.server-env.test.ts
node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/session-owner-first.e2e.test.ts ui/src/e2e/session-owner-warm-refresh.e2e.test.ts ui/src/e2e/chat-retained-pane-hydration.e2e.test.ts
pnpm protocol-registry:check
pnpm protocol:gen
pnpm protocol:check:swift
pnpm protocol:gen:kotlin
node --import tsx scripts/check-protocol-since.mts
node .artifacts/pr-130294/live-roster.mjs --phase candidate-2

The task-only live harness and generated media are not product files.

The earlier rebase-only rank-up move is intentionally skipped: the branch is conflict-free, current-main owner paths were checked, and landing will require green CI on the final head. The new behavioral repairs warrant a fresh rating: @clawsweeper re-review.

roster-live-8x.mp4

Shared row before the live metadata update

The same shared row after one event-driven refresh

@steipete
steipete marked this pull request as ready for review August 26, 2026 18:33
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 5:07 PM ET / 21:07 UTC.

ClawSweeper review

What this changes

The PR makes the Control UI obtain an authenticated owner-first session roster in the sessions.subscribe response and use one canonical list request for subsequent refreshes.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open for normal maintainer landing review. The proposed Gateway-owned bootstrap and UI consumer form one coherent path with no concrete patch defect found, but the branch is behind main, required checks are still running, and this checkout could not hydrate the current-main/base objects for a final three-way comparison.

Priority: P2
Reviewed head: 96e5796c7afcdaf4b0b2678a3f02ba6dd71d078a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The implementation and focused coverage are coherent, with final landing confidence gated on the exact merge-result checks.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied comment nevertheless describes a built Gateway and served Control UI run with redacted synthetic profiles and before/after media.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied comment nevertheless describes a built Gateway and served Control UI run with redacted synthetic profiles and before/after media.
Evidence reviewed 7 items Gateway bootstrap owner: The subscription validates the established list parameters, registers event delivery before the projection, and delegates the snapshot to the canonical list handler.
Viewer-specific projection: The list handler derives the viewer only from the authenticated profile and passes it to the owner-first projection; the cache key also includes that identity.
Pagination invariant: Owner rows are prepended only on page zero, deduplicated against the shared page, while nextOffset and hasMore remain calculated from the shared page.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/session-owner-first.e2e.test.ts

Result: FAIL (failed) — step 1 run node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/session-owner-first.e2e.test.ts: previous terminal command was still running after 30 seconds: "node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/session-owner-first.e2e.test.ts"

RUN  v4.1.11 /tmp/clawsweeper-live-proof-130294-jhH8gb/target

[vitest] still running with no output for 30000ms.

Assertions:

  • FAIL expect_output: hydrates the owner-first roster with the event subscription

How this fits together

The Control UI loads session navigation from the Gateway and refreshes it after session-change events. The Gateway owns authorization, pagination, and viewer-specific roster projection before the UI renders the resulting rows.

flowchart LR
  UI[Control UI connection] --> Subscribe[Session subscription request]
  Subscribe --> Gateway[Gateway authorization and roster projection]
  Gateway --> Snapshot[Bootstrap roster response]
  Gateway --> Events[Session change events]
  Snapshot --> Roster[UI session roster]
  Events --> Refresh[One canonical refresh]
  Refresh --> Roster
Loading

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch behind main and its required checks are still queued or running; final merge safety requires an up-to-date merge-result review and green required checks on the exact landing head.
Agent review details

Security

None.

PR surface

Source +94, Tests +79, Docs +52, Other +4. Total +229 across 28 files.

View PR surface stats
Area Files Added Removed Net
Source 15 217 123 +94
Tests 10 264 185 +79
Docs 2 57 5 +52
Config 0 0 0 0
Generated 0 0 0 0
Other 1 4 0 +4
Total 28 542 313 +229

Review metrics

Metric Value Why it matters
Production versus test delta production +154/-118; tests/support +327/-190; docs +57/-5; generated Swift +4 The net production growth implements the new canonical bootstrap and bounded authenticated projection while removing duplicate UI orchestration.

Stored data model

Persistent data-model change detected: persistent cache schema: src/gateway/server-methods/sessions-read-cache.test.ts, serialized state: packages/gateway-protocol/src/schema/sessions.ts, serialized state: src/gateway/server-methods/sessions-list-cache.ts, serialized state: src/gateway/server-methods/sessions-read-cache.test-support.ts, serialized state: src/gateway/server-methods/sessions-read-cache.test.ts, serialized state: src/gateway/server-methods/sessions-read.ts, and 27 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the canonical Gateway projection and single-request UI bootstrap only after GitHub verifies the final merge result and required checks; preserve the documented empty-request acknowledgement behavior for existing clients.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the canonical Gateway projection and single-request UI bootstrap only after GitHub verifies the final merge result and required checks; preserve the documented empty-request acknowledgement behavior for existing clients.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a defect report: this is a performance and protocol enhancement. The supplied PR comment includes an after-fix Gateway and browser exercise, while current-main pre-change execution could not be run from this partial clone.

Is this the best way to solve the issue?

Yes, based on the reviewed source: registering events before delegating to the existing authorized list projection keeps one canonical owner for visibility, paging, and viewer-specific rows rather than duplicating that logic in the UI.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 2df646128092.

Labels

Label justifications:

  • P2: This changes normal Control UI roster loading and Gateway session projection behavior with a bounded user-facing blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied comment nevertheless describes a built Gateway and served Control UI run with redacted synthetic profiles and before/after media.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the current roster-bootstrap, cache-isolation, projection, and UI refresh work, and prior merged session-roster history also attributes substantial work to Peter Steinberger. (role: recent area contributor; confidence: high; commits: 96e5796c7afc, ce96f3281df0, b0e8a985ee11; files: src/gateway/session-utils-list.ts, src/gateway/server-methods/sessions-read.ts, ui/src/lib/sessions/session-roster-refresh.ts)
  • RoboClaw: Feature history identifies the prior merged owner-first roster implementation as the foundation this PR consolidates. (role: feature introducer; confidence: medium; commits: b0e8a985ee11; files: ui/src/lib/sessions/session-roster-refresh.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the required checks finish on the final mergeable head and recheck the resulting merge ref.

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 (2 earlier review cycles)
  • reviewed 2026-08-26T18:41:03.430Z sha fe25350 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-26T19:23:55.109Z sha fe25350 :: needs maintainer review before merge. :: none

@steipete steipete self-assigned this Aug 26, 2026
Scope cached projections to the authenticated viewer, apply startup admission
consistently, and preserve the independent owner and shared preview budgets.
Regenerate the Swift client and document the bootstrap and cursor contract.
Publish Gateway test configuration atomically to remove the deferred-reader race.

Co-authored-by: Amp <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: L and removed size: M labels Aug 26, 2026
@steipete steipete changed the title improve(ui): load session roster with one bootstrap request perf(ui): bootstrap session rosters in one request Aug 26, 2026
@steipete
steipete merged commit a482a50 into main Aug 26, 2026
218 checks passed
@steipete
steipete deleted the perf/session-bootstrap-rpc branch August 26, 2026 21:34
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
* perf(ui): collapse session roster bootstrap RPCs

Amp-Thread-ID: https://ampcode.com/threads/T-01a037b3-be95-76ea-8fb3-75979929acf1

* fix(gateway): isolate and bound session roster bootstrap

Scope cached projections to the authenticated viewer, apply startup admission
consistently, and preserve the independent owner and shared preview budgets.
Regenerate the Swift client and document the bootstrap and cursor contract.
Publish Gateway test configuration atomically to remove the deferred-reader race.

Co-authored-by: Amp <[email protected]>

* test(gateway): extract session roster cache fixtures

---------

Co-authored-by: Amp <[email protected]>
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 maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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.

2 participants