Skip to content

fix(ui): load older chat history through one reader-edge owner - #204600

Merged
obviyus merged 2 commits into
mainfrom
fix/chat-history-reading-owner
Nov 24, 2026
Merged

obviyus merged 2 commits into
mainfrom
fix/chat-history-reading-owner

Conversation

@obviyus

@obviyus obviyus commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes #204562.

On WebKit, a reader who pressed Home in a long chat sometimes never got older history: the reader reached the top (or stopped part-way) and no chat.history page was requested. chat-history-reading-stability.e2e.test.ts (webkit, 390 px) failed on scheduled main with messageCount: 30 instead of 190, also after #204416.

Cause: the scroll offset has several writers (native Home input, TranscriptReaderAnchor corrections, virtual-core), and the older-history trigger only fired when a particular writer landed at a particular time. Instrumented runs on a CPU-starved Linux WebKit showed four paths:

  1. The native smooth scroll skipped the 0-1,200 px prefetch band between frames, and the anchor's held correction wrote the rest of the way to the top. That write is maintenance, so the band-crossing intent gate never saw a reader movement.
  2. The IntersectionObserver reported the edge during a maintenance write; the callback dropped it and waited for "the next sync", which needed another upward reader scroll that never came.
  3. Same as 2, through an observer created before the gesture.
  4. Virtual-core's 150 ms isScrolling debounce lapsed between two frames of the slow smooth scroll. The anchor took that as the end of native scrolling, wrote a correction, and the write cancelled the Home scroll thousands of pixels from the top. WebKit's scrollend is not a safe substitute: it fired twice for one smooth scroll.

Change

One owner: ChatPaneHistory.evaluateHistoryEdge() decides "the reader is at the history edge, load older". It runs on every transcript offset publication (whichever writer moved the offset) and at the existing pane-commit call site. It loads when the reader's intent is upward and scrollTop is within CHAT_HISTORY_PREFETCH_EDGE_PX, or for the existing one-shot short-viewport fill.

  • Reader intent is set only by the reader: upward input (Home, PageUp, ArrowUp, wheel, touch), now with no distance check, so Home from 11,000 px counts; or native upward movement the transcript did not write (scrollbar). Downward reader movement withdraws it. One gesture arms one load: starting the load consumes the intent, and continuous input (a wheel stream, smooth-scroll frames) cannot re-arm it until the gesture idles.
  • Removed: the history IntersectionObserver and its sentinel element (historyObserver*, syncHistoryObserver, clearHistoryObserver, the sentinel ref, the .chat-history-sentinel element and CSS, and the transcript overlay slot that only carried it), the band-crossing scroll gate, and the "drop the callback during maintenance and wait for another sync" branch.
  • Writer fix (path 4): TranscriptReaderAnchor keeps holding a correction while an input's own scrolling continues. Once the input has produced a scroll, only that input's idle ends the hold, and native motion after an early idle re-asserts the gesture. A transcript write ends the gesture. Non-input motion behaves as before. Because virtual-core's idle flush can run before the input's own idle, a correction held only by native input is rechecked on the next animation frame. A continuing smooth scroll delivers its scroll event before animation-frame callbacks, so it keeps the hold; an ended one settles.
  • Production code: +114 / -177 lines.

User impact

  • Home or PageUp from far down now reaches the top and loads older history every time.
  • Accepted edge case: if the reader's last input was upward and a programmatic jump (reply link, search) then lands within 1,200 px of the top, one older page prefetches. Before, that needed new reader input.
  • No other change in when history loads.

Evidence

  • Linux WebKit, Playwright, node:24-bookworm, container limited to 1 CPU, chat-history-reading-stability (webkit, 390 px), uninstrumented: base 68f294f fails 4 of 60 runs (all messageCount: 30, the CI signature); this head 86f9e04 fails 0 of 64.
  • Hosted CI on 86f9e04: green.
  • New tests in chat-pane-history.test.ts: one load per upward intent on a short page (removing the consume step makes it chain 6 loads; red), the short-viewport fill stays one-shot, and a Home press loads when a layout correction (not the reader) lands the offset at the edge.
  • New idle-gap case in chat-transcript-reader-anchor.browser.test.ts: a held correction stays held when virtual-core goes idle mid smooth scroll (red on base: expected 420 to be 500), and settles one frame after the input's own idle.
  • Pane, transcript, offset-observer and reader-anchor tests: 14 files, 280 tests pass. History e2e set (31 files): 30 pass; initial-connect-splash "keeps finalized recording pixels intact" fails the same way on the base locally (screen-recording environment, unrelated).

@clawsweeper

clawsweeper Bot commented Nov 24, 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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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. labels Nov 24, 2026
@clawsweeper

clawsweeper Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR replaces observer-based older-history triggering with reader-intent evaluation and preserves native scrolling across premature virtualizer idle signals.

Example: Press Home in a long conversation on 390-pixel WebKit with a CPU-starved runner.

  • Before: The conversation can retain only 30 of 190 messages because older history is never requested.
  • After: The intended result is that Home completes and older history loads even when a reader-anchor correction reaches the edge.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is focused and CI is green, but the required runtime evidence is absent.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Pressing Home can stop before the top or reach it without loading older conversation messages.
Reason: The reported failure violates established history navigation, and the collaborator-authored direction includes the narrow prefetch tradeoff.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it addresses a concrete WebKit history-navigation failure through the existing owners, and no definite introduced correctness or security defect was found.

Priority: P2
Reviewed head: 86f9e04c97e5d77807cc53eac19da71657b3c950

Before merge

None.

Findings

None.

Tests

  • Low-value test ui/src/pages/chat/chat-pane-history.test.ts: Remove the new “keeps the short-viewport fill one-shot” case: it mocks the loader and duplicates the stronger autofill test that verifies actual loaded messages, request bounds, and reopening.
  • Missing end-to-end proof: Provide a redacted recording or runtime trace on the reviewed head showing Home in one-CPU, 390-pixel WebKit loading the older page and preserving the reader’s position through correction settlement.
Agent review details

How this fits together

The Control UI transcript observes native input and scroll offsets, preserves the reader’s position through row measurements, and asks the existing history loader for older Gateway or catalog pages.

flowchart TD
  A[Reader input] --> B[Transcript offset owner]
  B --> C[Reader anchor]
  B --> D[History edge evaluator]
  C --> B
  E[Pane commit] --> D
  D --> F[Existing history loader]
  F --> G[Transcript rows]
Loading

Technical review

Best possible solution:

Keep history admission in ChatPaneHistory and native-scroll preservation in the existing offset and reader-anchor owners, with the superseded observer path removed.

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

The linked report provides a concrete one-CPU Linux WebKit scenario, and current-main source supports the maintenance-arrival and premature-idle paths; this read-only review did not execute it.

Is this the best way to solve the issue?

The change addresses both history admission and the correction writer using existing owners, removes the replaced path completely, and introduces no unnecessary production layer.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • History admission and automatic fill keeps the original intent (b410516: Bound startup history downloads and reserve subsequent paging for reader intent; later source uses a one-shot viewport fill.)
  • History sentinel and overlay removal changes intended behavior with a stated reason (fix: keep older chat history reachable when message rows shift #204216: Keep the paging boundary reachable while reader-anchor corrections shift measured rows.)
  • Reader-anchor native-offset hold keeps the original intent (f725c9f: Hold corrections in the row column because native scroll writes can cancel WebKit gestures.)
  • Input-scrolling idle lifecycle keeps the original intent (9913a32: Prevent an earlier movement’s idle signal from clearing a newly started Home gesture.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source -63, Tests -82. Total -145 across 28 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 15 114 177 -63
Tests 13 133 215 -82
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 28 247 392 -145

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test changes Production +114/-177; tests and support +133/-215 The reduction comes from removing observer machinery and obsolete fixtures while retaining focused history and idle-gap regressions.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #204562
Summary: This PR is the candidate repair for the remaining Home-navigation failure after the earlier idle-signal fix.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P2: Intermittent WebKit keyboard navigation leaves older history unloaded, with Show earlier available as an in-product alternative.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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: Intermittent WebKit keyboard navigation leaves older history unloaded, with Show earlier available as an in-product alternative.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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 November 24, 2026, 6:02 AM ET / 11:02 UTC.

@obviyus
obviyus merged commit ab100d2 into main Nov 24, 2026
115 checks passed
@obviyus
obviyus deleted the fix/chat-history-reading-owner branch November 24, 2026 11:29
@obviyus

obviyus commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as ab100d2.

  • Bug: on WebKit, Home in a long chat sometimes stopped part-way or never loaded older history. Several writers move the scroll offset, and the older-history trigger only fired when one particular writer landed at the right time.
  • Fix: one owner (evaluateHistoryEdge) decides history loading on every offset publication, from reader intent plus position. The reader anchor no longer writes into a running native smooth scroll. The history IntersectionObserver and its sentinel are gone (production code -63 lines).
  • Proof: 1-CPU Linux WebKit loop, base 4 of 60 failed, this head 0 of 64; hosted CI green; new tests for one load per intent and for the idle gap.

tideclaw-bot pushed a commit that referenced this pull request Nov 25, 2026
## What Problem This Solves

Fixes #204562.

On WebKit, a reader who pressed **Home** in a long chat sometimes never got older history: the reader reached the top (or stopped part-way) and no `chat.history` page was requested. `chat-history-reading-stability.e2e.test.ts` (webkit, 390 px) failed on scheduled `main` with `messageCount: 30` instead of 190, also after #204416.

Cause: the scroll offset has several writers (native Home input, `TranscriptReaderAnchor` corrections, virtual-core), and the older-history trigger only fired when a particular writer landed at a particular time. Instrumented runs on a CPU-starved Linux WebKit showed four paths:

1. The native smooth scroll skipped the 0-1,200 px prefetch band between frames, and the anchor's held correction wrote the rest of the way to the top. That write is maintenance, so the band-crossing intent gate never saw a reader movement.
2. The `IntersectionObserver` reported the edge during a maintenance write; the callback dropped it and waited for "the next sync", which needed another upward reader scroll that never came.
3. Same as 2, through an observer created before the gesture.
4. Virtual-core's 150 ms `isScrolling` debounce lapsed between two frames of the slow smooth scroll. The anchor took that as the end of native scrolling, wrote a correction, and the write cancelled the Home scroll thousands of pixels from the top. WebKit's `scrollend` is not a safe substitute: it fired twice for one smooth scroll.

## Change

One owner: `ChatPaneHistory.evaluateHistoryEdge()` decides "the reader is at the history edge, load older". It runs on every transcript offset publication (whichever writer moved the offset) and at the existing pane-commit call site. It loads when the reader's intent is upward and `scrollTop` is within `CHAT_HISTORY_PREFETCH_EDGE_PX`, or for the existing one-shot short-viewport fill.

- Reader intent is set only by the reader: upward input (Home, PageUp, ArrowUp, wheel, touch), now with no distance check, so Home from 11,000 px counts; or native upward movement the transcript did not write (scrollbar). Downward reader movement withdraws it. One gesture arms one load: starting the load consumes the intent, and continuous input (a wheel stream, smooth-scroll frames) cannot re-arm it until the gesture idles.
- Removed: the history `IntersectionObserver` and its sentinel element (`historyObserver*`, `syncHistoryObserver`, `clearHistoryObserver`, the sentinel ref, the `.chat-history-sentinel` element and CSS, and the transcript `overlay` slot that only carried it), the band-crossing scroll gate, and the "drop the callback during maintenance and wait for another sync" branch.
- Writer fix (path 4): `TranscriptReaderAnchor` keeps holding a correction while an input's own scrolling continues. Once the input has produced a scroll, only that input's idle ends the hold, and native motion after an early idle re-asserts the gesture. A transcript write ends the gesture. Non-input motion behaves as before. Because virtual-core's idle flush can run before the input's own idle, a correction held only by native input is rechecked on the next animation frame. A continuing smooth scroll delivers its scroll event before animation-frame callbacks, so it keeps the hold; an ended one settles.
- Production code: +114 / -177 lines.

## User impact

- Home or PageUp from far down now reaches the top and loads older history every time.
- Accepted edge case: if the reader's last input was upward and a programmatic jump (reply link, search) then lands within 1,200 px of the top, one older page prefetches. Before, that needed new reader input.
- No other change in when history loads.

## Evidence

- Linux WebKit, Playwright, `node:24-bookworm`, container limited to 1 CPU, `chat-history-reading-stability` (webkit, 390 px), uninstrumented: base 68f294f **fails 4 of 60 runs** (all `messageCount: 30`, the CI signature); this head 86f9e04 **fails 0 of 64**.
- Hosted CI on 86f9e04: green.
- New tests in `chat-pane-history.test.ts`: one load per upward intent on a short page (removing the consume step makes it chain 6 loads; red), the short-viewport fill stays one-shot, and a Home press loads when a layout correction (not the reader) lands the offset at the edge.
- New `idle-gap` case in `chat-transcript-reader-anchor.browser.test.ts`: a held correction stays held when virtual-core goes idle mid smooth scroll (red on base: `expected 420 to be 500`), and settles one frame after the input's own idle.
- Pane, transcript, offset-observer and reader-anchor tests: 14 files, 280 tests pass. History e2e set (31 files): 30 pass; `initial-connect-splash` "keeps finalized recording pixels intact" fails the same way on the base locally (screen-recording environment, unrelated).

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit ab100d2)
Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 25, 2026
…law#204600)

## What Problem This Solves

Fixes openclaw#204562.

On WebKit, a reader who pressed **Home** in a long chat sometimes never got older history: the reader reached the top (or stopped part-way) and no `chat.history` page was requested. `chat-history-reading-stability.e2e.test.ts` (webkit, 390 px) failed on scheduled `main` with `messageCount: 30` instead of 190, also after openclaw#204416.

Cause: the scroll offset has several writers (native Home input, `TranscriptReaderAnchor` corrections, virtual-core), and the older-history trigger only fired when a particular writer landed at a particular time. Instrumented runs on a CPU-starved Linux WebKit showed four paths:

1. The native smooth scroll skipped the 0-1,200 px prefetch band between frames, and the anchor's held correction wrote the rest of the way to the top. That write is maintenance, so the band-crossing intent gate never saw a reader movement.
2. The `IntersectionObserver` reported the edge during a maintenance write; the callback dropped it and waited for "the next sync", which needed another upward reader scroll that never came.
3. Same as 2, through an observer created before the gesture.
4. Virtual-core's 150 ms `isScrolling` debounce lapsed between two frames of the slow smooth scroll. The anchor took that as the end of native scrolling, wrote a correction, and the write cancelled the Home scroll thousands of pixels from the top. WebKit's `scrollend` is not a safe substitute: it fired twice for one smooth scroll.

## Change

One owner: `ChatPaneHistory.evaluateHistoryEdge()` decides "the reader is at the history edge, load older". It runs on every transcript offset publication (whichever writer moved the offset) and at the existing pane-commit call site. It loads when the reader's intent is upward and `scrollTop` is within `CHAT_HISTORY_PREFETCH_EDGE_PX`, or for the existing one-shot short-viewport fill.

- Reader intent is set only by the reader: upward input (Home, PageUp, ArrowUp, wheel, touch), now with no distance check, so Home from 11,000 px counts; or native upward movement the transcript did not write (scrollbar). Downward reader movement withdraws it. One gesture arms one load: starting the load consumes the intent, and continuous input (a wheel stream, smooth-scroll frames) cannot re-arm it until the gesture idles.
- Removed: the history `IntersectionObserver` and its sentinel element (`historyObserver*`, `syncHistoryObserver`, `clearHistoryObserver`, the sentinel ref, the `.chat-history-sentinel` element and CSS, and the transcript `overlay` slot that only carried it), the band-crossing scroll gate, and the "drop the callback during maintenance and wait for another sync" branch.
- Writer fix (path 4): `TranscriptReaderAnchor` keeps holding a correction while an input's own scrolling continues. Once the input has produced a scroll, only that input's idle ends the hold, and native motion after an early idle re-asserts the gesture. A transcript write ends the gesture. Non-input motion behaves as before. Because virtual-core's idle flush can run before the input's own idle, a correction held only by native input is rechecked on the next animation frame. A continuing smooth scroll delivers its scroll event before animation-frame callbacks, so it keeps the hold; an ended one settles.
- Production code: +114 / -177 lines.

## User impact

- Home or PageUp from far down now reaches the top and loads older history every time.
- Accepted edge case: if the reader's last input was upward and a programmatic jump (reply link, search) then lands within 1,200 px of the top, one older page prefetches. Before, that needed new reader input.
- No other change in when history loads.

## Evidence

- Linux WebKit, Playwright, `node:24-bookworm`, container limited to 1 CPU, `chat-history-reading-stability` (webkit, 390 px), uninstrumented: base 0dad4de **fails 4 of 60 runs** (all `messageCount: 30`, the CI signature); this head 86f9e04 **fails 0 of 64**.
- Hosted CI on 86f9e04: green.
- New tests in `chat-pane-history.test.ts`: one load per upward intent on a short page (removing the consume step makes it chain 6 loads; red), the short-viewport fill stays one-shot, and a Home press loads when a layout correction (not the reader) lands the offset at the edge.
- New `idle-gap` case in `chat-transcript-reader-anchor.browser.test.ts`: a held correction stays held when virtual-core goes idle mid smooth scroll (red on base: `expected 420 to be 500`), and settles one frame after the input's own idle.
- Pane, transcript, offset-observer and reader-anchor tests: 14 files, 280 tests pass. History e2e set (31 files): 30 pass; `initial-connect-splash` "keeps finalized recording pixels intact" fails the same way on the base locally (screen-recording environment, unrelated).

Co-authored-by: Ayaan Zaidi <[email protected]>
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 P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L 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.

chat-history-reading-stability (webkit, 390 px): Home still leaves older history unloaded on slow runners

1 participant