[codex] preserve visible window state during activation#166
Conversation
- avoid calling ShowWindow on already visible windows during activation prep - move foreground-sensitive tests onto the repo-owned DesktopManager.TestApp harness - add coverage that maximized harness windows stay maximized after activation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe241a7570
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| manager.MaximizeWindow(window); | ||
| Thread.Sleep(150); | ||
| manager.ActivateWindow(window); |
There was a problem hiding this comment.
Handle activation-policy failures in maximized activation test
When RUN_FOREGROUND_UI_TESTS is enabled on Windows configurations that block focus stealing (the same UIPI/focus-policy scenario already handled in ActivateWindow_BringsToFront), manager.ActivateWindow(window) can throw InvalidOperationException. This new test does not catch that case, so it hard-fails instead of being marked inconclusive like the adjacent activation test, making the suite flaky in environments where foreground activation is intentionally restricted.
Useful? React with 👍 / 👎.
What changed
This change tightens the window-activation path so DesktopManager no longer changes the show state of a window that is already visible while trying to focus it.
It also moves the foreground-sensitive regression tests onto the repo-owned
DesktopManager.TestAppharness instead of depending on whichever window happens to be active during a test run.Why it changed
Running the foreground-focused tests could end up touching an arbitrary active window, which made the suite feel unsafe and could leave a maximized window restored to normal size.
The root cause was that activation preparation always called
ShowWindow, even for visible windows. That behavior is now limited to minimized or hidden windows, and the tests now target a specific DesktopManager-owned window end to end.Impact
Validation
dotnet test Sources/DesktopManager.Tests/DesktopManager.Tests.csproj -f net8.0-windows --filter "DesktopAutomationAssertionTests|WindowManagerFilterTests|WindowTopMostActivationTests"