Skip to content

fix(ui): speed up older chat history loading - #152979

Merged
steipete merged 3 commits into
mainfrom
codex/faster-chat-history
Sep 19, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/faster-chat-history

Conversation

@steipete

@steipete steipete commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes slow backscroll in long chats after older history pages were reduced to 512 KiB. Related: #152093.

User Impact

Older messages arrive in fewer batches, with less browser work as the loaded conversation grows. The small initial tail is unchanged. Older responses can again use the Gateway's existing 6 MiB ceiling, trading larger individual transfers for fewer round trips; message completeness and scroll anchoring are preserved. Slower-network and lower-memory-device timings remain unmeasured. The accepted tradeoff restores a previously used bounded response size while keeping startup small and prefetch limited to one staged page; no persistent comparison cache is added.

Why This Change Was Made

Remove the UI's older-page byte override while keeping its 1,000-message ceiling. Small responses repeated Gateway reads/projection and browser prepend work. For overlap detection, compare transcript IDs first and serialize only rows whose sources overlap, preserving distinct projected siblings and duplicate counts without a persistent cache.

Evidence

Real Chromium against an isolated Gateway, using the same synthetic 900-message conversation and approximately 4 KiB of text per message:

Measurement Before After
Older-history requests 8 1
Backscroll completion 2.68–2.91 s (two runs) 656 ms
Browser long-task time during backscroll 883–1,051 ms 124 ms
Messages restored, in order 900 900

The local browser measurement includes successive scroll gestures, response application, and prepend work; it is not a production-network latency claim. The initial tail remains 59 messages in this fixture. One larger request returned the remaining 841 messages (3.72 MB).

These A/B measurements compare the original UI patch with its original base. After refreshing main and completing an upstream config-helper import cutover from #152490, the browser scenario passed again with all 900 messages in order, one older request, 435 ms backscroll completion, and 126 ms of browser long tasks. The full build (including 52 runtime-module checks), 87 config mutation tests, and independent review of the import repair passed. The same import correction reached main before this PR merged, so the landed diff contains the history improvement and test-observation fix, without additional config changes.

A separate prepend benchmark used 30 warm, alternating paired samples and checked exact output identity/order against the previous algorithm. With 1,000 incoming and 10,000 held messages, median prepend time fell from 62.9 to 1.93 ms for 4 KiB text and 75.8 to 1.87 ms for 8 KiB text. Disjoint pages serialize zero message-body bytes for deduplication; a 5% overlap serializes only the shared boundary.

The browser one-page regression and serialization-budget regressions failed on the original code. All 108 focused tests and eight browser E2E cases passed, including lossless Gateway pagination, projected siblings, duplicate multiplicity, timestamp normalization, reply navigation, underfilled viewports, scroll anchoring, and retry behavior. Runtime and UI builds, changed-file checks, all test typechecks, UI typechecking, lint, and formatting passed. Independent review found no actionable P0–P2 findings.

CI also exposed an unrelated Node 24.19 test-observation flake in tool cancellation. A deterministic GC probe showed that an unobserved composite abort signal can lose its weak source before a later getter. The fake tool now subscribes during execution and asserts exactly one revocation, retaining its prior assertions; production cancellation is unchanged. The full six-test cancellation file passes on the exact CI Node version, and independent review passed.

Inspected synthetic before/after captures show the same oldest messages after complete history loading:

Before: complete synthetic chat history

After: complete synthetic chat history

@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.

@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
@steipete
steipete marked this pull request as ready for review September 19, 2026 15:13
@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, 12:13 PM ET / 16:13 UTC (Revision 4).

ClawSweeper review

What this changes

The Control UI loads larger older-history pages and avoids comparing nonoverlapping message bodies, with updated regression coverage, a config-helper import repair, and a cancellation-test observation fix.

Merge readiness

✅ Ready for maintainer review

The optimization remains absent from current main, and the supplied real-Gateway evidence supports it. No actionable correctness or security findings remain.

Priority: P2
Reviewed head: fa00b8767eefd5eb768bdeac2fe9eb44392b39d6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, supported optimization with meaningful real-path measurements and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied Chromium run exercises the changed older-history request and prepend owners through a real isolated Gateway, preserving all 900 messages while reducing requests and measured browser work. Inspected screenshots corroborate retained content; the measurements remain local-fixture results, not slow-network claims.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied Chromium run exercises the changed older-history request and prepend owners through a real isolated Gateway, preserving all 900 messages while reducing requests and measured browser work. Inspected screenshots corroborate retained content; the measurements remain local-fixture results, not slow-network claims.
Evidence reviewed 9 items Introduced scope: Reviewed the pinned merge-base-to-head changes. The host-verified test merge has the pinned base and original head as its parents and contains the same introduced file set; unrelated endpoint drift was excluded.
Current-main necessity: Fetched main retains the 512 KiB older-page override and the previous full-projection identity implementation. The proposed source-overlap optimization is absent.
Bounded page-size tradeoff: Older requests retain the 1,000-message limit and use the Gateway's existing 6 MiB ceiling. Startup remains capped at 256 KiB, and the pane retains one staged older page. The maintainer-authored body explicitly accepts larger transfers and identifies slow-network and low-memory timings as unmeasured.
Findings None None.
Security None None.

How this fits together

The Control UI requests stored conversation pages from the Gateway when readers scroll backward. It merges those pages into the displayed conversation while preserving message identity, order, and scroll position.

flowchart LR
  A[Backscroll or viewport filling] --> B[Older-history request]
  B --> C[Gateway response limits]
  C --> D[Stored conversation page]
  D --> E[Check overlapping message sources]
  E --> F[Prepend messages and preserve scroll]
  F --> G[Stage one next page]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +20, Tests +54, Docs 0. Total +74 across 16 files.

View PR surface stats
Area Files Added Removed Net
Source 6 58 38 +20
Tests 9 128 74 +54
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 16 187 113 +74

Review metrics

Metric Value Why it matters
Older-page budget 512 KiB target → existing 6 MiB ceiling; 1,000-message limit retained This is the explicitly accepted transfer-size tradeoff behind the reduced request count.
Production versus test growth Production net +20 lines; tests and test support net +54 lines Production growth implements overlap filtering while replacing the old prepend method and avoiding a persistent comparison cache.

Technical review

Best possible solution:

Keep startup small while amortizing backscroll work within the existing Gateway limits and preserving exact message and scroll behavior.

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

Yes: current main retains the small-page request path, and the supplied 900-message real-Gateway comparison establishes a focused reproduction scenario. This reviewer did not rerun it.

Is this the best way to solve the issue?

Yes: the patch reuses the existing Gateway budget owner and narrows expensive comparisons without introducing another cache, configuration option, or competing pagination path.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This improves long-chat backscroll responsiveness without evidence of an urgent outage or data-loss defect.
  • 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 supplied Chromium run exercises the changed older-history request and prepend owners through a real isolated Gateway, preserving all 900 messages while reducing requests and measured browser work. Inspected screenshots corroborate retained content; the measurements remain local-fixture results, not slow-network claims.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied Chromium run exercises the changed older-history request and prepend owners through a real isolated Gateway, preserving all 900 messages while reducing requests and measured browser work. Inspected screenshots corroborate retained content; the measurements remain local-fixture results, not slow-network claims.

Evidence

What I checked:

  • Introduced scope: Reviewed the pinned merge-base-to-head changes. The host-verified test merge has the pinned base and original head as its parents and contains the same introduced file set; unrelated endpoint drift was excluded. (fa00b8767eef)
  • Current-main necessity: Fetched main retains the 512 KiB older-page override and the previous full-projection identity implementation. The proposed source-overlap optimization is absent. (ui/src/lib/chat/history-message-identity.ts:50, 2b341cd3cef7)
  • Bounded page-size tradeoff: Older requests retain the 1,000-message limit and use the Gateway's existing 6 MiB ceiling. Startup remains capped at 256 KiB, and the pane retains one staged older page. The maintainer-authored body explicitly accepts larger transfers and identifies slow-network and low-memory timings as unmeasured. (ui/src/pages/chat/chat-history-request.ts:311, fa00b8767eef)
  • Merge semantics and regression coverage: The production prepend path calls the extracted helper. Source filtering preserves full projection comparisons for overlaps, duplicate multiplicity, timestamp normalization, and unidentified messages without a persistent cache. Existing session and request-generation guards remain intact. (ui/src/lib/chat/history-message-identity.ts:81, fa00b8767eef)
  • Real browser evidence: Captured body sourceRevision fc30a182f552347aa487c8dc4517808395a372d5874a6eb107ed3a46841daa6f reports real Chromium against an isolated Gateway: 900 ordered messages, eight older requests reduced to one, and 2.68–2.91 seconds reduced to 656 ms. After the config import repair, the scenario reportedly passed again at 435 ms. Both downloaded before/after images were inspected and show the oldest synthetic messages; timing support comes from the reported runtime measurements, not the screenshots alone. (ui/src/e2e/chat-loading-performance.real-gateway.e2e.test.ts:548, fa00b8767eef)
  • Config cutover repair: The merged helper extraction removed the old export and preserved the helper body in value-tree.ts. This branch updates the include writer to that canonical owner and removes an unused import; it changes no config format, write authority, or migration behavior. (src/config/mutate.include-io.ts:31, fa00b8767eef)

Likely related people:

  • 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 (3 earlier review cycles)
  • reviewed 2026-09-19T15:18:32.200Z sha ebef5a97abde6d83b412675816bf020430c8d82b :: blocked before merge. :: none
  • reviewed 2026-09-19T15:29:18.657Z sha ebef5a97abde6d83b412675816bf020430c8d82b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-19T15:44:13.904Z sha 8be10d292996761a4a31bde49b7f6eb25b26c45e :: blocked before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Sep 19, 2026
Restore Gateway-owned older-page byte limits and compare full message projections only for overlapping transcript sources. Keep the small startup tail and preserve projected siblings, duplicate counts, and scroll behavior.

Real-Gateway synthetic backscroll improved from eight requests and 2.68–2.91 seconds to one request and 656 ms for 900 messages. Long-task time fell from 883–1051 ms to 124 ms. Focused tests, browser proof, changed checks, and independent review passed.
Subscribe the fake tool to its abort notification and assert exactly one delivery. Node 24 composites can lose an unobserved weak source to GC before a post-request aborted getter. Keep all previous assertions and leave production cancellation unchanged.
Use the canonical value-tree helper in the include writer and remove the unused mutation import. This completes the caller migration from #152490 without restoring the old export. All 87 config mutation tests, a full build, and independent review passed.
@steipete
steipete force-pushed the codex/faster-chat-history branch from 8be10d2 to fa00b87 Compare September 19, 2026 16:07
@steipete
steipete merged commit 68df653 into main Sep 19, 2026
220 of 221 checks passed
@steipete
steipete deleted the codex/faster-chat-history branch September 19, 2026 16:42
@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): speed up older chat history loading

Restore Gateway-owned older-page byte limits and compare full message projections only for overlapping transcript sources. Keep the small startup tail and preserve projected siblings, duplicate counts, and scroll behavior.

Real-Gateway synthetic backscroll improved from eight requests and 2.68–2.91 seconds to one request and 656 ms for 900 messages. Long-task time fell from 883–1051 ms to 124 ms. Focused tests, browser proof, changed checks, and independent review passed.

* test(gateway): observe tool revocation before owner collection

Subscribe the fake tool to its abort notification and assert exactly one delivery. Node 24 composites can lose an unobserved weak source to GC before a post-request aborted getter. Keep all previous assertions and leave production cancellation unchanged.

* fix(config): complete include value validation import cutover

Use the canonical value-tree helper in the include writer and remove the unused mutation import. This completes the caller migration from openclaw#152490 without restoring the old export. All 87 config mutation tests, a full build, and independent review passed.
steipete added a commit that referenced this pull request Oct 6, 2026
50f38c6 (#165897) intentionally changed ordinary history responses to
a 512 KiB target and documented continuation through nextOffset. The old
single-request assertion measured scrolling through all 900 messages under
the previous 6 MiB policy from #152979; it did not measure opening a chat.

Match older requests to committed pagination steps, check contiguous
coverage and bounded nonempty responses, and allow at most one staged
successor. Assert that all three startup samples issue no older-history
requests. Preserve the ordered transcript, initial-tail, identity, Home,
avatar, and cache assertions.

The real Gateway reproduces the old failure with eight requests for eight
backscroll steps. Startup remains one reply with 59 messages and 260,813 history bytes. The
updated file passes locally, as do type-aware/boundary lint, its test-type
graph, formatting, full local check-changed, and independent P2 review. No production or dependency
changes; security-fast's source-map-js advisory (#165918) is inherited.

Testbox-congestion exception: the lease timed out after 15 minutes queued,
before sync or execution. Use the authorized ready-PR fallback; three
Linux real-Gateway runs and the complete owning UI e2e config remain unrun.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 7, 2026
815d4c3 (openclaw#165897) intentionally changed ordinary history responses to
a 512 KiB target and documented continuation through nextOffset. The old
single-request assertion measured scrolling through all 900 messages under
the previous 6 MiB policy from openclaw#152979; it did not measure opening a chat.

Match older requests to committed pagination steps, check contiguous
coverage and bounded nonempty responses, and allow at most one staged
successor. Assert that all three startup samples issue no older-history
requests. Preserve the ordered transcript, initial-tail, identity, Home,
avatar, and cache assertions.

The real Gateway reproduces the old failure with eight requests for eight
backscroll steps. Startup remains one reply with 59 messages and 260,813 history bytes. The
updated file passes locally, as do type-aware/boundary lint, its test-type
graph, formatting, full local check-changed, and independent P2 review. No production or dependency
changes; security-fast's source-map-js advisory (openclaw#165918) is inherited.

Testbox-congestion exception: the lease timed out after 15 minutes queued,
before sync or execution. Use the authorized ready-PR fallback; three
Linux real-Gateway runs and the complete owning UI e2e config remain unrun.
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 gateway Gateway runtime 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