Repository navigation
feat(audit): report controls that share one accessible name - #4771
Conversation
Add the ambiguous-name finding kind: two or more evaluated controls of one role that carry one accessible name on the captured screen. Names that differ only by case or surrounding whitespace count as one name. Each affected control reports a warning with the shared label and the count, and the guidance asks for a unique label that names its target.
Size Report
Startup median (7 runs, lower is better):
|
|
The audit check has one false positive at c5878c8: a single control can be reported as ambiguous with itself. The The help text promises behavior the code does not have until that is fixed. Not blocking, take or leave: The finding rests on the PR's own test shape, not a measured live capture. CI is still finishing, and nothing has failed. There are no conflicts. Before merge, the count has to cover logical controls only, with the shared predicate and the flipped test. |
…s three, name role-only lines
|
Thanks for the update. The earlier findings are addressed, but one false negative remains in the audit at 1b9a951. evaluatedNameGroup drops every only-child of a same-role control from the shared-name count, even when the parent is not evaluated. If the parent is disabled, non-hittable, zero-rect, system-owned or ref-less, it is excluded at line 111, and its child is excluded at line 114, so that control is counted zero times. For example, Button(enabled:false, "Save") > Button("Save") plus a plain Button("Save") gives count 1 and no finding. Two such wrapped pairs also give no finding. The old code reported both children. This hides two controls an agent cannot tell apart by name, and the "reported once per control" text in help/commands.md is wrong for this shape. collapseIntoParent already keeps the child when the parent does not report that kind (tests at lines 302-320), so the two sites share a predicate but disagree on the outcome. Please make a child count as the same control as its parent only when the parent speaks for it: the parent is itself evaluated (has a ref and passes isActionable), has the same role, and has exactly one child. Putting the parent-evaluated condition inside isDuplicateExposure should do it, and it does not change collapseIntoParent. Please add a test where a disabled or ref-less wrapper over a "Save" child, plus a plain "Save" button, reports two findings with count 2. Not blocking, take or leave: the multi-wrapped test at snapshot-audit.test.ts:264 asserts only kind and ref, and the old code gives the same summary (count 4), so asserting detail { name: "Save", count: 2 } on both findings would pin the logical count. Checks are still running, with Smoke Tests in progress and nothing failed so far. The change only touches the pure audit function and its unit test. Before merge, the wrapped-child count needs the single predicate and the new test. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on 1b9a951. The verdict and the full list are in the summary comment.
|
Fixed at 9bce6b6.
|
|
The PR is ready at 9bce6b6. The earlier findings from #4771 (comment) are fixed in the code. Not blocking: the relocated doc comment in https://github.com/callstack/agent-device/blob/9bce6b6/packages/capture-kit/src/snapshot/snapshot-audit.ts#L67 has a blank line between it and The open thread on a wrapper with a differing child name (#4771 (comment)) is half fixed. The unevaluated-parent case is fixed, because The Runner Build (tvOS + visionOS + watchOS) check failed. This diff touches only TypeScript, not the runner sources or the Xcode project, so the failure looks unrelated. It failed during action setup with a cache-download race, so a rerun should clear it. No conflicts are known. |
Apex Sentinel · ✅ Approve · review of
|
| Where | Finding |
|---|---|
packages/capture-kit/src/snapshot/snapshot-audit.ts:122 |
Shared-name count drops sole-child controls even when their names differ |
Reviewed with this repository's own Sentinel configuration (96a2813c555e).
💬 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.
There was a problem hiding this comment.
Apex Sentinel: 1 finding moved to a new line on 9bce6b6. The verdict and the full list are in the summary comment.
| for (const node of nodes) { | ||
| const control = evaluated.get(node.index); | ||
| if (control?.name === undefined || isDuplicateExposure(node, control.role, facts, evaluated)) | ||
| continue; | ||
| const group = nameGroupKey(control.role, control.name); | ||
| counts.set(group, (counts.get(group) ?? 0) + 1); |
There was a problem hiding this comment.
🟡 Minor · Shared-name count drops sole-child controls even when their names differ
Node 2 button "Continue" (sole child of node 1 button "Save") is skipped by countSharedNames, so the button\0continue group holds only node 3 and is filtered as count 1, reporting no ambiguity even though two buttons share the name "Continue". isDuplicateExposure compares only roles and child counts, never the parent's resolved name with the child's, so the dedup meant for one control exposed twice also silences two distinct controls.
| for (const node of nodes) { | |
| const control = evaluated.get(node.index); | |
| if (control?.name === undefined || isDuplicateExposure(node, control.role, facts, evaluated)) | |
| continue; | |
| const group = nameGroupKey(control.role, control.name); | |
| counts.set(group, (counts.get(group) ?? 0) + 1); | |
| for (const node of nodes) { | |
| const control = evaluated.get(node.index); | |
| if (control?.name === undefined) continue; | |
| const parent = evaluated.get(node.parentIndex ?? -1); | |
| const onlyChild = facts.children.get(node.parentIndex ?? -1)?.length === 1; | |
| if (parent?.role === control.role && onlyChild && parent.name === control.name) continue; | |
| const group = nameGroupKey(control.role, control.name); | |
| counts.set(group, (counts.get(group) ?? 0) + 1); | |
| } |
Details
persona: senior-developer, maintainability, javascript
Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.
Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.
* origin/main: (70 commits) refactor(apple-runner): one RUNNER_ERROR_CODES row per runner error code with parity/docs gates (callstack#4774) fix(android): require acknowledgements for test IME typing (callstack#4722) feat(scroll): add scroll refresh for pull-to-refresh (callstack#4770) refactor(host-kit): add request Scope and use it for the wait capture deadline (callstack#4794) fix(android): let permission all change nothing on an app that declares no permissions (callstack#4796) fix(cli): replace the CLI session and generated remote config instead of rewriting them in place (callstack#4797) fix(host-kit): accept a group-writable script directory the user owns (callstack#4799) fix(cli): escape control characters at the CLI's stdout and stderr writes (callstack#4778) fix(audit): do not report rows under a persistent bar that scrolling reveals (callstack#4775) fix(daemon): refuse an unsafe state directory before first use (callstack#4783) refactor: settle remaining single-deadline races through settleWithin (callstack#4788) refactor(host-kit): settle deadline races via settleWithin with R87 race ratchet (callstack#4766) fix(android): authenticate and bound persistent snapshot helper sessions (callstack#4729) fix(daemon): bound upload ingress and finalization (callstack#4721) chore(gates): ratchet wire-published reason literals by value (R89) (callstack#4779) feat(audit): evaluate role-less clickable views on Android (callstack#4780) fix(mutation): keep umask-setting tests out of Stryker's thread pool (callstack#4785) feat(audit): report controls that share one accessible name (callstack#4771) fix(contracts): pair open runtime hints with their apply operation (callstack#4754) refactor(daemon): report startup progress over the launch channel instead of marker files (callstack#4777) ...
Summary
audittreated any nonempty name as valid. Three buttons named "Save" looked fine, so a screen-reader user and an agent could not tell them apart.This adds the
ambiguous-namefinding kind. Two or more evaluated controls of one role that share one accessible name on the captured screen each report a warning. The detail gives the shared label and the count. Names that differ only by case or surrounding whitespace count as one name. Controls of different roles may still share a name. System bars and keyboard keys stay excluded, and the existing wrapper collapse keeps a duplicated control silent.Touched files: 10. Scope stayed in the audit owner plus its contracts, output, help, and docs. No device-facing behavior changed, so no device run was needed.
agent-device audit # @e4 ambiguous-name button "Save" Name shared by 3 controls of this role--jsonadds the kind tofindings[].kindandguidance, withdetail: { name, count }.Closes #4762
Validation
Tested SHA: c5878c8
pnpm check:affected --runpassed withexactCommit=true: format, lint, typecheck, layering, fallow, build, vitest-related, unit, command-docs, docs-links, docs-prose. Web smoke, replay and Linux lanes stay GitHub-authoritative.The new capture-kit and command-output tests fail on the base and pass at this head. Provider integration for
ios-auditandandroid-auditpasses locally; the iOS clean-screen fixture now names its two buttons differently, since it must prove "no findings".No unresolved risks.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.