Skip to content

Stabilize Windows UIA focus live gate - #391

Closed
coneilen wants to merge 0 commit into
scgopi:mainfrom
coneilen:coneilen-microsoft-harden-uia-focus-gate
Closed

coneilen wants to merge 0 commit into
scgopi:mainfrom
coneilen:coneilen-microsoft-harden-uia-focus-gate

Conversation

@coneilen

@coneilen coneilen commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Hardens the Windows native UI Automation worktree-row focus assertion against shared CI desktop-focus churn without weakening the assertion or changing product behavior.

Changes

  • Preserve the existing 30-second focus-retention polling loop and hard failure/diagnostics.
  • Reorder each polling iteration to settle briefly (40ms) after ActivateWindow before calling SetFocus, so the row's focus assertion is the last action before sampling FocusedElement.
  • Keep a final bounded nudge (300ms settle + short recheck) before the hard failure, using the same settle-then-focus-then-check ordering.

Notes on iteration

A first attempt (commit 7db72cd) only added a trailing final nudge without reordering; it still reproduced the failure on hosted windows-spikes (https://github.com/scgopi/GraphCode/actions/runs/35476483960/job/105986495560) with the identical symptom, showing the interfering refocus lands after SetFocus inside every loop iteration, not only at the loop boundary. Commit a3d6910 reorders each iteration accordingly.

Test plan

RED: Tools/windows/validate.ps1 -Task all -SkipTrayLive -SkipWslRemoteE2E on PR #387 commit 1ed41ca -> failed in windows-spikes with worktree row could not retain focus against concurrent desktop focus changes; focused=Text Area:Text Area (https://github.com/scgopi/GraphCode/actions/runs/35475073552/job/105985602192)
GREEN: PowerShell parser on Tools/windows/uia-live-gate.ps1 at commit a3d6910 -> passed with no parse errors; pwsh -NoProfile -File Tools/windows/Tests/ValidationRunner.Tests.ps1 -> PASS
REGRESSION: pwsh -NoProfile -File Tools/windows/validate.ps1 -Task windows-shell -SkipTrayLive -> reached the pre-UIA Swift release build and stopped on the known local SDK limitation missing required modules: '_complex', 'ucrt'; hosted windows-spikes runs the complete gate and is the authoritative pass/fail signal for this change

Checklist

  • I have read the Contributing Guidelines
  • I have signed off my commits (git commit -s) per the DCO
  • Tests pass locally (make test) — not applicable to this Windows-only test-infrastructure change; focused validation is documented above
  • Code follows the existing style (git diff --check)
  • I added the focused synchronization behavior after reproducing the intended RED failure in the linked same-source CI run, and iterated after the first fix attempt was disproven by hosted CI

@coneilen coneilen closed this Sep 21, 2026
@coneilen
coneilen force-pushed the coneilen-microsoft-harden-uia-focus-gate branch from 0cac713 to 0210e0e Compare September 21, 2026 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant