Repository navigation
fix(ui): reduce layout work when loading chat history - #153137
Conversation
|
🦞👀 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 maintainer review before merge. Reviewed September 19, 2026, 4:17 PM ET / 20:17 UTC (Revision 2). ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherThe 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]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +65, Tests +132. Total +197 across 4 files. View PR surface stats
Review metrics
Technical reviewBest 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. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
* fix(ui): reduce layout work when loading chat history * style(ui): make optional measurement result explicit
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
97340d4388f9ed957a4c098bd05deefdece32518; the requiredopenclaw/ci-gateis green. ClawSweeper also reviewed that exact head with no actionable findings.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.
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.
Before
After