fix: improve Android snapshot fidelity#580
Conversation
|
ec3e5c5 to
3645382
Compare
3645382 to
5c2d9f6
Compare
Code reviewOverviewRefactors Android helper snapshot presentation into a new The new heuristics are intricate but generally well-structured. A few asymmetries and behavioral reductions deserve attention. FindingsBugs1 — Passive descendants are removed without label promotion (asymmetric → can silently drop visible text). ( for (const descendant of descendants) {
if (isPassiveRowContent(descendant)) {
markNodeAndDescendantsForRemoval(nodes, descendant.index, removed);
}
}So a passive text/image child whose rect falls outside the parent bounds — or that is rectless ( Issues to verify2 — 3 — Overlay labels can now be 4 — Loss of 5 — More aggressive collapsing of existing scenarios. The RN-row test changed from "8 visible / Collapsed 2" to "6 visible / Collapsed 4", merging what were previously separate 6 — Nits
Test coverageThe cited tests genuinely exercise most new behavior: Android overlay raw-pixel alignment, unlabeled bottom-tab inclusion (no invented labels), tall-row trimming ( Gaps:
SummaryThe core coordinate-system fix is correct (Android uiautomator bounds == screenshot pixels, so dropping Reviewed with Claude Code. Generated by Claude Code |
|
Addressed the review points in What changed:
Confirmed intentional:
Validation:
|
Summary
Improve Android
snapshot -iandscreenshot --overlay-refsfidelity by replacing Android-helper-specific noise cleanup with generic row promotion/collapse heuristics and by making Android overlay refs use screenshot-pixel coordinates directly.Before/after cases checked during verification:
overlayRefs[].rectstill reports the underlying accessibility bounds.ViewGrouptab controls were visible but did not get clickable overlay refs. After, bounded unlabeled clickable controls get refs without inventing labels, so agents can target bottom navigation from the screenshot.Adam/Hello from Adamcontrols inside the same row. After, repeated descendants collapse into the row when they are contained in the same hittable target, preserving distinct sibling controls.[content above scroll-area hidden]renders at the top of the scroll area and[content below scroll-area hidden]renders at the bottom.snapshot --rawstill bypasses the Android presentation filters, so the full helper hierarchy remains available for debugging and exact inspection.Why this is better:
The interactive snapshot is smaller and more agent-oriented without reducing raw information fidelity. Agents see fewer duplicate passive nodes, clearer row-level labels, clickable screenshot refs for visible unlabeled controls, and less ambiguous scroll context. The cleanup stays generic rather than baking in app-specific cases like email rows or composer-adjacent bottom navigation.
Scope: 18 touched files. Android snapshot presentation, screenshot overlay refs, shared snapshot output formatting, focused tests, and SkillGym runner-environment guard/docs.
Validation
Focused tests passed:
pnpm exec vitest run src/utils/__tests__/output.test.tspnpm exec vitest run src/daemon/__tests__/screenshot-overlay.test.tsnode --test test/skillgym/runner-environment.test.tspnpm check:quickpnpm buildgit diff --checkManual verification covered Android Settings, built-in Android apps, YouTube, Expensify with Metro prepared on port 8082, and the test app across more than six screens with scrolling,
snapshot -i,snapshot --raw, andscreenshot --overlay-refscomparisons.SkillGym:
pnpm exec skillgym run ./test/skillgym/suites/agent-device-smoke-suite.ts --config ./test/skillgym/skillgym.config.ts --case open-and-snapshotfailed before assertions because both external runners crashed in the network-restricted Codex sandbox.pnpm test:skillgym,pnpm test:skillgym:case open-and-snapshot, and directskillgym run --config ./test/skillgym/skillgym.config.tsfail fast inCODEX_SANDBOX_NETWORK_DISABLED=1with instructions to run from a normal authenticated local shell.SKILLGYM_ALLOW_EXTERNAL_RUNNERS_IN_SANDBOX=1for sandboxes that have approved network access.pnpm test:skillgym:case open-and-snapshotand directskillgym run --case open-and-snapshot; both now stop before build/runner launch with the explanatory message.Known local gap:
pnpm check:unitstill fails locally on the pre-existing MP4 fallback test insrc/utils/__tests__/video.test.ts; sandbox-only listener failures cleared when rerun outside the sandbox.