Skip to content

perf(control-ui): reduce forced layout during cold reloads - #169288

Merged
steipete merged 4 commits into
mainfrom
steipete/coldload-forced-layout
Oct 12, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/coldload-forced-layout

Conversation

@steipete

@steipete steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A signed-in reload of a dashboard deep link repeatedly forces layout while scroll indicators, sidebar state, and the divider update. The campaign trace recorded 122 forced layouts and 658 ms of total layout in the first 4.5 seconds.

User Impact

Less synchronous layout work during reload, with the existing scroll fades, resize gestures, divider persistence, and transcript anchoring retained. No configuration, server records, or migrations change.

Why This Change Was Made

One ResizeObserver now serves scroll-state directives and sidebar classification. It shares the existing marquee read/write batching pattern through a common frame owner: all geometry reads finish before changed state is published. The sidebar geometry commit joins that batch. This removes per-directive microtasks/observers, the duplicate sidebar classifier, and separate marquee/sidebar frame queues. The observer is released when its last subscriber disconnects.

The divider renders its supplied ratio and measures for user interaction. Transcript rendering uses the already-owned scroll margin; initial viewport measurement, prepend anchoring, and end-follow retain their existing timing. This is a bounded improvement, not a claim that all transcript geometry reads are gone.

Evidence

Exact comparison: base d220cac2b74433fdb189ac381b9fca2bfcaf7e07, head 54e3646ad3843fed2e31c2d9e17ba350ed41edc3. Three new headless Chrome reloads per revision, first five seconds after navigationStart. Synthetic source-Vite/mock-Gateway fixture: 100 messages, 80 supplied sessions (10 initially visible), an empty Dashboard side panel, one paused goal, and 2,043 DOM elements. A Layout event with a JS stack counts as forced.

Median Before After
Forced layouts 57 31
Forced layout duration 105.997 ms 69.191 ms
All layouts 69 47
All layout duration 107.784 ms 82.130 ms

These are comparative synthetic measurements, not deployed Team timings. Inspected before/after screenshots retain the same layout and transcript end position; no private captures were uploaded.

The scroll batching regression fails against the original interleaved microtask reads/writes. The divider regression fails against its original render-time measurement. Existing lifecycle tests exposed and verified idle-observer retirement. Single-file wall times with the pnpm test runner (node scripts/run-vitest.mjs <file> --maxWorkers=1): scroll state 2.34 s, divider 3.64 s, sidebar lifecycle 4.46 s, sidebar interactions 8.54 s, progress card 2.83 s.

Focused Testbox proof (tbx_01m4p2jt4sypa9app86hstgj7z) passed, including 33 browser assertions for marquee lifecycle, transcript geometry and end-follow. Autoreview is clean at P0–P2. The full UI E2E suite ran on the final head on AWS (cbx_562afe011595): 694 files passed, 48 failed, one skipped; 3,282 assertions passed, 83 failed, three skipped. Missing Playwright FFmpeg caused most failures. After installing the pinned browser/video prerequisite, the failed-file replay passed 147 assertions and left 17 failures. All 17 reproduce on the exact main-base source, with the PR source restored afterward. The lane's spatial fades, panel geometry/persistence, width-resize anchoring, reasoning follow, and dashboard first-paint cases pass.

The exact-head CI run is red on the inherited model-catalog error-copy assertion (model-provider-usage-outcomes.e2e.test.ts), and fail-fast cancelled remaining jobs. Its fixture rejects discovery with “Model catalog temporarily unavailable”; the assertion expects the generic successful-partial-discovery warning. The same failure is confirmed on the base. Other baseline failures are listed below rather than hidden by retries or changed assertions.

Full-suite baseline failures and validation limits

All remaining failed assertions reproduce on the base: automation private-path permission admission (1); cached cold-load anchor (1); saved-reader restoration (1); history hydration (1); history prepend controls (2); retained-table overflow (1); split-rail Escape dismissal (2); rail Escape dismissal (2); scroll affordance (1); subagent waiting state (1); external session history/paging (3); model catalog copy (1).

An extra whole-UI unit/browser run passed 21,900 assertions, with one menu hit-test failure and a terminal test collection error. The terminal's repository-relative file path fails from the package working directory on the base too. The menu hit-test passes in isolated execution on both the base and the PR head; its full-suite ordering issue is not root-caused here.

The unfiltered changed-file gate reaches an inherited dead-export audit failure, reproduced on the base. All remaining changed-file gates passed in 5m45s on the exact head with OPENCLAW_CHECK_CHANGED_SKIP_DEADCODE=1, scoped to that reproduced baseline failure. The asset budget also reports 36 chat requests against a limit of 35 on both base and head. Regenerating the boot manifest still reports 36 and mostly changes unrelated migration entries; that generated churn is not included. No budget threshold is relaxed.

Production delta: +222 / −151 = +71 LOC across 10 production files. The requested exclusion-based diff also counts two net lines in the sidebar test helper (+73 total). Growth pays for the shared subscription/disconnection owner and frame scheduler while deleting the superseded queues and classifier.

Before: exact-base synthetic dashboard reload

After: exact-head synthetic dashboard reload

@clawsweeper

clawsweeper Bot commented Oct 11, 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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR batches Control UI geometry measurements and reuses transcript margins to reduce forced layout during reloads.

Example: Reload the synthetic Dashboard split containing 100 transcript messages and a paused goal.

  • Before: The supplied Chrome comparison reports a median of 57 forced layouts.
  • After: The same fixture reports 31 forced layouts.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful browser-supported optimization with one unresolved accessibility defect.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (screenshot): The supplied exact-base/head Chrome comparison exercises the actual Control UI through source Vite with a synthetic mock Gateway, transcript, Dashboard split, and paused goal; inspected before/after screenshots preserve presentation, and the recorded measurements show reduced forced layout.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Signed-in Dashboard reloads repeatedly force synchronous browser layout, delaying rendering.
Reason: The maintainer-authored direction has comparable browser measurements and consolidates existing geometry work without adding settings or persistent state.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR open: the measured reload optimization remains useful, but the previously reported separator accessibility regression still blocks merge.

Priority: P2
Reviewed head: 54e3646ad3843fed2e31c2d9e17ba350ed41edc3

Before merge

  • Preserve accurate separator values for measurement-backed callers (P2) - The previously reported regression remains. chat-sidebar-region supplies splitRatio: 0.5 and obtains the actual split through measureRatio. Publishing props.splitRatio makes a 700px main pane beside a 300px right panel expose aria-valuenow="50" instead of "70". A later label or orientation update can also overwrite the accurate value published during interaction. Carry the actual ratio from the geometry owner or publish a measurement through the shared frame batch, and retain a regression covering that caller without restoring synchronous render-time reads.

Findings

  • [P2] Preserve accurate separator values for measurement-backed callers — ui/src/components/resizable-divider.ts:207

Tests

  • Missing end-to-end proof: The supplied browser proof establishes the reload improvement; the divider regression needs to cover accurate current values for the production measurement-backed side-panel caller.
Agent review details

How this fits together

Control UI render, resize, and scroll events enter browser geometry owners, which publish overflow indicators, sidebar presentation, panel geometry notifications, and transcript offsets.

flowchart TD
  A[Render resize and scroll events] --> B[Shared layout frame]
  B --> C[Scroll and marquee measurements]
  B --> D[Panel geometry measurements]
  C --> E[Overflow and fade state]
  D --> F[Transcript geometry notifications]
  G[Owned transcript margin] --> H[Transcript rendering]
Loading

Technical review

Best possible solution:

Keep the shared geometry batching while publishing the separator's actual split through its existing geometry owner.

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

The supplied browser comparison establishes the reload problem, and the production caller plus introduced value publication establish the accessibility failure; this read-only review ran no target code or tests.

Is this the best way to solve the issue?

Shared read-before-write batching is a reasonable bounded optimization, provided measurement-backed divider callers retain accurate accessibility state.

Full review comments:

  • [P2] Preserve accurate separator values for measurement-backed callers — ui/src/components/resizable-divider.ts:207
    The previously reported regression remains. chat-sidebar-region supplies splitRatio: 0.5 and obtains the actual split through measureRatio. Publishing props.splitRatio makes a 700px main pane beside a 300px right panel expose aria-valuenow="50" instead of "70". A later label or orientation update can also overwrite the accurate value published during interaction. Carry the actual ratio from the geometry owner or publish a measurement through the shared frame batch, and retain a regression covering that caller without restoring synchronous render-time reads.
    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 5b29c851c827.

Provenance checked

  • Scroll fades and sidebar classification changes intended behavior with a stated reason (92aa0ba: Retained content and resized attachment/menu surfaces needed current overflow indicators; the sidebar controller maintained equivalent edge classification.)
  • Marquee frame batching keeps the original intent (4818138: The Solid migration retained marquee lifecycle and read-before-write measurement behavior; sharing its scheduler preserves that intent.)
  • Sidebar geometry commits keeps the original intent (2969f4b: Panel measurements were deferred until nested renders completed to reduce layout stalls.)
  • Transcript header and row margins changes intended behavior with a stated reason (d70f835: Header changes and history prepends compensate reader position through the virtualizer; this PR explains reusing the viewport-owned margin while retaining that adjustment.)
  • Separator current-value publication changes intended behavior with a stated reason (84255bc: The Solid migration preserved measurement-backed current values; this PR explains avoiding render-time measurements, but its replacement loses accuracy for the existing side-panel caller.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test ui/src/components/resizable-divider.test.ts ui/src/pages/chat/components/chat-sidebar-region.test.ts --maxWorkers=1
  • pnpm test ui/src/components/scroll-state.test.ts --maxWorkers=1
  • Verify that a 700px main pane and 300px right panel expose aria-valuenow=70 before interaction and retain accurate values after resizing and label/orientation updates.
  • git diff --check

What I checked:

PR surface

Source +71, Tests +152. Total +223 across 14 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 10 222 151 +71
Tests 4 159 7 +152
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 381 158 +223

Review metrics

Metric Value Why it matters
Production versus test growth Production +222/-151; tests and support +159/-7 Production growth consolidates subscriptions and frame scheduling while deleting separate queues; tests protect read-before-write ordering and lifecycle behavior.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The performance improvement has bounded Control UI impact, and the remaining defect misreports separator values to assistive technology.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • 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.

History

Review history (6 earlier review cycles)
  • reviewed 2026-10-11T18:58:34.524Z sha a55bca915a72657e3e87e570d2994abed9b5298d :: needs changes before merge. :: [P2] Preserve accurate separator values for measurement-backed callers
  • reviewed 2026-10-11T19:22:22.596Z sha e0a0efc0da1a0247b92ea1bbdc1452bd6ed7627e :: needs changes before merge. :: [P2] Preserve accurate separator values for measurement-backed callers
  • reviewed 2026-10-11T20:01:43.293Z sha eaa93429d78b13af4e84c5efbbebd696afcb3c21 :: needs changes before merge. :: [P2] Preserve accurate separator values for measurement-backed callers | [P2] Adapt existing test waits to deferred layout publication
  • reviewed 2026-10-11T20:26:57.042Z sha 54e3646 :: needs changes before merge. :: [P2] Preserve accurate separator values for measurement-backed callers
  • reviewed 2026-10-11T23:00:50.372Z sha 54e3646 :: needs changes before merge. :: [P2] Preserve accurate separator values for measurement-backed callers
  • reviewed 2026-10-12T01:03:58.641Z sha 54e3646 :: needs changes before merge. :: [P2] Preserve accurate separator values for measurement-backed callers

Reviewed October 11, 2026, 9:11 PM ET / October 12, 2026, 01:11 UTC (Revision 7).

@steipete
steipete force-pushed the steipete/coldload-forced-layout branch 2 times, most recently from e0a0efc to eaa9342 Compare October 11, 2026 19:42
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Oct 11, 2026
@steipete
steipete force-pushed the steipete/coldload-forced-layout branch from eaa9342 to 54e3646 Compare October 11, 2026 20:10
@clawsweeper clawsweeper Bot added the proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. label Oct 11, 2026
@steipete
steipete merged commit dc1c912 into main Oct 12, 2026
158 of 182 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Landed with an admin squash merge pinned to the reviewed head 54e3646ad384 (GitHub reported it mergeable).

After re-running only the failed/cancelled jobs of run 38171052556, every job passed except checks-ui-e2e (2/3), which failed only ui/src/e2e/model-provider-usage-outcomes.e2e.test.ts → "keeps configured models visible when their catalog fails" (55 passed, 1 failed). That failure reproduces on this PR's base (lane evidence in the PR) and the PR does not touch model-provider or catalog code. All three UI unit shards, types, lint, guards, source contracts, and node-changed passed on this head; the lane's full UI e2e run had only base-reproduced failures.

@steipete
steipete deleted the steipete/coldload-forced-layout branch October 12, 2026 01:54
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
…169288)

Scroll-state directives and the sidebar session scroll classifier now share one ResizeObserver and a frame-batched layout scheduler that reads each element's geometry once per frame before any writes and publishes only changed state. The side-panel divider no longer measures on every update, and transcript header/virtualizer reuse transcript-owned geometry. Synthetic cold reloads: forced layouts 57 -> 31 (median), forced-layout time 106 -> 69 ms in the first 5 s.
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 P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant