Repository navigation
fix(ui): load older chat history through one reader-edge owner - #204600
Conversation
Co-authored-by: obviyus <[email protected]>
Co-authored-by: obviyus <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource -63, Tests -82. Total -145 across 28 files. Added test files: 0. View PR surface stats
Preflight sourceSource 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
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 24, 2026, 6:02 AM ET / 11:02 UTC. |
|
Landed as ab100d2.
|
## 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]>
…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]>
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.historypage was requested.chat-history-reading-stability.e2e.test.ts(webkit, 390 px) failed on scheduledmainwithmessageCount: 30instead of 190, also after #204416.Cause: the scroll offset has several writers (native Home input,
TranscriptReaderAnchorcorrections, 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:IntersectionObserverreported 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.isScrollingdebounce 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'sscrollendis 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 andscrollTopis withinCHAT_HISTORY_PREFETCH_EDGE_PX, or for the existing one-shot short-viewport fill.IntersectionObserverand its sentinel element (historyObserver*,syncHistoryObserver,clearHistoryObserver, the sentinel ref, the.chat-history-sentinelelement and CSS, and the transcriptoverlayslot that only carried it), the band-crossing scroll gate, and the "drop the callback during maintenance and wait for another sync" branch.TranscriptReaderAnchorkeeps 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.User impact
Evidence
node:24-bookworm, container limited to 1 CPU,chat-history-reading-stability(webkit, 390 px), uninstrumented: base 68f294f fails 4 of 60 runs (allmessageCount: 30, the CI signature); this head 86f9e04 fails 0 of 64.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.idle-gapcase inchat-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.initial-connect-splash"keeps finalized recording pixels intact" fails the same way on the base locally (screen-recording environment, unrelated).