Skip to content

perf(ui): defer startup error graph and rich toast styles - #193385

Merged
steipete merged 7 commits into
mainfrom
solid2/w-startup-error-graph-1105
Nov 5, 2026
Merged

steipete merged 7 commits into
mainfrom
solid2/w-startup-error-graph-1105

Conversation

@steipete

@steipete steipete commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Connection error handling pulled the full cause-graph formatter and protocol detail registry into the initial Control UI bundle. Rich toast styling also loaded before any toast appeared. Related: #192419, #192057.

User Impact

Startup downloads less JavaScript and CSS. Network failures and access guidance remain readable offline. If the lazy toast renderer fails, its message, Retry, and Dismiss controls remain visible instead of collapsing into a blank card.

Why This Change Was Made

Keep a synchronous, redacted connection summary available before optional chunks load, and defer full native error formatting. Preserve the public protocol exports while extracting narrow discriminants and the missing-scope reader. The remaining eager graph came from low-level transports importing a one-line stringifier from the full error module; give that unchanged helper a leaf entry and migrate all three Gateway client callers, preserving the original re-exports.

Load rich toast styles with the existing lazy renderer and retain its minimal fallback layout in startup CSS. Native completion remains owned by the existing pending-request map, so late formatting cannot revive a cancelled request. No new dependencies or user configuration options. No asset caps or baselines are raised.

Evidence

Same-machine production builds compare ef81b2545c8c with this head, with build metadata pinned identically. The strict base comparison passes. The full error-graph module is absent from the initial chunk; only its one-line coercion leaf remains there.

Gzip surface Base Head Change
Startup JS 92,477 B 90,564 B −1,913 B
Startup CSS 36,982 B 36,279 B −703 B
Startup requests 3 JS / 1 CSS 3 JS / 1 CSS unchanged
Total CSS 323,518 B 322,815 B −703 B
Chat boot JS 1,287,334 B 1,286,923 B −411 B
New boot JS 800,345 B 800,201 B −144 B

The absolute total-CSS and route caps already failed on the base. All these surfaces shrink; no cap or baseline was raised. Startup JS also returns below its absolute enforcement limit.

All 360/360 observations passed: 20 interleaved base/head/A–A sets for cold and warm boot at local, 100 ms, and 250 ms latency. Headless Chromium used production bundles, a synthetic Gateway, and renderer thread CPU counters. Warm boot is a same-context reload; request routing disables HTTP cache, so this is application-state warmth rather than an HTTP-cache benchmark.

Readiness, median / p95 ms Base Head A/A control
cold-boot / localhost 451.6 / 549.7 448.7 / 463.8 453.9 / 474.1
cold-boot / rtt-100ms 958.2 / 982.7 954.8 / 980.3 960.3 / 973.8
cold-boot / rtt-250ms 1852.2 / 1874.5 1854.0 / 1871.1 1852.1 / 1881.0
warm-boot / localhost 302.3 / 325.2 303.6 / 329.2 305.2 / 370.7
warm-boot / rtt-100ms 740.7 / 788.5 742.9 / 764.4 742.9 / 778.8
warm-boot / rtt-250ms 1621.5 / 1632.1 1624.9 / 1682.3 1620.6 / 1643.4

Readiness medians move by at most 0.5%. Warm local p95 moves +1.2% and warm 250 ms p95 +3.1%; the unchanged local A/A control moves +14.0%, demonstrating host noise. Per the noisy-host rule, the CPU and structural evidence qualify the result: head/base median script CPU ranges −1.0% to +2.1%, median task CPU −1.5% to +0.7%; no CPU cell approaches the 5% band. Warm 250 ms script/task p95 improve 3.5%/2.1%. Startup request counts remain unchanged. This is a byte reduction with readiness preserved, not a claimed latency speedup.

Validation: UI typecheck; scoped lint/format; controller guard; production Knip; normalization package build; 42 error-formatting tests, 34 native authorization tests, existing failed-import toast recovery, the real-browser fallback-layout regression, 86 normalization/request/handshake assertions, and 44 Vite-config assertions. The browser regression initially failed at Vitest mock setup; it now throws from the isolated renderer and passes, while the existing Node test and production capture cover actual chunk rejection.

The before/after screenshots use only synthetic data, in headless Chromium at 1440 px and 390 px. Normal toast geometry is unchanged. Offline fallback height changes from a blank 24 px card to a readable 52 px card; dismissal works and no page errors occur. Captures block both the toast chunk and the stale-asset HEAD probe to represent an actually offline browser.

Touched-file LOC: production 8,173 → 8,244 (+71); tests 2,589 → 2,689 (+100); tooling/config 8,686 → 8,716 (+30). Most CSS moves unchanged. In the two touched Solid views: effects, cleanup hooks, listeners, DOM queries, flushes, and owner APIs remain 0 → 0; memos remain 5 → 5 and lazy boundaries 1 → 1.

CSS attribution

The historical 2.8 KB growth spans components (~1,226 B gzip, including ~808 B of toast rules), mobile layout (~683 B), base styles (~558 B), and controls. Substitution estimates are not additive. Mobile header and control styles are needed for first paint; this change defers the rich toast subset. All 716 inspected selector/declaration entries remain represented.

Before: desktop synthetic toasts

After: desktop synthetic toasts

Before: desktop offline renderer fallback

After: desktop readable offline fallback

Before: mobile synthetic toasts

After: mobile synthetic toasts

Before: mobile offline renderer fallback

After: mobile readable offline fallback

CI and review

Independent review covered the full change and each substantive follow-up, with no remaining P0–P2 findings. CI caught missing canonical/wrapper inventory entries after moving the stringifier, a missing severity in the browser fixture, and two stale fixture assumptions. These are fixed: the toast fixture stays within its original line allocation, phone-session rows use equal fixed timestamps, and the browser-config test selects a named normal Chromium file instead of filesystem discovery order.

Additional focused proof: coercion guard and affected test-typecheck; 23 wrapper-closure assertions; the 16 provisioning cases initially failing in CI; 40 session-view tests; seven browser-config tests. The production bundle is unchanged by these test/tooling follow-ups.

A separate Darwin-only provisioning test (materializes full cold/warm PR siblings, then preserves native sparse transitions) timed out at its existing 120-second limit both on this change and untouched base ef81b2545c8c. That remains recorded as a failed local check; no timeout was raised.

CI run 42016335435 completed with 137 successful jobs, 20 skipped jobs, and two failed test jobs plus the aggregate gate. The Gateway case preserves restricted Goal returns and cancels revoked returns before further effects reproduces with the same assertion on untouched base ef81b2545c8c; its test and policy inputs also match the actual CI base and tested merge.

The initial Incognito timeout passed on the one CI retry, as well as focused local runs on the original base, actual CI base, and PR head. That retry exposed a different failure: Slack inline identity exhausted its existing 30-second assertion window while its in-process Gateway spent 28 seconds loading the persisted-history adapter. Prepare that adapter after fixture seeding, before Gateway startup. This test-only change does not start a worker/read a database early, send a warm-up RPC, or change assertions/timeouts. Its focused test, matching test typecheck, lint, formatting and independent review pass. Final exact-head CI run 42024449568 completed with 139 successful jobs and 20 skipped. Both real-Gateway shards (including Slack and Incognito), all remaining UI checks, and security-fast passed. The only test failure is the exactly reproduced inherited Gateway assertion above, plus its aggregate gate. Landed through native inherited-failure recovery as dfbd7d5cc2f3b258a9a2cc2233c8d5863c6e5d65, with current checkout, unchanged-input, and baseline evidence; failed CI is not described as green.

Keep redacted connection summaries and scope guidance available when optional chunks cannot load. Preserve protocol exports through narrow error modules, and retain a visible toast fallback with Retry and Dismiss while deferring the rich notification styles.
Move the unchanged error stringifier to a leaf module and retain its existing exports. Narrow startup consumers so the full cause graph no longer shares the connection entry chunk, and preserve scope recovery wording without allocating a lookup map.
@steipete steipete added the ci:full Keep ordinary native-locale CI selection on the next PR run. label Nov 5, 2026
@clawsweeper

clawsweeper Bot commented Nov 5, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 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-11-05T12:09:58.851716Z 11e91cd 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 gateway Gateway runtime scripts Repository scripts size: XL labels Nov 5, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 5, 2026
@steipete
steipete enabled auto-merge (squash) November 5, 2026 10:15
@clawsweeper

clawsweeper Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR defers detailed connection diagnostics and rich toast styles while preserving readable offline recovery controls.

Example: The production Control UI cannot download the toast renderer while offline.

  • Before: A blank toast card hides the failure and recovery controls.
  • After: The card displays “Couldn’t load this panel.” with Retry and Dismiss controls.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful and visibly demonstrated UI work, blocked by two concrete omissions in the shared-helper cutover.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (screenshot): Inspected production Chromium before/after screenshots demonstrate preserved desktop toast appearance and a readable offline renderer-failure surface; the supplied build and browser measurements support byte reduction without claiming live Gateway latency improvement.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: The first Control UI load downloads optional diagnostic code and rich notification styles before they are needed.
Reason: The maintainer-authored direction has measurable byte savings, preserves established presentation contracts, and adds no user setting.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep this PR open: the startup reduction is useful, but extracting the stringifier breaks PR-tooling bootstrap and leaves the coercion guard registered against its old location.

Priority: P2
Reviewed head: e4221606ded9e1120aa579dcaf53e273bb6a7c2f

Before merge

  • Include the extracted stringifier in the PR wrapper inventory (P1) - The retained error-coercion entry now unconditionally imports stringified-error.js, but scripts/pr-lib/wrapper-components.txt includes only the former module. Trusted wrapper extraction therefore omits the new dependency and fails before lease/bootstrap work can start. Exact-head eager-import-closure CI records both the missing inventory entry and the resulting Cannot find module failure. Add packages/normalization-core/src/stringified-error.ts to the existing inventory.
  • Move the canonical coercion registration with the declaration (P2) - The guard still registers toStringifiedError as a function declared in error-coercion.ts. Its replacement re-export is ignored by the direct-declaration/export audit, while the actual declaration in stringified-error.ts has no registered owner. This causes banned-declaration and stale-registration failures, matching the failing coercion-helpers check. Move the helper's owner registration to the new leaf and include that leaf in the canonical module audit without weakening the guard.

Findings

  • [P1] Include the extracted stringifier in the PR wrapper inventory — packages/normalization-core/src/error-coercion.ts:2
  • [P2] Move the canonical coercion registration with the declaration — packages/normalization-core/src/stringified-error.ts:2-3
Agent review details

How this fits together

The Control UI converts Gateway and browser failures into redacted messages; its existing lazy toast renderer presents notifications, while shared normalization helpers also serve extracted maintainer tooling.

flowchart TD
  A[Gateway and browser failures] --> B[Connection summary]
  B --> C[Immediate redacted guidance]
  B --> D[Lazy detailed formatter]
  E[Toast owner] --> F[Lazy renderer and rich styles]
  E --> G[Eager recovery controls]
Loading

Technical review

Best possible solution:

Retain the leaf extraction and existing UI owners, then update the wrapper inventory and canonical-helper registrations together.

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

Source inspection establishes both incomplete cutovers, and exact-head CI independently records the extracted-wrapper module failure; no local execution was performed.

Is this the best way to solve the issue?

Deferring optional diagnostics and styles through existing owners is appropriate, provided the helper move also updates its extraction and guard consumers.

Full review comments:

  • [P1] Include the extracted stringifier in the PR wrapper inventory — packages/normalization-core/src/error-coercion.ts:2
    The retained error-coercion entry now unconditionally imports stringified-error.js, but scripts/pr-lib/wrapper-components.txt includes only the former module. Trusted wrapper extraction therefore omits the new dependency and fails before lease/bootstrap work can start. Exact-head eager-import-closure CI records both the missing inventory entry and the resulting Cannot find module failure. Add packages/normalization-core/src/stringified-error.ts to the existing inventory.
    Confidence: 1
  • [P2] Move the canonical coercion registration with the declaration — packages/normalization-core/src/stringified-error.ts:2-3
    The guard still registers toStringifiedError as a function declared in error-coercion.ts. Its replacement re-export is ignored by the direct-declaration/export audit, while the actual declaration in stringified-error.ts has no registered owner. This causes banned-declaration and stale-registration failures, matching the failing coercion-helpers check. Move the helper's owner registration to the new leaf and include that leaf in the canonical module audit without weakening the guard.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7ec1d3e861ce.

Provenance checked

  • Shared stringifier ownership keeps the original intent (964c8c8: Consolidate equivalent coercion helpers under one canonical owner and enforce their declaration boundaries.)
  • Readable programming errors and scope guidance keeps the original intent (fix(ui): show readable errors instead of programming errors #191192: Hide programming defects behind readable fallback text while retaining actionable network errors and diagnostics; the subsequent scope formatter adds accurate access guidance.)
  • Toast lanes and presentation keeps the original intent (improve(ui): stack toasts in a center lane and an arrivals lane #192014: Preserve multiple notifications in separate feedback and arrival lanes with accessible dismissal and paused timers.)
  • Native authentication completion keeps the original intent (28e16ee: Reuse the native app's approved identity while preserving request, document, and authorization ownership.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm check:coercion-helpers
  • pnpm test test/scripts/check-coercion-helper-declarations.test.ts test/scripts/check-coercion-helper-declarations.io.test.ts
  • pnpm test test/scripts/eager-import-closure.test.ts test/scripts/pr-wrapper-source-closure.test.ts
  • git diff --check

What I checked:

Likely related people:

  • Vyctor H. Brzezowski: Raw commit 98561a5 adds ui/src/lib/toast-host.tsx:17 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 98561a57a6e2; files: ui/src/lib/toast-host.tsx)

PR surface

Source +85, Tests +98, Config +8, Other +2. Total +193 across 31 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 23 530 445 +85
Tests 4 99 1 +98
Docs 0 0 0 0
Config 2 8 0 +8
Generated 0 0 0 0
Other 2 4 2 +2
Total 31 641 448 +193

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test growth Production +71 lines; tests +98 lines The growth supports narrow import boundaries and offline recovery without adding another state owner; the omitted tooling consumers need completion.

Labels

Label changes:

  • add P2: This is a bounded startup improvement with focused tooling repairs and no demonstrated urgent user-facing outage.
  • add merge-risk: 🚨 automation: The new transitive import is absent from extracted PR-tooling sources and produces an observed bootstrap failure.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🐚 platinum hermit and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This is a bounded startup improvement with focused tooling repairs and no demonstrated urgent user-facing outage.
  • merge-risk: 🚨 automation: The new transitive import is absent from extracted PR-tooling sources and produces an observed bootstrap failure.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🐚 platinum hermit and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

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 November 5, 2026, 5:18 AM ET / 10:18 UTC.

@steipete
steipete disabled auto-merge November 5, 2026 10:22
@steipete
steipete merged commit dfbd7d5 into main Nov 5, 2026
234 of 239 checks passed
@steipete
steipete deleted the solid2/w-startup-error-graph-1105 branch November 5, 2026 12:32
@steipete

steipete commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 6, 2026
…93385)

* perf(ui): defer connection diagnostics and rich toast styles

Keep redacted connection summaries and scope guidance available when optional chunks cannot load. Preserve protocol exports through narrow error modules, and retain a visible toast fallback with Retry and Dismiss while deferring the rich notification styles.

* perf(ui): isolate transport coercion from diagnostic graph

Move the unchanged error stringifier to a leaf module and retain its existing exports. Narrow startup consumers so the full cause graph no longer shares the connection entry chunk, and preserve scope recovery wording without allocating a lookup map.

* fix(ui): complete startup error leaf integration

* test(ui): keep offline toast fixture within allocation

* test(ui): stabilize phone session fixture ordering

* test(ui): select regular Chromium scope explicitly

* test(ui): prepare inline history adapter before browser 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:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. gateway Gateway runtime scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant