Skip to content

fix(tests): read chat text from complete UI Automation snapshots - #2364

Merged
bkudiess merged 1 commit into
openclaw:mainfrom
bkudiess:bkudiess/flake-findtext-timeline-stale
Nov 24, 2026
Merged

bkudiess merged 1 commit into
openclaw:mainfrom
bkudiess:bkudiess/flake-findtext-timeline-stale

Conversation

@bkudiess

@bkudiess bkudiess commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 657330abd19a43eafd865c521d14a83d7bcb3f8c

Dimension Assessment Rationale
Change confidence 9.5/10 ↑ Native RED/GREEN on the CI trigger: pre-fix 1/10 natural and 4/7 injected failures with the exact CI stack; final 10/10 injected passes (2 with confirmed-disconnected nodes).
↑ Negative control 2/2: incomplete snapshots never yield "absent"; never-complete ones throw.
↑ 20/20 repeats on two bases; contention soak 9/9 runs; dual-model review with no MEDIUM+ left after 3 rounds.
↑ x64 CI run 45329116369 passed on the first attempt for this exact head: fixture UI shards A and B, new-and-changed soak, Tray and UI suites, CodeQL.
↓ Helpers are shared by about 150 call sites; one Crabbox-only SystemsDesign shard failure (pre-existing .Single) passed 6/6 in isolation and in CI.
Diagnosis confidence 9.5/10 ↑ CI stack matches exactly: ElementNotAvailableException from element.Current.Name in FindText, reached from a direct Assert.False(IsVisibleInTimeline(...)).
↑ Reproduced on Crabbox RTX 2 with no injection (1/10 pre-fix) and with a session-switch injection (4/7 pre-fix), same stack.
↑ The same churn also produces cached error markers (COMException 0x80040201), observed and handled.
Evidence fit 9.5/10 ↑ Same test, same helper, same frame and line as main run 45274282812 and PR run 44932626804.
↑ The injection drives the real trigger (session round trip between lookup and read) and logged confirmed-disconnected nodes before the read.
↑ x64 CI also passed on the first attempt.
↓ The local repro host was ARM64 native.

What Problem This Solves

Main is red because a Windows UI test failed while reading chat text during a session switch. RepeatedSessionSwitchingKeepsNativeTimelineResponsive threw ElementNotAvailableException in the shared FindText helper when the chat timeline re-rendered between finding a text node and reading its name. Every developer's CI can hit this, because about 150 call sites share these helpers.

User Impact

User impact: No product behavior changes. Developers get reliable Gateway fixture UI tests for any check that looks up chat or page text while the UI is re-rendering.

Why This Change Was Made

The shared lookups (FindText, FindButtonContaining, FindTimeline, AppWindows, both IsVisibleInTimeline overloads, HasVisibleLongHistory) now read a single UI Automation snapshot. The properties they use (name, off-screen state, bounds) come back in the same FindAll/FindFirst response, so a node removed after the lookup can no longer fail a later read.

A node or scope torn down while UIA builds that response makes the observation incomplete. A match among readable nodes is still valid, but "absent" or "not visible" is only reported from a complete observation. Visibility is part of the match, so a readable off-screen duplicate cannot hide an unreadable visible one.

One bounded, paced retry owner re-observes incomplete snapshots (OPENCLAW_UIA_COMPLETE_SNAPSHOT_TIMEOUT_SECONDS, default 5 s). It then throws ElementNotAvailableException, which WaitUiAsync polls treat as "not yet" and direct asserts surface as a failure. Torn-down means only ElementNotAvailableException, or a COMException with 0x8000FFFF (existing repo precedent) or 0x80040201 (UIA_E_ELEMENTNOTAVAILABLE from a cached error marker, observed here).

Why #2357 missed this sibling. #2357 fixed the same class at one call site: it moved AssertStableInkAsync's FindText into WaitUiAsync, which already swallows ElementNotAvailableException per poll. Its sweep covered that test and its capture and diagnostic path, not the shared helpers. FindText itself still read .Current.Name on every FindAll result. Many callers use these helpers directly, outside a poll: Assert.False(IsVisibleInTimeline(...)) at GatewayFixtureReactorProofTests.cs:41, Assert.Null(FindText(...)) and others. So the race stayed reachable. This PR fixes the helpers, so every caller gets the fix.

Class, sweep and scope
  • Class 2 (stale UIA element), second hit: main run 45274282812 on 01eeb99, and PR run 44932626804.
  • Sweep: every helper on the FindText / IsVisibleInTimeline path across the GatewayFixture* partials:
    • FindText, FindButtonContaining, FindTimeline and AppWindows;
    • both IsVisibleInTimeline overloads and HasVisibleLongHistory;
    • the long-history timeout diagnostics;
    • four FindText(...)!.Current.Name reads (now .Cached.Name);
    • the inline FindTimeline(run)!.FindAll + .Current.Name in GatewayFixtureChatRunCorrelationTests.cs (now FindTimelineTexts).
  • Timing ratchet: GatewayFixtureChatRunCorrelationTests.cs one-shot UIA lookups lowered from 3 to 2.
  • Not changed, noted for follow-up: inline FindAll + .Current.Name sites in other files run inside polls or are outside this helper path.
  • Scroll and transcript product code is untouched (owned by fix(chat): conversation stays at the bottom while following, with one scroll owner #2126).

Evidence

All native runs ran on Crabbox RTX 2 (ARM64, console session 1, through an interactive scheduled task), never on a developer desktop. Isolated OPENCLAW_TRAY_* folders were used, and real-profile manifests were checked before and after.

Check Code Result
Pre-fix, no injection base 1/10 failed with the exact CI stack (FindText → IsVisibleInTimeline → ReactorProofTests:41)
Pre-fix, session-switch injection between lookup and read base + temp injection 4/7 failed with the exact CI stack; one run logged 8/67 matched nodes disconnected before the read
Cache only, no completeness rule (intermediate) rejected 2/8 failed with COMException from cached error markers. This led to the completeness rule.
Final, same injection final + temp injection 10/10 passed; 2 runs logged 8/67 matched nodes disconnected before the read
Negative control: on-screen match made unreadable for 3 observations, off-screen duplicates kept final + temp 2/2: the lookup still reported visible (so Assert.False would still fail). An observation that never completes threw after about 5 s instead of reporting absent.
Repeats, screenshots 0 and 1, native keyboard input final on 6958dae, and again on 32acdd4 20/20 and 20/20
Contention soak (CI soak env, all runs with CPU burners), 7 changed tests final 6/6 runs on 6958dae (screenshots 0 and 1) and 3/3 on 32acdd4 (screenshots 0), 5 tests each; the 2 keyboard-gated tests are excluded by the soak, as in CI
Full Gateway fixture shard (All = A+B, -Screenshots -NativeInputProof -KeyboardProof) final Profile/app lane 57/57. UI lane 126/133 with the fix vs 124/133 on the unmodified base, same run conditions. Both share the host-display failures (DPI width tiers, hero wash, Sessions gallery, GatewayManagement tooltip). Base alone failed RepeatedSessionSwitchingKeepsNativeTimelineResponsive with the exact CI stack. The fix run alone failed SystemsDesign_RealAppLightAndDark (pre-existing .Single over live windows), which then passed 6/6 in isolation. The keyboard lane did not run because the UI lane failed first; the 2 keyboard-gated tests fail identically on base on this host.

Review: dual-model review (Claude Opus 5.5 and GPT-6 Astra long-context, high effort), with three delta rounds.

  • Round 1 (both models, MEDIUM): skipping unreadable nodes let absence asserts pass. Fixed with the complete-snapshot rule.
  • Round 2, both models (MEDIUM): a name-only match let Assert.False(IsVisibleInTimeline) pass on partial data. Fixed: visibility is now in the predicate.
  • Round 2, Opus only (MEDIUM): a torn-down whole FindAll/FindFirst wasn't treated as incomplete. Fixed.
  • Final round: no MEDIUM or above from either model.
  • Two LOWs are left as is (theoretical in current layouts): the text search spans all app windows, as FindText did before; and ObserveTimeline reports "complete" once it finds a timeline.

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-harness reliability only. No product UI, installer, architecture, Gateway or capability behavior changed.

Validation

Builds, static checks and managed suites:

  • ./build.ps1 (local, x64, on 32acdd4): passed.
  • pwsh -NoProfile -File ./scripts/validate-test-timing-patterns.ps1: passed (baseline lowered for my file only).
  • git --no-pager diff --check: clean.
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore (Crabbox RTX 2): passed locally (x64): exit 0, 5972 passed, 0 failed. On Crabbox 1 environment failure (Normalizer_BashUppercaseC_IsNoclobberNotInline: bash not on the host PATH; Shared is untouched by this diff).
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore (Crabbox RTX 2): passed: 6941/6941 (win-arm64, isolated OPENCLAW_TRAY_*).

Native runs on Crabbox RTX 2 used Invoke-NativeUiTest.ps1 (desktop lock, Active-desktop check, isolated OPENCLAW_TRAY_* folders, real-profile check), scripts/Invoke-CiTestSoak.ps1 and scripts/test-gateway-fixture.ps1, all with win-arm64. Results are in the Evidence table.

Real Behavior Proof

  • Environment tested: Crabbox RTX 2 (testpc, Windows ARM64, console session 1), fixture Gateway.
  • PR head or commit tested: 657330abd19a43eafd865c521d14a83d7bcb3f8c (= 32acdd4 + this diff; the final repeats and soak ran on that exact tree before commit; earlier proof ran on 6958dae + the identical diff).
  • Exact steps or command run: see Validation; RED/GREEN used a temporary, uncommitted, env-gated injection (OPENCLAW_TEST_INJECT_STALE_FINDTEXT).
  • Evidence after fix: the Evidence table above.
  • Observed result: no ElementNotAvailableException or COMException from the shared lookups in any final-revision run.
  • Screenshot or artifact links verified? N/A (TRX and console logs are on the host under C:\oc\runs).
  • Not verified or blocked:
    • x64 native runs (the host is ARM64; CI covers x64);
    • other inline .Current reads outside this helper path;
    • the natural failure rate on x64 CI is low, so local repeats cannot prove absence of the race statistically. The injected RED/GREEN and the negative control carry that proof.

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

Compatibility and Migration

  • Backward compatible? Yes
  • Config or environment changes? No (an optional test-only OPENCLAW_UIA_COMPLETE_SNAPSHOT_TIMEOUT_SECONDS override, default 5 s)
  • Migration needed? No

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.

Shared Gateway fixture lookups (FindText, FindButtonContaining, FindTimeline,
AppWindows, IsVisibleInTimeline, HasVisibleLongHistory) read Name, IsOffscreen
and BoundingRectangle from the FindAll/FindFirst response instead of later
.Current reads, so a node removed by a session switch cannot fail the read.
Absence and "not visible" are reported only from a complete observation; one
bounded, paced retry owner re-observes torn-down snapshots.

Fixes the ElementNotAvailableException in FindText via IsVisibleInTimeline
that failed RepeatedSessionSwitchingKeepsNativeTimelineResponsive on main.

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

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

clawsweeper Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

This PR makes shared fixture UI lookups read cached properties and require complete observations before reporting absence.

Example: A session switch removes a text node while RepeatedSessionSwitchingKeepsNativeTimelineResponsive checks for another conversation's history.

  • Before: Reading element.Current.Name can throw ElementNotAvailableException and fail the test.
  • After: The lookup uses cached properties and re-observes incomplete reads before deciding that the text is absent.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A source-supported shared repair with no actionable findings; native validation is reported rather than attached, and the containing fixture suite retains failures.
Proof confidence 🦐 gold shrimp (3/6) Only test-harness behavior changes, so shipped-product proof is unnecessary; reported native ARM64 fault injection exercises the changed UIA helpers, while host-local logs and outstanding x64 checks limit independent validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Developers encounter unrelated CI failures when session changes invalidate text elements during fixture assertions.
Reason: The maintainer-authored repair follows existing UI Automation caching and complete-read patterns; its new timeout override is test-only and does not alter persisted settings.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR repairs a source-confirmed test failure still reachable on main, with no actionable correctness or security findings.

Priority: P2
Reviewed head: 657330abd19a43eafd865c521d14a83d7bcb3f8c

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway fixture tests drive the real Companion application against synthetic Gateway data; shared UI Automation helpers turn owned-window text and geometry observations into test assertions.

flowchart LR
  A[Fixture Gateway] --> B[Companion application]
  B --> C[UI Automation provider]
  C --> D[Cached property observations]
  D --> E[Complete observation check]
  E --> F[Fixture assertions]
Loading

Technical review

Best possible solution:

Land the shared cached-observation repair while preserving complete-read requirements and all existing rendering assertions.

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

Main exposes the enumerate-then-read stale-element path, and the body reports matching natural and injected native failures; this read-only review did not rerun them.

Is this the best way to solve the issue?

The defect is reading live properties after enumeration; the invariant is that incomplete reads cannot prove absence, and the smallest complete fix is cached lookup properties plus one bounded observation owner in the existing shared helpers.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Scott Hanselman: Raw commit 3e74082 adds tests/OpenClaw.Tray.UITests/GatewayFixtureUiTests.cs:270 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3e740827aeb1; files: tests/OpenClaw.Tray.UITests/GatewayFixtureUiTests.cs)
  • Karen: Raw commit a4dd026 adds tests/OpenClaw.Tray.UITests/GatewayFixtureReactorProofTests.cs:23 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a4dd026cc5f8; files: tests/OpenClaw.Tray.UITests/GatewayFixtureReactorProofTests.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
Change scope Production +0/-0; test sources and baseline +175/-52 The growth centralizes stale-read handling in existing fixture helpers without adding product machinery or a new test host.

Labels

Label changes:

  • add P2: A concrete shared native-test failure can block unrelated CI work, with no shipped-product behavior change.
  • 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: A concrete shared native-test failure can block unrelated CI work, with no shipped-product behavior change.
  • 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.

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 24, 2026, 12:02 AM ET / 05:02 UTC.

@bkudiess
bkudiess merged commit f86e395 into openclaw:main Nov 24, 2026
36 checks passed
vincentkoc added a commit that referenced this pull request Nov 24, 2026
…ersion7-coordinated-2355-20261124

* commit 'f86e395d5c8edbc968d8d6e789d1ac16a1124a80':
  fix(tests): read chat text from complete UIA snapshots (#2364)
  fix: reduce typing lag in long chats (#2343)
  fix(tests): wait for the Sessions gallery window (#2337)
  fix(migration): keep the shutdown request until the receiver reads it (#2360)
  fix(tests): isolate settings publication tests from ThreadPool pressure (#2359)
  fix: keep candidate builds from contending on GitHub environment exports
  fix(tests): prevent stale chat ink captures (#2357)
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