Skip to content

fix(chat): restore the tail when switching conversations - #1438

Closed
shanselman wants to merge 2 commits into
mainfrom
shanselman-chat-session-tail-restoration
Closed

shanselman wants to merge 2 commits into
mainfrom
shanselman-chat-session-tail-restoration

Conversation

@shanselman

@shanselman shanselman commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #1437. Follow-up context: #1424.

Status: rejected candidate, investigation continues

Do not merge. The one-key candidate at 4101ee5d21e0cfbe031e4956fe4ca10b27598003 performed worse in the controlled, guarded real-application comparison. It is not a verified fix. Earlier mounted-host passes and clean source review are insufficient and do not override these results.

What Problem This Solves

The target bug is returning to a populated conversation and seeing its first messages instead of the previously visible tail. The bug predates this patch; no known-good version or introducing commit has been established, so it is not yet a confirmed regression window.

Latest real behavior proof

Predeclared budget: five sequential non-Dev Release runs per arm, alternating A/B. Both used the same unchanged GatewayFixtureUiTests.SessionPickerSwitchesRealHistoriesAndShowsMessage240AtBothWidths test, scenario, natural message-240 assertion and timeout. There was no manual scrolling before the natural-tail gate and no retry-until-green.

Arm Source Passed Natural-tail assertion failures Hangs Loaded XAML verified
A Exact published harness afc3e9f7e616bde264ed78490e6738d0c1bbbd44 4 1 0 5/5
B Same harness plus only the two-line session/generation key and comment from 4101ee5d 0 5 0 5/5

All five B failures followed the first A selection and subsequent B history request. The unchanged test only selects B after the first A natural-tail assertion passes. The failure is therefore on return to the cached long conversation, not its first selection.

The comparison used separate short-path owned worktrees and normal self-contained Windows App SDK app outputs. Each run's actually loaded Microsoft.UI.Xaml.dll and Microsoft.UI.Xaml.Controls.dll paths and SHA-256 hashes matched that arm's output. Both used the same native binaries:

  • XAML: B241F72BFC9460E823D8A122FBDBC2E2D7AC6BA60B9E5BF981E9B5054D4555B5
  • Controls: BFB7EE4E86F00B9365FA50DECA8D30BF32C71ACAA536779D20DCF17AE32EC725

Both runtime configurations retained OpenClaw.GatewayFixtureIsolationVersion=1 and System.Diagnostics.Debugger.IsSupported=false. This is explicitly combined harness+candidate proof, not an untouched fix-PR-head full-app run. Neither PR base was changed and the combined overlay was not pushed.

Every outcome, screenshot, Gateway trace, binary/runtime hash and exact command is retained under the coordinating session's fixture-comparison artifacts (contract.json, provenance.json, results.json, and a1 through b5). These identifiers refer to retained local artifacts, not public download links. Earlier MAX_PATH build failures are separate setup evidence and did not consume or alter the five UI runs per arm.

Why the original candidate is being withdrawn

The candidate keyed the outer ItemsView/scroll-controller decorator by session and timeline generation. The controlled real-app results reject the apparent improvement from the exploratory mounted tests. Next work is bounded to comparable Request/Update/mount/disposal tracing in the actual guarded application before proposing another product change.

The exploratory VSTest host also exposed independent initialization and runtime mismatches, including loading installed 2.5.1 native binaries instead of the app's bundled 2.4.0 payload. Those experiments and their failures are preserved separately. They are not evidence that the product bug is fixed, and speculative controller/test-host/runtime workarounds are not being folded into the landing patch.

Required proof pools

  • windows-winui-interactive: populated-session return, actual final-message visibility, native lifetime, streaming and scroll-away behavior.

Validation

Historical validation of head 4101ee5d, before the decisive comparison:

  • .\build.ps1: passed, all five projects and documentation gate.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore: 3,984 passed, 32 skipped.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: 2,978 passed.
  • Mounted native Debug: 6 passed, 1 initial-tail failure.
  • Mounted native non-Dev Release: 7 passed.
  • Structured Codex branch review: no actionable source findings.

These results do not make the current candidate merge-ready. The unchanged real-app natural-tail gate is the decisive failed check.

Security and scope

The fixture guards remained enabled. No installed pairings, credentials, autostart, toast registration, WSL Gateway or default MCP port were touched. No parent-checkout edits and no merge were performed. The separately published harness is #1439 (feat: explore and test the app without a live Gateway); its assertion is unchanged.

Fixes: #1437

Scope the native ItemsView and scroll-controller decorator to session and timeline generation. Keep same-session scrolling, virtualization, and row-targeted navigation unchanged. Add mounted native regression and lifecycle proof with isolated XAML resource setup.

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

Copilot-Session: 8346e696-3092-49d5-98be-80b5cae59048
Use the ScrollView operation correlation for manual reader scrolling after all natural-tail assertions. Keep token/revision checks strictly about reconciled native identity and supersede their pending navigation before checking a new session.

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

Copilot-Session: 8346e696-3092-49d5-98be-80b5cae59048
@clawsweeper

clawsweeper Bot commented Sep 17, 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 P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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. labels Sep 17, 2026
@clawsweeper

clawsweeper Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Codex review: blocked before merge. Reviewed October 5, 2026, 6:54 PM ET / 22:54 UTC (Revision 5).

ClawSweeper review

What this changes

The branch recreates the native chat list when the conversation or timeline generation changes and adds mounted scrolling tests, test-host XAML support, and testing guidance.

Regression provenance

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

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep open for the collaborator-led investigation, but block landing the withdrawn candidate. The controlled comparison reports worse cached-session tail restoration, and neither current main nor the related dependency work establishes a fix.

Priority: P2
Reviewed head: 4101ee5d21e0cfbe031e4956fe4ca10b27598003

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) PR readiness rating was derived from proof quality, review findings, security review, and reviewer confidence.
Proof confidence 🌊 off-meta tidepool Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Evidence reviewed 9 items Pinned introduced change: The merge-base-to-head diff adds the session/generation key to the outer scroll-controller decorator. The original blob lacks that key. The introduced scope is four files; checkout and original PR head are both 4101ee5. No verified test merge is available, so no claim is made that merging removes current-main changes.
Controlled comparison rejects the candidate: The complete supplied PR body, captured with sourceRevision 3dd6b1651c99b19670ead2faf0e59a232ab92497df952a66dd0fcb6ddf459572, explicitly says not to merge. Five alternating non-Dev Release runs per arm used the unchanged real-app natural-tail assertion: baseline passed 4/5, while the same harness plus only the introduced production key passed 0/5. Native XAML payloads were verified in every run. These are reported results from a combined harness/candidate overlay, not independently replayed exact-head runs; underlying local artifacts are identified but not publicly linked.
Prior blocker remains applicable: The previous completed review at this same head already raised 'Replace the rejected session-key lifetime change'. The pinned reviewed SHA and checkout SHA are identical, and the comparison has no delta. This is an unchanged prior blocker, not a newly discovered finding.
Findings 1 actionable finding [P2] Replace the rejected session-key lifetime change
Security None None.

How this fits together

The native chat timeline receives conversation history and streaming updates from the chat provider. Its virtualized message list and scroll controller determine which messages remain visible when conversations change or new content arrives.

flowchart LR
  A[Conversation selection] --> B[History and timeline updates]
  B --> C[Native chat timeline]
  C --> D[Session and generation identity]
  D --> E[Virtualized message list]
  E --> F[Layout and tail positioning]
  F --> G[Visible conversation messages]
Loading

Before merge

  • Replace the rejected session-key lifetime change (P2) - This key replaces the native ItemsView and its positioner whenever the conversation changes. The supplied controlled Release comparison isolates these production lines: the unchanged cached-return assertion passed 4/5 baseline runs and 0/5 candidate runs after initial long-session selection succeeded. The author consequently withdrew this approach. Remove or replace this lifetime change before landing and align the identity assertions and documentation with the replacement. The precise native lifecycle cause remains unproven.
  • Resolve merge risk (P1) - The session-key lifetime change worsened cached-return tail visibility in the reported controlled comparison; the native lifecycle cause remains unresolved.
  • Resolve merge risk (P1) - A replacement needs current-source guarded native-app evidence for cached-session returns, streaming follow, and reader-position preservation; mounted-host passes do not resolve the observed failure.
  • Complete next step (P2) - Replace the rejected lifetime change, align its tests and documentation, and obtain successful guarded native-app tail-restoration evidence before landing.
  • Improve patch quality - Address the highest-priority review finding and re-run the changed-surface validation.

Findings

  • [P2] Replace the rejected session-key lifetime change — src/OpenClaw.Tray.WinUI/Chat/ReactorChatTimeline.cs:170-171
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test growth production +2/-0, tests +297/-1, docs +19/-0 The small production lifetime change is supported by extensive mounted coverage, but that coverage did not predict the real-app comparison.
Controlled native comparison baseline 4/5 passed; candidate 0/5 passed The reported isolated comparison rejects the proposed fix despite earlier mounted-test successes.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #1437
Summary: The paired issue owns the cached-session return failure; this PR is its explicitly rejected candidate, not an established fix.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Replace the rejected lifetime change (recommended)
    Trace request, update, mount, and disposal behavior in the guarded application, then replace the key-based approach and align its tests and documentation with the validated solution.
  2. Keep the candidate parked
    Leave the draft unmerged while the paired issue retains the failure and investigation evidence.

Technical review

Best possible solution:

Restore reliable row-targeted tail positioning across cached-session returns while preserving virtualization and scroll-away behavior, using the guarded real-app fixture to validate the actual final message.

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

Yes, a concrete investigation path exists through guarded Release A-to-B-to-A selection and natural message-240 visibility. The historical failure is intermittent, and this read-only review did not reproduce it on current main.

Is this the best way to solve the issue?

No. The isolated comparison rejects the session-key approach; trace the real application's lifecycle before selecting another production change.

Full review comments:

  • [P2] Replace the rejected session-key lifetime change — src/OpenClaw.Tray.WinUI/Chat/ReactorChatTimeline.cs:170-171
    This key replaces the native ItemsView and its positioner whenever the conversation changes. The supplied controlled Release comparison isolates these production lines: the unchanged cached-return assertion passed 4/5 baseline runs and 0/5 candidate runs after initial long-session selection succeeded. The author consequently withdrew this approach. Remove or replace this lifetime change before landing and align the identity assertions and documentation with the replacement. The precise native lifecycle cause remains unproven.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded native-chat scrolling repair whose rejected candidate remains under investigation; check failures alone do not increase priority.
  • merge-risk: 🚨 compatibility: Replacing the native list on session changes worsened existing cached-return scrolling in the controlled comparison.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.

Evidence

What I checked:

  • Pinned introduced change: The merge-base-to-head diff adds the session/generation key to the outer scroll-controller decorator. The original blob lacks that key. The introduced scope is four files; checkout and original PR head are both 4101ee5. No verified test merge is available, so no claim is made that merging removes current-main changes. (src/OpenClaw.Tray.WinUI/Chat/ReactorChatTimeline.cs:171, 4101ee5d21e0)
  • Controlled comparison rejects the candidate: The complete supplied PR body, captured with sourceRevision 3dd6b1651c99b19670ead2faf0e59a232ab92497df952a66dd0fcb6ddf459572, explicitly says not to merge. Five alternating non-Dev Release runs per arm used the unchanged real-app natural-tail assertion: baseline passed 4/5, while the same harness plus only the introduced production key passed 0/5. Native XAML payloads were verified in every run. These are reported results from a combined harness/candidate overlay, not independently replayed exact-head runs; underlying local artifacts are identified but not publicly linked. (4101ee5d21e0)
  • Prior blocker remains applicable: The previous completed review at this same head already raised 'Replace the rejected session-key lifetime change'. The pinned reviewed SHA and checkout SHA are identical, and the comparison has no delta. This is an unchanged prior blocker, not a newly discovered finding. (src/OpenClaw.Tray.WinUI/Chat/ReactorChatTimeline.cs:171, 4101ee5d21e0)
  • Current main preserves the unresolved problem: Current-main fixture documentation records intermittent A-to-B-to-A returns to messages 1-3, successful Gateway histories, and unresolved automation timing. It links Chat can return to the first message instead of the tail when switching back to a populated session #1437 and requires preserving the failing assertion. The current native fixture test checks natural message-240 visibility before driving the scrollbar. (docs/GATEWAY_FIXTURE_TESTING.md:103, 3eb2001e6ab6)
  • Release and current-main boundary: GitHub identifies v2026.9.4 as the latest release, published September 15. Its scroll-controller blob and current main's blob are both c861cb14ac13d955861412361a7d2102b180109e. Current main still uses the existing request/update and row-targeted navigation owner without the proposed outer key. This establishes no shipped or main-only fix for the central problem. (src/OpenClaw.Tray.WinUI/Chat/ReactorItemsViewScrollController.cs:31, 3eb2001e6ab6)
  • Related work supplies infrastructure, not a replacement fix: Merged feat: explore and test the app without a live Gateway #1439 supplies the guarded real-app fixture and explicitly preserves the failure. Merged improve(chat): modernize the native chat experience #1459 states that it does not replace scrolling algorithms. Open fix(chat): adopt Reactor preview.16 session-switch crash workaround #1549 reports failed message-240 visibility in both Debug and Release and explicitly leaves the separate scrolling concerns unresolved.

Likely related people:

  • karkarl: 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)
  • bkudiess: 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 (4 earlier review cycles)
  • reviewed 2026-09-17T17:23:51.505Z sha 4101ee5 :: blocked before merge. :: none
  • reviewed 2026-09-17T17:30:42.059Z sha 4101ee5 :: blocked before merge. :: none
  • reviewed 2026-09-17T19:03:50.309Z sha 4101ee5 :: blocked before merge. :: [P2] Replace the rejected session-key lifetime change
  • reviewed 2026-09-17T20:27:46.376Z sha 4101ee5 :: blocked before merge. :: [P2] Replace the rejected session-key lifetime change

@shanselman shanselman added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 17, 2026
@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. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 17, 2026
@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 17, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

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

Copy link
Copy Markdown
Contributor

Closing due to inactivity.
If this PR should be revived, reopen it with current context and a fresh validation plan.

@github-actions github-actions Bot closed this Oct 13, 2026
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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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.

Chat can return to the first message instead of the tail when switching back to a populated session

1 participant