Skip to content

perf(chat): pace board history refreshes and reuse cursors - #174407

Merged
steipete merged 1 commit into
mainfrom
perf/chat-history-cost-1326
Oct 16, 2026
Merged

steipete merged 1 commit into
mainfrom
perf/chat-history-cost-1326

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

An open board session summary rereads its full 20-message tail on every matching session or message event, including unchanged transcript windows. Its in-flight refresh loop immediately starts another full read when events arrive during a request.

User Impact

Board summaries catch up incrementally and combine event bursts into paced refreshes. Opening, reconnecting, and manual Retry still load immediately; hidden summaries stop reading and reload on return. Automatic updates can appear up to the existing refresh coordinator's four-to-five-second collection window later, with five-to-15-second pacing after slow reads. Rendering is unchanged.

Why This Change Was Made

The main chat already uses cursor catch-up, bounded worker-projected pages, and shared in-flight reads. Its post-message recovery is necessary because live events deliberately omit some history projections. Public-page HTTP ETags are a separate transport; unchanged WebSocket history already has an empty-delta response carrying current metadata.

The board now reuses the existing event refresh coordinator instead of its immediate pending/dirty loop. It folds cursor envelopes through the shared transcript reducer, retains only 20 messages, and replaces the tail after cursor reset. All existing event invalidations remain, including metadata and access changes. The server also carries maxChars into delta projection so the board's 12,000-character previews do not silently revert to the 8,000-character default after catch-up.

Evidence

  • Original-code UI regressions fail for immediate event rereads and missing cursor reuse.
  • Patched focused checks: UI summary + existing refresh coordinator 16 passed (11.47 s command wall, 9.45 s Vitest); Gateway request budgets + transcript projection 19 passed (122.97 s command wall; 101.15 s Vitest including 66% worker compilation; no suite run). The new request-boundary regression fails on the original 8,000-character cursor cap and passes with the requested 12,000-character cap.
  • After the mechanical conflict rebase, 31 focused tests passed on 945ad91c1a9e10f601b5d0844fd5f664f00c175a (three files, 91.72 s). The first attempt stopped during setup because installed dependencies lagged the rebased lockfile; a frozen-lockfile install repaired the local toolchain. All seven changed files pass formatting with the updated pinned formatter. The reviewed implementation is unchanged; conflict resolution preserves main's new Solid bridge/avatar imports and plugin-steering option alongside the cursor text cap.
  • Synthetic event replay through the production coordinator: 60 matching events spaced one second apart produce 60 → 12 automatic reads/minute (80% fewer), excluding initial load. Clock and jitter fixed; this is not a measured production traffic reduction.
  • Isolated Linux benchmark, Node 26.8.1: 5,000 sessions, 6,000 retained runs, 15,000 participant rows, 1,000 archived sessions, 200 approvals, 100 cron jobs, 12 projects, 250,998,784-byte final agent DB. One session has an additional 200 mixed 32 KB user/assistant/tool rows. Actual history handler, transcript worker, row projection, and native frame serialization; bypasses WebSocket/auth dispatch. Three alternating rounds of 300 samples per shape after 20 warmups; values below are medians of round means.
Request Handler ms Main-thread CPU ms Response bytes
Before: full 20-message tail 15.404 4.271 200,954
After: unchanged cursor 4.584 2.612 2,881
After: one-message catch-up 6.925 3.844 20,781

Unchanged catch-up uses 38.8% less main CPU and 98.6% fewer response bytes. Full-tail control is neutral within observed round spread: 15.404 → 15.107 ms wall, 4.271 → 4.450 ms main CPU. The corrected text cap adds 4,000 bytes to the one-message delta compared with the old incorrectly capped delta.

Production delta: +29 lines (52 added, 23 deleted); the removed pending/dirty scheduling is replaced by the existing coordinator. Growth implements the existing cursor/reset wire contract and bounded reducer replay while preserving the board's preview cap. No new cache, config, schema, or transport.

Independent Codex autoreview: scoped-clean through P2, no accepted/actionable findings. Changed-file formatting, scoped repository lint, and diff checks passed.

  • Broad validation belongs to PR CI; no Testbox/Crabbox leases used.
  • This does not attribute production call volume to individual connected clients. Delta projection remains on the main thread; normal bounded full pages already project and encode in the transcript worker.

Inherited CI Failures

Run 38930867257, attempt 1, tests merge 52ab6ad0e81e9fbab53fa3e96f1d2edb3d2e3fe3: main parent 04d8503ee8ab97218b3283968293d079b1a8b219 plus this PR's exact head. Both failures are outside the seven-file diff. Each failed job log was fetched once; no CI reruns.

The automatic table labels both failures “new” relative to the older scheduled main run 38924503696. The direct reproductions below use CI's actual, newer main parent and establish that the PR did not introduce them.

  • check-guards: duplicate-scan target coverage omits cli-parent-lifetime.mjs. Running the unchanged production checker with --coverage against each tree's complete tracked-path index reproduces the identical missing path and exit 1 on both base and merge. Only checker files and indexes were materialized in an isolated Linux sandbox; no full duplicate scan or full checkout was needed.
  • checks-fast-baseline-ratchets: mock-export guard rejects src/flows/doctor-plugin-source-captures.test.ts:32, mocking ../process/supervisor/darwin-bun-process-census.js without preserving exports or declaring isolation. A focused replay through the actual native TypeScript parser and mock scanner reproduces the identical missing-baseline factory on both base and merge (fingerprint 0f314816d50228e6240f1048998f802dd80d499ba91277a72f2a366e9c574dd2, exit 1). Test source, target module, scanner, parser, and baseline ledger are byte-identical across those trees. This replays the failing factory decision, not the entire repository ratchet.

CI is complete on the exact head: build, production/test types, lint, all UI and changed Gateway tests, E2E, and security checks passed. The only failed jobs are the two attributed above and their aggregate gate. Hosted code review also completed with no findings. Landing uses the authorized inherited-failure exception; failed CI is not represented as green.

@clawsweeper

clawsweeper Bot commented Oct 16, 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 size: S labels Oct 16, 2026
Keep summary updates bounded and incremental through the existing refresh coordinator and transcript reducer. Preserve the requested maxChars limit during delta catch-up.
@steipete
steipete force-pushed the perf/chat-history-cost-1326 branch from 95b8bb2 to 945ad91 Compare October 16, 2026 16:17
@steipete
steipete marked this pull request as ready for review October 16, 2026 16:18
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T16:21:29.631933Z 945ad91 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@steipete
steipete merged commit cfc5fcf into main Oct 16, 2026
209 of 214 checks passed
@steipete
steipete deleted the perf/chat-history-cost-1326 branch October 16, 2026 16:34
@steipete

Copy link
Copy Markdown
Contributor Author

Merged reviewed head 945ad91c1a9e10f601b5d0844fd5f664f00c175a as cfc5fcf02b6b1d5ff72b4fdfce4f82e9a982371a under the authorized inherited-failure exception.

CI run 38930867257 completed. Build, lint, production/test types, UI/Gateway tests, E2E, and security passed. The two inherited failures are check-guards (uncovered cli-parent-lifetime.mjs) and checks-fast-baseline-ratchets (doctor-plugin-source-captures.test.ts:32 mock-export violation), plus their aggregate CI status. Both reproduce against the actual CI main parent 04d8503ee8ab97218b3283968293d079b1a8b219 and tested merge 52ab6ad0e81e9fbab53fa3e96f1d2edb3d2e3fe3; commands, scope, and matching failure signatures are recorded in the PR body. The automated “new” classification compared an older scheduled main run. No CI reruns were used.

The independent review and hosted exact-head code review were clean. The native publisher stopped before submission because its separate PR review worktree was absent; the explicitly authorized exact-SHA REST fallback performed the squash merge.

vincentkoc added a commit that referenced this pull request Oct 16, 2026
* commit 'a4c73619a5c': (29 commits)
  test: align model and Discord fixtures with runtime owners
  perf(sessions): reuse startup deletion discovery (#174408)
  fix(gateway): attribute ephemeral connections in normal logs (#174406)
  test(telegram): consolidate duplicate coverage (batch d117) (#173112)
  perf(doctor): avoid redundant backup and transcript reads (#174416)
  fix(update): avoid redundant reads for closed SQLite generations (#174426)
  fix(ui): Activity page tabs collapse to a few pixels on desktop (#173856)
  fix(decisions): skip prefilter for empty tool surfaces (#174269)
  perf(sqlite): retain unchanged database proofs across schema updates (#174409)
  refactor(test): remove duplicate export collision checks (#174391)
  fix: clear unused MCP and identity helper exports (#174421)
  fix(test): supply SQLite reliability fixture catalog
  refactor(mattermost): use the guarded transport directly (#174419)
  refactor(agents): trust prepared provider facts (#174388)
  fix(control-ui): open submenus immediately on click (#174292)
  test(anthropic): synchronize the late-send fixture with initialization
  refactor(ui): scope Plugins page state to Solid owners (#174281)
  perf(chat): pace board history refreshes and reuse cursors (#174407)
  perf(sqlite): bound session receipt scope publication (#174395)
  refactor(openrouter): share key budget test fixtures (#174340)
  ...
vincentkoc added a commit that referenced this pull request Oct 16, 2026
…157433

* commit '2e8bfec53fc1cf06c9e438f42b027a82e04ace9a': (29 commits)
  test: align model and Discord fixtures with runtime owners
  perf(sessions): reuse startup deletion discovery (#174408)
  fix(gateway): attribute ephemeral connections in normal logs (#174406)
  test(telegram): consolidate duplicate coverage (batch d117) (#173112)
  perf(doctor): avoid redundant backup and transcript reads (#174416)
  fix(update): avoid redundant reads for closed SQLite generations (#174426)
  fix(ui): Activity page tabs collapse to a few pixels on desktop (#173856)
  fix(decisions): skip prefilter for empty tool surfaces (#174269)
  perf(sqlite): retain unchanged database proofs across schema updates (#174409)
  refactor(test): remove duplicate export collision checks (#174391)
  fix: clear unused MCP and identity helper exports (#174421)
  fix(test): supply SQLite reliability fixture catalog
  refactor(mattermost): use the guarded transport directly (#174419)
  refactor(agents): trust prepared provider facts (#174388)
  fix(control-ui): open submenus immediately on click (#174292)
  test(anthropic): synchronize the late-send fixture with initialization
  refactor(ui): scope Plugins page state to Solid owners (#174281)
  perf(chat): pace board history refreshes and reuse cursors (#174407)
  perf(sqlite): bound session receipt scope publication (#174395)
  refactor(openrouter): share key budget test fixtures (#174340)
  ...
vincentkoc added a commit that referenced this pull request Oct 16, 2026
…/decision-onnx-v2-proof-20261016

* commit '2e8bfec53fc1cf06c9e438f42b027a82e04ace9a': (29 commits)
  test: align model and Discord fixtures with runtime owners
  perf(sessions): reuse startup deletion discovery (#174408)
  fix(gateway): attribute ephemeral connections in normal logs (#174406)
  test(telegram): consolidate duplicate coverage (batch d117) (#173112)
  perf(doctor): avoid redundant backup and transcript reads (#174416)
  fix(update): avoid redundant reads for closed SQLite generations (#174426)
  fix(ui): Activity page tabs collapse to a few pixels on desktop (#173856)
  fix(decisions): skip prefilter for empty tool surfaces (#174269)
  perf(sqlite): retain unchanged database proofs across schema updates (#174409)
  refactor(test): remove duplicate export collision checks (#174391)
  fix: clear unused MCP and identity helper exports (#174421)
  fix(test): supply SQLite reliability fixture catalog
  refactor(mattermost): use the guarded transport directly (#174419)
  refactor(agents): trust prepared provider facts (#174388)
  fix(control-ui): open submenus immediately on click (#174292)
  test(anthropic): synchronize the late-send fixture with initialization
  refactor(ui): scope Plugins page state to Solid owners (#174281)
  perf(chat): pace board history refreshes and reuse cursors (#174407)
  perf(sqlite): bound session receipt scope publication (#174395)
  refactor(openrouter): share key budget test fixtures (#174340)
  ...
vincentkoc added a commit that referenced this pull request Oct 16, 2026
…ision-accounting-native

* commit '2e8bfec53fc1cf06c9e438f42b027a82e04ace9a': (29 commits)
  test: align model and Discord fixtures with runtime owners
  perf(sessions): reuse startup deletion discovery (#174408)
  fix(gateway): attribute ephemeral connections in normal logs (#174406)
  test(telegram): consolidate duplicate coverage (batch d117) (#173112)
  perf(doctor): avoid redundant backup and transcript reads (#174416)
  fix(update): avoid redundant reads for closed SQLite generations (#174426)
  fix(ui): Activity page tabs collapse to a few pixels on desktop (#173856)
  fix(decisions): skip prefilter for empty tool surfaces (#174269)
  perf(sqlite): retain unchanged database proofs across schema updates (#174409)
  refactor(test): remove duplicate export collision checks (#174391)
  fix: clear unused MCP and identity helper exports (#174421)
  fix(test): supply SQLite reliability fixture catalog
  refactor(mattermost): use the guarded transport directly (#174419)
  refactor(agents): trust prepared provider facts (#174388)
  fix(control-ui): open submenus immediately on click (#174292)
  test(anthropic): synchronize the late-send fixture with initialization
  refactor(ui): scope Plugins page state to Solid owners (#174281)
  perf(chat): pace board history refreshes and reuse cursors (#174407)
  perf(sqlite): bound session receipt scope publication (#174395)
  refactor(openrouter): share key budget test fixtures (#174340)
  ...
vincentkoc added a commit that referenced this pull request Oct 16, 2026
…158510

* commit '26cbd409b9753a9318a6dc09f97b2f0b4b776a09': (29 commits)
  test: align model and Discord fixtures with runtime owners
  perf(sessions): reuse startup deletion discovery (#174408)
  fix(gateway): attribute ephemeral connections in normal logs (#174406)
  test(telegram): consolidate duplicate coverage (batch d117) (#173112)
  perf(doctor): avoid redundant backup and transcript reads (#174416)
  fix(update): avoid redundant reads for closed SQLite generations (#174426)
  fix(ui): Activity page tabs collapse to a few pixels on desktop (#173856)
  fix(decisions): skip prefilter for empty tool surfaces (#174269)
  perf(sqlite): retain unchanged database proofs across schema updates (#174409)
  refactor(test): remove duplicate export collision checks (#174391)
  fix: clear unused MCP and identity helper exports (#174421)
  fix(test): supply SQLite reliability fixture catalog
  refactor(mattermost): use the guarded transport directly (#174419)
  refactor(agents): trust prepared provider facts (#174388)
  fix(control-ui): open submenus immediately on click (#174292)
  test(anthropic): synchronize the late-send fixture with initialization
  refactor(ui): scope Plugins page state to Solid owners (#174281)
  perf(chat): pace board history refreshes and reuse cursors (#174407)
  perf(sqlite): bound session receipt scope publication (#174395)
  refactor(openrouter): share key budget test fixtures (#174340)
  ...
vincentkoc added a commit that referenced this pull request Oct 16, 2026
…esafe-decision-native

* commit '26cbd409b9753a9318a6dc09f97b2f0b4b776a09': (29 commits)
  test: align model and Discord fixtures with runtime owners
  perf(sessions): reuse startup deletion discovery (#174408)
  fix(gateway): attribute ephemeral connections in normal logs (#174406)
  test(telegram): consolidate duplicate coverage (batch d117) (#173112)
  perf(doctor): avoid redundant backup and transcript reads (#174416)
  fix(update): avoid redundant reads for closed SQLite generations (#174426)
  fix(ui): Activity page tabs collapse to a few pixels on desktop (#173856)
  fix(decisions): skip prefilter for empty tool surfaces (#174269)
  perf(sqlite): retain unchanged database proofs across schema updates (#174409)
  refactor(test): remove duplicate export collision checks (#174391)
  fix: clear unused MCP and identity helper exports (#174421)
  fix(test): supply SQLite reliability fixture catalog
  refactor(mattermost): use the guarded transport directly (#174419)
  refactor(agents): trust prepared provider facts (#174388)
  fix(control-ui): open submenus immediately on click (#174292)
  test(anthropic): synchronize the late-send fixture with initialization
  refactor(ui): scope Plugins page state to Solid owners (#174281)
  perf(chat): pace board history refreshes and reuse cursors (#174407)
  perf(sqlite): bound session receipt scope publication (#174395)
  refactor(openrouter): share key budget test fixtures (#174340)
  ...
vincentkoc added a commit that referenced this pull request Oct 16, 2026
…/decision-tool-v2-proof-20261016

* commit '26cbd409b9753a9318a6dc09f97b2f0b4b776a09': (29 commits)
  test: align model and Discord fixtures with runtime owners
  perf(sessions): reuse startup deletion discovery (#174408)
  fix(gateway): attribute ephemeral connections in normal logs (#174406)
  test(telegram): consolidate duplicate coverage (batch d117) (#173112)
  perf(doctor): avoid redundant backup and transcript reads (#174416)
  fix(update): avoid redundant reads for closed SQLite generations (#174426)
  fix(ui): Activity page tabs collapse to a few pixels on desktop (#173856)
  fix(decisions): skip prefilter for empty tool surfaces (#174269)
  perf(sqlite): retain unchanged database proofs across schema updates (#174409)
  refactor(test): remove duplicate export collision checks (#174391)
  fix: clear unused MCP and identity helper exports (#174421)
  fix(test): supply SQLite reliability fixture catalog
  refactor(mattermost): use the guarded transport directly (#174419)
  refactor(agents): trust prepared provider facts (#174388)
  fix(control-ui): open submenus immediately on click (#174292)
  test(anthropic): synchronize the late-send fixture with initialization
  refactor(ui): scope Plugins page state to Solid owners (#174281)
  perf(chat): pace board history refreshes and reuse cursors (#174407)
  perf(sqlite): bound session receipt scope publication (#174395)
  refactor(openrouter): share key budget test fixtures (#174340)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
…174407)

Keep summary updates bounded and incremental through the existing refresh coordinator and transcript reducer. Preserve the requested maxChars limit during delta catch-up.
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 size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant