Skip to content

improve(ui): open Activity images faster after idle - #184776

Merged
steipete merged 4 commits into
mainfrom
solid2/w-perf-activity-next-preload
Oct 26, 2026
Merged

steipete merged 4 commits into
mainfrom
solid2/w-perf-activity-next-preload

Conversation

@steipete

@steipete steipete commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Activity preloads New Session code while idle, leaving its image viewer to load only after the user clicks a gallery image.

User Impact

After Activity has been idle, its first image opens about 45% faster at 100 ms HTTP latency. Startup bytes and cold Activity payload are unchanged.

The measured tradeoff is an extra 0.116 ms of action layout work at the median (+8.81%; p95 +0.074 ms/+4.72%). The coordinator accepted that bounded cost: first-open wall time, action task CPU and script CPU improve, and total sampled layout stays neutral. This is not an all-metrics-clean result.

Why This Change Was Made

Add Activity's existing lazy image-viewer entry to the existing navigation preload descriptor. The existing idle owner downloads the viewer instead of falling back to New Session; module evaluation and styles still wait for the click. No new loader, cache, dependency or lifecycle owner.

The benchmark adds synthetic empty/gallery Activity states, native image/Escape checks, immediate and warmed first-open measurements, and separate idle/preload-verification CPU phases. The separation prevents descriptor polling from being counted as idle work.

Evidence

Frozen production comparison: 2988b14f22e6 → bb013a233608. Original published source head: df6684f28b00; its later commit adds only the benchmark and fixture. Replacement head: 71f6d6b18d36, merged with main cd3bcc017653 and the two reviewed test corrections. The nine reviewed scheduling sources and package inputs are byte-identical to the validated correction; no new runtime measurement is claimed for the updated main context. Timing uses the identical reviewed Activity observer from c71833910666, transplanted into the final benchmark with newer-main Apps/Dock handling preserved.

Surface / phase Before After
Startup JS gzip / requests 271,119 B / 5 271,119 B / 5
Startup CSS gzip / requests 31,981 B / 1 31,981 B / 1
Activity cold JS, raw / wire 4,036,852 B / 1,131,602 B unchanged
Idle JS, wire / requests 84,618 B / 6 13,600 B / 2
Idle CSS, wire / requests 8,071 B / 2 1,876 B / 1
Warm click JS, wire / requests 13,600 B / 2 0 B / 0

Remote warmed image opening, pooled 30 interleaved A/A/B triplets (corrected 20 and one confirmation of 10 retained):

Metric Before median / p95 After median / p95 Change median / p95
First image ready 226.65 / 244.50 ms 125.15 / 140.50 ms −44.78% / −42.54%
Action task CPU 32.745 / 34.908 ms 31.560 / 33.808 ms −3.62% / −3.15%
Action script CPU 4.431 / 4.794 ms 4.1965 / 4.675 ms −5.29% / −2.48%
Action layout CPU 1.3105 / 1.568 ms 1.426 / 1.642 ms +8.81% / +4.72%
Sum of sampled task phases 285.768 / 294.557 ms 279.7195 / 298.899 ms −2.12% / +1.47%
Sum of sampled layout phases 13.4075 / 16.333 ms 13.3725 / 14.741 ms −0.26% / −9.75%

The phase sums cover cold, fixed idle, preload verification and click; they are not uninterrupted profiles. Remote HTTP is emulated at 100 ms / 10 Mbps; the synthetic WebSocket is unthrottled. Host load and A/A controls are retained. The corrected 20 and confirmation 10 independently show about 45% faster warm opening. Localhost warm opening improves 1.26% median / 13.46% p95 in the corrected 20-triplet run.

Proof Result
pnpm ui:build, strict performance check, base/head comparison Passed both frozen production revisions; zero startup growth
Production Knip Passed on production head; later benchmark-only commit adds no production caller/export
pnpm tsgo:scripts and scoped format / diff checks Passed once on the final benchmark source
Synthetic browser coverage 12 base/head × local/remote empty-idle, gallery-immediate and gallery-warmed contexts; qualified clocks; actual image readiness and Escape passed
Corrected timing 180 contexts plus the retained original 240; one additional 30-context remote warm confirmation
Confirmation integrity 30/30 clocks passed (max residual 0.461 ms), zero errors, frozen 5,028-file inventories unchanged per variant
Review Production config and observer changes scoped-clean; exact earlier Activity source lineage and final mechanical integration reviewed by coordinator

The original warm-idle CPU sample included descriptor polling and is not reused; corrected phase boundaries provide the warm CPU evidence above. All original raw results are retained.

Immediate-open adverse tails are retained: pooled 30 remote wall p95 is +61.62% and local p95 +9.19%. All 180 immediate actions ended before the earliest possible changed descriptor fetch (at least 62.44 ms before it), using the native idle-runtime completion + 500 ms bound and the gallery button's lack of a direct-intent preload selector. Those tails precede this change's execution; no immediate samples were discarded. Empty-state coverage proves post-idle transfer/non-evaluation and rendering, not that an empty RPC response had settled at the cold-ready cutoff.

The full integration review attempt timed out without a report and is recorded as unavailable, not clean. Review reuse is supported by six actual scoped-clean observer reviews plus the separate production review, exact hashes, and coordinator inspection of the small newer-main integration differences. CI remains the broad proof; request ci:full for the shared preload/overlay path before landing.

CI scheduling corrections

The original df6684f28b00 run (40353585617) failed two UI tests: follows outside layout shifts and a signaled ancestor animation and keeps the preference visible while admitted events update execution metadata. Both exact tests passed in the then-latest completed scheduled main run (40347483110, 496f32bef297). They are not classified as inherited.

The same run also failed persists visible selections and refreshes queued requests on desktop and mobile. It matched the older scheduled-main run 40347483110, but the newer completed scheduled-main run observed at 16:58 UTC, 40352459041 (503bc1bd4499), passes all three exact test names. None is currently classified as inherited. All seven regular Control UI E2E shards, real-Gateway shard 1, security and performance checks passed. The two-file correction below addresses only the source-supported unit-test scheduling issues; it does not establish a fix for the real-Gateway failure. Replacement-head CI must be evaluated separately.

A bounded two-file replay passed 34/34 tests on both the CI base (6a1f6b0c7bc7) and its exact synthetic PR merge (15a91aab7f0d). The original failures did not reproduce; those passes do not establish a repaired root cause, and their durations are not performance evidence.

The test-only correction samples overlay geometry after the animation-frame callback batch and settles Vitest-tracked dynamic imports before asserting queued chat delivery. It preserves the live animation, one-pixel threshold, cleanup checks, delivery payload, held acknowledgement and existing bounded assertion. No production behavior or timeout is changed. The corrected two-file run passed 34/34 once; pnpm tsgo:ui, scoped format and diff checks passed. Independent P0–P2 review found no actionable defects in the two corrections and retained the non-reproduction caveat. Replacement-head full CI run 40368078178 passed on 71f6d6b18d3613c21b004cc4afa7121f1e635e83: 44 successful checks and 25 expected skips, including all three UI unit shards, all seven UI E2E shards, both real-Gateway shards, and openclaw/ci-gate. Observed complete at 2026-10-26 18:05:41 UTC.

These corrections add one line to each existing test file: overlay 395→396 LOC, chat controls 772→773 LOC. The historical Activity performance table above remains pinned to its frozen production comparison; it is not a measurement of newly merged main.

Reproduction and change size

Use frozen base/head production bundles with the committed benchmark:

node --import ./scripts/tsx.mjs scripts/bench-control-ui-route-leaks.ts \
  --bundle-dir BASE_UI --compare-bundle-dir HEAD_UI \
  --routes activity --activity-media gallery \
  --interactions activity-lightbox --mode timing --pairs 20 --profiles local,remote

Separate coverage passes use --mode coverage --screenshots; immediate opening uses --interactions activity-lightbox-immediate; empty idle uses --activity-media empty --interactions activity-idle. The confirmation uses 10 remote-only triplets.

Code Before LOC After LOC
Production preload configuration 107 108
Existing route benchmark 1,767 2,023
New Activity fixture/helper 0 120
Activity production and benchmark subtotal 1,874 2,251
Overlay browser test (current-main baseline) 395 396
Chat controls test 772 773
Full five-file total 3,041 3,420

The full five-file count is verified against merge base cd3bcc017653 and replacement head 71f6d6b18d36. The production change is one line. The benchmark growth supplies the requested reproducible route/interaction workload, raw network cutoffs, clock qualification, and failure evidence; it adds no production state or abstraction. Simplification review retained the existing preload owner and fixture contract and found no smaller complete runtime change.

Before / after gallery readiness (synthetic data):

Activity gallery before
Activity gallery after

Before / after image opening (existing entry animation may be at different frames):

Activity image viewer before
Activity image viewer after

@steipete steipete added the ci:full Keep ordinary native-locale CI selection on the next PR run. label Oct 26, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T17:25:08.435080Z 71f6d6b New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui scripts Repository scripts size: M labels Oct 26, 2026
@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 26, 2026
@steipete
steipete enabled auto-merge (squash) October 26, 2026 16:04
@clawsweeper

clawsweeper Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR preloads Activity’s image viewer during idle time and extends the existing benchmark to measure image opening.

Example: Open the first Activity gallery image after idle with 100 ms emulated HTTP latency.

  • Before: Reported median image readiness is 226.65 ms, with viewer JavaScript fetched after clicking.
  • After: Reported median readiness is 125.15 ms, with no additional JavaScript requests during the warmed click.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, minimal runtime change with production-browser evidence, explicit measurement limits, and no actionable findings; broad CI is still pending.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied frozen production-browser comparison exercises the actual HTTP asset preload owner and native Activity viewer with synthetic Gateway data, reporting completed image readiness, Escape dismissal, zero warmed-click JavaScript requests, and approximately 45% faster remote opening; inspected viewer screenshots corroborate rendering, while timing values remain contributor-reported measurements.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Opening the first Activity image after idle still waits for the image-viewer code to download.
Reason: The maintainer-authored direction delivers a measured remote first-open improvement through one existing extension point and explicitly accepts the bounded layout-cost tradeoff.

Merge readiness

✅ Ready for maintainer review

This PR provides a focused Activity performance improvement using the existing preload owner; no actionable correctness or security defect was found, and required CI remains pending.

Priority: P2
Reviewed head: df6684f28b0026144f73f9281650799e66177b02

Before merge

None.

Findings

None.

Agent review details

How this fits together

The build converts named UI module entries into a hashed asset descriptor, which the existing shell idle owner consumes to prepare browser assets before native image-viewer interaction.

flowchart LR
  A[Build module entries] --> B[Hashed preload descriptor]
  B --> C[Shell idle owner]
  C --> D[Browser asset preparation]
  D --> E[Activity image click]
  E --> F[Lazy image viewer]
Loading

Technical review

Best possible solution:

Retain the single Activity descriptor entry and focused benchmark coverage, then land through the existing required CI gates.

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

Current main’s missing Activity next-interaction entry and the existing New Session fallback establish the source path; the PR supplies a reproducible production-browser comparison, which was inspected without executing target code.

Is this the best way to solve the issue?

The smallest complete runtime change is the added descriptor entry: it prepares the existing viewer through the existing idle owner while preserving lazy evaluation and stylesheet application.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 91fa755ffd6d.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +1, Other +376. Total +377 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 1 0 +1
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 405 29 +376
Total 3 406 29 +377

Review metrics

Metric Value Why it matters
Production versus benchmark growth Production configuration +1 line; benchmark and fixture +405/-29 lines. The runtime change uses the existing owner; benchmark growth supplies distinct empty, immediate, warmed, clock-qualification, and phase-accounting scenarios.
New benchmark option --activity-media empty|gallery The new flag selects synthetic benchmark data and adds no product configuration or persisted preference.

Labels

Label changes:

  • add P2: This improves first image opening on a limited UI surface without an urgent availability or delivery failure.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: This improves first image opening on a limited UI surface without an urgent availability or delivery failure.
  • 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.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 26, 2026, 12:08 PM ET / 16:08 UTC.

@steipete
steipete disabled auto-merge October 26, 2026 17:21
@steipete
steipete merged commit 0c2d51f into main Oct 26, 2026
120 of 121 checks passed
@steipete
steipete deleted the solid2/w-perf-activity-next-preload branch October 26, 2026 18: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 Oct 27, 2026
* perf(ui): preload the next Activity image interaction

* test(ui): measure Activity preload and first-open phases

* test(ui): settle animation and lazy delivery before assertions
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 ci:full Keep ordinary native-locale CI selection on the next PR run. clawsweeper:intake:feature Preliminary submission classification; full source review pending. scripts Repository scripts size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant