Repository navigation
fix(tests): main search tests wait for search elements instead of one lookup - #2334
Conversation
…of one lookup MainSearch_MessageHitOpensItsNativeConversationWithoutSending failed on main with a NullReferenceException in SearchEdit: the search input that the preceding wait had just seen was missing from the next one-shot UIA lookup. SearchEditAsync now re-acquires the input until it is an enabled Edit that supports ValuePattern, and reports the last observed state on timeout. Every SearchEdit caller uses it. Co-authored-by: Copilot App <[email protected]>
… of one lookup The message-hit test still captured its screenshot from a one-shot FindById(SearchResultsList)! right after the wait that saw the list, the same failure mode as the search input. Lookups that follow a wait in the touched search tests now use bounded re-lookups (WaitForElementByIdAsync, a FindInApp variant and SearchScrollAsync for the result list scroll host), and wait conditions no longer dereference a missing element. The one-shot UIA lookup baseline drops to 5 for the search tests and 20 for the Dashboard tests. 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 replaces one-shot search-test element lookups with bounded waits and lowers the corresponding timing-pattern baselines. Example: The message-hit test opens search with Ctrl+E and enters “lighthouse” after three transient WorkspaceSearchBox lookup misses.
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 test race still present on main, and the review found no actionable introduced defects. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway fixture UI tests drive Companion through Windows UI Automation; the changed helpers turn transient element availability into bounded acquisition while retaining navigation, focus, accessibility, and draft assertions. flowchart LR
A[Fixture UI tests] --> B[Bounded UIA acquisition]
B --> C[Native SearchHost]
C --> D[Shared search controller]
D --> E[Fixture Gateway]
C --> F[Navigation and draft assertions]
Technical reviewBest possible solution: Land the bounded element-acquisition repair with the existing behavioral assertions and tightened timing baseline intact. Do we have a high-confidence way to reproduce the issue? Main's SearchEdit dereferences a nullable lookup after a separate readiness wait, directly explaining the reported NullReferenceException; the author reports matching injected reproduction, but this review executed no tests. Is this the best way to solve the issue? The defect is reacquisition after readiness; the invariant is unchanged behavioral assertions, and the smallest complete repair uses the existing polling owner to return captured usable elements, as this patch does. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 757bb2272d48. 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 18, 2026, 9:39 PM ET / November 19, 2026, 02:39 UTC. |
Related: #2262
What Problem This Solves
Main CI keeps failing in the Mock Gateway fixture UI shard B. The search test
MainSearch_MessageHitOpensItsNativeConversationWithoutSendingopens Companion's main search and fails with aNullReferenceExceptionbefore it types. It failed three times on 2026-11-18: maincf58b639(run 44418135075), main996ac69c(run 44425756439) and #2329 (run 44431345467). Contributors then have to rerun CI to get a green result.User Impact
User impact: none. Companion behavior does not change. Main and PR CI no longer fail when the search box briefly drops out of a single UI Automation lookup.
Why This Change Was Made
Each test waited until the search box appeared and then looked it up again once with
SearchEdit. If that second lookup missed the box, the test crashed. In CI the failing line wasSearchEdit:205(element.Current, afterFindById(...)!). That line means the second lookup returned null, even though the wait had just seen the box. The failure screenshot shows the search flyout open with the box present. The box is theSearchHostTextBox, so the inner-Edit lookup was not involved.SearchEditAsyncreplacesSearchEdit. It uses the existingWaitUiAsyncwith its normal 20-second limit and looks up the box again on every poll. It returns only an Edit that is enabled and supportsValuePattern. If it times out, the error names the input that was awaited and the last observed state:input missing,no Edit,Edit disabled,Edit has no ValuePatternorready. All 21 callers use it: the main search tests and the Channels search test in the Dashboard file.The same tests had other one-shot lookups right after waits. One was the screenshot target
FindById(run, "SearchResultsList")!in the failing test. EachFindById(...)!,FindInApp(...)!orFindFirst(...)!that ran right after a wait, before the next input action, now uses a bounded re-lookup: the existingWaitForElementByIdAsync, a newWaitForInAppAsync, or a newSearchScrollAsyncfor the result list's scroll host, which replaces the one-shotScrollSearch. Wait conditions that could dereference a missing element (!.Current) now use null-safe pattern checks.ComposerTextreturns an empty string while the composer is briefly missing, so waits keep polling and draft assertions still fail if the draft is lost. The test-timing ratchet baseline drops from 52 to 5 one-shot UIA lookups in the main search file and from 21 to 20 in the Dashboard file. The 5 that remain follow a foreground-activation action or are catch-block diagnostics.Why it started now
cf58b639, no MainSearch test failed. The first failure was on 2026-11-18.30cfe593. The only commit between that run and the first failure is fix(tests): Systems hero proof reads the issues icon before its button hosts it #2321, which is test-only (SystemsPageProofTests.cs).ci.ymllast changed on 2026-11-16.SearchHostlast changed on 2026-11-12 (fix: Dashboard loses the selected chat on newer Gateways #2125). No product change in the failure window affects search.Evidence
WorkspaceSearchBoxlookups miss after the wait first saw the box. This change was not committed. The test failed with the CI stack:NullReferenceExceptionatSearchEditline 205, called from the test lambda at line 181.OPENCLAW_GATEWAY_FIXTURE_SCREENSHOTSset to 0 and to 1.SearchEditAsyncpolled through the misses.SearchResultsListlookups were made to miss. With the first commit's one-shot line 190, the test failed at:190:OwnedWindowCapture.SaveCorethrewElementNotAvailableException("control was detached or re-rendered"). With the final head, the test polled through the three misses and passed with screenshots set to 0 and to 1.MainSearch_*andChannelsSearch_OpensDashboardFromWorkspaceAndSettings) passed on this head with screenshots set to 0, as in the CI soak, and set to 1.Change Type
Scope
winnodeRequired proof pools
none: this changes only fixture UI tests and a timing-ratchet baseline. The CI fixture UI shards already run the changed tests on a Windows desktop runner. No product behavior, visual output or capability changes.Validation
All checks ran on head
82ff4048264a5bfd866dc999beedf7b602b3653c, based on origin/main757bb2272d48e499e5ece6ea8e75ddfe87602c42, with a clean tree and isolatedOPENCLAW_TRAY_DATA_DIR,OPENCLAW_TRAY_APPDATA_DIRandOPENCLAW_TRAY_LOCALAPPDATA_DIR../scripts/validate-test-timing-patterns.ps1: passed after lowering the two touched baseline entries.git diff --check origin/main: passed../build.ps1: passed ("All builds succeeded").dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj: passed, 5961 passed, 29 skipped, 0 failed.dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj: passed, 6829 passed, 0 failed.dotnet test tests/OpenClaw.Tray.UITests -c Debug -r win-x64 -p:DevBuild=false --filter "FullyQualifiedName~GatewayFixtureUiTests.MainSearch_|FullyQualifiedName~GatewayFixtureUiTests.ChannelsSearch_OpensDashboardFromWorkspaceAndSettings"withOPENCLAW_RUN_GATEWAY_FIXTURE_UI=1: 18 of 18 passed withOPENCLAW_GATEWAY_FIXTURE_SCREENSHOTS=0, and 18 of 18 passed with=1.a0f424f6): no CRITICAL or HIGH findings. The second commit has not been reviewed. See Review Conversations.Real Behavior Proof
82ff4048264a5bfd866dc999beedf7b602b3653c(clean tree)dotnet testcommand in Validation. RED and GREEN used the same single-test filter onMainSearch_MessageHitOpensItsNativeConversationWithoutSendingwith temporary, uncommitted lookup-miss changes forWorkspaceSearchBoxandSearchResultsList.NullReferenceException at SearchEdit ... GatewayFixtureMainSearchUiTests.cs:line 205, called from line 181. GREEN passed after three injected misses. Without injection, all 18 changed tests passed with screenshots set to 0 and to 1.Assert.NullandAssert.NotNulllookups after waits were left unchanged. They have no!, so a miss fails the assertion. Tests in other files were not changed.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
Review findings from the first commit (Claude Opus 5.5 and GPT-6 Astra on a0f424f; the second commit has not been reviewed):
ElementNotAvailableException, the timeout's "Last state" text is not updated. Fix: passonProbeErrortoWaitUiAsync(99% fix confidence).FindById(run, "SearchResultsList")!at line 190 of the target test, along with the other one-shot lookups after waits in the touched tests.