Repository navigation
Add --type/--root/--class-name to every single-element ui command - #932
Conversation
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. ✅ 8210 passed, 37 skipped out of 8247 tests in 1255.1s (+99 tests, +163.1s vs. baseline) Test Coverage✅ 86.5% line coverage, 81.1% branch coverage · ✅ no change vs. baseline CLI Startup Time60ms 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))) 932Switching 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 932Run Updated 2026-10-08 03:42:36 UTC · commit |
… aliases - the -a hosted-app fallback and inspect --interactive editable elements move to their own PR into main - element filters on every selector command move into #932 - 'find' and 'tree' are no longer aliases; as unknown commands they suggest 'search' and 'inspect' - remove stray blank lines in record/touch/pen/inspect/screenshot help examples Co-authored-by: Copilot App <[email protected]>
c87dc43 to
5f3d0b3
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Filtered capture can silently widen scope, send-keys --target remains unsupported, and npm recording drops explicit empty filters.
Review effort: Balanced
Findings: 1
Open (3)
What changed in this PR
Extends UI element filters across single-target commands, with strict matching, generated API updates, documentation, and tests.
Changes:
- Adds
--type,--root, and--class-namefiltering to action, gesture, inspection, and capture commands. - Adds filtered-invoke identity checks and ambiguity handling.
- Updates npm bindings, schema, documentation, skills, and tests.
| File | Description |
|---|---|
src/winapp-npm/src/winapp-commands.ts |
Adds generated filter options and forwarding. |
src/winapp-npm/src/ui-record-guard.ts |
Forwards recording filters. |
src/winapp-CLI/WinApp.UIAutomation/Services/UiAutomationService.cs |
Adds provider identity comparison. |
src/winapp-CLI/WinApp.UIAutomation/Services/IUiAutomation.cs |
Exposes identity comparison contract. |
src/winapp-CLI/WinApp.UIAutomation.TestSupport/FakeUiServices.cs |
Extends query test instrumentation. |
src/winapp-CLI/WinApp.UIAutomation.Tests/RealUiAutomationTests.ExplicitActions.cs |
Tests strict filtered actions. |
src/winapp-CLI/WinApp.UIAutomation.Tests/GestureTargetingTests.cs |
Updates test implementation contract. |
src/winapp-CLI/WinApp.Cli/Helpers/UiErrors.cs |
Supports injected error output. |
src/winapp-CLI/WinApp.Cli/Helpers/PointerCommandSupport.cs |
Applies filters to pointer targets. |
src/winapp-CLI/WinApp.Cli/Commands/UiTouchCommand.cs |
Adds filtered touch targeting. |
src/winapp-CLI/WinApp.Cli/Commands/UiSetValueCommand.cs |
Adds filtered value targeting. |
src/winapp-CLI/WinApp.Cli/Commands/UiScrollIntoViewCommand.cs |
Adds filtered element targeting. |
src/winapp-CLI/WinApp.Cli/Commands/UiScrollCommand.cs |
Adds filtered scroll targeting. |
src/winapp-CLI/WinApp.Cli/Commands/UiScreenshotCommand.cs |
Resolves filtered capture targets. |
src/winapp-CLI/WinApp.Cli/Commands/UiRecordCommand.cs |
Resolves filtered recording targets. |
src/winapp-CLI/WinApp.Cli/Commands/UiQueryOptions.cs |
Generalizes shared element filters. |
src/winapp-CLI/WinApp.Cli/Commands/UiPenCommand.cs |
Adds filtered pen targeting. |
src/winapp-CLI/WinApp.Cli/Commands/UiInvokeCommand.cs |
Enforces unique, stable filtered invocation. |
src/winapp-CLI/WinApp.Cli/Commands/UiInspectCommand.cs |
Adds filtered subtree inspection. |
src/winapp-CLI/WinApp.Cli/Commands/UiHoverCommand.cs |
Adds filtered hover targeting. |
src/winapp-CLI/WinApp.Cli/Commands/UiFocusCommand.cs |
Adds filtered focus targeting. |
src/winapp-CLI/WinApp.Cli/Commands/UiClickCommand.cs |
Adds filtered click targeting. |
src/winapp-CLI/WinApp.Cli/Commands/GuestDesktopCaptureCommand.cs |
Updates recording-handler dependencies. |
src/winapp-CLI/WinApp.Cli.Tests/UiCommandTests.Screenshot.cs |
Updates screenshot test construction. |
src/winapp-CLI/WinApp.Cli.Tests/UiCommandTests.Record.Stdin.cs |
Updates recording test construction. |
src/winapp-CLI/WinApp.Cli.Tests/UiCommandTests.Query.cs |
Tests filter scope and command parity. |
src/winapp-CLI/WinApp.Cli.Tests/UiCommandTests.Invoke.cs |
Tests filtered invocation behavior. |
src/winapp-CLI/WinApp.Cli.Tests/RealRecordingTests.Helpers.cs |
Forwards identity comparison in tests. |
src/winapp-CLI/WinApp.Cli.Tests/DesktopCaptureTests.cs |
Updates guest recording tests. |
plugins/winapp/skills/winapp-ui-automation/SKILL.md |
Documents action-command filtering. |
docs/usage.md |
Adds shared filter guidance. |
docs/ui-automation.md |
Documents filtering semantics and failures. |
docs/npm-usage.md |
Regenerates npm API documentation. |
docs/cli-schema.json |
Regenerates CLI option schema. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.


Description
A label like "Save" often matches more than one element: the button and its own text block, for example. Before this change, only the read commands (
search,get-value,get-property,wait-for,inspect) could narrow a selector with--type,--root, or--class-name. Commands that act on an element could not, so agents had to find the slug first and then retry.Now these
winapp uicommands also accept the filters on their element selector:invoke,set-value,click,focus,hover,scroll,scroll-into-view,screenshot,record,touch,pen, andinspectwith a selector.drag(two selectors) andsend-keys --targetdo not. With filters, the selector and all filters must match exactly one element in the target app or window.For
invoke:--action.--action, a filtered invoke still tries the invoke patterns in order on that one element.Usage Example
Failure behavior:
ambiguous_selectorand does not act. Commands that act on the element count matches in every window they search. For example, if the main window and an owned dialog both have a "Subject" field,winapp ui set-value Subject "draft" -a MyApp --type Editfails instead of editing the main window's field. Narrow the filters or use a unique slug fromwinapp ui inspectorwinapp ui search.searchitself still lists every match.invokealso fails if the matched element is replaced or its window is recycled before it acts; other commands re-read the selector just before acting, as they do without filters.inspect,screenshot, andrecordhave an optional selector): rejected withinvalid_arguments.touch --at,pen --ator--path): rejected, because coordinates bypass the selector.Where the element is searched:
inspectandscreenshotlook only in the window they display.recordalso searches the app's popups and owned dialogs, and records from the window where the unique match was found.The npm
uiRecordwrapper forwardstype,root, andclassName, including explicit empty strings, as the CLI does.Related Issue
N/A
Type of Change
Checklist
plugins/winapp/skills/Screenshots / Demo
N/A: CLI-only change. The commands above are illustrative examples, not captured output.
Additional Notes
Validation (local, current head):
scripts/build-cli.ps1 -SkipTests -SkipMsixpassed. The generated CLI schema and npm docs/wrappers are committed.UiCommandTestsandDesktopCaptureTests: 882 passed, 1 skipped (interactive-desktop-only recording test).npm testinsrc/winapp-npm: 312 passed.scripts/validate-plugin-package.ps1passed.Compatibility: Filters on
invokewithout--actionwere rejected only in this unreleased PR. Allowing them changes no published behavior. All other commands gain new optional flags; omitting them keeps today's behavior.