Repository navigation
fix: pinned pages can crash Companion after Settings refreshes its agent list - #2171
Conversation
…ent list SettingsShellView rebuilt its agent rows by clearing and recreating every NavigationViewItem on each agents.list update. WinUI keeps SplitView callbacks on those rows (microsoft/microsoft-ui-xaml#10757, fixed upstream by #12235 but not in Windows App SDK 2.6.5). After a removed row is collected, hiding the Settings pane for an embedded pinned page called into the freed row: an access violation, or an E_FAIL that UIA reported as "Pattern not found" in the DashboardsRenderNativeReportsTabsAndFailureStates CI flake. KeyedMenuRows reuses rows by key and never releases a row it created, and the Settings agent menu now uses it. The Dashboards test also waits for the re-created pinned row to be present and selected instead of reading it once. Co-authored-by: Copilot App <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThe PR preserves Settings agent-row identity across refreshes and waits for the re-pinned Dashboards row to become selected in the UI test. Example: Settings receives the agents main and ops repeatedly, then the user opens the Dashboards pin.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses a concrete crash path still present on main, and review found no actionable patch defects. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherSettingsShellView turns cached Gateway agent data into native navigation rows; Workspace pin activation hides that navigation pane while displaying an embedded Settings page. flowchart TD
A[Gateway agent list] --> B[SettingsShellView]
B --> C[KeyedMenuRows]
C --> D[Retained agent rows]
E[Workspace pin activation] --> B
B --> F[Embedded page and pane transition]
Technical reviewBest possible solution: Retain keyed Settings agent rows for the view lifetime while preserving Gateway order, labels, and existing embedded-page navigation. Do we have a high-confidence way to reproduce the issue? Current-main source contains the row replacement and pane-transition trigger, corroborated by the upstream fix and the reported native stack; the intermittent crash was not independently executed during this read-only review. Is this the best way to solve the issue? The fix preserves the necessary invariant that removed rows remain alive during later pane callbacks, uses the existing ordering owner, and avoids hiding partially applied navigation behind retries. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5e8824267216. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
Likely related people:
Preflight sourceSource 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
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 13, 2026, 10:08 AM ET / 15:08 UTC. |
GatewayFixtureNativeDashboardsUiTests.cs produced repeated CI flakes from one-shot FindById(...)! reads after a re-render or resize (openclaw#2171, openclaw#2193). Sweep the remaining 30 into bounded waits: invocations wait until the control is present and enabled and invoke once, reads wait for presence and keep the polled element, and lambdas inside waits treat a missing peer as not ready. A local run also showed DashboardsBackdropSpansGalleryAndBoardInBothThemes failing with "Named backdrop host is missing": its stability wait polled a helper that threw when the host peer was briefly absent during the minimum-width resize. The backdrop and responsive stability waits now treat a missing host as not ready, restart their stability window, and return the settled width so callers do not re-read it once. The one-shot lookup baseline entry for this file drops from 30 to 0. Co-authored-by: Copilot App <[email protected]>
…ion element is briefly missing after a re-render or resize (#2222) * test(dashboards): wait for UIA peers instead of one-shot reads GatewayFixtureNativeDashboardsUiTests.cs produced repeated CI flakes from one-shot FindById(...)! reads after a re-render or resize (#2171, #2193). Sweep the remaining 30 into bounded waits: invocations wait until the control is present and enabled and invoke once, reads wait for presence and keep the polled element, and lambdas inside waits treat a missing peer as not ready. A local run also showed DashboardsBackdropSpansGalleryAndBoardInBothThemes failing with "Named backdrop host is missing": its stability wait polled a helper that threw when the host peer was briefly absent during the minimum-width resize. The backdrop and responsive stability waits now treat a missing host as not ready, restart their stability window, and return the settled width so callers do not re-read it once. The one-shot lookup baseline entry for this file drops from 30 to 0. Co-authored-by: Copilot App <[email protected]> * test(dashboards): give the widget pixel wait a named budget and report widget state The new-test soak's CPU-contention run failed DashboardsRenderNativeReportsTabsAndFailureStates with "Timed out waiting for visible dashboard pixels: 99.97, Uptime". The failure frame shows the HTML Service health widget still in the product's Slow state ("This widget is taking longer than usual to load") 30.1 s after board.get. On CI, boards normally render in 1.8-6.6 s (12 samples, 4 runs). Replace the literal 30 s with DashboardPixelsTimeout (default 60 s, override OPENCLAW_GATEWAY_FIXTURE_DASHBOARD_PIXELS_TIMEOUT_SECONDS, capped at 90 s): one product frame retry after its 30 s load deadline plus a normal render, inside the 150 s test body budget. On timeout, the message now names each widget's Loading, Slow, Error or NeedsApproval state, so a slow load stays distinguishable from a failed one. The diagnostic never replaces the timeout. Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: Copilot App <[email protected]>
What Problem This Solves
Fixes: Companion can crash (
0xC0000005) or silently fail to open a pinned page after Settings has refreshed its agent list. In CI, this shows up as the intermittentGatewayFixtureUiTests.DashboardsRenderNativeReportsTabsAndFailureStatesfailureCOMException: Pattern not found(most recently main run 42980649021 and #2161 run 43404129857). It is also behind theSettingsPane_KeepsToggleChoiceAcrossPinnedPagesAndRestart"Pattern not found" failure that another session hit locally.User Impact
User impact: opening a pinned page beside the sidebar (for example Dashboards or Connection) no longer risks crashing Companion or leaving it on a blank, half-applied Settings view. This happened after the Gateway had sent its agent list more than once, which is normal at startup and after reconnects. It is most reachable through UI Automation (Narrator and test automation) because those activate the row without moving focus first. The same path also runs for pointer clicks. Settings agent rows now keep their identity across agent-list refreshes, so their order and labels follow the Gateway as before.
Why This Change Was Made
SettingsShellView.RebuildAgentNavItemsclearedAgentsNavItem.MenuItemsand recreated every agent row on eachAppState.AgentsListchange. The fixture sendsagents.listthree times at startup.This hits WinUI bug microsoft/microsoft-ui-xaml#10757:
NavigationViewItemregisters SplitView property callbacks that capture the raw item.In our app, opening a pinned page runs
OnPinItemInvoked→OpenSettings→SettingsShellView.ContentOnly = true→NavigationView.IsPaneVisible = false. That applies thePaneCollapsedvisual state, which changes the SplitView and reaches the collected agent rows. A full crash dump shows this native stack:NavigationView::UpdatePaneVisibility→GoToState→NavigationViewItem::OnSplitViewPropertyChanged→NavigationViewItemPresenter::UpdateCompactPaneLength→ access violation.When the fault surfaces as
E_FAILinstead of a crash, the exception escapes theItemInvokedhandler, and UIA returns it fromSelectionItemPattern.Select()as "Pattern not found". The CI artifacts match this:board.getorsessions.listrequest follows the click;The fix adds
KeyedMenuRows, which keeps one row per key, reuses it on every sync and never releases a row it created. Settings agent rows use it, so a refresh reorders or relabels rows in place instead of replacing them. A removed agent's row stays referenced, so WinUI never calls into a collected item, and the row is reused if that agent returns.Windows App SDK status (checked 2026-11-13): this app ships Windows App SDK 2.6.5, and the crash reproduces on it. Neither the 2.6.5 nor the 2.6.6-experimental release notes mention #10757 or #12235. Once a Windows App SDK release includes #12235,
KeyedMenuRowscan drop the rows it keeps for removed keys.This PR also fixes a separate one-shot UIA read in the same test (main run 43430233130,
NullReferenceExceptionatGatewayFixtureNativeDashboardsUiTests.cs:1343). After the unpin/re-pin loop, the test read the re-createdWorkspacePinnedPage:dashboardsrow once. It now waits for that row to be present and selected. The selected-state requirement is unchanged.The shared test
Invokehelper is deliberately unchanged. The "Pattern not found" call had already reached product code, so retrying it could re-run a partly applied action and would hide this crash.Not in this PR: the Workspace sidebar also removes NavigationViewItems (session rows in
SyncSessionItems, pinned-page rows inPinnedPageRows). That is the same bug class, and it moves to a separate follow-up that reusesKeyedMenuRows.Evidence
maincode, the app crashed in 5 of 8 runs with the native stack above.bd6a2dbd0plus this diff (Claude Opus 5.5 and GPT-6 Astra long-context, both high effort). Neither found a CRITICAL, HIGH or MEDIUM issue.Change Type
Scope
winnodeRequired proof pools
windows-winui-interactive: covered by isolated fixture runs of the WinUI app for the affected flows. See Validation and Real Behavior Proof.Validation
All runs were local on Windows x64 at 175% DPI, with isolated profiles. Metadata for the real
%APPDATA%/%LOCALAPPDATA%\OpenClawTraywas unchanged after every run.DashboardsRenderNativeReportsTabsAndFailureStates(Light and Dark)SettingsPane_KeepsToggleChoiceAcrossPinnedPagesAndRestartmain: 5 of 8 crashed; fix: 20/20 survivedKeyedMenuRowsTests(new)scripts\test-gateway-fixture.ps1, current Debug app)fixture-profile-app) 56/56 passed. UI tests without the keyboard requirement: 124/125 passed. The one failure isAutomations_ScopesToAgentsAndCoversMainStates(Light), an AxeBoundingRectangleSizeReasonableviolation that only occurs locally at 175% DPI. UI tests that require keyboard proof: 5/9 passed, and the same 4 fail identically onmainbd6a2dbd0on this machine. The UI sets were run directly withdotnet testand the same filters, because the script caps a run at 1800 s and the local UI set takes about 29 minutes..\scripts\validate-test-timing-patterns.ps1: passed. The one-shot UIA lookup baseline forGatewayFixtureNativeDashboardsUiTests.csdrops from 32 to 31../build.ps1: all builds succeeded.dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj: 5862 passed, 0 failed, 29 skipped. An earlier run had 1 unrelated failure that passed on rerun; this PR changes no Shared code.dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj: 6444 passed, 0 failed.Real Behavior Proof
dotnet test tests/OpenClaw.Tray.UITests -c Debug -r win-x64 -p:DevBuild=false --no-build --filter "FullyQualifiedName~DashboardsRenderNativeReportsTabsAndFailureStates"withOPENCLAW_RUN_GATEWAY_FIXTURE_UI=1.SettingsPane_KeepsToggleChoiceAcrossPinnedPagesAndRestart.OpenClaw.Tray.WinUI.exe.Yes/No/N/A): N/A (local artifacts only).DefaultAgentNavItem(agent:main) is replaced on the first sync rather than adopted. Its generated field keeps it alive, so it is not collected.Clear()did this on every refresh.Security Impact
Yes/No): NoYes/No): NoYes/No): NoYes/No): NoYes/No): NoYes, explain the risk and mitigation: N/ACompatibility and Migration
Yes/No): YesYes/No): NoYes/No): NoReview Conversations