Skip to content

perf: load web chat history in larger, faster batches - #133565

Merged
steipete merged 3 commits into
mainfrom
codex/faster-web-history
Aug 30, 2026
Merged

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

Conversation

@steipete

@steipete steipete commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Opening and scrolling through long Control UI conversations repeatedly pauses to load small history pages. Preparing larger pages also spends unnecessary CPU scanning ordinary reply text and validating message fields that the caller does not use.

Why This Change Was Made

Increase the shared recent-history window from 100 to 400 messages and older pages from 400 to 1,000. Session prefetch, refresh, and task previews use the same recent window. Existing response byte limits, text caps, cache bounds, virtualization, and projection lookback remain in force.

Make punctuation and trailing-control-token matching start at the string edges; skip runtime-context and sender parsing when required markers are absent; avoid media scans and repeated control classification when they cannot affect the result. Browser tool predicates now inspect only role and string-valued tool identifiers. Text, media, custom tokens, forwarded replies, and scroll anchoring retain their behavior.

User Impact

Four times as much recent history is available on open, and larger older pages reduce request/prepend frequency. Gateway preparation is substantially cheaper. Larger pages still cost more per browser prepend, especially on slower CPUs; 400 is the measured initial-window compromise. No configuration, dependency, schema, or protocol changes.

Evidence

Real SQLite transcripts with 3,000 alternating user/assistant messages; five warmups and 30 timed reads per window. Rich messages contain 2,048 Markdown characters. Both sides of each comparison ran on the same Blacksmith Testbox with Node inspector profiling enabled. Times exclude RPC/network and browser work.

Paired profile comparison 400 messages 1,000 messages
Original → edge-punctuation optimization 45.99 → 23.71 ms 114.05 → 57.93 ms
Edge-optimized baseline → final patch, fresh lease 22.69 → 11.48 ms 56.09 → 31.08 ms

Payload byte counts stayed identical. The trailing-token classifier's sampled self time fell from 507.6 to 10.7 ms in the second comparison. Short-message preparation improved too: 9.05 → 6.53 ms for 400 rows.

Chromium 144, production bundle, 1280×800, synthetic Gateway: 60 paired browser samples, five fresh contexts per scenario. The final 1,000-row prepend median was 229.7 → 211.3 ms on normal CPU; 1,000-row initial render was 1,202.2 → 1,031.6 ms under 4× CPU throttling. Browser gains are smaller and noisy; the default 400-row initial median changed only 218.1 → 212.7 ms. Maximum anchor drift remained 1.875 px. These timings exclude network/Gateway latency.

Fresh Codex autoreview reported no blocking findings. The first PR CI run caught two optional regex-capture type accesses; both are corrected, with 92 token tests, a strict module type check, formatting, targeted lint, and a second clean Codex review. The full local type check is blocked by unrelated errors in the shared logging dependency installation; fresh hosted CI verifies the complete build. Validation: 693 focused/integration tests across 16 files, seven native-history browser scenarios, lint, formatting, and diff checks passed. This includes real ephemeral Gateway REST/SSE history, projection/media/forwarding, runtime-context stripping, message normalization, and scrolling/retry/prefetch. The trailing-token rewrite matched the original in 140,000 deterministic differential cases including Unicode and custom tokens. The first page-size pass additionally passed 900 focused tests and 12 browser scenarios.

Proof runs: initial measurements and tests, paired final measurements and tests. Both task-owned Testbox leases were stopped after command success; the backing job may show cancellation from lease cleanup. Temporary measurement harnesses and CPU profiles are retained locally and excluded from the source diff.

Production LOC: +47/-27 (net +20); tests +130/-92 (net +38); docs +1/-1. Added production lines express measured skip conditions and backward suffix capture. Smaller initial raw lookback was rejected because earlier tool calls and audio supplements can affect later projection.

The second CI run passed the history, browser, type, lint, and package checks, but exposed a pre-existing docs-navigation test that hard-coded the release list. Current main adds releases/2026.8.1, so this PR also removes that copied inventory while retaining localized route parity, labels, ordering, and duplicate checks. The focused navigation test passes against current-main docs input; this follow-up changes no production code.

Exact local follow-up commands:

node scripts/run-vitest.mjs src/auto-reply/tokens.test.ts
node scripts/run-tsgo.mjs --ignoreConfig --noEmit --strict --noUncheckedIndexedAccess --target es2022 --module nodenext --types node --skipLibCheck src/auto-reply/tokens.ts
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/auto-reply/tokens.ts
node scripts/run-vitest.mjs test/scripts/docs-sync-publish.test.ts -t 'keeps generated locale navigation aligned with English routes'
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.scripts.json test/scripts/docs-sync-publish.test.ts
git diff --check

The navigation check first used current-main docs/docs.json as its input, then restored the branch input. A concurrent main change subsequently updated the same hard-coded release lists; the rebase preserves the reviewed parity-based test. The focused test passes again on the rebased tree, and the history modules and test are byte-identical to their reviewed versions.

Synthetic before/after captures

The viewport intentionally stays the same because rows are virtualized; the loaded-history count changes from 100 to 400. Both captures were inspected and contain only synthetic data.

Before: 100 messages loaded.

Before: synthetic chat with 100 messages loaded

After: 400 messages loaded.

After: synthetic chat with 400 messages loaded

@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 30, 2026
@steipete
steipete marked this pull request as ready for review August 30, 2026 21:33
@steipete steipete self-assigned this Aug 30, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 6:32 PM ET / 22:32 UTC.

ClawSweeper review

What this changes

The branch expands Control UI chat-history batches, updates pagination coverage and docs, and removes avoidable work from history-display preparation.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This member-owned PR remains necessary: current main still requests 100 recent and 400 older rows, while the branch safely raises those bounded requests to 400 and 1,000 within the existing Gateway contract. No blocking patch defect was found; retain it for normal maintainer review after exact-head CI completes.

Priority: P2
Reviewed head: 75591d318b4924c38579e28094a3a35662400311
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A normal good-quality performance patch with centralized limits, bounded server support, and focused coverage; remaining exact-head CI is a merge gate rather than a patch-quality defect.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored PR is exempt from the external-contributor proof gate; its supplied Testbox measurements and before/after Control UI captures nevertheless directly concern the changed history loading and rendering flow.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored PR is exempt from the external-contributor proof gate; its supplied Testbox measurements and before/after Control UI captures nevertheless directly concern the changed history loading and rendering flow.
Evidence reviewed 6 items Current-main gap and introduced limits: The reviewed PR changes the centralized recent/startup request window from 100 to 400 and the older-page window from 400 to 1,000; the base revision still has the former values, so current main does not already provide the requested behavior.
Gateway contract permits the larger page: The wire schema caps chat-history requests at the shared 1,000-entry constant, and the request handler independently clamps requests to that same maximum.
Pagination owner and coverage: The history loader uses the two limits at the initial and older-page entry points; focused tests cover the 1,000-row pagination, prefetch staging, and scroll anchoring paths.
Findings None None.
Security None None.

How this fits together

Control UI Chat requests stored session history from Gateway, projects rows into display-safe messages, and virtualizes them for initial rendering and older-message pagination. The changed limits affect the request volume at open, refresh, prefetch, and scroll-back boundaries.

flowchart LR
A[Stored session transcript] --> B[Gateway history API]
B --> C[Control UI history loader]
C --> D[Display projection]
D --> E[Virtualized chat view]
E --> F[Older-page prefetch]
Loading

Decision needed

Question Recommendation
Should this member-owned default change to Control UI history batch sizes merge once the exact-head checks are green? Merge after exact-head CI: Accept the measured 400 recent and 1,000 older-page defaults after required checks complete successfully.

Why: The limits alter the default browser workload and user-visible history availability; the branch is technically bounded, but final acceptance is an owner-level performance tradeoff.

Before merge

  • Resolve merge risk (P1) - Exact-head CI is still in progress; landing should wait for the remaining required checks rather than rely on the earlier validation links alone.
Agent review details

Security

None.

PR surface

Source +20, Tests +38, Docs 0. Total +58 across 28 files.

View PR surface stats
Area Files Added Removed Net
Source 9 47 27 +20
Tests 18 130 92 +38
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 28 178 120 +58

Review metrics

Metric Value Why it matters
Production versus test delta production +47/-27 (net +20); tests +130/-92 (net +38); docs 0 net The production growth is confined to measured fast paths and the batch constants; the larger test change updates request, pagination, and display-boundary coverage.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the centralized 400/1,000 request policy, its existing Gateway cap, and the pagination/scroll regression coverage as one bounded Control UI performance change.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the centralized 400/1,000 request policy, its existing Gateway cap, and the pagination/scroll regression coverage as one bounded Control UI performance change.

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

Not applicable as a defect reproduction: this is a measured performance and default-window change, with supplied benchmark and browser-flow evidence for the affected path.

Is this the best way to solve the issue?

Yes: the limits are changed at the shared Control UI requester, while the existing Gateway schema and server clamp retain the 1,000-entry boundary without adding configuration or protocol surface.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7504a3b3c453.

Labels

Label justifications:

  • P2: This is a bounded improvement to long-session Control UI responsiveness, without evidence of an urgent outage or data-loss regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored PR is exempt from the external-contributor proof gate; its supplied Testbox measurements and before/after Control UI captures nevertheless directly concern the changed history loading and rendering flow.

Evidence

What I checked:

  • Current-main gap and introduced limits: The reviewed PR changes the centralized recent/startup request window from 100 to 400 and the older-page window from 400 to 1,000; the base revision still has the former values, so current main does not already provide the requested behavior. (ui/src/pages/chat/chat-history.ts:107, 75591d318b49)
  • Gateway contract permits the larger page: The wire schema caps chat-history requests at the shared 1,000-entry constant, and the request handler independently clamps requests to that same maximum. (packages/gateway-protocol/src/schema/logs-chat.ts:31, 75591d318b49)
  • Pagination owner and coverage: The history loader uses the two limits at the initial and older-page entry points; focused tests cover the 1,000-row pagination, prefetch staging, and scroll anchoring paths. (ui/src/pages/chat/chat-history.ts:1773, 75591d318b49)
  • Display projection preserves suppression ordering: The sanitizer still drops suppressible assistant rows before sanitization and only repeats that check when sanitization changed a row, avoiding redundant classification without bypassing the raw-row suppression decision. (src/gateway/chat-display-projection.sanitize.ts:724, 75591d318b49)
  • Feature-history routing: Recent history-path commits on current main are authored by Peter Steinberger, including the immediate adjacent session-history repairs; sparse history prevented verification of a precise line-introduction patch, so no introduction coordinate is asserted. (ui/src/pages/chat/chat-history.ts:107, af8dad8e9e32)
  • Supplied behavior proof: The PR body supplies before/after synthetic Control UI captures and Testbox benchmark/validation links for the changed history flow. It is a member-authored PR, so the external-contributor proof gate does not apply. (75591d318b49)

Likely related people:

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

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Wait for required checks on commit 75591d3 to finish successfully.

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 (2 earlier review cycles)
  • reviewed 2026-08-30T21:52:43.404Z sha f54c6800f3fc1c677a48c56c6b5b28770def57d9 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T22:18:48.989Z sha e755ce0a59921ed7a39217c9e8d38c17116c339a :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 30, 2026
@steipete
steipete force-pushed the codex/faster-web-history branch from e755ce0 to 75591d3 Compare August 30, 2026 22:25
@steipete

Copy link
Copy Markdown
Contributor Author

Ready to land the maintainer-requested 400-message initial window and 1,000-message older pages. The measured browser/server tradeoff is accepted; existing Gateway entry/byte caps, virtualization, and projection lookback remain. This resolves the default-size decision in the latest ClawSweeper review.

The final head is 75591d318b4924c38579e28094a3a35662400311. Exact-head CI passed, satisfying the remaining ClawSweeper check/rank-up item. Native review artifacts validate with zero findings, and Codex autoreview found no actionable defects in the performance patch or either CI correction.

CI caught two capture-group type accesses, now corrected, and a pre-existing hard-coded docs release inventory, now replaced by locale parity against English navigation. The later rebase resolved a concurrent release-inventory update; reviewed history modules and the parity test stayed byte-identical, and the focused navigation test passed again.

The PR body contains commands, Testbox run links, Node/browser measurements, inspected synthetic before/after captures, and measurement limits. Production: +47/-27 (net +20); tests: +130/-92 (net +38); docs: net zero. The remaining CPU costs are SQLite parsing/iteration and inbound metadata work; reducing projection lookback needs separate tool/audio boundary proof.

@steipete
steipete merged commit cd3543f into main Aug 30, 2026
254 checks passed
@steipete
steipete deleted the codex/faster-web-history branch August 30, 2026 22:43
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to shojikumaru/openclaw that referenced this pull request Aug 30, 2026
…cked-delivery

* origin/main:
  fix(ui): wait for restored draft before clearing (openclaw#133575)
  fix(deps): update fast-uri security patches (openclaw#133572)
  test: reduce workflow sanity fixture cleanup time (openclaw#133588)
  fix(media): normalize detected Matroska MIME (openclaw#133383)
  refactor(docker): retire ClawDock shell helpers (openclaw#133594)
  perf(browser): reuse snapshot refs and screenshot metadata (openclaw#133598)
  perf: load web chat history in larger, faster batches (openclaw#133565)
  fix(plugins): keep bundled plugins bundled when selected by plugins.load.paths (openclaw#133584)
  test: isolate shared /tmp session-store paths in runner and health suites (openclaw#133568)
  fix(cron): avoid no-op schedule repair writes (openclaw#133552)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
* perf: load web chat history in larger, faster batches

* fix: type-check history token capture groups

* test: derive localized release routes from English navigation
hartmark added a commit to hartmark/openclaw that referenced this pull request Sep 17, 2026
…prior run, seen on other unrelated PRs openclaw#140331/openclaw#133565/openclaw#133580, passes locally on current main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling 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. 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