Repository navigation
Fix ui/devtools window targeting and unclear error messages - #1161
Zach Teutsch (zateutsch) wants to merge 4 commits into
Conversation
- -a by title prefers an exact title match; -a by PID/name skips the in-process DevTools inspector window - -w and --root accept 0x hex handles; bad -w values explain what a handle looks like - devtools parse errors point at --help instead of printing the full help page; the pointer names the full command path - devtools errors and query output use plain sentences instead of raw tokens; known HRESULTs get a meaning - --of-type with a type not in the window says so - step-aside line no longer says the app runs without DevTools when it exited or headless inspection still works - run --devtools off closes the running instance so its files can be replaced - clearer binding-host and get-source stale messages Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 64d9ea83-443c-4cf5-80bc-2611af3c5216
…sing the app - ui element commands no longer fall back to controls in the DevTools inspector when the app lacks them - the inspector title check lives in one place (UiTargetResolver), shared with ui screenshot - 'unknown-child' search truncation gets a plain sentence - usage.md run section and the troubleshoot skill say run closes a copy running from the same layout Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 64d9ea83-443c-4cf5-80bc-2611af3c5216
There was a problem hiding this comment.
🔵 Needs a closer look
Live inspector targeting and expanded process termination still need Windows runtime verification, and the native C++ change was not built or tested locally.
No open issues 🎉
What changed in this PR
This PR addresses #1147 by improving window selection and error messages across winapp ui and winapp devtools.
Changes:
- Prefers app windows over the in-process DevTools inspector and exact titles over partial matches.
- Accepts hexadecimal handles, shortens parse errors, and adds clearer failure explanations and recovery steps.
- Closes running app copies before registration even with DevTools off, with updated tests and documentation.
| File | Description |
|---|---|
| src/winapp-devtools/test/binding-relay-tests.cpp | Checks the revised binding-host guidance. |
| src/winapp-devtools/native/WinApp.DevTools.Native/DevToolsBindingRelay.cpp | Recommends relaunching with DevTools enabled. |
| src/winapp-CLI/WinApp.UIAutomation/Services/UiTargetResolver.cs | Prefers app windows and exact title matches. |
| src/winapp-CLI/WinApp.UIAutomation/Services/UiAutomationService.cs | Excludes inspector controls from fallback searches. |
| src/winapp-CLI/WinApp.UIAutomation.Tests/UiTargetResolverTests.cs | Tests inspector filtering and exact-title selection. |
| src/winapp-CLI/WinApp.UIAutomation.Tests/RealUiAutomationTests.Coverage.cs | Tests that element searches exclude inspector controls. |
| src/winapp-CLI/WinApp.Cli/Services/DevTools/DevToolsErrors.cs | Explains failure tokens and common Windows error codes. |
| src/winapp-CLI/WinApp.Cli/Program.cs | Shortens DevTools parse errors and fixes nested help pointers. |
| src/winapp-CLI/WinApp.Cli/Commands/UiScreenshotCommand.cs | Reuses shared inspector-window detection. |
| src/winapp-CLI/WinApp.Cli/Commands/SharedUiOptions.cs | Parses decimal and hexadecimal window handles. |
| src/winapp-CLI/WinApp.Cli/Commands/RunCommand.DevTools.cs | Avoids misleading fallback messages after exit or partial success. |
| src/winapp-CLI/WinApp.Cli/Commands/RunCommand.cs | Closes running layout processes regardless of DevTools mode. |
| src/winapp-CLI/WinApp.Cli/Commands/DevToolsQueryOptions.cs | Clarifies query errors while preserving JSON output. |
| src/winapp-CLI/WinApp.Cli/Commands/DevToolsLiveCommand.cs | Accepts and normalizes hexadecimal root handles. |
| src/winapp-CLI/WinApp.Cli/Commands/DevToolsGetSourceCommand.cs | Recommends rebuilding and relaunching for stale source. |
| src/winapp-CLI/WinApp.Cli.Tests/WinAppParserConfigurationTests.cs | Tests handle formats and invalid-value guidance. |
| src/winapp-CLI/WinApp.Cli.Tests/UiHelpTests.cs | Tests concise DevTools parse-error output. |
| src/winapp-CLI/WinApp.Cli.Tests/DevToolsRunTests.cs | Tests revised run messages and closing with DevTools off. |
| src/winapp-CLI/WinApp.Cli.Tests/DevToolsAgentCommandTests.cs | Tests readable error descriptions. |
| plugins/winapp/skills/winapp-troubleshoot/SKILL.md | Updates guidance for running apps and locked files. |
| docs/usage.md | Documents automatic app closure and hexadecimal handles. |
| docs/ui-automation.md | Shows equivalent decimal and hexadecimal handles. |
| docs/guides/devtools.md | Links app-closure guidance to the run documentation. |
Review effort: Balanced
The DevTools e2e test targets inspector controls with -a <pid> (ui wait-for WinAppDevToolsAddComment). Element search already tries the app's main window first, so the filter only blocked that case. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 64d9ea83-443c-4cf5-80bc-2611af3c5216
Build Metrics ReportValidation passed. All required build and validation jobs succeeded. Binary Sizes
.NET Test Results (TRX reports)Other suites are reflected in the overall validation status above. ✅ 10681 passed, 43 skipped out of 10724 tests in 2268.9s (+17 tests, -315.4s vs. baseline) Test Coverage✅ 87.4% line coverage, 81.4% branch coverage · ✅ no change vs. baseline CLI Startup Time49ms median (x64, Try This BuildInstalls the MSIX for your architecture, replacing any previously installed build. Needs the GitHub CLI — the command offers to install it and sign you in if it is missing. & ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) 1161Switching between builds often?Put the tool on your PATH once: & ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) -AddToPathThen this build is just: winapp-pr 1161Run Updated 2026-10-22 23:01:07 UTC · commit |
PR Review — zateutsch-validate-ui-window-targeting-issue vs mainDecisionMerge. The solution builds, the related tests pass, and the new handle parsing and short error messages worked against a real Notepad window. I found one optional docs inaccuracy. Must fixNone. The PR can merge as it is. Non-blockingThe docs promise a 2-second grace period that some apps don't get
What was exercised
|
Jaylyn Barbee (Jaylyn-Barbee)
left a comment
There was a problem hiding this comment.
Approved with one optional fix.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 64d9ea83-443c-4cf5-80bc-2611af3c5216
|
Jaylyn Barbee (@Jaylyn-Barbee) Fixed in 5008a8e: the |
What and why
winapp uiandwinapp devtoolssometimes acted on the wrong window, and several errors showed raw codes or .NET type names instead of saying what to do. Now:-a <pid>targets the app, not the DevTools inspector (the DevTools window that runs inside the app's process), even when the inspector is in front.-a "My App"prefers the window titled exactly that over "My App 2".-wand--rootaccept0xhex as well as decimal, so a handle copied from Spy++ or a debugger works. A bad value says what a handle looks like.Run 'winapp devtools comments add --help' for usage.instead of the whole help page.searchoutput use sentences instead of tokens likeno-matchorcensus-cap, and known HRESULTs get a short meaning, for example0x802B000A (XAML could not be parsed).--of-type Nopesays no element has that type. JSON output is unchanged.winapp runno longer says "the app runs without DevTools" when the app exited, or when headless inspection still works. The binding-host message says to relaunch withwinapp run --devtools on, andget-sourcesays to rebuild and relaunch.--devtools offwith the app open.winapp run --devtools offused to fail with "still running" when the app was open. It now closes the running copy first, as--devtools onalready did.Fixes #1147
Before / after
winapp ui inspect -w <hex handle>andwinapp devtools comments add -a 1(missing--text), onmainand on this branch:Before
After
Not tested / risks
winapp runnow closes a copy of the app running from the same build folder in every mode, including--devtools offand--no-launch. It asks the app to close and ends it after 2 seconds, or right away if the app has no window or is showing a dialog. This is documented indocs/usage.mdunderrun.DevToolsBindingRelay.cppand its test) locally.DevToolsRunTests.Default_ConnectFailure_HumanOutputIsOnePlainLinestalls when the whole class runs in parallel locally but passes alone. This looks pre-existing.Checklist
plugins/winapp/skills/updated if user-facing behavior changed