Skip to content

fix(ui): reduce layout work when loading chat history - #153137

Merged
steipete merged 2 commits into
mainfrom
codex/history-loading-next
Sep 19, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/history-loading-next

Conversation

@steipete

@steipete steipete commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Loading older chat history still spends unnecessary browser time remeasuring long-message previews, even after the larger-page fix in #152979.

User Impact

Older history becomes available sooner while preserving the same message previews, expansion controls, and reading position. No configuration or migration is needed.

Why This Change Was Made

Keep each unchanged preview's measurement lifecycle and batch all preview geometry reads before applying their clamps. Previously, rerenders reinstalled observers and interleaved DOM writes with layout reads for every long message. Content changes, resizing, font loads, expansion, and reconnects still trigger fresh measurements.

The synthetic 900-message real-Gateway comparison shows about 55% less disclosure measurement CPU (53.34 → 24.17 ms) and 10% lower average time through paint (408.6 → 365.8 ms) across five alternating pairs. Individual total timings remain noisy: two candidate samples were 9 ms and 6 ms slower, and long tasks were not consistently reduced. This changes presentation work only; Gateway history ownership and the transcript virtualizer stay intact.

Evidence

  • Hosted CI passed on 97340d4388f9ed957a4c098bd05deefdece32518; the required openclaw/ci-gate is green. ClawSweeper also reviewed that exact head with no actionable findings.
  • Core/UI type checks, i18n, dead-export scans, formatting, and lint passed. Lint was rechecked after a behavior-preserving explicit-undefined return correction. Independent review found no actionable P0–P2 findings.
  • 39 focused unit cases, 14 forwarded-disclosure browser cases, and 40 E2E cases passed. The browser cases cover desktop/mobile, light/dark, images, five-line previews, rendered-short content, font/viewport changes, native details, browser reveal, and frame-by-frame expansion anchoring.
  • Regression proof failed on the original code: unchanged rerenders performed extra layout reads, and two disclosure rows interleaved layout writes with reads. The candidate passes, including content/font invalidation and disconnect/reconnect.
  • The performance fixture now records time through the pane update and two animation frames, plus an opt-in CPU profile, so deferred layout work stays inside the measurement window.

Final alternating measurements

Same macOS host, production UI build, Chromium, isolated real Gateway, synthetic 900-message transcript, CPU profiling enabled. Timings are measurements, not universal latency guarantees.

Sample Messages loaded (ms) Through paint (ms) Long-task duration (ms) Disclosure self CPU (ms)
Before 1 357 399 126 47.20
After 1 288 319 53 19.52
Before 2 331 362 134 46.80
After 2 343 371 172 24.78
Before 3 384 409 213 60.31
After 3 357 395 181 26.90
Before 4 352 374 201 62.90
After 4 347 380 176 25.96
Before 5 466 499 187 49.47
After 5 340 364 177 23.68
Earlier exploratory repetitions, before the paint-settling endpoint was added

These measured the loaded-message endpoint only and are not included in the through-paint comparison above. All samples are retained, including the slower candidate run.

Sample Messages loaded (ms) Long-task duration (ms) Disclosure self CPU (ms)
Before 1 318 115 42.35
After 1 280 0 19.03
Before 2 316 119 39.91
After 2 277 51 20.61
Before 3 339 128 41.24
After 3 332 170 20.68

Before

Synthetic older history before optimization

After

Synthetic older history after optimization

@clawsweeper

clawsweeper Bot commented Sep 19, 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.

@steipete
steipete marked this pull request as ready for review September 19, 2026 19:46
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: M maintainer Maintainer-authored PR labels Sep 19, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 Sep 19, 2026
@clawsweeper

clawsweeper Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 19, 2026, 4:17 PM ET / 20:17 UTC (Revision 2).

ClawSweeper review

What this changes

The PR retains and batches chat-preview measurements to reduce history-loading layout work, and adds regression coverage, CPU profiling, and rendering-time documentation.

Merge readiness

✅ Ready for maintainer review

This remains a useful, distinct optimization with convincing performance evidence and no actionable introduced defects. Current main still performs the repeated measurements; the earlier pagination fix does not supersede this work.

Priority: P2
Reviewed head: 97340d4388f9ed957a4c098bd05deefdece32518

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct optimization with strong comparative runtime evidence and meaningful lifecycle regression coverage.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The changed preview renderer is exercised by production-build Chromium backscroll against an isolated real Gateway with 900 synthetic messages. Five alternating before/after samples show reduced measurement CPU and average time through rendering; inspected screenshots supplement those measurements with visible parity.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The changed preview renderer is exercised by production-build Chromium backscroll against an isolated real Gateway with 900 synthetic messages. Five alternating before/after samples show reduced measurement CPU and average time through rendering; inspected screenshots supplement those measurements with visible parity.
Evidence reviewed 9 items Introduced scope and lifecycle: The pinned introduction delta contains only the preview optimization, its regression test, performance instrumentation, and documentation. The production owner removes pending measurements and font listeners on disconnection, rejects retired generations, and separates layout reads from writes.
Current main still needs the optimization: Fetched main still creates a fresh measurement callback during rendering and removes the clamp immediately before each message's geometry reads. The current branch introduces retention and batching beyond that implementation.
Latest-release comparison: The supplied latest release, v2026.9.5, also contains the per-message measurement implementation without this batching or retained ref lifecycle.
Findings None None.
Security None None.

How this fits together

The Control UI renders messages received from Gateway history into expandable chat previews. This change optimizes browser geometry measurements without changing transcript storage, history pagination, or message content.

flowchart TD
  A[Gateway chat history] --> B[Rendered message content]
  B --> C{Preview inputs changed?}
  C -->|No| D[Retain measurement lifecycle]
  C -->|Yes| E[Queue geometry measurement]
  F[Resize font load or reconnect] --> E
  E --> G[Batch layout reads]
  G --> H[Apply preview clamps and controls]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +65, Tests +132. Total +197 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 95 30 +65
Tests 3 132 0 +132
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 227 30 +197

Review metrics

Metric Value Why it matters
Measured rendering benefit 5 alternating pairs; disclosure CPU −55%; average rendering time −10% The real-Gateway comparison supports the optimization while documenting timing variability.
Production versus test growth Production +65 net lines; tests +125 net lines Production growth implements batching and lifecycle cleanup, backed by regression coverage and retained performance instrumentation.

Technical review

Best possible solution:

Keep preview measurement lifecycle in the existing renderer, retain explicit invalidation, and batch geometry work while preserving message visibility and reading position.

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

Yes: current source reinstalls measurement callbacks on unchanged rerenders and interleaves per-message layout writes and reads. The supplied real-Gateway comparison exercises that path; this review did not execute it.

Is this the best way to solve the issue?

Yes: retaining the existing renderer's lifecycle and batching its measurements addresses the demonstrated overhead without adding another history owner or changing stored preferences.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This improves long-chat loading performance within a bounded presentation path without an urgent availability or data-integrity failure.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The changed preview renderer is exercised by production-build Chromium backscroll against an isolated real Gateway with 900 synthetic messages. Five alternating before/after samples show reduced measurement CPU and average time through rendering; inspected screenshots supplement those measurements with visible parity.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed preview renderer is exercised by production-build Chromium backscroll against an isolated real Gateway with 900 synthetic messages. Five alternating before/after samples show reduced measurement CPU and average time through rendering; inspected screenshots supplement those measurements with visible parity.

Evidence

What I checked:

  • Introduced scope and lifecycle: The pinned introduction delta contains only the preview optimization, its regression test, performance instrumentation, and documentation. The production owner removes pending measurements and font listeners on disconnection, rejects retired generations, and separates layout reads from writes. (ui/src/pages/chat/components/chat-message-text.ts:101, 97340d4388f9)
  • Current main still needs the optimization: Fetched main still creates a fresh measurement callback during rendering and removes the clamp immediately before each message's geometry reads. The current branch introduces retention and batching beyond that implementation. (ui/src/pages/chat/components/chat-message-text.ts:94, cc7e211d146f)
  • Latest-release comparison: The supplied latest release, v2026.9.5, also contains the per-message measurement implementation without this batching or retained ref lifecycle. (ui/src/pages/chat/components/chat-message-text.ts:94, ec9c1a13db89)
  • Behavioral regression coverage: The added test exercises the actual renderer, checks that unchanged rerenders avoid geometry reads, verifies batching across two messages, and covers content, expansion, font, disconnect, and reconnect invalidation. Existing browser coverage checks forwarded previews and viewport resizing. Tests were inspected, not executed during this read-only review. (ui/src/pages/chat/components/chat-message-markdown.test.ts:150, 97340d4388f9)
  • Real browser performance proof: The captured PR body reports five alternating comparisons using a production UI build, Chromium, and an isolated real Gateway with 900 synthetic messages: average disclosure CPU falls from 53.34 to 24.17 ms and rendering time from 408.6 to 365.8 ms. Slower candidate samples and inconsistent long-task gains are explicitly retained. Both downloaded before/after images were inspected and show matching loaded history and preview controls; performance confidence comes from the measurements, not screenshots alone. (97340d4388f9)
  • Performance measurement boundary: The real-Gateway fixture measures through the pane update and two animation frames, saves an opt-in CPU profile, and checks all 900 message identities in order. This directly exercises the rendering owner changed by the patch. (ui/src/e2e/chat-loading-performance.real-gateway.e2e.test.ts:548, 97340d4388f9)

Likely related people:

  • vyctorbrzezowski: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (1 earlier review cycle)
  • reviewed 2026-09-19T19:57:06.751Z sha 97340d4 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit b183809 into main Sep 19, 2026
181 checks passed
@steipete
steipete deleted the codex/history-loading-next branch September 19, 2026 20:41
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 20, 2026
* fix(ui): reduce layout work when loading chat history

* style(ui): make optional measurement result explicit
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 maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

1 participant