Repository navigation
Fix ui --json reporting invokableAncestor as disabled at 0,0 - #1099
Conversation
The flattened invokableAncestor hint copied only type/name/automationId/selector/isInvokable, so its non-nullable isEnabled, isOffscreen and bounds serialized as false/0. Copy them, and share the projection between UiElementScrubber and inspect. Closes #1094 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
The focused value-copying fix preserves cycle prevention and covers both projection paths with regression assertions; tests were not run during this review.
0 open findings
What changed in this PR
Fixes #1094: ui --json now reports the invokable ancestor’s actual enabled state, visibility, and bounds instead of default values.
Changes:
- Shares the ancestor projection across commands while preserving cycle prevention.
- Adds regression assertions and corrects the documented JSON example.
| File | Description |
|---|---|
| src/winapp-CLI/WinApp.Cli/Helpers/UiElementScrubber.cs | Copies ancestor state and bounds into a shared, non-recursive hint. |
| src/winapp-CLI/WinApp.Cli/Commands/UiInspectCommand.cs | Uses the shared ancestor projection. |
| src/winapp-CLI/WinApp.Cli.Tests/UiHelpersTests.cs | Checks preservation of ancestor state and bounds. |
| src/winapp-CLI/WinApp.Cli.Tests/UiCommandTests.cs | Checks serialized ancestor values and absence of recursive fields. |
| plugins/winapp/skills/winapp-ui-automation/references/ui-json-envelope.md | Corrects ancestor values in the JSON example. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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. ✅ 8697 passed, 39 skipped out of 8736 tests in 1642.6s (+26.8s vs. baseline) Test Coverage✅ 87.5% line coverage, 81.9% branch coverage · ✅ no change vs. baseline CLI Startup Time58ms 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))) 1099Switching 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 1099Run Updated 2026-10-15 19:43:51 UTC · commit |
…e-ancestor-bounds
What and why
When a
winapp uicommand matches an element that can't be clicked itself (for example, a label inside a button), its--jsonoutput includes aninvokableAncestor: the nearest parent that can be clicked. That nested object always said"isEnabled": falsewithx,y,widthandheightall0, even when the button was enabled and on screen. A script reading it would think the button was disabled and at the screen origin.Now
invokableAncestorcarries the parent's realisEnabled,isOffscreenand bounds — the same values you get by reading that parent on its own. This affectssearch,get-property,get-focused,wait-forandinspect --interactive. It still has nochildrenor nestedinvokableAncestor, so the output stays small and can't loop.The skill reference
ui-json-envelope.mdshowed the wrong zeros in its example; that's corrected too.Closes #1094
Part of #1084
Before / after
winapp ui search lblSave -a AncestorDemo --jsonagainst a WinForms window with a "Save" label inside an enabled button:Before (main) — ancestor reported disabled at 0,0
After — matches
winapp ui get-property btn-btnsave-5233 --json(isEnabled: true,255,284 200x50)Not tested / risks
None. Tested on a real window for
searchandget-property;inspect --interactiveis covered by unit tests.Checklist
plugins/winapp/skills/updated if user-facing behavior changedNotes for reviewers
The source values were already correct on every path that sets
InvokableAncestor(all build it throughToUiElementor from the inspect walk). The bug was only in the two copies of the flattening projection —UiElementScrubberandUiInspectCommand.StripRedundant— which now share oneToAncestorHinthelper.