fix(webchat): paginate tool-heavy chat history#87111
Conversation
|
Codex review: needs changes before merge. Reviewed June 24, 2026, 2:57 PM ET / 18:57 UTC. Summary PR surface: Source +614, Tests +232, Docs +2, Other +112. Total +960 across 24 files. Reproducibility: yes. At source level, current main has bounded Review metrics: 2 noteworthy metrics.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Mantis proof suggestion Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Land the bounded pagination only after Swift source compatibility is preserved, load-older styling matches the rendered markup, and maintainers explicitly accept the public Do we have a high-confidence way to reproduce the issue? Yes. At source level, current main has bounded Is this the best way to solve the issue? Yes with repairs. Bounded cursor pagination plus a WebChat load-older control is better than raising history limits because it preserves payload caps, but this branch still needs Swift defaulting, selector alignment, and maintainer session-state approval before it is the best landing version. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4c841ac575d7. Label changesLabel justifications:
Evidence reviewedPR surface: Source +614, Tests +232, Docs +2, Other +112. Total +960 across 24 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
|
ClawSweeper PR egg: ✨ hatched 🥚 common Tiny Crabkin. Rarity: 🥚 common. Trait: sniffs out flaky tests. DetailsShare on X: post this hatch
About:
|
|
@copilot resolve the merge conflicts in this pull request |
Resolved and committed in |
There was a problem hiding this comment.
Pull request overview
This PR adds cursor-based pagination for WebChat history so tool-heavy transcripts can load recent conversation first and fetch older turns on demand, while preserving gateway history filtering behavior.
Changes:
- Adds
beforeSeqpagination support and response metadata tochat.history. - Wires WebChat state, controller, view, CSS, and tests for “Load older messages.”
- Updates docs/tests and includes many formatting/import-order-only changes outside the pagination path.
Reviewed changes
Copilot reviewed 66 out of 68 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/gateway/server-methods/chat.ts |
Implements paged chat history projection and metadata. |
src/gateway/session-utils.ts |
Exports reverse transcript visitor. |
src/gateway/session-utils.fs.ts |
Adds reverse transcript traversal helper. |
src/gateway/protocol/schema/logs-chat.ts |
Adds beforeSeq request validation. |
src/gateway/protocol/index.test.ts |
Covers beforeSeq validation. |
src/gateway/server.chat.gateway-server-chat-b.test.ts |
Adds gateway pagination regression tests. |
src/gateway/server-methods/server-methods.test.ts |
Covers canvas page-boundary behavior. |
ui/src/ui/controllers/chat.ts |
Adds pagination state and older-page loading. |
ui/src/ui/controllers/chat.test.ts |
Covers pagination state and prepend behavior. |
ui/src/ui/views/chat.ts |
Renders load-older control. |
ui/src/ui/views/chat.test.ts |
Tests load-older button rendering/clicking. |
ui/src/ui/e2e/chat-flow.e2e.test.ts |
Adds GUI pagination E2E coverage. |
ui/src/ui/app.ts |
Adds app-level pagination state. |
ui/src/ui/app-view-state.ts |
Extends app view state type. |
ui/src/ui/app-render.ts |
Wires older-history loading into chat view. |
ui/src/ui/app-render.helpers.ts |
Resets pagination on session switch. |
ui/src/ui/app-chat.ts |
Resets pagination on history clear. |
ui/src/styles/chat/grouped.css |
Styles load-older row/button. |
ui/src/ui/chat/build-chat-items.ts |
Removes fixed 100-message render cap. |
ui/src/ui/chat/build-chat-items.test.ts |
Updates render-limit expectations. |
ui/src/ui/chat/history-limits.ts |
Adds dedicated input recall limit. |
ui/src/ui/chat/input-history.ts |
Uses input-specific recall limit. |
scripts/control-ui-mock-dev.ts |
Adds paged mock chat history. |
docs/web/webchat.md |
Documents WebChat pagination. |
docs/gateway/protocol.md |
Documents chat.history pagination fields. |
| Other touched files | Formatting/import-order-only changes. |
| } | ||
| // Keep input recall aligned with what chat UI renders: only consider the visible history window. | ||
| const start = Math.max(0, messages.length - CHAT_HISTORY_RENDER_LIMIT); | ||
| const start = Math.max(0, messages.length - CHAT_INPUT_HISTORY_RECALL_LIMIT); |
|
@clawsweeper review |
f521658 to
afa6756
Compare
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
afa6756 to
43dddb2
Compare
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Summary
origin/mainas one clean WebChat/Gateway pagination commit.chat.historycursor pagination withbeforeSeq,hasMore,nextBeforeSeq,oldestSeq, andnewestSeq.__openclaw.seqvalues.Load older messagescontrol with loading/disabled state, prepend/dedupe behavior, and scroll-position preservation.Release note: WebChat can load older transcript pages in tool-heavy Codex sessions without unbounded history payloads.
Scope cleanup
extensions/diffs/assets/viewer-runtime.jsgenerated-asset drift by rebuilding from currentorigin/main.src/flows/doctor-core-checks.runtime.tsand other unrelated mainline changes untouched.Real behavior proof
Behavior addressed: WebChat no longer strands users with only 1-2 useful turns when tool-heavy transcript rows fill the bounded recent history slice.
Real environment tested: Local Codex worktree at
f521658dc573c80495ed52ebf8502dba2b77c0fa; Control UI mock dev server athttp://127.0.0.1:5187/chat.Exact steps or command run after this patch:
node --import tsx scripts/protocol-gen.ts && node --import tsx scripts/protocol-gen-swift.ts && git diff --checknode_modules/.bin/oxlint src/gateway/server-methods/chat.ts src/gateway/session-utils.fs.ts ui/src/ui/controllers/chat.ts ui/src/ui/chat/build-chat-items.ts scripts/control-ui-mock-dev.ts src/gateway/server.chat.gateway-server-chat-b.test.ts src/gateway/session-utils.fs.test.ts ui/src/ui/controllers/chat.test.ts ui/src/ui/chat/build-chat-items.test.ts ui/src/ui/e2e/chat-flow.e2e.test.ts --config .oxlintrc.jsonnode scripts/run-vitest.mjs src/gateway/session-utils.fs.test.ts src/gateway/protocol/index.test.ts ui/src/ui/controllers/chat.test.ts ui/src/ui/views/chat.test.ts ui/src/ui/chat/build-chat-items.test.tsnode scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/ui/e2e/chat-flow.e2e.test.ts.agents/skills/autoreview/scripts/autoreview --mode localnode --import tsx scripts/control-ui-mock-dev.ts --port 5187, then Playwright opened/chat, clickedLoad older messagestwice, and checked the final page state.Evidence after fix:
chat.historyrequest includesbeforeSeq.beforeSeqmodel output.git diff --check: clean.oldest page 01,middle page 01, andrecent page 01were visible together;Load older messagesbutton count was0oncehasMore=false.Observed result after fix:
Load older messagesappears while older transcript pages exist.hasMore=false.What was not tested:
Cannot find package 'rastermill' imported from src/media/image-ops.ts. In that command,src/gateway/server-methods/server-methods.test.tsandsrc/gateway/server.chat.gateway-server-chat-b.test.tsfailed during import before the gateway cases could execute.Regression coverage
beforeSeq.Load older messagescontrol.beforeSeqrequest.Risk checklist
Did user-visible behavior change? Yes.
Did config, environment, or migration behavior change? No.
Did security, auth, secrets, network, or tool execution behavior change? No.
Highest-risk area: Gateway
chat.historypagination semantics around active transcript branches, hidden/tool-only rows, byte budgets, and imported CLI augmentation.Mitigation: Kept the protocol additive, preserved existing history caps/budgets/placeholders, limited imported history to first-page augmentation, added focused edge-case tests, ran UI E2E, and reran autoreview until clean.
Current review state
Next action: wait for CI on
f521658dc573c80495ed52ebf8502dba2b77c0faand maintainer/ClawSweeper re-review on the clean rebased SHA.Addressed comments:
extensions/diffs/assets/viewer-runtime.jsrewrite is gone.requestHostUpdate?.()applied; stale input-history comment updated.beforeSeq.origin/main, with unrelated conflicts/churn removed instead of preserving the dirty merge commit.