Repository navigation
perf(control-ui): remove a transcript readiness round trip - #182846
Conversation
Return an optional initial chat snapshot after observer admission, preserving cursor reads and history retries while removing one sequential round trip from chat startup and session switches.
Initialize presentation code per actual history worker instead of warming only the slot selected by a pool task. Keep database admission in its existing prewarm owner and remove the superseded request flag. Search, projection, and maintenance workers remain lazy.
|
🦞👀 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 real behavior proof before merge. What this changesThis PR returns initial chat history with message-subscription admission and prepares each foreground history worker. Example: Open agent:main:wire-fixture-b over a 100 ms RTT connection.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 4 items remain Keep this maintainer-authored draft open: the optimization is useful, but the combined response introduces an approval-disclosure regression. Priority: P2 Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherThe Control UI acquires a Gateway message observer, then publishes bounded transcript data through its existing history owner; SQLite transcript workers supply the history. flowchart LR
A[Control UI] --> B[Subscription coordinator]
B --> C[Gateway observer admission]
C --> D[Canonical history reader]
D --> E[Transcript workers]
E --> F[Combined response]
F --> G[UI history owner]
Technical reviewBest possible solution: Keep replay and session-access custody through final publication, recheck disclosure authority after history completes, and release custody afterward. Do we have a high-confidence way to reproduce the issue? Source establishes the serial subscription/history path and the introduced replay-disclosure window; no target code or tests were executed during this read-only review. Is this the best way to solve the issue? Combining admission with the canonical reader is a sound optimization, but moving final publication beyond the existing access lifetime violates its disclosure contract. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f3464c792dbf. Provenance checked
TestingProof path: shipped entry point. SecurityNeeds attention: The combined acknowledgment can disclose approval presentation details after session access is revoked. EvidenceSecurity concerns:
What I checked:
PR surfaceSource +249, Tests +472, Docs +48, Other +326. Total +1095 across 38 files. Added test files: 3. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 24, 2026, 4:22 PM ET / 20:22 UTC. |
Preserve main-owned snapshot retirement and owned serialized buffers while issuing the initial history subscription without waiting for browser storage. Cover delayed storage and a changed cursor through the existing history owner.
Consume the exact full-page subscription receipt when browser storage restores a cursor during admission. Keep cursor-delta mismatches on the current history read path. The regression made two RPCs on the prior head and one with this fix.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 12e339678d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Keep replay and scoped read resources through the canonical history read, recheck disclosure authority before publication, and roll back provisional observers on revoked access. Update CI observers for combined history responses, preserve actual session capability behavior in fixtures, and remove speculative validator prefetch.
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…182846) * perf(control-ui): read initial history with message subscription Return an optional initial chat snapshot after observer admission, preserving cursor reads and history retries while removing one sequential round trip from chat startup and session switches. * perf(control-ui): defer reaction reads until transcript paint * test(perf): bound simulated remote link queues * perf(control-ui): prepare each foreground history worker Initialize presentation code per actual history worker instead of warming only the slot selected by a pool task. Keep database admission in its existing prewarm owner and remove the superseded request flag. Search, projection, and maintenance workers remain lazy. * test(perf): cover authenticated warm boot in wire benchmark * test(perf): count gateway process work through readiness * perf(ui): retain full initial history across cache hydration Consume the exact full-page subscription receipt when browser storage restores a cursor during admission. Keep cursor-delta mismatches on the current history read path. The regression made two RPCs on the prior head and one with this fix. * fix(ui): retain subscription authority through initial history Keep replay and scoped read resources through the canonical history read, recheck disclosure authority before publication, and roll back provisional observers on revoked access. Update CI observers for combined history responses, preserve actual session capability behavior in fixtures, and remove speculative validator prefetch. * chore(ui): attach history safety invariant to assertion
) The Control UI mock Gateway answered sessions.messages.subscribe with only the canonical key, even when the request asked for initialHistory. Since #182846 the real Gateway returns the initial transcript inside the subscription reply, so the fixture forced a fallback chat.startup round trip that production no longer makes. Every reload benchmark and browser test therefore measured an outdated request chain. The mock subscription now builds initialHistory from the existing startup-response owner when requested, matching the Gateway contract. Scenarios that exercise the separate chat.startup fallback opt in with subscriptionInitialHistory: false. Browser tests wait on subscription readiness instead of the removed standalone history request, and the warm-reload probe recognizes the subscribed-history transport. Test and tooling only; no runtime code changes. Exact-head CI green; focused fixture and probe tests plus native e2e of the rebased files pass; full AWS UI suite earlier: 3,275 passed, 2 failures reproduced on main.
…claw#183832) The Control UI mock Gateway answered sessions.messages.subscribe with only the canonical key, even when the request asked for initialHistory. Since openclaw#182846 the real Gateway returns the initial transcript inside the subscription reply, so the fixture forced a fallback chat.startup round trip that production no longer makes. Every reload benchmark and browser test therefore measured an outdated request chain. The mock subscription now builds initialHistory from the existing startup-response owner when requested, matching the Gateway contract. Scenarios that exercise the separate chat.startup fallback opt in with subscriptionInitialHistory: false. Browser tests wait on subscription readiness instead of the removed standalone history request, and the warm-reload probe recognizes the subscribed-history transport. Test and tooling only; no runtime code changes. Exact-head CI green; focused fixture and probe tests plus native e2e of the rebased files pass; full AWS UI suite earlier: 3,275 passed, 2 failures reproduced on main.
What Problem This Solves
Remote chat reloads and session switches waited for a message-subscription acknowledgment before issuing the initial transcript request, adding a full network round trip.
User Impact
The initial transcript arrives with the subscription acknowledgment. Live events remain covered by the admitted observer, and history failures retain the subscription and use the existing retry path.
Why This Change Was Made
The Gateway accepts an optional
initialHistoryrequest onsessions.messages.subscribe, registers the observer first, and invokes the canonicalchat.startupreader. The UI consumes that one-shot result through its existing history owner, including the exact cached cursor/state revisions and stale-result checks. Existing clients omit the new field and retain their response shape; the wire protocol remains v4. The UI and Gateway ship together.Approval-enabled subscriptions keep their scoped read, replay, and session-access authority through history preparation and recheck immediately before committing the observer and publishing. The provisional observer already delivers events, so revocation can roll it back without leaving an unowned subscription. History read failure alone still returns a retryable history receipt with the authorized observer.
Snapshot restoration stays independent of subscription setup, which never waits for IndexedDB. The optional speculative validator prefetch was removed to retain the existing loader ownership and import budget. A full page requested before storage settles already covers a subsequently restored cache: the history owner consumes it under the original exact request parameters. Delta requests still discard mismatched cursor/state receipts and issue a current history read. A late stored snapshot cannot replace live history. Automatic reaction baseline reads wait for transcript readiness, using the existing hydration callback; live reaction events and writes remain immediate. HTML retains its existing
private, no-storebootstrap contract. The transport requiresconnectas the first frame and admission before ordinary requests, so pre-connect pipelining cannot remove that exchange. HTML contains the current authority-scoped bootstrap preferences and plugin grants, so this change retains its existing cache contract rather than splitting them into another fetch.Config reads, snapshot validation, and session resolution overlap this authenticated warm path. Composer readiness retains three client-initiated exchanges plus a server push; combining history does not remove a composer dependency.
The first cold read exposed a separate pool issue: the existing prewarm task prepared only whichever history worker accepted it. A later request could select the other foreground worker and spend over a second loading presentation modules. Each existing foreground worker now prepares that same module group at startup, including replacement workers. Database admission stays in its existing prewarm owner; search, projection, and maintenance workers retain their lazy graphs. The existing two-worker foreground pool and its capacity are unchanged; preparation now follows each worker's lifetime.
Evidence
Rerunnable workload (both source checkouts detached, with their built bundles; output outside either repository):
Repeat with
--profile local; use the same base revision on both sides for the A/A control. Final-head functional checks omit the two comparison arguments and use--pairs 1. The committed benchmark guide describes the fixture and counters. The integrated byte check waspnpm ui:check-performance:base db9330ab86addb6d08d0b0679f9b05b0122ad2bd.Acceptance rule: five base/base A/A pairs, then ten interleaved base/head pairs per profile (twenty when the A/A timing control falls outside the band), median and nearest-rank p95; remote profile is 100 ms RTT / 10 Mbps. Target: 30% lower remote warm transcript/composer medians. Local median regression must stay within 5% with no worse p95. When the A/A control falls outside the timing band, judge twenty paired samples with renderer thread CPU and structural counts; also report Gateway-process CPU and readiness RSS with their A/A variability. The final workload uses synthetic token authentication on both sides and waits, outside timed intervals, for the real app-written boot record and persisted transcript cursor. Earlier auth:none diagnostics are excluded from the final cohort; this is not a direct timing comparison with #182752.
The final five-pair A/A control and 20 interleaved base/head pairs per profile are complete. The A/A timing control missed the band, so CPU and structural counters are reported alongside all timings. The additional continuous CPU diagnostics below report the work overlapping each action; all original samples remain included.
The timing table describes the pinned pre-integration
1d9da0d/d879c6esource pair, not the final integrated head. Measurements use 20 serial interleaved pairs per profile and a five-pair A/A control. Values below are median / nearest-rank p95 [min–max], in milliseconds unless marked MiB. Renderer counters use thread CPU time.The −30% remote warm-readiness target was not reached: transcript improved 3.4%, composer 6.1%, and session-switch transcript 13.8%. Localhost switch transcript improved 26.5%; warm transcript stayed nearly flat and warm composer median increased 5.3%. The A/A control itself missed the timing band. During localhost measurement, host load reached 79.1 and one cold candidate took 48.6 seconds; all samples remain included. These wall timings are not treated as clean-host latency guarantees.
CPU, RSS, and control details
Gateway-process CPU includes its worker threads and the Node benchmark/proxy, measured through the driver readiness assertion; it excludes Chromium and the post-ready tail. It is not whole-session CPU. The original remote switch window increases 193.1%; the independent continuous/task-labelled investigation is reported below. Its exact historical cause remains unknown because that cohort did not record worker tasks.
RSS is a snapshot at readiness, not peak memory or a retention proof. The A/A control has substantial process-CPU drift even for identical sources. Renderer CPU and structural counts are the primary checks under the noisy-host rule. The additional process-CPU investigation below retains the original increase and separates observed work from inferred attribution.
Measured source pair: base
1d9da0d5dce9ea92065015cb5de0671d2e68db8b, headd879c6ec8d57ed753582f63c932ccddcbb516295. Subsequent integration throughdb9330ab86addb6d08d0b0679f9b05b0122ad2bdincludes other lanes’ startup, canonical history, transcript-storage, and virtualizer changes. These timing cohorts describe their pinned source pair; final integrated build checks and bounded smoke are recorded separately. The initial integration checkpoint was7505f76b6fd181404e77fe4017763d05f0533ee5; a final functional trace found and reproduced the late-cache full-page race, which the history owner now handles without another read in12e339678d673ed752a1fd40529e3b916e86714b.Additional CPU attribution (diagnostics, not a replacement timing cohort): four counter-only captures in base/head/head/base order include New Session, return to A, switch to B, and a one-second tail. Continuous process CPU was 2,047 / 708 / 2,090 / 1,951 ms, respectively; main-thread CPU was 298 / 298 / 326 / 433 ms. The large same-head variation demonstrates why short readiness windows cannot isolate this request’s CPU.
A separate task-labelled base/head pair records identical work: 39 tasks from setup through the tail, 10 during the measured sequence, the same task-kind counts, 84 trace events each, and zero drops. No worker starts inside the window. Head’s two eager-prewarm workers already existed about 33 seconds before New Session. Continuous process CPU falls 1,336 → 1,137 ms, main-thread CPU 373 → 338 ms, and switch-window process CPU 442 → 314 ms. The worker observed serving the RPC history task uses 54 → 8 ms sampled switch CPU (it also serves reactions, pending inputs, and progress; this is not exclusive RPC CPU).
The task trace independently identifies a non-history
session-exact-entriesread overlapping switch readiness and continuing into the tail. Its worker’s sampled continuous CPU increases 246 → 298 ms while history-serving worker work falls. Native/nested/untracked CPU remains separate. These captures establish equal task counts, lower repeated history-serving work, and substantial background overlap; they cannot retroactively identify the exact cause of the original 193% process-window increase. No profiler is activated by these counter/task captures; product-owned automatic stall profiling may run independently. The instrumented all-isolate profiles were used only for exploration because their overhead changes scheduling.The remote-link simulator was corrected before the accepted cohort: it now bounds each shared-bandwidth direction, rotates active flows in 16 KiB turns, overlaps propagation, honors backpressure, and drops cancelled flow reservations. The previous unbounded future reservations could make a cancelled speculative preload delay the next navigation. A real TCP half-close test and four shaping/cancellation tests pass; all accepted base/head measurements use the same corrected instrument.
Final matched builds at
1cb20e1b5258d68b7009c8fa1550feb8fc405f57against basedb9330ab86addb6d08d0b0679f9b05b0122ad2bduse one Node 26.12.1 / Vite 8.3.4 / Pako 3.0.2 toolchain and fixed build identity. Startup is 281,207 → 281,247 B gzip (+40 B), seven JavaScript requests and one CSS request on both sides. Chat boot is 1,270,847 → 1,271,383 B (+536 B) with 19 JS / 3 CSS requests; New Session is 766,679 → 766,731 B (+52 B) with 16 JS / 3 CSS requests. Startup and New Session movement stays inside the 64 B build-variance allowance; the roughly half-KiB Chat increase accompanies one fewer serial history exchange. Strict base-relative comparison and verification of 2,322 finalized precompressed sidecars pass. Main's committed startup baseline remains unchanged at 281,702 B. All CSS is byte-identical; the absolute-only total-CSS ceiling remains exceeded on both sides (303,561 B versus 303,372 B), with zero growth and no allowance change.The worker initialization and custody checks pass 47 tests across three files; the new foreground-startup case fails on the previous worker source. The reaction owner suite passes 13 tests and post-transcript hydration passes seven on the integrated source. The actual-request reaction regression is red on the base and green with the guard. UI and core typechecks passed at
1cb20e1; the latest merged-head core type exception is recorded below. The later CI repair also passes focused lint, the assertion-safety and manual-import ratchets, the mock-export guard, the line-cap ratchet (38 changed source files), and the zero-cycle import check. Four real-Gateway observers now recognize bundled history while retaining transcript, cursor, recovery, and readiness assertions; the selected-agent fixture uses the real session capability. After integrating main’s nonblocking cache restoration and owned-buffer serialization, the 27-test warm-startup file, five history-issuance tests, and 15 serialization/transport tests pass. The first added lazy-import assertion raced module loading; it now waits for the observable request while storage stays unresolved.Focused proof: UI history issuance regression fails on the base and passes with the change; SDK one-shot ownership tests, protocol schema rejection, observer-before-history/failure tests, raw nested-array serialization, UI typecheck, scoped lint, and native protocol determinism pass. Production Knip was run on the integrated head and exact base
db9330ab86addb6d08d0b0679f9b05b0122ad2bd: both fail with the same four unused files:protocol-validator-schemas.ts,mcp-app-standalone-host.ts,repository-node-requirement.ts, andsrc/sessions/runtime-context.ts. No ignore or allowance was added.Independent Codex review: the full change, reaction scheduling fix, worker initialization, and measurement additions have no actionable P0–P2 findings; fresh full candidate review against integrated main completed in two isolated passes with no actionable P0–P2 findings. Review caught an event-triggered baseline read bypass in the first scheduling fix; the central owner now gates it. A subsequent hosted P1 found premature approval-authority release before initial history; the repair retains and rechecks that authority through publication. Its focused regression reaches the real history reader and is red on the previous handler.
pr-simplify: the existing history owner still owns retries and publication; the subscription coordinator retains only the observer, not a reusable history snapshot.LOC before/after across final changed files against the integrated base: production 7,923 → 8,151; tests 6,081 → 6,849; benchmark 1,196 → 1,522; protocol docs plus benchmark guide 1,002 → 1,050. The startup baseline remains unchanged from main. Generated validator output 23,052 → 23,071 lines; generated identifier renumbering accounts for the larger diff. Across the eight touched UI production files, the refactor census is 0 → 0 for rendering controllers, effects, render effects, untrack, DOM listeners/queries, flush, and owner APIs. No view owner is added.
Final functional smoke uses clean committed head
1cb20e1b5258d68b7009c8fa1550feb8fc405f57, one run per profile. These runs verify readiness and wire counts; they are not a new timing cohort. The local trace before the final repair made one subscription plus one redundant startup request on warm reload; the final local and remote traces make one subscription and no standalone history request.1cb20e1, local and 100 ms RTT / 10 Mbps, synthetic token authBefore (synthetic token-authenticated warm reload):
After (same synthetic conversation):
Final integration head
ed949658241b909f558ac8835b57a9d27a7ee929merges main8e7fedfafter a real conflict in the subscription handler. The resolution retains main’s synchronousrespondErrorhelper and the reviewed history/replay-authority lifetime. Both subscription suites pass all 12 cases, UI types and production Knip pass, and a fresh two-pass isolated review is clean. Earlier build, functional and timing numbers remain pinned to their stated revisions. The stable final tree is clean; Knip reports no findings on both final head and exact base.Full CI 40150818384 completed all 98 jobs: 76 passed, 19 skipped, and three failed. All UI, real-Gateway, PostgreSQL, lint, ratchet and
security-fastjobs passed. The only root failures arecheck-prod-typesandcheck-test-types-core-2; both report exactly TS2739 atsrc/gateway/server-methods/session-catalog.test-helpers.ts(122,5)(missingminProtocol,maxProtocol,client). The aggregateopenclaw/ci-gatefails from those two roots. This exact diagnostic also fails in latest completed scheduled main 40149301577 and was reproduced locally on exact base8e7fedf. The CI checkout is4e30f074, merging this PR head intod2af8361; its ordered parents and tree are verified, and all seven relevant helper/type/config inputs are unchanged. Landing uses the native inherited-failure recovery; CI is not represented as green.