Skip to content

fix(chat): long chats reach the latest message after a resize and a scroll to the end - #2417

Merged
bkudiess merged 2 commits into
openclaw:mainfrom
bkudiess:bkudiess/flake-sidebar-message240
Dec 1, 2026
Merged

bkudiess merged 2 commits into
openclaw:mainfrom
bkudiess:bkudiess/flake-sidebar-message240

Conversation

@bkudiess

@bkudiess bkudiess commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: f6985c99f7c4c5488e021b80162c38e7e36f6161

Dimension Assessment Rationale
Change confidence 9.5/10 ↑ Targeted in-flight remeasure injection: 10/10 fix runs where it fired landed at the exact end; the same injection failed main 6/6.
↑ Final code passed the message-240 test 20/20 (screenshots 0 and 1, native keyboard) and 10/10 under CPU burners on Crabbox ARM64.
↑ Three policy tests each fail when one part of the fix is removed (growth refill, landing-retry reset, pending coalescing); Shared, Tray, build, timing ratchet and docs checks pass locally.
↑ Dual-model review: no CRITICAL or HIGH; both MEDIUM findings fixed and delta-reviewed.
↓ Behavior change for every resized chat: up to 8 growth corrections plus 2 landing retries per resize or revision; no visible-jitter measurement.
↑ CI green on this head (run 46545948597 attempt 2), including both Mock Gateway fixture lanes, the chat-layout UI shard and the new-test soak.
↓ Attempt 1 lost the Tray UI lane to the tracked 0xC0000409 testhost crash outside this diff; one failed-jobs rerun was used.
↓ Crabbox full shard and ReactorChatLayoutProof class have host-limited failures that also fail on clean main.
Diagnosis confidence 9/10 ↑ Instrumented main runs: in 9 of 10 contended runs the wide step reached the end only on its last landing retry, with no growth credit after the session switch.
↑ Injecting one more in-flight remeasure reproduced the exact CI stack and diagnostics on main.
↓ Mechanism inferred from Crabbox traces and injection; CI runs carry no scroll diagnostics.
Evidence fit 9/10 ↑ CI failures on #2373 and #2296 match: "message 240 visible at wide width", message bounds Empty and offscreen, Jump to latest shown, final message clipped below the composer.
↓ No CI trace confirms the exhausted-budget state directly.

Related: #2126

What Problem This Solves

In a long chat, after switching sessions and making the window wider, scrolling to the end with a screen reader (UI Automation) could stop short of the last message. The final message stayed below the visible area and Jump to latest stayed on screen. CI caught this as an intermittent failure of GatewayFixtureUiTests.SidebarSwitchesRealHistoriesAndShowsMessage240AtBothWidths on unrelated PRs (#2373, #2296).

User Impact

User impact: long chats reliably reach the latest message after a window resize and a scroll to the end, including through screen readers, and the message-240 CI test stops failing for unrelated PRs.

Why This Change Was Made

The chat corrects the scroll position when messages measure taller than estimated. After a session switch, that transcript had no growth correction left, and a resize granted only one correction plus two landing retries per transcript revision. When rows kept remeasuring while a correction was moving, every budget ran out and the view stopped short.

A viewport resize now grants its own bounded budget: up to 8 growth corrections, and the 2 landing retries again. Growth seen while a correction still waits for layout spends nothing, because that correction reads the newest size. Native remeasurement never refills a budget, reader input still clears it, and a reader who scrolled away is never pulled back. This ports the held fix ae0867aa onto current main and keeps #2319's landing retries and pinned correction anchor. The single scroll owner in #2126 remains the structural fix; this stays small until then.

Cause, class and sibling sweep
  • Why now: the held fix was parked on 11-18 ("publish only if it recurs"). It recurred on fix: finish Companion upgrades that hung on the old startup task #2373 (run 45622133119 attempt 2) and feat(themes): follow the dashboard accent with the Gateway theme #2296 (run 45692719980 attempt 1), both at the wide width. Barbara chose to land it as its own product fix.
  • Class: product race (taxonomy 10), user visible: a screen reader scroll to the end can stop short. A test-side wait would hide it.
  • Mechanism (Crabbox traces, main 5e4d198): Request() clears TailReflowCorrection after UpdateContentRevision, so growth credit stays false for the same-revision session. The wide step relied on the resize's one correction plus both landing retries (MaxLandingRetries = 2); 9 of 10 contended runs used the last retry.
  • Sweep: all callers of TailReflowCorrection (OnSizeChanged, OnExtentChanged, ObserveGeometry, OnScrollCompleted, CancelPendingNavigation, Request, UpdateTail) were checked. Review found one sibling: a pending-correction flag left set when the tail became invalid. It is now cleared in UpdateTail.
  • The 11-13 held commit's stale-target re-arm was not ported. fix: land on the latest chat message when a conversation's rows arrive in two steps #2319's correlated landing retries now cover that case.

Evidence

RED, then GREEN, of the exact CI failure. An env-gated, uncommitted, host-only injection grew the tail row 48 DIP right after each of the first three correction dispatches, so rows remeasure while a correction is moving. Diagnostic logging proved each injection fired.

Build Runs where all 3 injections fired Result
main 5e4d1986 6 (5 of 12, 1 of 4) 6/6 failed: Timed out waiting for message 240 visible at wide width, messageBounds: Empty, messageOffscreen: true. Trace: both landing retries spent, no growth credit, view short (for example off=41467 max=41987).
fix 10 of 12 10/10 passed, last landing at exact end (for example off=41755.5 max=41755.5).

Before (main plus injection): message 240 below the viewport, Jump to latest shown. After (fix plus the same injection): FINAL MESSAGE 240 and END 240 visible. Screenshots are kept in the run artifacts listed below.

Required proof pools

  • windows-winui-interactive: native chat scroll behavior in the isolated WinUI app (Gateway fixture), proven on Crabbox with the shared desktop lock and isolated profile folders.

Validation

Check Where Result
./build.ps1 local x64 ✅ exit 0
dotnet test tests/OpenClaw.Shared.Tests local x64 ✅ 6179 passed, 0 failed, 29 skipped
dotnet test tests/OpenClaw.Tray.Tests local x64, final tree ✅ 7090 passed, 0 failed
ChatTimelinePresentationTests on the final tests local x64 ✅ 125 passed
Policy tests with each part of the fix removed (3 mutations) local x64 ✅ each mutation fails one test
scripts/validate-test-timing-patterns.ps1, git diff --check, scripts/validate-docs.ps1 local ✅ passed
Message-240 test ×10, screenshots 0 and 1, native keyboard Crabbox RTX 2, ARM64 200% DPI ✅ 20/20
Message-240 test under CPU burners, screenshots 0 and 1 Crabbox RTX 2 ✅ 10/10
Changed policy tests ×10, 3 under CPU burners (repo soak equivalent; the repo soak hardcodes win-x64 and this host is ARM64) Crabbox RTX 2 ✅ 10/10
Full Gateway fixture shard (test-gateway-fixture.ps1 -UiShard All -Screenshots -NativeInputProof -KeyboardProof) Crabbox RTX 2 profile app 57/57 ✅; fixture UI 127 passed, 8 failed. All failing methods also fail on clean main on this host (1386-DIP width limit, Dashboards/Automations/Systems layout, Gateway management topology). None involve chat.
ReactorChatLayoutProofTests class Crabbox RTX 2 249–252 passed. HistoryRail hover (4) and OpenMenuShortcutDiagnostic fail identically on clean main. SendAtTail…JumpFlash flakes with the same signature on both (fix 5 of 40 cases, main 7 of 40). NewestHistoryWindow(following: False) flakes on both (1 in 5).

Crabbox runs used host commit db65766d (main 5e4d1986 plus this change before the doc-only review edits and the rebase); the product code under src is identical to this head. The policy tests were later consolidated from four methods into three, with the same coverage (mutation-checked). Run folders on RTX 2: C:\oc\m240-runs\{redinj,redinj12,greeninj,fx10,fxcpu0,fxcpu1,shard,unitsoak,rclp,rclpmain,sh8fix,sh8main,sendfix,sendmain}.

Review: Hanselman dual-model review (claude-opus-5.5 high; gpt-6-astra long_context high), plus a delta re-review of both fixes. No CRITICAL or HIGH. Fixed: a stale pending-correction flag (MEDIUM), and docs that overstated UI Automation precedence (MEDIUM; plus the send-landing exception both models flagged). Not changed here: no source-shape guard for the controller wiring; a landing retry can be spent while a newer correction is queued; landing verification ignores correction state; and a rare stale flag from ObserveGeometry while rows are invalid (all LOW).

Real behavior proof

The message-240 Gateway fixture test drives the real app: session switches, a window resize, and a UI Automation scroll to 0% then 100%. Under the in-flight remeasure injection, main reproduces the CI failure and this change reaches the final message.

CI: green on this head, run 46545948597 attempt 2. Attempt 1 hit the tracked Tray UI testhost fail-fast crash (0xC0000409, 0 failed assertions, outside this diff). c62c8b7, with identical product code, was green on its first attempt (run 46522371146): both Mock Gateway fixture lanes, the chat-layout UI shard, the new-test soak and all other required checks passed.

Not verified: no visible-jitter measurement during streaming. The repo soak script itself could not run on the ARM64 host (equivalent run above). The injection emulates late remeasurement; it is not a natural CI trace.

@clawsweeper

clawsweeper Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

🦞👀
Pull request received.

ClawSweeper review complete

ClawSweeper finished reviewing this revision.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 30, 2026
@clawsweeper

clawsweeper Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codex review: passed.

What this changes

Give resized chats a bounded correction budget so late message remeasurement does not leave the final message below the viewport.

Example: Switch to a 240-message conversation, widen the window, and use UI Automation to scroll to 100%.

  • Before: Late remeasurement can exhaust correction attempts while message 240 remains below the composer.
  • After: Resize replenishes eight growth corrections and two landing retries, allowing the view to reach the current end.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, worthwhile patch with distinct regression coverage and no definite introduced defect; inspectable behavior evidence remains limited.
Proof confidence 🦐 gold shrimp (3/6) The body supplies native fixture results and before/after geometry for session switching, resize, and UI Automation scrolling on ARM64, but the available images concern an older theme change and the reported host source equivalence could not be verified; no contributor action is required under the proof exemption.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

The scores reflect the reviewer's assessment. Real behavior proof is not required for maintainer- or bot-authored pull requests.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A long conversation can stop short of its final message after resizing and scrolling to the end.
Reason: The change repairs expected latest-message navigation, preserves existing ownership, and has direction established by its collaborator author and prior area work.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a concrete scrolling defect still present on fetched main, with no blocking introduced bugs found.

Reviewed head: c62c8b74fabb67c93a27add425717715a99c4aa0

Before merge

None.

Findings

None.

Agent review details

How this fits together

ReactorChatTimeline supplies transcript revisions and tail identity to InitialTailPositioner, which applies TailReflowCorrection decisions through the native WinUI ScrollView.

flowchart TD
  A[Transcript revision and tail identity] --> B[InitialTailPositioner]
  C[Resize and extent events] --> B
  D[Reader input] --> B
  B --> E[TailReflowCorrection]
  E --> F[Bounded correction admission]
  F --> G[Native ScrollView]
Loading

Technical review

Best possible solution:

Retain the existing scroll owner and replenish its bounded correction budgets on resize while preserving reader cancellation and lifecycle fencing.

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

Source confirms the exhausted-budget path, and the author reports matching native failures under injected remeasurement; this review did not independently execute the intermittent UI scenario.

Is this the best way to solve the issue?

This is a focused repair of the demonstrated budget exhaustion using the existing policy, with finite retries and unchanged reader admission, rather than requiring the broader draft ownership rewrite.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Extent-growth correction budget changes intended behavior with a stated reason (3d5f142: Allow one exact-bottom correction per immutable transcript update without allowing correction-induced native remeasurement to replenish it.)
  • Landing retry budget changes intended behavior with a stated reason (8ffe470: Retry corrections that land short after virtual-row remeasurement, bounded to prevent estimate churn from looping.)
  • Native anchoring and request fencing keeps the original intent (ca8fb4a: Use stable native anchoring and immutable, revalidated tail requests to avoid stale navigation and streamed-growth scroll loops.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Pinned introduced change: The pinned diff changes the existing policy and controller, adds focused budget tests, and updates their documentation without introducing another scroll owner. (src/OpenClaw.Tray.WinUI/Chat/TailNavigationPolicy.cs:446, c62c8b74fabb)
  • Fix remains absent from main: Fetched main retains the single growth credit and calls Arm on resize, without replenishing growth or landing budgets; Request clears growth credit after the revision update. (src/OpenClaw.Tray.WinUI/Chat/TailNavigationPolicy.cs:446, 29f0553fbed0)
  • Production integration and cancellation: Extent growth now passes the pending-correction state into the policy; existing follow, initial-positioning, reader-anchor, dispatch-generation, cancellation, unload, and disposal gates remain in place. (src/OpenClaw.Tray.WinUI/Chat/ReactorItemsViewScrollController.cs:815, c62c8b74fabb)
  • Distinct regression coverage: Tests cover same-revision resize replenishment, exhausted growth budgets, pending corrections preserving credit, landing-retry replenishment, and cancellation; existing reader and initial-positioning admission tests remain. (tests/OpenClaw.Tray.Tests/ChatTimelinePresentationTests.cs:504, c62c8b74fabb)
  • Reported native results and evidence limits: The complete PR body reports six failing main runs and ten passing fix runs under injected remeasurement, including after-fix geometry off=41755.5 max=41755.5, plus thirty uninstrumented or contended message-240 passes. The prepared screenshots show an older theme change. The reported host commit db65766d is unavailable through GitHub, so its equivalence to this head could not be independently verified. (c62c8b74fabb)
  • Validation receipts: The author reports a successful build, Shared tests with 6179 passes and 29 skips, Tray tests with 7090 passes, and 126 focused passes after rebase. Exact-head Tray/setup/integration and changed-test soak checks succeeded; several native UI and security checks remained in progress. No builds or tests were run during this read-only review. (c62c8b74fabb)

Likely related people:

  • Barbara Kudiess: Raw commit 0bd9348 adds src/OpenClaw.Tray.WinUI/Chat/TailNavigationPolicy.cs:27 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0bd934818151; files: src/OpenClaw.Tray.WinUI/Chat/TailNavigationPolicy.cs)
  • Karen: Raw commit ca8fb4a adds src/OpenClaw.Tray.WinUI/Chat/TailNavigationPolicy.cs:5 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ca8fb4a404ad; files: src/OpenClaw.Tray.WinUI/Chat/TailNavigationPolicy.cs)

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 and test delta Production +34/-10; tests +86/-1; documentation +18/-6. Growth stays in existing owners and adds coverage for distinct budget and cancellation failures.

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.

Label justifications:

  • 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 readiness starts with the lower of the proof and patch scores. It is capped at 3/6 if the fix is partial, the change offers little benefit, a product decision is still open, or the PR reverses an earlier decision without saying why. ✨ 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 30, 2026, 5:13 PM ET / 22:13 UTC.

bkudiess and others added 2 commits November 30, 2026 16:31
…croll to the end

After a session switch the chat has no extent-growth correction left for that
transcript revision, and a viewport resize granted only one correction plus the
two landing retries per revision. Virtualized rows realized by a resize and a
UI Automation scroll to the end keep remeasuring while a correction is in flight,
so the final message could stop short of the viewport with Jump to latest shown
(CI flake GatewayFixtureUiTests.SidebarSwitchesRealHistoriesAndShowsMessage240AtBothWidths).

- TailReflowCorrection: bounded growth budget (MaxGrowthCorrections = 8) per
  content revision or viewport resize; a resize also refills the two landing
  retries. Native remeasurement never refills either; reader input still clears.
- Growth seen while a correction waits for layout spends no credit.
- UpdateTail clears a pending-correction flag whose dispatch was abandoned.
- Docs and ledger state the bounded budgets and the existing UI Automation
  scroll-away limitation (openclaw#2126 is the structural fix).

Ported from the held fix ae0867a onto current main, keeping openclaw#2319's landing
retries and pinned correction anchor.

Co-authored-by: Copilot App <[email protected]>
@bkudiess
bkudiess force-pushed the bkudiess/flake-sidebar-message240 branch from c62c8b7 to f6985c9 Compare December 1, 2026 00:31
@bkudiess
bkudiess merged commit 30d159c into openclaw:main Dec 1, 2026
55 of 57 checks passed
bkudiess added a commit that referenced this pull request Dec 1, 2026
…d test (#2424)

#2417 consolidated TailReflowCorrection_ResizeGrantsTheBoundedBudgetWithoutANewRevision
into TailReflowCorrection_ResizeRefillsGrowthAndLandingBudgetsWithoutANewRevision but
left docs/ARCHITECTURE.md naming the old method, so
ArchitectureLedgerConsistencyTests.Named_guard_tests_exist_in_test_sources fails on main.

Co-authored-by: Copilot App <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. P2 Normal priority bug or improvement 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant