Skip to content

fix(ui): keep older chat history still while reading it - #190286

Merged
roboclaw-bot merged 8 commits into
mainfrom
openclaw/delta-crayfish
Nov 1, 2026
Merged

roboclaw-bot merged 8 commits into
mainfrom
openclaw/delta-crayfish

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

On mobile (reported from iOS Safari), messages jump around while you scroll up through older chat history after it loads. Three things cause it, and each one moves the messages on screen when a row above the viewport changes size:

  1. Rows skipped by content-visibility: auto (≤768 px). Offscreen overscan rows keep their virtual estimate (120 px) until they reach the viewport. Then they render at full size and push the messages being read down, by up to about 1,300 px in the repro.
  2. Corrections land one frame late. Since fix(ui): prevent resize errors when scrolling chat images #188470, virtual-core applies row measurements on the next animation frame, so it isn't committing the range inside native resize delivery. Rows lay out in normal flow, though, so each estimate→real correction above the reader is painted once as a jump before it snaps back.
  3. iOS defers every correction for the whole gesture. iOS WebKit cancels touch and momentum scrolling on a scrollTop write, so virtual-core holds every correction until scrolling settles. The transcript stays displaced for the whole fling, then snaps.

Solution

  • TranscriptReaderAnchor (new, owned by the virtualizer host) watches mounted rows. When a row above the viewport changes size, it corrects during that same resize delivery, before paint, using native geometry only. It never commits the range, so the fix(ui): prevent resize errors when scrolling chat images #188470 contract still holds:
    • Outside iOS gestures, it writes scrollTop. Like virtual-core's own path, the write is recorded as maintenance and the native range grows first.
    • During iOS touch or momentum, it shifts the row column instead: a negative margin, mirrored in scrollMargin so virtual and DOM offsets still agree. The shift folds into scrollTop when virtual-core reports that scrolling has settled. It skips elastic overscroll.
    • When virtual-core lands the measured size, the anchor's predicate reconciles it (no double correction). It also takes over iOS-held corrections that virtual-core would otherwise defer. Restoration, scroll commands, and the prepend and disclosure anchors still own placement while they are active.
    • Hidden panes (collapsed side panel, clientHeight 0) report zero-height rows; those deliveries are ignored so a restored panel keeps its reading position.
  • The compensation predicate now covers rows above the reader in both scroll directions. Virtual-core's default skipped re-measured rows while scrolling backward, which is exactly when reading older history.
  • Mobile rows no longer use content-visibility: auto. The virtualizer already limits how many rows are mounted, so overscan rows now lay out (and get measured) while still offscreen.
  • The history sentinel's IntersectionObserver now observes anew when it fires during a maintenance correction. It used to drop that notification, and since an unchanged intersection is never reported again, auto-loading at the top could get stuck.
  • Row-key commits moved into chat-transcript-header.ts (with the existing header-margin helper) to stay under the host's line budget.

Evidence

  • New ui/src/e2e/chat-history-reading-stability.e2e.test.ts: 30 recent + 160 older variable-height messages. It reads up to the top to load the older page, then reads upward through it for 240 frames, sampling the painted frame and following the first visible message.
    • Base (bf73e1aa): fails on all three — Chromium 390 px with iPhone UA: 36 shifted frames, worst 1,255 px; WebKit 390 px: 29 shifted frames, worst 1,246 px; Chromium 1280 px: 38 shifted frames, worst 809 px.
    • This branch: 0 shifted frames on all three.
  • Existing e2e: chat-history-prepend-anchor (all variants, including touch and momentum), session-dashboard-active-panel (caught the hidden-pane case in CI; fixed and green), session-progress-scroll, chat-widget-autosize, chat-composer-accessory-focus, warm-boot, post-deploy-session-entry, chat-saved-attempt-navigation, claude-sessions, chat-flow.messaging: all green.
  • Unit and browser: all chat-transcript-* tests, chat history, thread, page and session-progress suites — 988 tests green after merging current main.
  • Real Gateway (temporary harness, not committed): isolated Gateway, a 400-message session, the real chat.startup plus chat.history paging at 390 px with an iPhone UA, reading upward through about 90 messages (1,109 frames): 0 shifted frames on this branch, so no regression. In that harness the base build also showed 0, because the rows had real sizes cached before they mounted, so this run is no-regression evidence, not a reproduction.
  • pnpm tsgo:ui, oxlint, stylelint, oxfmt, madge import cycles, assertion-safety ratchet, pnpm ui:i18n:verify, git diff --check.
  • main was merged in to pick up the fix for an inherited check-lint-core-2 failure (src/skills/workshop/experience-review.test.ts, untouched here).

Test change

chat-transcript-end-follow.browser.test.ts ("holds the canceled viewport…") used to grow the earlier row in the same task as cancelScroll(). Now that is a real resize above the reader, and it gets compensated. The fixture now grows the row while the smooth journey is still in flight, which is the skipped-measurement case the test is about. The assertions are unchanged.

Accepted edges

  • iOS: if you reach the very top in the same gesture that accumulated a column shift, the first rows stay clipped above the edge until the gesture settles (one fold, invisible to the reader).
  • A row that grows above the reader and unmounts before its measurement lands has its correction retired instead of reverted.

Not verified

  • No physical iPhone. iOS behavior was exercised through virtual-core's UA-based iOS path in Chromium and Playwright WebKit.

Worked on by

roboclaw-bot and others added 2 commits November 1, 2026 11:30
Rows above the reader changed size without a same-frame correction:
- mobile rows skipped by content-visibility kept their estimate until
  they reached the viewport, then pushed the visible messages down;
- virtual-core lands row measurements a frame later, so each
  correction painted as a jump;
- on iOS virtual-core defers corrections for the whole touch and
  momentum gesture, leaving the transcript displaced until it snapped.

A reader anchor now compensates rows above the viewport during resize
delivery with native geometry only (scrollTop, or a column shift on iOS
that folds into scrollTop when scrolling settles) and reconciles when
virtual-core lands the size. The history sentinel observes anew when a
correction coincides with reaching the top edge.

Co-authored-by: vyctorbrzezowski <[email protected]>
Worked on by:
- @vyctorbrzezowski

Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: 1b49cc4a-1ce9-4ee7-8436-8ff6ecd56f5d
@clawsweeper

clawsweeper Bot commented Nov 1, 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. 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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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 Nov 1, 2026
@clawsweeper

clawsweeper Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR compensates for transcript row resizing so older chat messages stay in place while readers scroll upward.

Example: Read upward through 160 older variable-height messages at a 390 px viewport.

  • Before: The PR reports message displacement reaching 1,255 px in Chromium.
  • After: The PR reports zero shifted frames with the reader anchor enabled.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The fix has clear user value and focused regression coverage, but a hidden-panel regression, failing source guards, and insufficient changed-behavior proof prevent a pass.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 3 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Messages move unexpectedly while users read older chat history.
Reason: Stable reading position is an existing product contract, and the maintainer-authored PR establishes direction without requiring another product decision.

Merge readiness

⛔ Needs changes before merge - 4 items remain

Keep this useful, maintainer-authored PR open, but fix the hidden-panel scroll regression and two source-backed CI blockers before merging.

Priority: P2
Reviewed head: 8cd37dbbb33ce76482976f16b0c5bbdda24847f1

Before merge

  • Preserve cached heights when retained panels are hidden (P2) - Hiding a retained dashboard conversation produces zero-size observations while its rows remain connected. This observer stores those zero heights, then interprets restored heights above the viewport as new growth and applies an extra scroll correction when Panels reopens. The existing measureTranscriptRow owner preserves hidden measurements, but this path reads borderBoxSize directly. Exact-head dashboard CI records scrollTop 1744 instead of 1444 after reopening. Ignore hidden zero-width receipts without rejecting legitimate visible zero-height rows, following the existing measurement contract.
  • Remove the anchor's reverse dependency on its host (P2) - The host imports TranscriptReaderAnchor, and this new type import points back to the host. The repository's import-cycle checker includes type-only imports, so this creates a cycle and blocks check-guards-architecture; CI identifies madge-import-cycles as failing. Define the narrow host contract using leaf types or callbacks instead of deriving it from ChatSessionVirtualizerHost.
  • Satisfy the assertion-safety contract for observed rows (P3) - The new HTMLElement assertion has no SAFETY invariant and no baseline allowance, so it adds a governed assertion and fails the assertion-safety ratchet reported by CI. Preserve the HTMLElement type through registration or document the verified invariant that this observer only receives rows registered by observe(HTMLElement); do not increase the baseline.
  • Explain or restore the original intent of Hidden-panel measurement retention - b67eb3e: Retain cached dimensions for zero-width observations captured while a panel is hidden, including delayed delivery after reveal.

Findings

  • [P2] Preserve cached heights when retained panels are hidden — ui/src/pages/chat/components/chat-transcript-reader-anchor.ts:105-114
  • [P2] Remove the anchor's reverse dependency on its host — ui/src/pages/chat/components/chat-transcript-reader-anchor.ts:4-8
  • [P3] Satisfy the assertion-safety contract for observed rows — ui/src/pages/chat/components/chat-transcript-reader-anchor.ts:97

Provenance

  • Hidden-panel measurement retention changes intended behavior without addressing why it exists (b67eb3e: Retain cached dimensions for zero-width observations captured while a panel is hidden, including delayed delivery after reveal.)

Tests

  • Missing end-to-end proof: Provide a sanitized recording or frame trace of uncached older-history scrolling through the served Control UI; the reported real-Gateway scenario also passes on base.
Agent review details

How this fits together

The Control UI transcript host combines paginated messages, virtual row measurements, and reader input to maintain the visible range and native scroll position.

flowchart TD
  A[Paginated chat history] --> B[Transcript host]
  B --> C[Virtualizer and row renderer]
  C --> D[Native row resize observations]
  D --> E[Reader anchor]
  E --> F[Scroll offset or held column shift]
  F --> C
Loading

Technical review

Best possible solution:

Keep the host-owned reader compensation, preserve hidden-row measurements, and use a leaf dependency contract that passes the existing guards.

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

The source exposes delayed row compensation and backward-scroll behavior, and the PR reports failing-base browser cases; this read-only review ran no target code.

Is this the best way to solve the issue?

Same-frame native compensation addresses the stated invariant without restoring resize-loop-prone range commits, but the new observer must honor the existing hidden-pane measurement contract.

Full review comments:

  • [P2] Preserve cached heights when retained panels are hidden — ui/src/pages/chat/components/chat-transcript-reader-anchor.ts:105-114
    Hiding a retained dashboard conversation produces zero-size observations while its rows remain connected. This observer stores those zero heights, then interprets restored heights above the viewport as new growth and applies an extra scroll correction when Panels reopens. The existing measureTranscriptRow owner preserves hidden measurements, but this path reads borderBoxSize directly. Exact-head dashboard CI records scrollTop 1744 instead of 1444 after reopening. Ignore hidden zero-width receipts without rejecting legitimate visible zero-height rows, following the existing measurement contract.
    Confidence: 0.98
  • [P2] Remove the anchor's reverse dependency on its host — ui/src/pages/chat/components/chat-transcript-reader-anchor.ts:4-8
    The host imports TranscriptReaderAnchor, and this new type import points back to the host. The repository's import-cycle checker includes type-only imports, so this creates a cycle and blocks check-guards-architecture; CI identifies madge-import-cycles as failing. Define the narrow host contract using leaf types or callbacks instead of deriving it from ChatSessionVirtualizerHost.
    Confidence: 0.99
  • [P3] Satisfy the assertion-safety contract for observed rows — ui/src/pages/chat/components/chat-transcript-reader-anchor.ts:97
    The new HTMLElement assertion has no SAFETY invariant and no baseline allowance, so it adds a governed assertion and fails the assertion-safety ratchet reported by CI. Preserve the HTMLElement type through registration or document the verified invariant that this observer only receives rows registered by observe(HTMLElement); do not increase the baseline.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Deferred virtual row measurements keeps the original intent (7e4ffc5: Defer row-driven range commits to avoid native ResizeObserver loops while keeping viewport compensation synchronous.)
  • Initial placement and compensation ownership keeps the original intent (c476ce6: Retain the requested initial range until placement finishes or reader input takes over.)
  • Compact row content visibility changes intended behavior with a stated reason (52b43f7: Remove automatic content skipping only on desktop while preserving compact scrolling behavior; this PR explains its broader removal with measured reading-position failures.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm check:madge-import-cycles
  • pnpm check:assertion-safety
  • pnpm tsgo:ui
  • pnpm exec vitest run --config ui/vitest.config.ts ui/src/pages/chat/components/chat-transcript-row-refs.test.ts --maxWorkers=1
  • pnpm exec vitest run --config ui/vitest.config.ts ui/src/e2e/session-dashboard-active-panel.e2e.test.ts ui/src/e2e/chat-history-reading-stability.e2e.test.ts --maxWorkers=1

What I checked:

PR surface

Source +304, Tests +153. Total +457 across 10 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 8 342 38 +304
Tests 2 154 1 +153
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 496 39 +457

Labels

Label changes:

  • add P2: Reading-position jumps impair long-history browsing, with a limited and recoverable user impact.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: Reading-position jumps impair long-history browsing, with a limited and recoverable user impact.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 1, 2026, 6:49 AM ET / 11:49 UTC.

roboclaw-bot and others added 6 commits November 1, 2026 11:50
A collapsed side panel reports zero-height rows; compensating them moved
the restored reading position. Also type the reader anchor's host
structurally so it does not import its owner, and drop the unchecked
entry-target assertion.

Co-authored-by: vyctorbrzezowski <[email protected]>
Worked on by:
- @vyctorbrzezowski

Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: e5ce6995-83a6-4b8c-b7f9-7a487dbf4515
Worked on by:
- @vyctorbrzezowski

Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: 81cfeeb3-954f-4e42-bf8d-c5d1ad277862
Follow the transcript measurement contract: hidden rows keep their last
height, while a visible row may legitimately measure zero.

Co-authored-by: vyctorbrzezowski <[email protected]>
Worked on by:
- @vyctorbrzezowski

Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: e0ecec8d-a0d2-413d-ada7-408389b84f79
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: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant