Skip to content

fix(tests): prevent stale chat ink captures - #2357

Merged
bkudiess merged 1 commit into
openclaw:mainfrom
bkudiess:bkudiess-flake-chat-ink-stale-uia
Nov 23, 2026
Merged

bkudiess merged 1 commit into
openclaw:mainfrom
bkudiess:bkudiess-flake-chat-ink-stale-uia

Conversation

@bkudiess

Copy link
Copy Markdown
Collaborator

What Problem This Solves

The chat ink stability test can fail when a Windows UI Automation element becomes stale between lookup and capture. This unrelated test failure blocks developers' CI.

User Impact

User impact: No product behavior changes. Developers get a more reliable chat ink stability test.

Why This Change Was Made

Each frame reacquires its window and text element inside the existing bounded stale-element wait. Pixel assertions remain outside the retry. The touched test and helper path, including screenshot and diagnostic paths, were swept for stale-element siblings.

Evidence

An injected stale element reproduced the ElementNotAvailableException in FindText called from AssertStableInkAsync; the same injection passed with the fix. The affected UI shard and repeated native tests passed. Two independent reviewers found no medium-or-higher issues; one noted that visibility and capture use separate lookups and that timeout diagnostics do not retain the last stale exception. Both are bounded by the existing wait; pixel assertions are not retried.

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

  • .\build.ps1: passed.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore: 5,972 passed, 29 skipped, 0 failed.
  • dotnet build .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj then dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: 6,938 passed, 0 skipped or failed on isolated Crabbox RTX 1 (static SSH, Windows ARM64; run run_ea2e98e2a7e6672784b45c28750adb4a).
  • pwsh -NoProfile -File .\scripts\validate-test-timing-patterns.ps1: passed.
  • git diff --check: passed.
  • Focused native test: 10 consecutive passes each with fixture screenshots disabled and enabled, with native input enabled.
  • .\scripts\Invoke-CiTestSoak.ps1 -SelectionPath <selection> -ResultsDirectory <results>: 10 of 10 passes for each screenshot setting, with 16 externally owned CPU burners throughout each run and native input enabled. Internal soak contention count was zero.
  • Affected fixture UI shard A: 88 passed, 0 failed or skipped.

Real Behavior Proof

  • Environment tested: Isolated local Windows x64 native fixture; isolated Crabbox RTX 1 Windows ARM64 for Tray suite.
  • PR head or commit tested: Source corresponding to commit c20185fcf535e489feb3c6346f85d79247bdb1f2: base 91070a21147a2624599de21fbfa5ab2ce79704ab plus the two-file candidate (diff hash c33b6e4f6b5541bc9ebd2371bc2532dceac1bf5c). Validation and review were performed before committing.
  • Exact steps or command run: Inject a one-shot ElementNotAvailableException in FindText and run InteractiveWork_DoesNotFadeCompletedMessagePixels before and after the repair; remove the injection; run the affected shard and native repetitions.
  • Evidence after fix: The injection fired and the focused test passed; the uninstrumented shard and both contention soaks passed.
  • Observed result: Transient stale UIA references are reacquired; completed-message pixel assertions still execute.
  • Screenshot or artifact links verified? (Yes/No/N/A): N/A. No screenshots published.
  • Not verified or blocked: First-attempt PR CI is pending. This test-only change does not claim live gateway or product UI acceptance proof.

Security Impact

  • New permissions or capabilities? (Yes/No): No
  • Secrets or tokens handling changed? (Yes/No): No
  • New or changed network calls? (Yes/No): No
  • Command or tool execution surface changed? (Yes/No): No
  • Data access scope changed? (Yes/No): No
  • If any answer is Yes, explain the risk and mitigation: N/A

Compatibility and Migration

  • Backward compatible? (Yes/No): Yes
  • Config or environment changes? (Yes/No): No
  • Migration needed? (Yes/No): 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.

Reacquire UI Automation elements while capturing each frame so transient stale references do not fail the ink stability test.

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

clawsweeper Bot commented Nov 23, 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. clawsweeper:intake:needs-repro 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 23, 2026
@clawsweeper

clawsweeper Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

This PR reacquires chat UI Automation elements inside the existing bounded wait before capturing each ink-stability frame.

Example: FindText throws ElementNotAvailableException while capturing initial-ink-00.png.

  • Before: The exception escapes the capture loop and fails the test.
  • After: The existing wait reacquires the elements and retries capture, then evaluates the unchanged pixel assertions.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with reported native fault-injection validation; supporting output is not attached and some exact-head CI checks remain in progress.
Proof confidence 🦐 gold shrimp (3/6) Only test harness behavior changes, so shipped-product proof is unnecessary; the body reports source-matched fault injection and native fixture runs.
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 can encounter unrelated CI failures when chat capture uses a stale UI Automation reference.
Reason: The maintainer-authored direction follows the existing deterministic-test contract and preserves the rendering regression checks.

Merge readiness

✅ Ready for maintainer review

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

Priority: P2
Reviewed head: c20185fcf535e489feb3c6346f85d79247bdb1f2

Before merge

None.

Findings

None.

Agent review details

How this fits together

The native Gateway fixture test drives Companion against synthetic chat data, locates owned UI Automation elements, captures window pixels and checks that completed messages remain readable.

flowchart LR
  A[Synthetic chat fixture] --> B[Companion window]
  B --> C[Bounded UIA wait]
  C --> D[Owned window capture]
  D --> E[Pixel assertions]
Loading

Technical review

Best possible solution:

Land the focused capture retry using the existing wait and ownership checks while preserving all pixel assertions.

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

Main visibly allows stale-element exceptions from lookup or capture to escape; the author also reports a targeted before/after injection, which this read-only review did not rerun.

Is this the best way to solve the issue?

The defect is capture outside the stale-element boundary; the invariant is that ownership and readable-ink failures remain fatal, and the smallest complete fix is to reacquire and capture inside the existing wait as this patch does.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 91070a21147a.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned patch and current-main failure: Main performs FindText and capture outside the stale-element wait; the introduced patch moves both into that existing wait without retrying pixel assertions. (tests/OpenClaw.Tray.UITests/GatewayFixtureInteractiveUiTests.cs:22, c20185fcf535)
  • Existing retry contract: WaitUiAsync catches ElementNotAvailableException only and delegates to the fixture's bounded wait; assertion failures still propagate. (tests/OpenClaw.Tray.UITests/GatewayFixtureUiTests.cs:2445, c20185fcf535)
  • Timing policy preserved: The documented policy requires acquiring UIA elements inside the wait; reducing the baseline from 14 to 13 matches removal of one FindText null-forgiving lookup. (docs/TEST_COVERAGE.md:899, c20185fcf535)
  • Reported validation and discussion: The body reports injected stale-element failure before repair and success afterward, native repetitions, an 88-test fixture shard pass and required local validation; discussion contains only review-status bot comments and no human objection. (c20185fcf535)
  • Exact-head CI: Fast validation, changed-test soak and Tray/setup/integration checks passed; several native UI and security checks remain in progress, with no failed check reported. (c20185fcf535)
  • Policy and inspection limits: Read the complete root AGENTS.md; no scoped AGENTS.md exists under tests and no maintainer-notes directory exists. The explicit single-reviewer instruction supersedes the autoreview-helper route. Extended content history for the unchanged shared fixture helper hit an unavailable old blob; changed-file history and current helper source were available. No builds, tests or additional reviewers were run. (AGENTS.md:13, c20185fcf535)

Likely related people:

  • Barbara Kudiess: Raw commit 243f9cf adds tests/OpenClaw.Tray.UITests/GatewayFixtureInteractiveUiTests.cs:9 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 243f9cff53d8; files: tests/OpenClaw.Tray.UITests/GatewayFixtureInteractiveUiTests.cs)
  • Karen: Raw commit 5ca1513 adds tests/OpenClaw.Tray.UITests/GatewayFixtureInteractiveUiTests.cs:41 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 5ca151308f65; files: tests/OpenClaw.Tray.UITests/GatewayFixtureInteractiveUiTests.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; tests and baseline +10/-4 The small increase reuses existing retry machinery and leaves product behavior unchanged.

Labels

Label changes:

  • add P2: A narrow native test reliability repair prevents unrelated CI failures without changing the shipped application.
  • 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 narrow native test reliability repair prevents unrelated CI failures without changing the shipped application.
  • 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 23, 2026, 1:35 PM ET / 18:35 UTC.

@bkudiess
bkudiess merged commit 9ced24f into openclaw:main Nov 23, 2026
39 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