Skip to content

fix(harmonyos): label snapshot nodes with their visible text - #4926

Merged
thymikee merged 2 commits into
0.22from
fix/0.22-harmonyos-snapshot-labels
Nov 21, 2026
Merged

thymikee merged 2 commits into
0.22from
fix/0.22-harmonyos-snapshot-labels

Conversation

@thymikee

@thymikee thymikee commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Summary

ArkUI reports a control's words outside the control. A Toggle answers with its resource id and no text; the string on the screen is a sibling Text of the row container, and every such container reports the same id (SwitchMenuComponent). The mapping had nowhere to take the words from, so label fell through to the id (#4906).

It now reads them off the control's row: the nearest container that holds the control and no other control. That is the settings row of a Toggle, and the title bar of a back Button. A control holding another control takes no label — those words are the nested control's own, and both would answer one selector. Borrowed text must contain a letter, so the clock digits and padding blanks ArkUI also reports stay out of labels while a node's own value reports them unchanged. The resource id stays the identifier.

That fixes #4907 at this site: the unlabeled back button's press fell through to the nearest label in the whole capture, the merged status-bar window's StatusBarBridgeView, 136 px above it. The title bar now names the button.

Fixes #4906
Fixes #4907

Before / after

snapshot -i on Settings > Developer options:

- @e10 [toggle] "entry_toggle_usb_debug"
+ @e10 [toggle] "USB debugging"

- press @e1 -> "refLabel": "StatusBarBridgeView"
+ press @e1 -> "refLabel": "Developer options"

Validation

  • pnpm lint, pnpm typecheck, pnpm format, pnpm check:layering, pnpm run check:package, npx vitest run --project unit-core (all green)
  • New fixture tests from a sanitized real device dump: 4 fail on 0.22, pass here
  • Live on a nova 14 (OpenHarmony 6.1.1, 4UQ9K25710015363), branch CLI, isolated home:
$ agent-device open com.huawei.hmos.settings --platform harmonyos --session hmos-labels
$ agent-device snapshot -i --session hmos-labels
@e1 [button] "Developer options"
@e3 [toggle] "Developer options"
@e10 [toggle] "USB debugging"
$ agent-device press @e1 --session hmos-labels --json
  "message": "Tapped @e1 (108, 189)",
  "refLabel": "Developer options",
  "selectorChain": ["role=\"button\" label=\"Developer options\""]
$ agent-device close --session hmos-labels
$ agent-device daemon stop

Get evidence
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff Turn on auto-fix

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.16 MB 6.16 MB 0 B
Package (unpacked) 6.16 MB 6.16 MB 0 B
Package (download) 1.88 MB 1.88 MB +4 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 19.1 ms 19.1 ms +0.1 ms
CLI --help 37.0 ms 36.9 ms -0.1 ms

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Apex Sentinel: 1 new finding on 68bf549. The verdict and the full list are in the summary comment.

@thymikee

Copy link
Copy Markdown
Member Author

This head (68bf549) conflicts with 0.22 and sits on an older 0.22 history: against the current base, its diff carries 63 commits and 881 files, while the change itself is the top commit. Please rebase the top commit onto the current 0.22 and push; the rebased head gets a full review.

ArkUI reports a control's words outside the control. A `Toggle` answers with its resource id
(`entry_toggle_usb_debug`) and no text; the words on the screen ("USB debugging") are a sibling
`Text` of the row container, and every such container reports the same `id`
(`SwitchMenuComponent`). An icon-only `Button` answers with neither. The mapping had nowhere to
take the words from, so `label` fell through to the id and `snapshot -i` printed
`entry_toggle_usb_debug` (#4906).

Read them off the control's row: the nearest container that holds the control and no other
control, which is the settings row of a `Toggle` and the title bar of a back `Button`. A control
that holds another control takes no label, because those words are the nested control's own and
both would answer one selector. Borrowed text has to contain a letter, so the clock digits and
padding blanks ArkUI also reports stay out of labels while a node's own `value` keeps reporting
them unchanged. The resource id stays the node's `identifier`, and a node's own accessibility
description still wins.

That fixes #4907 at this site. The back button carried no label of its own, so its press fell
through to the nearest label in the whole capture, which was the merged status-bar window's
`StatusBarBridgeView`, 136 px above it. The title bar now names the button, so the press reports
"Developer options" and that fallback never runs. A control whose row renders no words still
reports none, which is what a press on one should say.

Two passes over the captured tree, so no capture pays for it twice. Live-verified on a nova 14
(OpenHarmony 6.1.1) in Settings > Developer options.
A screen holding exactly one control made every ancestor of that control, up to and including the
capture root, a "container with one control". An icon-only FAB whose nearest words were hundreds of
pixels away therefore read the first words of the whole document — the headline — as its own label,
and `find`/`label="<headline>"` matched the button as well as the headline's own `Text`. The row
assignment was inherited by every node below a one-control container too, so an unclickable icon
wrapper inside a clickable title bar borrowed the title bar's first words from a branch it does not
sit in.

Read each node's row from its own ancestors instead of inheriting one, and hold a container to a
row's own size: it counts as the control's row only when the control's parsed bounds sit inside it
and it stands no taller than four times the control. Both already-shaped rows survive that bound —
across the real captures the container around a leaf control reaches at most 3.5 times its height —
while the column and screen containers above a lone control reach ten or more. The settings rows
still answer "USB debugging" and the back button still answers "Developer options"; a lone control
on a full-height page now reports no label at all.
@apex-sentinel-staging

This comment has been minimized.

@thymikee
thymikee force-pushed the fix/0.22-harmonyos-snapshot-labels branch from d58def2 to 3b3f24c Compare November 21, 2026 19:59
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 3b3f24c

Since the review of 68bf549: 1 new · 0 still open · 1 no longer raised

1 finding(s): 1 minor.

🟡 Minor (1)

Where Finding
packages/platform-harmonyos/src/snapshot.ts:76 🆕 Row height bound of 4x silently drops labels on rows taller than 4x a small control

1 finding below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (d6767e0910fc).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Apex Sentinel: 1 new finding on 3b3f24c. The verdict and the full list are in the summary comment.

@thymikee

Copy link
Copy Markdown
Member Author

The code at 3b3f24c is ready, and the 16 checks are green with none failing. Not blocking: Fixes #4907 could become Refs #4907, because the shared nearest-label fallback in resolveRefLabel still gives unlabeled refs a label from an unrelated node; the 4x row-height bound can skip a tall row (for example a two-line row around a small checkbox), which leaves it unlabeled as on base; and a borrowed label means a text= selector in a full capture can now match both the Text node and its control. These can be taken or left.

Not verified here: tests were not run locally, the live device transcript comes from the PR body, how find and press resolve a two-node text= match on HarmonyOS, and the 3.5x-vs-10x row claim beyond the sanitized fixture.

Both earlier inline threads no longer apply, so they can be resolved. The lone-control-on-a-full-screen-page thread is fixed by the row height bound and its test: #4926 (comment). The thread on the 4x bound dropping labels on tall rows is benign, because a dropped label matches base behavior: #4926 (comment).

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 21, 2026
@thymikee
thymikee merged commit 634f5b8 into 0.22 Nov 21, 2026
16 checks passed
@thymikee
thymikee deleted the fix/0.22-harmonyos-snapshot-labels branch November 21, 2026 21:17
thymikee added a commit that referenced this pull request Nov 23, 2026
* fix(harmonyos): label snapshot nodes with their visible text

ArkUI reports a control's words outside the control. A `Toggle` answers with its resource id
(`entry_toggle_usb_debug`) and no text; the words on the screen ("USB debugging") are a sibling
`Text` of the row container, and every such container reports the same `id`
(`SwitchMenuComponent`). An icon-only `Button` answers with neither. The mapping had nowhere to
take the words from, so `label` fell through to the id and `snapshot -i` printed
`entry_toggle_usb_debug` (#4906).

Read them off the control's row: the nearest container that holds the control and no other
control, which is the settings row of a `Toggle` and the title bar of a back `Button`. A control
that holds another control takes no label, because those words are the nested control's own and
both would answer one selector. Borrowed text has to contain a letter, so the clock digits and
padding blanks ArkUI also reports stay out of labels while a node's own `value` keeps reporting
them unchanged. The resource id stays the node's `identifier`, and a node's own accessibility
description still wins.

That fixes #4907 at this site. The back button carried no label of its own, so its press fell
through to the nearest label in the whole capture, which was the merged status-bar window's
`StatusBarBridgeView`, 136 px above it. The title bar now names the button, so the press reports
"Developer options" and that fallback never runs. A control whose row renders no words still
reports none, which is what a press on one should say.

Two passes over the captured tree, so no capture pays for it twice. Live-verified on a nova 14
(OpenHarmony 6.1.1) in Settings > Developer options.

* fix(harmonyos): bound a control's borrowed row to a row's own size

A screen holding exactly one control made every ancestor of that control, up to and including the
capture root, a "container with one control". An icon-only FAB whose nearest words were hundreds of
pixels away therefore read the first words of the whole document — the headline — as its own label,
and `find`/`label="<headline>"` matched the button as well as the headline's own `Text`. The row
assignment was inherited by every node below a one-control container too, so an unclickable icon
wrapper inside a clickable title bar borrowed the title bar's first words from a branch it does not
sit in.

Read each node's row from its own ancestors instead of inheriting one, and hold a container to a
row's own size: it counts as the control's row only when the control's parsed bounds sit inside it
and it stands no taller than four times the control. Both already-shaped rows survive that bound —
across the real captures the container around a leaf control reaches at most 3.5 times its height —
while the column and screen containers above a lone control reach ten or more. The settings rows
still answer "USB debugging" and the back button still answers "Developer options"; a lone control
on a full-height page now reports no label at all.
hannojg pushed a commit to hannojg/agent-device that referenced this pull request Nov 23, 2026
…ck#4926)

* fix(harmonyos): label snapshot nodes with their visible text

ArkUI reports a control's words outside the control. A `Toggle` answers with its resource id
(`entry_toggle_usb_debug`) and no text; the words on the screen ("USB debugging") are a sibling
`Text` of the row container, and every such container reports the same `id`
(`SwitchMenuComponent`). An icon-only `Button` answers with neither. The mapping had nowhere to
take the words from, so `label` fell through to the id and `snapshot -i` printed
`entry_toggle_usb_debug` (callstack#4906).

Read them off the control's row: the nearest container that holds the control and no other
control, which is the settings row of a `Toggle` and the title bar of a back `Button`. A control
that holds another control takes no label, because those words are the nested control's own and
both would answer one selector. Borrowed text has to contain a letter, so the clock digits and
padding blanks ArkUI also reports stay out of labels while a node's own `value` keeps reporting
them unchanged. The resource id stays the node's `identifier`, and a node's own accessibility
description still wins.

That fixes callstack#4907 at this site. The back button carried no label of its own, so its press fell
through to the nearest label in the whole capture, which was the merged status-bar window's
`StatusBarBridgeView`, 136 px above it. The title bar now names the button, so the press reports
"Developer options" and that fallback never runs. A control whose row renders no words still
reports none, which is what a press on one should say.

Two passes over the captured tree, so no capture pays for it twice. Live-verified on a nova 14
(OpenHarmony 6.1.1) in Settings > Developer options.

* fix(harmonyos): bound a control's borrowed row to a row's own size

A screen holding exactly one control made every ancestor of that control, up to and including the
capture root, a "container with one control". An icon-only FAB whose nearest words were hundreds of
pixels away therefore read the first words of the whole document — the headline — as its own label,
and `find`/`label="<headline>"` matched the button as well as the headline's own `Text`. The row
assignment was inherited by every node below a one-control container too, so an unclickable icon
wrapper inside a clickable title bar borrowed the title bar's first words from a branch it does not
sit in.

Read each node's row from its own ancestors instead of inheriting one, and hold a container to a
row's own size: it counts as the control's row only when the control's parsed bounds sit inside it
and it stands no taller than four times the control. Both already-shaped rows survive that bound —
across the real captures the container around a leaf control reaches at most 3.5 times its height —
while the column and screen containers above a lone control reach ten or more. The settings rows
still answer "USB debugging" and the back button still answers "Developer options"; a lone control
on a full-height page now reports no label at all.
thymikee added a commit that referenced this pull request Nov 24, 2026
* fix(harmonyos): label snapshot nodes with their visible text

ArkUI reports a control's words outside the control. A `Toggle` answers with its resource id
(`entry_toggle_usb_debug`) and no text; the words on the screen ("USB debugging") are a sibling
`Text` of the row container, and every such container reports the same `id`
(`SwitchMenuComponent`). An icon-only `Button` answers with neither. The mapping had nowhere to
take the words from, so `label` fell through to the id and `snapshot -i` printed
`entry_toggle_usb_debug` (#4906).

Read them off the control's row: the nearest container that holds the control and no other
control, which is the settings row of a `Toggle` and the title bar of a back `Button`. A control
that holds another control takes no label, because those words are the nested control's own and
both would answer one selector. Borrowed text has to contain a letter, so the clock digits and
padding blanks ArkUI also reports stay out of labels while a node's own `value` keeps reporting
them unchanged. The resource id stays the node's `identifier`, and a node's own accessibility
description still wins.

That fixes #4907 at this site. The back button carried no label of its own, so its press fell
through to the nearest label in the whole capture, which was the merged status-bar window's
`StatusBarBridgeView`, 136 px above it. The title bar now names the button, so the press reports
"Developer options" and that fallback never runs. A control whose row renders no words still
reports none, which is what a press on one should say.

Two passes over the captured tree, so no capture pays for it twice. Live-verified on a nova 14
(OpenHarmony 6.1.1) in Settings > Developer options.

* fix(harmonyos): bound a control's borrowed row to a row's own size

A screen holding exactly one control made every ancestor of that control, up to and including the
capture root, a "container with one control". An icon-only FAB whose nearest words were hundreds of
pixels away therefore read the first words of the whole document — the headline — as its own label,
and `find`/`label="<headline>"` matched the button as well as the headline's own `Text`. The row
assignment was inherited by every node below a one-control container too, so an unclickable icon
wrapper inside a clickable title bar borrowed the title bar's first words from a branch it does not
sit in.

Read each node's row from its own ancestors instead of inheriting one, and hold a container to a
row's own size: it counts as the control's row only when the control's parsed bounds sit inside it
and it stands no taller than four times the control. Both already-shaped rows survive that bound —
across the real captures the container around a leaf control reaches at most 3.5 times its height —
while the column and screen containers above a lone control reach ten or more. The settings rows
still answer "USB debugging" and the back button still answers "Developer options"; a lone control
on a full-height page now reports no label at all.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant