Skip to content

fix(chat): conversation stays at the bottom while following, with one scroll owner - #2126

Draft
bkudiess wants to merge 1 commit into
openclaw:mainfrom
bkudiess:bkudiess-chat-scroll-owner
Draft

bkudiess wants to merge 1 commit into
openclaw:mainfrom
bkudiess:bkudiess-chat-scroll-owner

Conversation

@bkudiess

@bkudiess bkudiess commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #1089, #2117, #2048

What Problem This Solves

Fixes: chat scrolling keeps regressing (missing the bottom while streaming, overshooting after resize and reflow) because six unrelated layout PRs each patched scroll decisions locally in one 1,000-line controller.

User Impact

User impact: a followed conversation stays at the exact bottom through streaming, resize, expanding a tool card and session switches; scrolling up, keyboard reading or toggling a disclosure stops following, and Jump to latest shows only while reading.

Why This Change Was Made

ChatScrollPolicy is now the single, pure decision owner: a Landing / Following / Reading state machine with typed inputs and one command out. ReactorItemsViewScrollController.cs becomes a thin adapter that translates native events into those inputs and applies the command; it is the only code allowed to scroll the conversation. The native mechanics it keeps (layout waits, staged tail-row realization, landing confirmation, generation fencing) are unchanged.

Two native findings shaped the Following pin, both from traces of the existing proof:

  • Virtualized rows re-estimate the extent for a few frames after each change, and the offset can move up without user input. Treating that as navigation dropped follow mode, so only user input now leaves Following; other movement is drift and is pinned back.
  • An offset scroll to the extent end enters WinUI's extent-edge mode, where remeasured rows snap the offset back and oscillate. A pin therefore reuses the existing staged tail-row bring and is admitted against settled geometry.

Rule for future layout PRs (recorded in the ledger and chat visual design): do not patch scrolling. Fix a broken rule in ChatScrollPolicy with a new ChatScrollPolicyTests case. ConversationScrolling_HasOneNativeOwner fails if other chat code scrolls the conversation (popup lists in the composer and pickers are explicitly allowed).

Rebased onto main after #2117 and #2048 merged. #2117's interior bottom anchor (Math.BitDecrement(1.0)) is kept as the adapter's BottomAnchorRatio, and its exact one-pixel TailNavigationPolicy.IsAtBottom is what ChatScrollGeometry.AtBottom uses. Its extent-growth re-pin (one credit per Entries revision, only while following away from the bottom, never while landing or while a reader or disclosure owns the anchor) is folded into ChatScrollPolicy as a policy case rather than a second mechanism: ContentRevisionChanged (fed by the same contentRevision input) and resize are the only things that grant the bounded pin budget, so correction-induced remeasurement and same-revision rerenders cannot replenish it. TailReflowCorrection is removed; its ledger row is closed and points to the policy.

Evidence

  • 32 table-driven policy test cases in ChatScrollPolicyTests cover every rule, including the Debug overshoot and Release streaming-undershoot geometries, the feat(chat): open tool details beside native chat #2048 review's request that Jump to latest follow the mode rather than the raw offset, the pin budget per content revision, improve(chat): refine composer sizing and context controls #2117's same-key first-delta growth (46.29 px below an anchored tail) pinning only while following, and an already-at-bottom reload followed by one wheel notch.
  • New native proof ConversationScroll_FollowingKeepsTheExactBottomThroughStreamingResizeExpansionAndSessionSwitch (480 and 1100 px) asserts gap-to-bottom ≤ 1 px with Jump to latest hidden after landing, each streamed delta, resize both ways, a tool card, expanding it, a following reply, and switching sessions away and back.
  • The existing ConversationFeedback stream, resize and jump proof and ProgrammaticOrComposerFocusRetainsFollowing pass with visual capture enabled.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Required proof pools

  • windows-winui-interactive: chat transcript scrolling behavior in the isolated WinUI app (native proof below ran locally; interactive-pointer disclosure toggling is not yet proven natively).

Validation

All on d3d95fb8622f3027dc731abdf00c0fcd2f89b1a1 (base main 3d5f14270dd6bd8b260a723ff2e73a68ea858ca8), with isolated OPENCLAW_TRAY_DATA_DIR, OPENCLAW_TRAY_APPDATA_DIR, OPENCLAW_TRAY_LOCALAPPDATA_DIR:

  • ./build.ps1: all builds succeeded.
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj: 5,847 passed, 29 skipped, 0 failed.
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore: 6,359 passed, 0 failed.
  • dotnet test ./tests/OpenClaw.Tray.UITests/OpenClaw.Tray.UITests.csproj -r win-x64 --filter "FullyQualifiedName~ReactorChatLayoutProofTests|FullyQualifiedName~ReactorToolActivityProofTests": 207 passed, 3 skipped, 0 failed.
  • Scroll scenarios (ConversationFeedback_*, ConversationScroll_*, ProgrammaticOrComposerFocusRetainsFollowing) with OPENCLAW_VISUAL_TEST=1: 18/18 across three consecutive runs.
  • improve(chat): refine composer sizing and context controls #2117's anchor-row guard GatewayFixtureUiTests.SidebarSwitchesRealHistoriesAndShowsMessage240AtBothWidths with OPENCLAW_RUN_GATEWAY_FIXTURE_UI=1 and OPENCLAW_GATEWAY_FIXTURE_APP set to the freshly built x64 app: 1 passed.
  • .\scripts\validate-docs.ps1, .\scripts\validate-proof-pools.ps1, git diff --check: passed.
  • Real %APPDATA%\OpenClawTray and %LOCALAPPDATA%\OpenClawTray metadata manifests before and after all runs: no drift.
  • Rubber-duck review (pre-rebase head): three findings (landing baseline offset, pin layout-drain fallback, pin budget lifetime) fixed with regression tests.

Real Behavior Proof

  • Environment tested: Windows x64 dev host, Debug, WinUI 3 proof window via OpenClaw.Tray.UITests, isolated tray roots.
  • PR head or commit tested: d3d95fb8622f3027dc731abdf00c0fcd2f89b1a1.
  • Exact steps or command run: dotnet test tests\OpenClaw.Tray.UITests\OpenClaw.Tray.UITests.csproj -r win-x64 --filter "FullyQualifiedName~ConversationScroll_FollowingKeepsTheExactBottom|FullyQualifiedName~ConversationFeedback_ThinkingToolReviewsAndHistoryRetainComposerWithoutSearch|FullyQualifiedName~ProgrammaticOrComposerFocusRetainsFollowing" with OPENCLAW_VISUAL_TEST=1.
  • Evidence after fix: 18/18 passed across three runs; every phase waits for |ScrollableHeight - VerticalOffset| <= 1, an idle view and a zero-opacity Jump to latest. Captures Scroll-owner-following-480 and -1100 show the conversation at the exact bottom after switching sessions back.
  • Observed result: before the final design, traces showed the pin oscillating 23 to 59 px when it scrolled by offset, and follow mode dropping after a virtualization re-estimate moved the offset up; both are gone.
  • Screenshot or artifact links verified? (No): captures are local to the validation session.
  • Not verified or blocked: Release build native proof; pointer or Enter/Space disclosure toggling natively (covered by policy tests and the existing source guard; the native test expands programmatically); Narrator or UI Automation scrolling while following, which is now pinned back like other non-user movement.

Security Impact

  • New permissions or capabilities? (No)
  • Secrets or tokens handling changed? (No)
  • New or changed network calls? (No)
  • Command or tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any answer is Yes, explain the risk and mitigation: N/A

Compatibility and Migration

  • Backward compatible? (Yes)
  • Config or environment changes? (No)
  • Migration needed? (No)
  • If yes, list the exact upgrade steps: N/A

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

🦞👀
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 priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. 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. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codex review: needs changes before merge.

What this changes

This PR centralizes conversation scrolling decisions and pins followed conversations to the bottom through streaming and layout changes.

Example: A streamed reply increases the scrollable height from 1000 to 1250 pixels while the offset remains 999.5.

  • Before: The conversation can remain short of the newest content.
  • After: The policy requests a settled tail-row bring and keeps Jump to latest hidden.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful ownership consolidation with substantive reported validation, an introduced accessibility defect and harness-only inspectable evidence.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦐 gold shrimp (3/6) 2 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A followed conversation can miss the newest content during streaming or end beyond the bottom after reflow.
Reason: Maintainer-authored direction supports consolidating the repeatedly patched scroll rules into a tested owner.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this maintainer-authored draft open: the ownership transfer is useful, but the new follow rule overrides accessibility scrolling.

Priority: P2
Reviewed head: 8bff16a5c0be97a37e6a43fa241c639765c0eeea

Before merge

  • Preserve UI Automation scroll-away as reader intent (P2) - After landing at offset 1000 with scrollable height 1000, an accessibility client can request ScrollPattern.SetScrollPercent to move to offset 500 without producing pointer, keyboard-focus or mouse-controller events. _userScrolling remains false, so ViewChanged returns PinToBottom instead of entering Reading, and the adapter brings the tail back into view while Jump to latest stays hidden. Main explicitly lets a newer UI Automation scroll-away take precedence. Admit that reader operation through the existing owner before applying drift correction, and cover this path without first synthesizing keyboard focus.

Findings

  • [P2] Preserve UI Automation scroll-away as reader intent — src/OpenClaw.Tray.WinUI/Chat/ChatScrollPolicy.cs:196-201
  • [P3] Replace the escaped newline in the scrolling contract — docs/CHAT_VISUAL_DESIGN.md:363

Tests

  • Missing end-to-end proof: Provide inspectable current-head application evidence for streaming and resize recovery plus actual pointer, Enter/Space disclosure and automation scroll-away behavior; the supplied mounted tests and local-only captures do not establish those shipped-entry-point scenarios.
Agent review details

How this fits together

The Reactor chat timeline supplies keyed rows and navigation requests to a pure scroll policy; its native adapter applies decisions to the WinUI ItemsView and reports whether Jump to latest should appear.

flowchart LR
Timeline[Chat timeline] --> Policy[Scroll policy]
Input[Native input and geometry] --> Policy
Policy --> Adapter[Conversation scroll adapter]
Adapter --> View[WinUI ItemsView]
Policy --> Jump[Jump to latest visibility]
Loading

Technical review

Best possible solution:

Keep the single policy and staged native adapter while admitting assistive scroll intent before correcting genuine layout drift.

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

Main retains the reported reactive follow behavior, and the new policy deterministically pins a 1000-to-500 offset change without prior input; no target code or tests were run during this read-only review.

Is this the best way to solve the issue?

The ownership transfer is justified by repeated controller-level decisions and removes their old implementations, but treating every unmarked movement as drift breaks the existing automation reader contract.

Full review comments:

  • [P2] Preserve UI Automation scroll-away as reader intent — src/OpenClaw.Tray.WinUI/Chat/ChatScrollPolicy.cs:196-201
    After landing at offset 1000 with scrollable height 1000, an accessibility client can request ScrollPattern.SetScrollPercent to move to offset 500 without producing pointer, keyboard-focus or mouse-controller events. _userScrolling remains false, so ViewChanged returns PinToBottom instead of entering Reading, and the adapter brings the tail back into view while Jump to latest stays hidden. Main explicitly lets a newer UI Automation scroll-away take precedence. Admit that reader operation through the existing owner before applying drift correction, and cover this path without first synthesizing keyboard focus.
    Confidence: 0.99
  • [P3] Replace the escaped newline in the scrolling contract — docs/CHAT_VISUAL_DESIGN.md:363
    The added paragraph contains a literal backslash-n between 'and' and 'programmatic', so rendered documentation displays 'and\nprogrammatic'. Replace it with an actual newline or space.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Native anchoring and tail request fencing changes intended behavior with a stated reason (ca8fb4a: Stable native anchoring and immutable, revalidated requests avoid streamed-growth navigation and stale tail indices.)
  • Staged realization and bounded landing confirmation keeps the original intent (a4dd026: Avoid synchronous recycled-container navigation while preserving initial landing, reader cancellation and bounded recovery.)
  • Disclosure anchoring and tail visibility changes intended behavior with a stated reason (243f9cf: Keep reader-toggled disclosure headers stable and expose navigation back to the latest conversation content.)
  • Source guards and ownership documentation keeps the original intent (3f6765e: Protect landing, reflow and lifecycle invariants around native scrolling; the PR moves decision coverage to policy tests and updates the ledger.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Barbara Kudiess: Raw commit 243f9cf adds src/OpenClaw.Tray.WinUI/Chat/ReactorItemsViewScrollController.cs:658 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 243f9cff53d8; files: src/OpenClaw.Tray.WinUI/Chat/ReactorItemsViewScrollController.cs)
  • Karen: Raw commit ca8fb4a 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: 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 +515/-251; tests and project wiring +667/-337. Growth introduces a real pure-policy ownership seam and distinct native geometry coverage while removing the replaced decision paths.

Labels

Label changes:

  • add P2: Conversation following and accessibility reading are meaningful chat interactions with a limited affected surface.
  • add merge-risk: 🚨 compatibility: Existing UI Automation scroll-away behavior is replaced by automatic return to the tail.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: Conversation following and accessibility reading are meaningful chat interactions with a limited affected surface.
  • merge-risk: 🚨 compatibility: Existing UI Automation scroll-away behavior is replaced by automatic return to the tail.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • 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 12, 2026, 4:47 AM ET / 09:47 UTC.

Conversation scrolling decisions were spread across a dozen native handlers
and flags, and six feature PRs patched them locally after layout changes.

ChatScrollPolicy is now a pure Landing/Following/Reading state machine that
decides every scroll and Jump to latest visibility. The ItemsView adapter only
translates native events into policy inputs and applies the returned command.
Following pins the bottom through streaming, reflow and resize by reusing the
staged tail-row bring once layout settles; only user action leaves it, and a
toggled disclosure keeps its header in place.

A source guard fails if other chat code scrolls the conversation; the ledger
records the owner and the rule that layout PRs fix the policy, not scrolling.

Co-authored-by: Copilot App <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale due to inactivity.
Please update it or it will be closed.

@github-actions github-actions Bot added the stale label Nov 27, 2026
bkudiess added a commit to bkudiess/openclaw-windows-node that referenced this pull request Dec 1, 2026
…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 added a commit that referenced this pull request Dec 1, 2026
…croll to the end (#2417)

* fix(chat): long chats reach the latest message after a resize and a scroll 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 (#2126 is the structural fix).

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

Co-authored-by: Copilot App <[email protected]>

* test(chat): consolidate tail reflow budget tests

Co-authored-by: Copilot App <[email protected]>

---------

Co-authored-by: Copilot App <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. stale 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