Skip to content

fix(chat): work around WinUI session-switch crash - #1407

Closed
dotMorten wants to merge 1 commit into
openclaw:mainfrom
dotMorten:pr/1167
Closed

dotMorten wants to merge 1 commit into
openclaw:mainfrom
dotMorten:pr/1167

Conversation

@dotMorten

Copy link
Copy Markdown
Contributor

Summary

This is an application-side workaround for microsoft/microsoft-ui-xaml#11865, not a fix in WinUI.

Repeated chat-session switching can recycle a row retained by ItemsView.StartBringItemIntoView. A later native anchor request then rejects that row with E_INVALIDARG, terminating the app. The upstream issue includes the minimal reproducer and native failure details.

Replace automatic tail navigation with non-animated ScrollView.ScrollTo, using the current horizontal offset and scrollable height. This avoids the retained bring-into-view target. Keep the existing tail identity, generation, loaded-state, queue, and bottom-follow guards unchanged. Add a source regression guard against reintroducing the affected API and document the runtime proof path.

Ownership remains in InitialTailPositioner in ReactorItemsViewScrollController.cs. There is no new realization logic, layout loop, timer, or exception suppression.

Related: #1167. This targets the confirmed crash; it does not establish that the separately reported sustained UI-thread hang is resolved.

Required proof pools

  • windows-11-arm64: native ARM64 build and runtime validation on the architecture where the crash was investigated.
  • windows-winui-interactive: chat session navigation and visible timeline behavior.

Validation

  • .\build.ps1: passed, including repository documentation checks.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore: 3,998 passed, 34 skipped, 0 failed.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: 2,976 passed, 0 failed.
  • Rubber-duck review of the final diff and controller lifecycle: no actionable findings.
  • Structured autoreview: blocked. python .agents\skills\autoreview\scripts\autoreview --mode local exited 9009 because Python is not installed; Codex is also unavailable on PATH. No clean Codex review is claimed.

Real behavior proof

The developer confirmed the original ScrollView workaround worked. The PR preserves that small workaround.

The final ARM64 Debug build was also launched with isolated tray settings against a loopback-only synthetic gateway serving two 77-message, mixed-height histories. After selecting Workaround two, the app remained responsive, the composer was visible, and an inspected screenshot showed the final row completely:

Session: Workaround two
Workaround two: message 77
FINAL MESSAGE: Workaround two

The locally built WinApp CLI was used for UI automation, screenshots, ETW recording, and perf analyze. No private chat content, credentials, dumps, or raw traces are published.

Not verified / blocked

  • The extended automated switching loop did not complete: its session-row selector failed after one successful selection. This is not a passing 20-switch stress test.
  • ETW analysis returned partial evidence: 0 lost events/buffers, 1 decode error, and 51 incomplete scope boundaries. No timing or performance conclusion is claimed.
  • Streaming arrivals while scrolled up, tail positioning across every history shape, and the original sustained hang were not independently established by this closeout.

Use non-animated ScrollView extent navigation instead of retaining an ItemsView bring target across history replacement. Workaround for microsoft/microsoft-ui-xaml#11865; related to openclaw#1167.

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

clawsweeper Bot commented Sep 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 P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed September 28, 2026, 9:33 PM ET / September 29, 2026, 01:33 UTC (Revision 6).

ClawSweeper review

What this changes

The branch changes native chat tail navigation from targeting the last message row to scrolling to the current bottom extent, and updates a source guard and test-coverage documentation.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 7 items remain

The workaround addresses a documented WinUI crash mechanism, but it is not ready to merge. Maintainer testing at the unchanged PR head found that automatic scrolling stopped before the final message on initial load and repeated session switches. A later repair and its successful fixture runs remain uncommitted, and its scroll-away race is unresolved.

Priority: P1
Reviewed head: 1091062a0987dafe940cea5c2baf6049124b410d

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused patch has useful crash-mitigation evidence, but same-head native testing exposes a blocking final-row regression and the later repair remains unpublished.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: The changed production tail controller was exercised in an isolated ARM64 app with a loopback Gateway, but the contributor's single 77-row final-message observation is contradicted by a later native run at the same head that stopped above the final row on repeated switches. The successful 240-row Debug and Release results belong to an uncommitted follow-on with an unresolved scroll-away race. Add current-head native proof for repeated mixed-height switching, final-row visibility, and a scrolled-up reader after arrivals; redact private details in shared captures or logs. Updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The changed production tail controller was exercised in an isolated ARM64 app with a loopback Gateway, but the contributor's single 77-row final-message observation is contradicted by a later native run at the same head that stopped above the final row on repeated switches. The successful 240-row Debug and Release results belong to an uncommitted follow-on with an unresolved scroll-away race. Add current-head native proof for repeated mixed-height switching, final-row visibility, and a scrolled-up reader after arrivals; redact private details in shared captures or logs. Updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 7 items Introduced navigation change: The pinned PR delta replaces row-targeted bring-into-view with one ScrollTo call using ScrollableHeight.
One-shot tail request: The controller schedules a tail request after layout, while subsequent ViewChanged events classify whether the reader is following; the introduced call does not wait for later extent growth.
Maintainer native observation: The September 24 maintainer comment reports that a loopback Gateway supplied 77 mixed-height rows, but the unchanged PR head initially showed rows 72-76 and later switches settled above the final row. Manual scrolling revealed that the final row existed. The September 29 comment says the successful 240-row follow-on was local only and still has an identified scroll-away race.
Findings 1 actionable finding [P1] Keep the actual final message visible after virtualized rows expand
Security None None.

How this fits together

The Windows Companion receives chat history from a Gateway and renders it as virtualized native WinUI rows. Its tail-positioning controller moves the viewport toward the newest message when a session opens or a followed conversation grows.

flowchart LR
  A[Gateway chat history] --> B[Native timeline rows]
  B --> C[Tail-positioning controller]
  C --> D{Follow newest message?}
  D -->|Yes| E[WinUI scroll view]
  D -->|No| F[Keep reader position]
  E --> G[Visible chat messages]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The changed production tail controller was exercised in an isolated ARM64 app with a loopback Gateway, but the contributor's single 77-row final-message observation is contradicted by a later native run at the same head that stopped above the final row on repeated switches. The successful 240-row Debug and Release results belong to an uncommitted follow-on with an unresolved scroll-away race. Add current-head native proof for repeated mixed-height switching, final-row visibility, and a scrolled-up reader after arrivals; redact private details in shared captures or logs. Updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Keep the actual final message visible after virtualized rows expand (P1) - This replaces a request for the final row with one scroll to the extent measured at that instant. When mixed-height rows expand afterward, no later extent change retries navigation. A maintainer's ARM64 run at this same head saw initial and repeated session switches stop several rows short even though the final row was present; repair the positioning invariant before merge.
  • Resolve merge risk (P1) - Large or mixed-height histories can open above the newest message because the proposed scroll targets the extent before virtualized rows finish expanding; this was observed at the unchanged PR head.
  • Resolve merge risk (P1) - The local extent-follow repair is not on this branch, and its reported shrink-plus-scroll-away race could pull a reader back to the bottom.
  • Complete next step (P2) - Repair the final-row regression and scroll-away race on the PR branch, then provide current-head native Debug and Release proof before merge.
  • Improve patch quality - Commit a bounded final-row repair with a deterministic shrink-and-scroll-away policy and regression coverage.
  • Improve patch quality - Provide current-head Debug and production-shaped Release native evidence for repeated 240-row switches, final-row visibility, and reader-position preservation.

Findings

  • [P1] Keep the actual final message visible after virtualized rows expand — src/OpenClaw.Tray.WinUI/Chat/ReactorItemsViewScrollController.cs:272-275
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Changed scope 3 files; production +8/-6, tests +6/-3, docs +1 The patch is small, but it replaces the navigation operation that determines whether the newest message is visible.

Merge-risk options

Maintainer options:

  1. Repair tail positioning (recommended)
    Keep the branch open while a bounded controller fix reaches the actual last row and preserves scroll-away behavior under extent changes.
  2. Pause this workaround
    Leave the current Reactor mitigation in place if the native positioning invariant cannot be proved without a larger redesign.

Technical review

Best possible solution:

Preserve crash avoidance while making final-row positioning converge as virtualized rows expand, with a bounded policy that keeps a reader's position during simultaneous scrolling and extent changes; then prove repeated switching and scroll-away behavior in native Debug and Release fixtures.

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

Yes for the PR regression: a maintainer's isolated ARM64 Gateway fixture showed final rows offscreen at this unchanged head. The original WinUI crash has an upstream minimal reproduction, but this review did not reproduce that crash on current main.

Is this the best way to solve the issue?

No. Avoiding the retained WinUI anchor is a reasonable direction, but a one-time scroll to the current extent does not reliably reveal the actual final row after virtualized layout expands.

Full review comments:

  • [P1] Keep the actual final message visible after virtualized rows expand — src/OpenClaw.Tray.WinUI/Chat/ReactorItemsViewScrollController.cs:272-275
    This replaces a request for the final row with one scroll to the extent measured at that instant. When mixed-height rows expand afterward, no later extent change retries navigation. A maintainer's ARM64 run at this same head saw initial and repeated session switches stop several rows short even though the final row was present; repair the positioning invariant before merge.
    Confidence: 0.96

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The branch addresses a native chat crash, while same-head testing found a user-visible failure when opening or switching histories.
  • merge-risk: 🚨 compatibility: Replacing row-targeted navigation with a single extent scroll changes established chat-opening behavior and can leave the latest message offscreen.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The changed production tail controller was exercised in an isolated ARM64 app with a loopback Gateway, but the contributor's single 77-row final-message observation is contradicted by a later native run at the same head that stopped above the final row on repeated switches. The successful 240-row Debug and Release results belong to an uncommitted follow-on with an unresolved scroll-away race. Add current-head native proof for repeated mixed-height switching, final-row visibility, and a scrolled-up reader after arrivals; redact private details in shared captures or logs. Updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • karkarl: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Barbara Kudiess: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • shanselman: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-09-12T18:32:38.005Z sha 1091062 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-24T11:16:21.201Z sha 1091062 :: needs real behavior proof before merge. :: [P1] Keep the actual final message reachable after virtualized rows expand
  • reviewed 2026-09-24T15:22:05.850Z sha 1091062 :: needs real behavior proof before merge. :: [P1] Keep the final message visible after virtualized rows expand
  • reviewed 2026-09-24T15:39:25.994Z sha 1091062 :: needs real behavior proof before merge. :: [P1] Keep the final message visible after virtualized rows expand
  • reviewed 2026-09-29T00:55:55.017Z sha 1091062 :: needs real behavior proof before merge. :: [P1] Keep the final message visible after rows expand

@karkarl

karkarl commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Global repo triage reviewed exact head 1091062a0987dafe940cea5c2baf6049124b410d.

Decision: NEEDS_HUMAN_TEST. Take confidence: 70%. Recommendation confidence: 99%. Risk: High.

Static review found the workaround focused and existing guards preserved; exact-head CI is green. The remaining blocker is direct coverage of the reported trigger. Current runtime evidence covers one ARM64 selection but not repeated switching, and scroll-away behavior remains unverified.

Complete a reliable ARM64 WinUI loop across repeated mixed-height session switches, confirm final-row visibility after every switch, and verify new arrivals do not pull a scrolled-up reader to the bottom. This requires windows-11-arm64 and windows-winui-interactive. Coordinate this PR before #1449 because both alter the same navigation owner with incompatible assumptions.

@shanselman shanselman added status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. and removed status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. labels Sep 24, 2026
@shanselman

Copy link
Copy Markdown
Collaborator

Maintainer closeout at exact head 1091062a0987: ARM64 build, Shared (3,996 passed, 36 skipped), Tray (2,976 passed), 22 focused chat tests and the required CI Gate pass. An isolated Windows 11 ARM64 app launched successfully, but its fresh profile had no test gateway. We did not submit a consent-gated test connection while the user was unavailable, so repeated switching, the final row and scroll-away behavior remain unverified. This is a proof hold (about 70% take confidence), not a confirmed source defect. Please provide current-head repeated-switch/final-row/scroll-away evidence or a safe consented fixture route; we will then do one current-main integration pass. Keeping this separate from #1449 (improve(chat): remove an unnecessary wait when opening chat history), whose natural-tail evidence is negative.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 24, 2026
@shanselman

Copy link
Copy Markdown
Collaborator

Maintainer native follow-up at exact head 1091062a0987: HOLD, changed-path proof is negative. The one approved connection used a task-owned isolated ARM64 app and loopback-only synthetic Gateway with three sessions of 77 mixed-height history rows each. The Gateway confirmed history for each selected session. Opening main initially showed rows 72-76, not final row 77; the first switch to session two settled at 63-67, and the first switch to session one at 67-70. A manual scrollbar drag revealed the final row in session two, so the row existed but automatic tail placement had not reached it. Later return switches again settled above the final row.

Four short transitions remained responsive, which does not establish sustained crash avoidance. A manually scrolled-up reader stayed at rows 19-22 after a synthetic session.message; arrival application itself was not visually confirmed. Please fix automatic final-row placement across initial history replacement and repeated mixed-height switches while preserving the observed scroll-away guard, then provide new current-head native proof before integration or merge. A virtualized-scroll-extent race is a hypothesis, not a diagnosed cause. ARM64 build, Shared (3,996 passed/36 skipped), Tray (2,976 passed), focused chat (22 passed) and existing CI remain green, but do not override the visible behavior failure. No real user profile or external Gateway was used; the isolated app/server/profile were cleaned. Screenshots remain private. This is separate from #1449 (improve(chat): remove an unnecessary wait when opening chat history).

@shanselman shanselman added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 24, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 24, 2026
@shanselman

Copy link
Copy Markdown
Collaborator

Maintainer fixture comparison at unchanged PR head 1091062a0987 (the local repair is not committed or pushed): current main 273b0182 passed the fixture profile/integration stage 30/30 and native UI 3/4, failing natural visibility of message 240 before resize. An isolated integration of main + this PR + a local ExtentChanged follow-on patch passed the full ARM64 build, Shared (4,104 passed/35 skipped), Tray (3,075 passed), focused chat (27 passed), and made natural and narrow-width 240-row tail visibility pass. But its mandatory Debug native UI fixture was only 2/4: after resize and explicit UIA scroll from 0% to 100%, message 240 was not visible at wide width; Settings also timed out in that full run. Settings passed 1/1 when run alone in a fresh candidate profile, so that timeout is not independently reproducible, not a green full suite.

We attempted one bounded manual wide-scroll comparison, but the accessible 240-session picker popup did not activate the selected item and its separate PopupHost could not be inspected safely, so the UIA percent-scroll failure remains unclassified. No timer, layout loop, fixture assertion weakening, further form submission, or source push was made. The original contributor branch is unchanged and the four-file candidate remains uncommitted locally. Please keep this PR held until the 240-row Debug and production-shaped Release fixture passes with final-row visibility and scroll-away intact; I am happy to collaborate on a narrower tested fix. The disposable app/server/profiles and integration checkout were stopped and removed.

@shanselman shanselman added status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. and removed status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. labels Sep 24, 2026
@shanselman

Copy link
Copy Markdown
Collaborator

Maintainer revalidation of #1407 (fix(chat): work around WinUI session-switch crash) against main 015897024b28cd1b5bc36c61a0f669d537d74d65 and Windows App SDK 2.5.1: the contributor head remains 1091062a0987dafe940cea5c2baf6049124b410d. The four-file extent-follow repair is local only. No commit or push was made.

The prospective tree b97be012bff0c9d256fdd7466c182ead5243b815 passed ARM64 ./build.ps1, Shared tests (4,143 passed, 36 skipped), Tray tests (3,184 passed), and 28 focused chat tests. In an exclusive desktop slot, the fixture-backed Debug smoke passed 30/30 profile/integration and 5/5 native UI tests; the production-shaped Release smoke also passed 30/30 and 5/5. Both native smokes verified repeated 240-message session selection and final-row visibility at the actual 1500x720 and 1900x950 window sizes, plus Settings navigation. Separate isolated ARM64 UI inspection confirmed the final FIXTURE LONG END 240 row visible after Sessions > Open in chat and the Settings page marker. An earlier shared-desktop Debug run had timed out on that Sessions action while another checkout's UI tests were active; the exclusive rerun passed. No private screenshots or profiles were published.

Still held for correctness: Two final read-only reviewers independently identified an introduced scroll-away race in the local repair. When the extent shrinks during a simultaneous upward reader scroll, RebaseAfterExtentShrink lowers the remembered followed offset to the current offset before OnViewChanged classifies it. For example, after following offset 2000, a shrink to extent 1500 with reader offset 500 resets the reference to 500, so the code still reports following and a queued tail request may pull the reader back to bottom. The order of ExtentChanged and ViewChanged can also make that rebase use a pre-clamp offset. This violates the preserve-scrolled-up-reader requirement even though the fixture suite is green. The repair needs a bounded, deterministic policy and test for simultaneous shrink/scroll-away before publication. Main has since advanced to 0844c0fa4035d4237c81ea270aceacab725cec1b, so any eventual update must be re-integrated and revalidated. Please keep this contributor PR open; the local candidate and synthetic test artifacts are preserved for collaboration.

@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 29, 2026
@dotMorten dotMorten closed this Sep 29, 2026
@dotMorten

Copy link
Copy Markdown
Contributor Author

Closing in favor of the workaround in Reactor.

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. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants