Skip to content

fix: land on the latest chat message when a conversation's rows arrive in two steps - #2319

Merged
bkudiess merged 1 commit into
openclaw:mainfrom
bkudiess:bkudiess-chat-initial-landing-verify
Nov 18, 2026
Merged

bkudiess merged 1 commit into
openclaw:mainfrom
bkudiess:bkudiess-chat-initial-landing-verify

Conversation

@bkudiess

Copy link
Copy Markdown
Collaborator

Related: #2262

What Problem This Solves

When you open a chat or switch to a conversation, the transcript is supposed to land at the newest message. Sometimes it stays at the top instead, even though the chat still behaves as if it is following the newest message. This happens when the conversation first renders a short preview of its rows and then the full set arrives a moment later. The same bug makes ConversationParity_ProgrammaticOrComposerFocusRetainsFollowing flaky on main ("Initial tail did not settle: offset=0").

User Impact

User impact: opening or switching to a conversation now reaches the latest message even when its rows arrive in two steps. If the bounded recovery still cannot reach it, the view stays put with Jump to latest visible. It no longer sits at the top while claiming to follow.

Why This Change Was Made

The landing is confirmed on the first, short projection, where the top is also the bottom. When the full projection arrives:

  • the follow path queues its staged tail bring, but the reflow layout wait cancels it;
  • the reflow offset correction can then complete without moving;
  • nothing verifies the outcome, and the one-shot reflow credit is already spent.

This is a small targeted fix, not the staged scroll-owner rewrite. After a confirmed landing, a pure policy, InitialTailVerification, watches the settled view for one bounded window: 120 frames, with a fixed budget of two re-issues that is never replenished.

When it re-issues. All of these must hold:

  • the tail grew after the landing;
  • the view is still following;
  • the view is not at the bottom;
  • the view is idle, with unchanged geometry for 4 frames;
  • no owned work is pending (layout, render or confirmation waits, realization, queued follow, or a dispatched tail bring before its ScrollCompleted).

It then re-issues the existing staged tail bring. The dispatcher rechecks all of this before starting.

What stops it.

  • Arrival at the tail spends the growth and revokes any queued or realizing re-issue.
  • Reader input, history navigation, loss of following, row clearing, a new request, scroll-view replacement, unload and dispose end the window at once and revoke its work. It never resumes.

What it does not change. Follow and reflow admission are unchanged. Reader positions are never captured or restored. When the budget runs out, it logs a warning and leaves Jump to latest visible.

The new ledger row chat-initial-tail-verification in docs/ARCHITECTURE.md records the owner and these invariants. The policy is shaped to move into the planned single scroll policy later; #2126 stays draft.

Known limits (documented, not fixed here):

  • UIA scroll intent. UIA reader intent is only recognized through ViewChanged and following, the same signal main's follow and reflow already use. A no-op UIA SetScrollPercent(0) at offset 0, or a UIA move that stays within 60 px while the grown tail has not been reached yet, cannot be told apart from layout drift without a ScrollPresenter automation-peer route. Main's follow path behaves the same in those cases.
  • Frame-based window. The window counts rendered frames: about 2 s at 60 Hz and about 0.5 s at 240 Hz. A second projection arriving later than that falls back to today's behavior.
  • Rough edges, deferred:
    • a bring marker cancelled by another listener holds the window until its frame limit;
    • a re-issue still realizing at the frame limit is cancelled;
    • the exhaustion warning can fire while a run is streaming.
  • Scope. This PR covers the chat first-landing bug only, not the Systems page flake.

Evidence

  • Native RED on unmodified main (cc46d14c): ConversationParity_ProgrammaticOrComposerFocusRetainsFollowing failed in 9 of 12 cases over 6 runs. The signature matched CI: offset=0; maximum=816; count=4; expectedKey=…id:e2. Barbara's desktop session was Active, the native desktop lock was held, and the desktop-continuity monitor recorded no anomalies.
  • Native GREEN on this head: the same test passed in 16 of 16 cases over 8 runs. Earlier revisions of the fix also passed 12/12, 16/16 and 16/16.
  • Regressions on this head (all native):
    • ConversationFeedback_ThinkingToolReviewsAndHistoryRetainComposerWithoutSearch: 8/8.
    • Full ReactorChatLayoutProofTests class: 215 passed, 1 failed, 3 skipped. The failure, ProductionRoot_AlignsColumnAndKeepsEveryComposerActionReachable(width: 1200), is a sub-pixel composer geometry assert. It fails the same way on clean main on this host, along with the intermittent ReasoningPicker_MenuFocusAndDismissalDoNotCommit.
    • SidebarSwitchesRealHistoriesAndShowsMessage240AtBothWidths fixture: 2/2 on this head (5/5 across revisions of the fix).
    • MarkdownSelection_CopiesAcrossBlocksAndExcludesCollapsedAndNeighboringContent fixture (external UIA SetScrollPercent on the timeline): 2/2.
  • Reviews:
    • Astra (gpt-6-astra) design critique: 4 rounds. All findings closed, with the UIA exception above accepted. Final verdict GO.
    • Hanselman review: Claude Opus 5.5 and GPT-6 Astra (long context), high reasoning effort, on patch-id c769c679. Both GO, no blocking findings. Opus's non-blocking notes are listed under Known limits.

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 landing behavior in the isolated WinUI app. The native layout proofs and gateway-fixture UIA runs above were collected locally on Debug. Release native proof was not run.

Validation

Everything required passed on patch-id c769c679de001c215beefb24fab907db1a21fd4b (commit 1691d247), base cc46d14c. Tests used isolated OPENCLAW_TRAY_* profile roots, with OPENCLAW_STATE_DIR unset. The real profile showed no drift.

  • ./build.ps1: passed.
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore: passed (5910 passed, 29 skipped, 0 failed).
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore: passed (6761 passed, 0 failed). This includes 6 new InitialTailVerification_* policy tests.
  • .\scripts\validate-test-timing-patterns.ps1: passed.
  • .\scripts\validate-docs.ps1: passed.
  • .\scripts\validate-proof-pools.ps1: passed.
  • git diff --check: clean.
  • Native runs, each under the desktop lock with continuity monitoring (dotnet test tests\OpenClaw.Tray.UITests\OpenClaw.Tray.UITests.csproj -r win-x64 --no-build --filter …):
    • target test: main 9/12 failed; this head 16/16 passed;
    • ConversationFeedback: 8/8;
    • layout class: 215/216 non-skipped; the one failure is pre-existing on main;
    • Message240: 2/2 on this head;
    • Markdown selection: 2/2.

Real Behavior Proof

  • Environment tested: local Windows 11 dev box over RDP (session Active), Debug build, isolated test profile, native WinUI UI tests.
  • PR head or commit tested: 1691d247 (patch-id c769c679).
  • Exact steps or command run: dotnet test tests\OpenClaw.Tray.UITests\OpenClaw.Tray.UITests.csproj -r win-x64 --no-build --filter FullyQualifiedName~ReactorChatLayoutProofTests.ConversationParity_ProgrammaticOrComposerFocusRetainsFollowing, 8 runs.
  • Evidence after fix: 16/16 cases passed. On main: System.TimeoutException : Initial tail did not settle: frames=170; settled=0; extent=1404.67; viewport=588.67; offset=0; maximum=816; state=Idle; count=4; expectedKey=…id:e2.
  • Observed result: the transcript lands at the newest message after the two-step projection, in every run.
  • Screenshot or artifact links verified? N/A
  • Not verified or blocked: Release-configuration native proof, high-refresh-rate displays, and Narrator. External UIA is covered only by the Markdown-selection fixture.

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.

…ter landing

The initial landing can be confirmed on an early projection of the
transcript (for example two rows that fit without scrolling). When the
full projection arrives, the follow path's staged bring can be cancelled
by the reflow layout wait and the reflow offset correction can complete
without moving, so the view stays at the top while still following.

After a confirmed landing, InitialTailVerification watches the settled
view for one bounded window (120 frames, two re-issues, never
replenished). If the tail grew and the following view settles away from
it with no owned work pending, it re-issues the existing staged tail
bring. Arrival at the tail spends the growth and revokes queued work.
Reader input, history navigation, loss of following, row clearing, a new
request, scroll-view replacement, unload and dispose end the window.
Exhaustion logs a warning and leaves Jump to latest visible.

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

clawsweeper Bot commented Nov 18, 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. 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. 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 18, 2026
@clawsweeper

clawsweeper Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

This PR adds bounded verification that retries initial chat positioning when a later row projection leaves the newest message offscreen.

Example: A conversation first displays two rows that fit, then expands to four rows with a scrollable height of 816 pixels.

  • Before: The transcript can remain at offset 0 after follow and reflow work finish.
  • After: Within the verification window, the settled view retries the existing tail bring, unless reader input cancels it.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is focused and has substantive reported regression validation, but the required shipped-application behavior proof 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: Partial
User problem: Opening or switching conversations can leave the transcript at the top instead of showing the newest message.
Reason: The collaborator-authored direction repairs a documented interaction with existing navigation while explicitly leaving unrelated tracker failures and the broader draft separate.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored PR open: it addresses a source-supported chat landing failure still present on main, and review found no definite introduced code defect.

Priority: P2
Reviewed head: 1691d247d925089eeb4586ba2edded905d1bf20f

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Missing inspectable current-head Companion evidence showing natural latest-message landing after the two-step projection, including the required Release fixture coverage.
Agent review details

How this fits together

The Reactor timeline supplies keyed transcript rows to InitialTailPositioner, which coordinates native ItemsView scrolling and reports tail visibility to Jump to latest.

flowchart LR
Rows[Keyed transcript rows] --> Positioner[InitialTailPositioner]
Input[Reader input and native geometry] --> Positioner
Positioner --> Policy[InitialTailVerification]
Policy --> Bring[Existing staged tail bring]
Bring --> View[Native ItemsView]
Positioner --> Jump[Jump to latest visibility]
Loading

Technical review

Best possible solution:

Keep recovery within InitialTailPositioner, reuse staged native navigation, and preserve bounded work and reader cancellation.

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

Source supports the follow/reflow cancellation path, the linked tracker records the matching main failure, and the author reports repeated native reproduction; this review executed no target code.

Is this the best way to solve the issue?

The bounded verifier is a coherent scoped repair that reuses native realization and preserves existing admission rules; it does not resolve the broader scroll-owner work or projections arriving after its observation window.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Initial landing confirmation keeps the original intent (3f6765e: The commit added bounded confirmation because a dropped or reset native bring could leave restored history at the top.)
  • Staged native realization keeps the original intent (243f9cf: Stage realization across natural layout to avoid synchronous native navigation hangs while preserving identity checks and reader cancellation.)
  • Extent-growth and reflow admission keeps the original intent (3d5f142: Bound extent correction by immutable content revision and preserve disclosure and keyboard-reader ownership without replenishing credit from native remeasurement.)
  • Queued tail identity and anchoring keeps the original intent (ca8fb4a: Use stable native anchoring and validate queued requests against current identity, bounds, item count and generation.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Barbara Kudiess: Raw commit 3f6765e adds src/OpenClaw.Tray.WinUI/Chat/ReactorItemsViewScrollController.cs:163 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3f6765ea02f4; files: src/OpenClaw.Tray.WinUI/Chat/ReactorItemsViewScrollController.cs)
  • Karen: Raw commit ca8fb4a adds src/OpenClaw.Tray.WinUI/Chat/ReactorItemsViewScrollController.cs:137 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/ReactorItemsViewScrollController.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
Introduced growth Production +252/-0; tests +120/-0; ledger +1/-0 Growth implements bounded verification inside existing owners and covers distinct admission, cancellation, arrival and exhaustion behavior.

Labels

Label changes:

  • add P2: Conversation opening can miss the newest message, but Jump to latest provides an existing in-product recovery.
  • 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: Conversation opening can miss the newest message, but Jump to latest provides an existing in-product recovery.
  • 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 18, 2026, 4:12 PM ET / 21:12 UTC.

@bkudiess
bkudiess merged commit 558960d into openclaw:main Nov 18, 2026
36 checks passed
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. 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