Skip to content

Fix ui --json reporting invokableAncestor as disabled at 0,0 - #1099

Merged
Nikola Metulev (nmetulev) merged 4 commits into
mainfrom
nmetulev-fix-invokable-ancestor-bounds
Oct 15, 2026
Merged

Nikola Metulev (nmetulev) merged 4 commits into
mainfrom
nmetulev-fix-invokable-ancestor-bounds

Conversation

@nmetulev

Copy link
Copy Markdown
Member

What and why

When a winapp ui command matches an element that can't be clicked itself (for example, a label inside a button), its --json output includes an invokableAncestor: the nearest parent that can be clicked. That nested object always said "isEnabled": false with x, y, width and height all 0, 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 invokableAncestor carries the parent's real isEnabled, isOffscreen and bounds — the same values you get by reading that parent on its own. This affects search, get-property, get-focused, wait-for and inspect --interactive. It still has no children or nested invokableAncestor, so the output stays small and can't loop.

The skill reference ui-json-envelope.md showed the wrong zeros in its example; that's corrected too.

Closes #1094
Part of #1084

Before / after

winapp ui search lblSave -a AncestorDemo --json against a WinForms window with a "Save" label inside an enabled button:

Before (main) — ancestor reported disabled at 0,0

before

After — matches winapp ui get-property btn-btnsave-5233 --json (isEnabled: true, 255,284 200x50)

after

Not tested / risks

None. Tested on a real window for search and get-property; inspect --interactive is covered by unit tests.

Checklist

  • Tests added or updated
  • Tested locally on Windows
  • Docs, samples, and plugins/winapp/skills/ updated if user-facing behavior changed
Notes for reviewers

The source values were already correct on every path that sets InvokableAncestor (all build it through ToUiElement or from the inspect walk). The bug was only in the two copies of the flattening projection — UiElementScrubber and UiInspectCommand.StripRedundant — which now share one ToAncestorHint helper.

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>
Copilot AI balanced review requested due to automatic review settings October 14, 2026 22:57
@nmetulev Nikola Metulev (nmetulev) added the agent-preparing Agent is addressing feedback or completing required validation and CI label Oct 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

⏳ Build in progress — metrics below are from a previous commit and will update when the current build finishes.

Build Metrics Report

Validation passed. All required build and validation jobs succeeded.

Binary Sizes

Artifact Baseline Current Delta
CLI (ARM64) 59.50 MB 59.50 MB ✅ 0.0 KB (0.00%)
CLI (x64) 59.48 MB 59.48 MB ✅ 0.0 KB (0.00%)
MSIX (ARM64) 24.71 MB 24.71 MB 📉 -0.1 KB (-0.00%)
MSIX (x64) 26.21 MB 26.21 MB 📉 -0.2 KB (-0.00%)
NPM Package 51.54 MB 51.54 MB 📈 +0.1 KB (+0.00%)
NuGet Package 51.65 MB 51.65 MB 📈 +0.8 KB (+0.00%)

.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 Time

58ms median (x64, winapp --version) · 📉 -22ms vs. baseline

Try This Build

Installs 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))) 1099
Switching between builds often?

Put the tool on your PATH once:

& ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) -AddToPath

Then this build is just:

winapp-pr 1099

Run winapp-pr with no arguments to pick from a list of open PRs.


Updated 2026-10-15 19:43:51 UTC · commit 1fb7581 · workflow run

@nmetulev Nikola Metulev (nmetulev) added ready-for-review Agent work and technical checks complete; awaiting review or re-review, not approval or merge and removed agent-preparing Agent is addressing feedback or completing required validation and CI labels Oct 14, 2026
@nmetulev Nikola Metulev (nmetulev) added agent-preparing Agent is addressing feedback or completing required validation and CI ready-for-review Agent work and technical checks complete; awaiting review or re-review, not approval or merge and removed ready-for-review Agent work and technical checks complete; awaiting review or re-review, not approval or merge agent-preparing Agent is addressing feedback or completing required validation and CI labels Oct 15, 2026
@zateutsch
Zach Teutsch (zateutsch) enabled auto-merge (squash) October 15, 2026 22:06
@nmetulev
Nikola Metulev (nmetulev) merged commit 16991e0 into main Oct 15, 2026
3 checks passed
@nmetulev
Nikola Metulev (nmetulev) deleted the nmetulev-fix-invokable-ancestor-bounds branch October 15, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-not-needed ready-for-review Agent work and technical checks complete; awaiting review or re-review, not approval or merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: invokableAncestor in ui JSON reports a disabled element at 0,0

4 participants