Skip to content

fix(gateway): preserve older history across hidden message gaps - #188557

Merged
steipete merged 1 commit into
mainfrom
steipete/fix-chat-history-hasmore-dense-gap-20261030
Oct 30, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/fix-chat-history-hasmore-dense-gap-20261030

Conversation

@steipete

@steipete steipete commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes older chat history becoming unreachable across dense hidden-message runs after #188372.

User Impact

Earlier visible messages remain reachable through source-bound cursors and the established offset API. A fully consumed hidden prefix still terminates without offering a false continuation. The Control UI's no-throw/no-unusable-boundary behavior from #188372 is unchanged.

Why This Change Was Made

Tail and offset pages also carry source anchors. Requiring an encoded older cursor for every anchored page suppressed valid offsets on transcripts without message IDs. Preserve that numeric contract while respecting the reader's exhausted-source fact.

For ID-bearing transcripts, use the oldest raw source row consumed by the page, even when hidden. Keep the first retained visible boundary instead when a display limit or response budget omitted older visible messages; those messages must remain fetchable. This also avoids rereading hidden rows already consumed by the initial page.

Credit #188372 for the original hidden-prefix and UI repair; this is a focused follow-up, compatible with #188483's bidirectional oversized-message paging. The message-centered test now expects hasMore: true: message 1 precedes its [2, 3, 4] page and an older cursor exists. Its offset fields remain absent.

Evidence

Final head: 1b1029abcd3b31f719f30b262354fc4bff27e42a. Exact-head CI run 41097787302 completed successfully, including its final openclaw/ci-gate job. The final rebase was patch-identical to the reviewed change and includes #188483. The combined CI/security status is also green after completed-run reconciliation 41104900734: the first review had reported CI incomplete despite the successful gate job. Only the status review was reconciled; CI tests were not rerun.

  • On main, the unchanged dense-gap Gateway test fails because nextOffset is missing; the centered-page test fails on its stale hasMore assertion.
  • New tail/offset cursor regression is red on main: the initial page uses visible message 82 instead of consumed raw message 80. It follows the cursor to both older visible messages and independently verifies offset paging.
  • Focused Gateway/server/history proof: 136 tests pass across seven files, including the full chat server file, cursor/page/tail owners, transcript readers, and memory/SQLite history. The cursor file takes 29.75s; the remaining compatibility run takes 104.74s including compilation. PR CI supplies broad and exact-head proof.
  • The original dense-gap server test remains unchanged and passes. Both exhausted-hidden-prefix cases retain hasMore: false and pass.
  • Existing cursor traversal assertions now expect zero, rather than two, empty pages when the initial ordinary page already consumed those hidden rows. The older visible result is unchanged.
  • Native Control UI E2E: all 6 tests pass (23.00s), including tool-only missing-boundary behavior, error retry, and hidden-page traversal.
  • Changed-file oxlint and oxfmt, targeted Gateway-methods test typecheck, and diff whitespace check pass. Test-line ratchet passes without a baseline change.
  • Independent subagent review (autoreview route unavailable): clean P0–P2 review of the complete local diff against main at 90b5734. Canonical Codex autoreview preflight refused the configured provider route mismatch; no operator configuration was changed.

Production LOC: +10 across the existing three paging owners. The growth preserves distinct numeric and source-cursor contracts while retaining hidden-prefix termination. Correctness repair; no performance claims or stress benchmark required.

Rebase note (TS lead): main gained #188488 (legacy offset exhaustion: || (pagination && anchor.hasOlder)) after this branch was cut. The conflict in chat-history-response-page.ts resolves to this PR's condition. It covers #188488's case and also bounds it by nextOffset < totalMessages and response-budget trimming. Local proof on the rebased head 499cc5a: chat-history-handler.cli-import, chat-history-page-cursor, chat-history-pages and server.chat.gateway-server-chat-b (109 tests); ui chat-history-loading e2e (6 tests); tsgo:core; oxfmt and oxlint all pass.

@clawsweeper

clawsweeper Bot commented Oct 30, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 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-30T18:31:08.369771Z 499cc5a New commits
ℹ️ 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S labels Oct 30, 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: 🦐 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 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 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The PR preserves older-history continuation across hidden messages while retaining numeric-offset pagination and correct end-of-history detection.

Example: A transcript contains two older visible messages, 80 NO_REPLY messages, and one latest answer; chat.history requests limit=1 and offset=0.

  • Before: On an ID-less transcript, the latest answer can return without nextOffset, making the older visible messages unreachable through pagination.
  • After: The response returns nextOffset=1, and requesting limit=2 at that offset retrieves both older visible messages.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with useful reported integration coverage; supplied evidence does not establish the changed behavior through a shipped entry point.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate and introduces no material authority change; its reported Gateway tests exercise production owners in a harness, while the inspected screenshots cover the predecessor rather than the changed paging behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Older visible conversation messages can become unreachable when hidden rows separate them from the latest answer.
Reason: The maintainer-authored direction restores an established pagination contract with a small change and preserves the prior boundary-error repair.

Regression provenance

Regression provenance — verified: source commit 3d7b4c47e9c8 by Peter Steinberger; canonical PR #188372 (blame-to-merge-commit).

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR repairs a current-main history-pagination regression with a focused change to existing owners; no actionable correctness or security findings were identified.

Priority: P2
Reviewed head: 1b1029abcd3b31f719f30b262354fc4bff27e42a

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No supplied shipped-Gateway trace demonstrates this PR's ID-less offset continuation and ID-bearing dense-gap traversal.
Agent review details

How this fits together

Gateway chat.history reads bounded transcript windows, projects visible messages, and applies response budgets before returning messages and continuation metadata to clients.

flowchart LR
  A[History request] --> B[Transcript reader]
  B --> C[Display projection]
  C --> D[Response budget and cursors]
  D --> E[Messages and continuation]
Loading

Technical review

Best possible solution:

Retain this focused repair in the existing tail, cursor, and response owners while preserving exhausted-prefix termination and complete source groups.

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

Current-main source demonstrates the ID-less continuation failure, and the unchanged dense-gap Gateway test exercises its observable result; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch is the smallest complete repair found: it corrects boundary facts at their existing producer and restores numeric continuation without undoing hidden-prefix exhaustion.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Source-bound cursor selection keeps the original intent (e36feb2: Bound anchored responses while retaining fetchable source groups and physical-session identity.)
  • Continuation availability changes intended behavior with a stated reason (3d7b4c4: Stop false earlier-history continuation after the reader consumes an entirely hidden prefix.)
  • Consumed tail endpoints keeps the original intent (e5ca68c: Preserve complete source fragments and permit cursor progress through filtered pages.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 3d7b4c4 adds src/gateway/chat-history-response-page.ts:233 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3d7b4c47e9c8; files: src/gateway/chat-history-response-page.ts)

PR surface

Source +10, Tests +30, Docs +4. Total +44 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 18 8 +10
Tests 2 32 2 +30
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 54 10 +44

Review metrics

Metric Value Why it matters
Production versus test delta Production +18/-8; tests +32/-2 The small production increase preserves distinct cursor and offset contracts; the regression extends existing fixtures without introducing machinery.

Labels

Label changes:

  • add P2: Older messages can become unreachable through pagination on affected transcripts, with a limited history-reading blast radius.
  • 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.

Label justifications:

  • P2: Older messages can become unreachable through pagination on affected transcripts, with a limited history-reading blast radius.
  • 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.

Reviewed October 30, 2026, 1:34 PM ET / 17:34 UTC.

Keep consumed raw source boundaries for cursors without skipping visible rows omitted by page limits. Preserve the numeric-offset contract for ID-less transcripts while terminating fully consumed hidden prefixes. Follow-up to #188372, compatible with #188483.
@steipete
steipete force-pushed the steipete/fix-chat-history-hasmore-dense-gap-20261030 branch from 1b1029a to 499cc5a Compare October 30, 2026 18:29
@steipete
steipete merged commit b65482e into main Oct 30, 2026
38 of 41 checks passed
@steipete
steipete deleted the steipete/fix-chat-history-hasmore-dense-gap-20261030 branch October 30, 2026 18:29
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
…claw#188557)

Keep consumed raw source boundaries for cursors without skipping visible rows omitted by page limits. Preserve the numeric-offset contract for ID-less transcripts while terminating fully consumed hidden prefixes. Follow-up to openclaw#188372, compatible with openclaw#188483.
tideclaw-bot added a commit that referenced this pull request Nov 5, 2026
Backport accepted fixes onto 2026.11.5-beta.2.

Base: bc061f9
Canonical source tree before commit: e6c0c39

These are adapted/squashed backports; do not claim each is an exact Git cherry-pick.
Source provenance (selected verified commits; other cohorts use their frozen patch/adoption manifests):

runtime-B:
b20a0cc fix(macos): connect with configured credentials despite stale app environment (#191468)
c4c0942 fix(update): failed updates from 10.7–10.9 crash in automatic migration recovery (#189713)
6aae408 fix(update): preserve recovery errors and async triage callbacks (#191495)
8910654 fix(macos): prevent first-launch Gateway failures after upgrades (#191436)
00b2ff4 fix: parent sessions miss child approvals with a custom session store (#189827)
c6142a8 fix: avoid copying managed plugin binaries during Gateway startup (#187865)
e72b356 fix(anthropic): avoid token profile collisions (#187875)
807075d fix(anthropic): set API workspace at login (#186976)
bafe92f fix(exec): preserve no-timeout results from macOS app nodes (#190729)
9b05a64 fix(imessage): use a PostgreSQL-safe recovery cursor key (#184919)
6ba197f fix: session search on PostgreSQL scans every transcript row instead of using the text index (#187909)
4f49aa5 fix(sessions): PostgreSQL session search scans every transcript row again after the 5th search on a connection (#188979)
de3936c fix(macos): Mac tab shows a blank or stale page when a load fails (#185432)
e977080 fix(macos): prevent duplicate voice sends and false sent feedback (#186271)

provider-compaction:
1b43c2e fix(compaction): preserve active request provenance (#180214)
7b0cfe3 fix(google): restore tool calls with Python keyword parameters (#191561)
9039ceb fix(ci): keep compaction attribution helpers internal
d6a1327 feat(google): use the Interactions API for Gemini Flash models (#189395)
fe0f8d1 fix(google): Gemini models ignore configured topP (#190695)

history:
c51d733 fix(sessions): stop expanding archive reads from exhausting memory (#190690)
3c8bd4d fix(sessions): page oversized earlier history instead of failing at 8 MiB (#188450)
b195f61 fix(sessions): page oversized transcript history in both directions (#188483)
b65482e fix(gateway): preserve older history across hidden message gaps (#188557)
3d4fc94 fix(sessions): avoid oversized listing and imported-history reads (#189284)
33e7baf fix(sessions): bound active accounting without blocking writers (#190182)
682ade7 fix: preserve chat history continuation metadata (#188612)

runtime-C:
7e005b0 fix(macos): keep secrets when a Gateway config save fails (#187734)
15cf738 fix(macos): keep Gateway auth when Tailscale exposure is turned off (#187664)
b53a06b perf(update): read candidate state inventory without copying the shared database (#187921)
970fc4e fix: restore CLI message sends with agent tool policies (#188058)
73ad731 fix: stop model fallback when session capability metadata changes (#179312)
32305db fix: subagent turns fail after session metadata changes (#183501)
d13bd0f fix(codex): include relay conversation instructions in trajectory (#189005)
e375530 fix: replies after a plugin reload from Control UI go to the session's last external chat (#190982)
9346376 fix: reasoning-only retry is refused by Anthropic as reasoning_extraction (#184434)

direct-auth-state:
1b15408 fix(models): keep the model list when one plugin-owned provider lacks a credential (#189014)
7d8dc60 fix: recover startup migration with retained worker index (#189023)

capacity:
41772e3 fix(worktrees): settle completed disk debt on refused postchecks (#188727)

command-once-189369:
8269137 fix(plugins): plugin commands that continue the agent run three times on native command turns (#189369)

pg-board-189564:
7232a8d fix(boards): publish widgets with PostgreSQL storage (#189564)

queued-edit-189869:
92b32ca fix: hold queued messages through inline edits (#189869)

Preserve source attribution from original commits. For a genuinely exact individual pick only, use the conventional (cherry picked from commit <sha>) line.
Full file-level provenance: coverage-manifest.json; reviewed patch hashes: artifact-registry.json.
No held136/native82 content adopted by this work. No release or full-candidate qualification claim.

Additional original-source identities (exact adapted hunk scope is in frozen artifacts):
release-guides-185258: 39c37e6 docs(release): define ledger-first hotfix routing (#185258)
UI-history: 10a6e4f fix(ui): scope provider-add discovery warning to its own provider (#188541), 3d7b4c4 fix(ui): never fail loading earlier chat history without a boundary (#188372)
obsolete-cache-188203: 90d82c2 fix: preserve completed reasoning and refill chat snapshots (#188203)
webhook-169778: b1f643f fix(startup): keep webhook decisions startup recorded for channels Doctor left pending (#169778)
schema-lease-188391: ba6cfcd fix(state): keep lease renewal independent of parent admission (#188391)
backfill-188976: c75a8a8 fix(gateway): stop session row backfill once the Gateway is closing (#188976)
canonical-disable-188846: 88b56ee fix(config): auto-enable reads and writes mixed-case plugin policy under the canonical id (#188846)
matrix-177272: 5a6d22c fix(matrix): stop seeding new thread sessions from the room transcript (#177272)
provider-hook-189059: 0588f51 fix(models): isolate every per-provider catalog failure (#189059)
unicode-189868: 87396e7 fix(oc-path): avoid reading and editing a different Unicode key (#189868)
replay-cohort: 2031044 fix(sessions): acknowledge committed input retries without duplicate turns (#188527), 9114431 fix: resume configured fallback after interrupted attempts (#188672)

Co-authored-by: RomneyDa <[email protected]>
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: S 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