Skip to content

fix(tests): stop the Sessions gallery UI test failing when the pane toggle appears late - #2329

Merged
bkudiess merged 2 commits into
openclaw:mainfrom
bkudiess:bkudiess-fix-sessions-gallery-baseline-flake
Nov 19, 2026
Merged

bkudiess merged 2 commits into
openclaw:mainfrom
bkudiess:bkudiess-fix-sessions-gallery-baseline-flake

Conversation

@bkudiess

Copy link
Copy Markdown
Collaborator

Related: CI flake on main a912363, run 44386345268, job 135092115045. This is a different failure in the same test that #2132 fixed earlier.

What Problem This Solves

The "Mock Gateway application and compatibility tests" CI job sometimes fails in SessionsDesignNativeWindowGallery with a NullReferenceException. The test collapses the Settings pane, then immediately looks up the pane toggle button once. When UI Automation has not yet exposed the toggle, the lookup returns null and the test crashes. In the CI failure screenshot, the toggle is visibly rendered.

User Impact

User impact: there is no user-visible change. This is a test-only fix, so main CI no longer fails on this race.

Why This Change Was Made

The restore step now waits for the toggle to be present and enabled before invoking it, using the existing bounded InvokeWhenEnabledAsync helper. It then waits for an observable pane state instead of Thread.Sleep(250): the toolbar search button, which exists only while the pane is open. The matching collapse step earlier in the same flow gets the same treatment. The timing-pattern baseline is lowered for this file only: one fewer fixed delay and two fewer one-shot lookups. Product code is unchanged.

The 400 ms settle after the restore resize stays as it was. That resize changes only the height and is not part of this failure. A width-only wait there would have added new one-shot UIA lookups (review finding).

Evidence

  • RED: I temporarily changed the app locally (uncommitted) to hide the toggle from UIA for 4 s after each toggle, by setting AccessibilityView=Raw. Layout and focus are unchanged. With that change, the original test failed 2/2 with the exact CI stack: Invoke line 2236 ← RestoreBaselineWindow line 2570 ← test line 890.
  • GREEN: With the same injection, the fixed test passed 5/5. I verified that the rebuilt test binary contains RestoreBaselineWindowAsync.
  • Clean: Without injection, the fixed test passed 3/3. Earlier iterations of the fix passed 6 more clean runs.
  • The full required build, Shared tests and Tray tests pass. A dual-model review found no CRITICAL, HIGH or MEDIUM issues in the final diff.

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

  • none: test-only change to a gateway-fixture UI test. The existing "Mock Gateway application and compatibility tests" CI job runs it, and no capacity-dependent custom Windows proof applies.

Validation

Everything below passed on the final tree (base cf58b63936de01a66fe3b7bdb40616eda39cfbe0 plus this diff), on Windows x64. GitVersion needed a sanitized PATH to avoid exit code 9009.

  • ./scripts/validate-test-timing-patterns.ps1: passed.
  • git diff --check: clean.
  • ./build.ps1: all 5 projects built.
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj: Passed 5910, Skipped 29, Failed 0.
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj: Passed 6761, Failed 0.
  • Focused native test: dotnet test tests/OpenClaw.Tray.UITests/OpenClaw.Tray.UITests.csproj -c Debug -r win-x64 --no-build --filter "FullyQualifiedName~GatewayFixtureUiTests.SessionsDesignNativeWindowGallery" with OPENCLAW_RUN_GATEWAY_FIXTURE_UI=1, OPENCLAW_GATEWAY_FIXTURE_SCREENSHOTS=1, and isolated OPENCLAW_TRAY_DATA_DIR, OPENCLAW_TRAY_APPDATA_DIR and OPENCLAW_TRAY_LOCALAPPDATA_DIR temp directories. Results: RED 2/2 failed as expected, GREEN 5/5 passed with injection, and 3/3 passed clean.

Real Behavior Proof

  • Environment tested: Windows x64, active interactive RDP desktop session, Debug win-x64, isolated fixture profile.
  • PR head or commit tested: 61cc595ee4c3f06d260c7ecbc54e9e0b902ab971 (the final working tree before commit, base cf58b639).
  • Exact steps or command run: the focused dotnet test command above, with and without the temporary local AccessibilityView=Raw injection on SettingsTogglePane.
  • Evidence after fix: before the fix, System.NullReferenceException at GatewayFixtureUiTests.Invoke ← RestoreBaselineWindow ← SessionsDesignNativeWindowGallery (2/2). After the fix, Passed SessionsDesignNativeWindowGallery (5/5 with injection, 3/3 clean).
  • Observed result: the test waits for the toggle to return to the UIA tree, expands the pane and completes the gallery.
  • Screenshot or artifact links verified? N/A. The fixture artifacts are local only.
  • Not verified or blocked: this PR's own CI run. The injection was a local simulation of the UIA miss; I did not reproduce the original CI timing itself.

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.

… test

SessionsDesignNativeWindowGallery invoked SettingsTogglePane through a one-shot UIA lookup right after collapsing the pane. CI (run 44386345268) missed the rendered toggle once and failed with a NullReferenceException. Wait for the toggle to be present and enabled, then wait for the pane state to change, instead of using a fixed sleep. Harden the matching collapse step the same way.

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

clawsweeper Bot commented Nov 19, 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: 🦐 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. 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 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

This PR replaces immediate Settings pane toggle lookups and a fixed delay with bounded readiness and pane-state waits in the Sessions gallery test.

Example: SettingsTogglePane is temporarily absent from UI Automation for 4 seconds after collapsing the pane.

  • Before: The restore step immediately invokes a null lookup and throws NullReferenceException.
  • After: The test waits for an enabled toggle, invokes it once, and waits for the pane to expand.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and source-supported, with reported native fault-injection validation; the unclassified current-head soak failure limits validation confidence.
Proof confidence 🦐 gold shrimp (3/6) No shipped behavior changes; the reported native fixture runs exercise the changed test path, so separate shipped-entry-point proof is unnecessary.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Contributors encounter intermittent red CI when the Sessions gallery queries a pane toggle before UI Automation exposes it.
Reason: The maintainer-authored repair follows the documented deterministic-test pattern and preserves the gallery's existing coverage.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it provides a focused fix still absent from main, with no actionable defect found in the introduced diff.

Priority: P2
Reviewed head: 61cc595ee4c3f06d260c7ecbc54e9e0b902ab971

Before merge

None.

Findings

None.

Agent review details

How this fits together

The fixture UI suite drives the real Windows app against synthetic Gateway data and captures Sessions layouts through UI Automation.

flowchart LR
  A[Sessions gallery test] --> B[Bounded UIA readiness helper]
  B --> C[Settings pane toggle]
  C --> D[Settings shell pane state]
  D --> E[Search button visibility]
  E --> F[Layout captures and assertions]
Loading

Technical review

Best possible solution:

Retain the existing gallery owners and assertions while using bounded toggle acquisition and observable pane-state waits.

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

The base source invokes a nullable UIA lookup immediately after pane collapse, establishing the reported null-dereference path; the author also reports a matching injected reproduction.

Is this the best way to solve the issue?

The patch is the smallest complete repair: wait for the existing toggle, invoke once, observe the production pane state, and preserve layout checks without adding production machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Sessions gallery collapse and baseline restoration keeps the original intent (3f47e83: The native Sessions redesign added responsive gallery captures and restoration between states; the PR preserves those purposes while replacing immediate toggle access.)
  • Timing-pattern baseline keeps the original intent (ee8edbc: The timing ratchet prevents new flaky patterns and permits lowering counts when existing patterns are removed.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

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
Change size Production +0/-0; tests and baseline +17/-11 The small increase carries async waits through existing helpers and tightens the baseline by one fixed delay and two one-shot lookups.

Labels

Label changes:

  • add P2: This repairs an intermittent CI test failure without changing shipped application behavior.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp 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: This repairs an intermittent CI test failure without changing shipped application behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Diagnose the gallery failure in the current-head soak job before deciding whether any repair is needed.

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, 7:27 PM ET / November 19, 2026, 00:27 UTC.

The new-test soak sets OPENCLAW_GATEWAY_FIXTURE_SCREENSHOTS=0, so CaptureWidth failed reading a PNG that was never written. Hash captures and check their distinctness only when screenshots are enabled; geometry, tier and pane assertions still run.

Co-authored-by: Copilot App <[email protected]>
@bkudiess
bkudiess merged commit 7de197b into openclaw:main Nov 19, 2026
52 of 54 checks passed
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: 🦐 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant