Repository navigation
fix(tests): read chat text from complete UI Automation snapshots - #2364
Conversation
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]>
|
🦞👀 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 changesThis 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.
Review scores
ProductKind: Test only · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway 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]
Technical reviewBest 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
TestingProof path: in-process harness. 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 24, 2026, 12:02 AM ET / 05:02 UTC. |
…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)
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
657330abd19a43eafd865c521d14a83d7bcb3f8c↑ 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
SystemsDesignshard failure (pre-existing.Single) passed 6/6 in isolation and in CI.ElementNotAvailableExceptionfromelement.Current.NameinFindText, reached from a directAssert.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 (
COMException0x80040201), observed and handled.↑ 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.
RepeatedSessionSwitchingKeepsNativeTimelineResponsivethrewElementNotAvailableExceptionin the sharedFindTexthelper 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, bothIsVisibleInTimelineoverloads,HasVisibleLongHistory) now read a single UI Automation snapshot. The properties they use (name, off-screen state, bounds) come back in the sameFindAll/FindFirstresponse, 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 throwsElementNotAvailableException, whichWaitUiAsyncpolls treat as "not yet" and direct asserts surface as a failure. Torn-down means onlyElementNotAvailableException, or aCOMExceptionwith0x8000FFFF(existing repo precedent) or0x80040201(UIA_E_ELEMENTNOTAVAILABLEfrom a cached error marker, observed here).Why #2357 missed this sibling. #2357 fixed the same class at one call site: it moved
AssertStableInkAsync'sFindTextintoWaitUiAsync, which already swallowsElementNotAvailableExceptionper poll. Its sweep covered that test and its capture and diagnostic path, not the shared helpers.FindTextitself still read.Current.Nameon everyFindAllresult. Many callers use these helpers directly, outside a poll:Assert.False(IsVisibleInTimeline(...))atGatewayFixtureReactorProofTests.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
FindText/IsVisibleInTimelinepath across theGatewayFixture*partials:FindText,FindButtonContaining,FindTimelineandAppWindows;IsVisibleInTimelineoverloads andHasVisibleLongHistory;FindText(...)!.Current.Namereads (now.Cached.Name);FindTimeline(run)!.FindAll+.Current.NameinGatewayFixtureChatRunCorrelationTests.cs(nowFindTimelineTexts).GatewayFixtureChatRunCorrelationTests.csone-shot UIA lookups lowered from 3 to 2.FindAll+.Current.Namesites in other files run inside polls or are outside this helper path.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.FindText→IsVisibleInTimeline→ReactorProofTests:41)COMExceptionfrom cached error markers. This led to the completeness rule.Assert.Falsewould still fail). An observation that never completes threw after about 5 s instead of reporting absent.-Screenshots -NativeInputProof -KeyboardProof)RepeatedSessionSwitchingKeepsNativeTimelineResponsivewith the exact CI stack. The fix run alone failedSystemsDesign_RealAppLightAndDark(pre-existing.Singleover 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.
Assert.False(IsVisibleInTimeline)pass on partial data. Fixed: visibility is now in the predicate.FindAll/FindFirstwasn't treated as incomplete. Fixed.FindTextdid before; andObserveTimelinereports "complete" once it finds a timeline.Change Type
Scope
winnodeRequired 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, isolatedOPENCLAW_TRAY_*).Native runs on Crabbox RTX 2 used
Invoke-NativeUiTest.ps1(desktop lock, Active-desktop check, isolatedOPENCLAW_TRAY_*folders, real-profile check),scripts/Invoke-CiTestSoak.ps1andscripts/test-gateway-fixture.ps1, all withwin-arm64. Results are in the Evidence table.Real Behavior Proof
testpc, Windows ARM64, console session 1), fixture Gateway.657330abd19a43eafd865c521d14a83d7bcb3f8c(= 32acdd4 + this diff; the final repeats and soak ran on that exact tree before commit; earlier proof ran on 6958dae + the identical diff).OPENCLAW_TEST_INJECT_STALE_FINDTEXT).ElementNotAvailableExceptionorCOMExceptionfrom the shared lookups in any final-revision run.C:\oc\runs)..Currentreads outside this helper path;Security Impact
NoNoNoNoNoCompatibility and Migration
YesNo(an optional test-onlyOPENCLAW_UIA_COMPLETE_SNAPSHOT_TIMEOUT_SECONDSoverride, default 5 s)NoReview Conversations