Skip to content

fix(gateway): preserve history fragments across paged reads - #186536

Merged
vincentkoc merged 2 commits into
mainfrom
fix/control-ui-history-source-cursors-20261028
Oct 28, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
fix/control-ui-history-source-cursors-20261028

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes missing assistant commentary when a small history page splits the display fragments of one stored transcript row.

User Impact

Complete source-row groups remain reachable when opening and paging history. Ordinary tail and numeric-offset pages can now return directional history cursors, allowing clients to continue through bounded pages without reopening an anchor.

The requested message count is a soft target, including on the initial tail: a complete source group may exceed it. The existing response byte budget and fetchable oversized-message references still apply. Existing numeric pagination remains available.

Why This Change Was Made

The initial-tail count cap could return only the final fragment of an assistant row, while nextOffset skipped that entire stored row. Reuse the existing source-group pagination policy for both head and offset admission, removing the separate adjacent-only offset cap and strict head slice. Record consumed message endpoints before display filtering and carry those primitive facts into the existing cursor owner; hidden pages can then make progress without retaining another raw-message array.

Native cursor identity, current sharing checks, retained reset intervals, active-leaf and delta metadata remain governed by their existing owners. Claude CLI paging keeps its injected sequence resolver and source-reset semantics. No schema, config or runtime adapter changes.

Evidence

  • Red: published regression-only b822d73 on frozen 26e71ce returned only the final answer instead of two commentary fragments plus the final answer. The real SQLite/production history-handler/serialized-frame test failed at the intended assertion; seven siblings passed (149.10 s wrapper, Node 26.12.1, Darwin arm64). Response/transport callbacks were mocked.
  • Green candidate: 15 cases passed, followed by five selected final byte-budget/all-hidden/retained cases passing (13 skipped). Together these cover the current 18-case module, including ordinary tail, offset zero/middle, append then older/reverse traversal, hidden progress, byte caps, authorization, rewrite reset and retained physical history. Wrapper wall times: 103.35 s and 70.44 s.
  • Siblings: 39 tests passed across four files covering canonical tail pagination, Claude paging, request budgets/fetchable references and history state (80.37 s wrapper).
  • Full staged-source independent review and fresh autoreview: no actionable findings through P2. Formatting, actual native staged-content/freshness guard and unchanged candidate identity passed.
  • Linux/Node 24.22.1 Testbox: core production types and all 29 selected consumer test-type graphs passed on captured tree 107f694. Initial lint found one missing test-sort comparator; that one-line correction subsequently passed targeted type-aware lint and its three affected paging cases (15 skipped, 38.60 s wrapper) on the qualified Darwin/Node 26 owner. The original remote wrapper ended with exit 1, including a cleanup-reconciliation warning; this is not an aggregate-green remote run. Exact-head CI run 40641579246 completed successfully for dbc7d15. The current ClawSweeper review reports no findings, Before merge: None, and no Rank-up moves list.

Production: +65/-47 (net +18); tests: +166/-56 (net +110); docs: +2/-1. The production increase records cursor progress at its producer and reuses existing count policy. This is a pagination foundation for bounded history loading; no deployed Firefox heap reduction, live browser/WebSocket proof or performance measurement is claimed.

@vincentkoc vincentkoc self-assigned this Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 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 gateway Gateway runtime size: XS labels Oct 28, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR preserves complete transcript-row display fragments and adds existing directional cursors to ordinary history pages.

Example: Read an assistant row containing Commentary A, Commentary B, and Final answer with limit: 1, then request offset: 1.

  • Before: The newest page contains only Final answer, and the older page skips both commentary fragments.
  • After: The newest page contains all three assistant fragments, and the older page contains Earlier question exactly once.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A useful, focused owner-level repair with no actionable findings and reported integration regression coverage.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied validation exercises real SQLite, production history handlers, and serialized frames with mocked response callbacks, rather than a shipped Gateway transport.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Opening a small history page and then loading older messages can leave assistant commentary missing from the conversation.
Reason: The maintainer-authored direction restores complete source-row visibility through existing owners and retains bounded responses.

Merge readiness

✅ Ready for maintainer review

This PR completes the earlier regression-only draft with a focused repair for a defect still present on main; no actionable introduced bugs were found.

Priority: P2
Reviewed head: dbc7d15cefe176090c6a1f64fe79204fbf3e4f0d

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped Gateway/WebSocket run of the limit: 1 fragment scenario is supplied; the maintainer-authored PR is outside the ordinary contributor proof gate.
Agent review details

How this fits together

Gateway history handlers read persisted transcript rows, project display messages, and return byte-bounded pages with offsets and source-bound continuation cursors.

flowchart LR
  A[History client] --> B[Gateway history handler]
  B --> C[Transcript readers]
  C --> D[Display projection]
  D --> E[Source group selection]
  E --> F[Response budget and cursors]
  F --> A
Loading

Technical review

Best possible solution:

Use the shared source-group selector and existing cursor owner while preserving byte budgets, transcript bytes, and current sharing checks.

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

The concrete two-row regression matches main's strict tail slice and source-based offset advancement; the author reports an intended red-to-green result, and this read-only review ran no target code.

Is this the best way to solve the issue?

The patch repairs selection at the shared producer, removes the competing offset cap, and reuses existing cursor and budget contracts without unnecessary machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Tail and offset count selection changes intended behavior with a stated reason (110b747: The bounded older-page refactor retained a strict initial-tail slice while preserving source groups for older offsets; its stated goal was reliable bounded reads and consistent turn boundaries.)
  • Shared sequence-group closure keeps the original intent (7dd2721: The existing paginator explicitly closes pages over interleaved sequence groups because public sequence cursors cannot split one.)
  • Directional cursors, source identity, and response budgets keeps the original intent (e36feb2: Bound anchored responses, preserve physical transcript identity, and keep oversized source rows recoverable through existing message references.)
  • History kernel ownership and reset recovery keeps the original intent (63b1488: Share history kernels while leaving admission, authorization, CLI handling, and lifecycle ownership with their established callers; subsequent reset recovery remains intact.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit e36feb2 adds src/gateway/server-methods/chat-history-page-kernel.ts:382 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e36feb232b78; files: src/gateway/server-methods/chat-history-page-kernel.ts)

PR surface

Source +18, Tests +110, Docs +1. Total +129 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 65 47 +18
Tests 1 166 56 +110
Docs 2 2 1 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 233 104 +129

Review metrics

Metric Value Why it matters
Production versus test change Production +65/-47; tests +166/-56 The production growth carries consumed cursor endpoints while consolidating count selection; test growth covers distinct ordinary-page, visibility, append, and retained-history boundaries.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Small history pages can suppress displayed commentary fragments without losing stored transcript data or establishing an urgent widespread outage.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-28T05:08:05.679Z sha b822d73 :: needs changes before merge. :: none

Reviewed October 28, 2026, 2:08 AM ET / 06:08 UTC (Revision 2).

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M and removed size: XS labels Oct 28, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review October 28, 2026 06:03
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review current head dbc7d15cefe176090c6a1f64fe79204fbf3e4f0d. The production owner repair and executed red-to-green proof are now in the PR body; the earlier regression-only draft is complete.

@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 28, 2026
@clawsweeper clawsweeper Bot removed the clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. label Oct 28, 2026
@vincentkoc
vincentkoc merged commit e5ca68c into main Oct 28, 2026
224 checks passed
@vincentkoc
vincentkoc deleted the fix/control-ui-history-source-cursors-20261028 branch October 28, 2026 06:19
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 29, 2026
…#186536)

* test(gateway): reproduce split history source fragments

* fix(gateway): keep paged history source groups reachable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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