Summary
Add a --wait-for flag to agent-device snapshot that polls the accessibility tree until a target element appears, with configurable timeout.
Motivation
AI agents frequently need to wait for UI state changes: a modal to appear, a loading spinner to disappear, a specific button to become available. Today agents must implement their own polling loop: snapshot, check, sleep, retry. This burns tokens, adds latency, and duplicates logic across every agent workflow.
Proposed shape
agent-device snapshot --wait-for "button:contains('Submit')" --timeout 15
agent-device snapshot --wait-for "window:contains('Settings')" --timeout 10
agent-device tap "button:contains('Save')" --wait-for "text:contains('Saved!')" --timeout 5
Key design points
- Polls the accessibility tree at a reasonable interval (e.g. 500ms)
- Returns the snapshot as soon as the target element appears
- Returns exit code 1 + last snapshot if timeout expires
- Reuses existing selector/filter infrastructure
- Works with any command that produces a snapshot:
snapshot, tap, type, etc.
- Compact output: only the final snapshot (not intermediate polls)
Why small
The polling loop is straightforward, the selector infrastructure already exists, and this is purely a CLI orchestration feature - no new platform APIs or accessibility tree changes needed.
Summary
Add a
--wait-forflag toagent-device snapshotthat polls the accessibility tree until a target element appears, with configurable timeout.Motivation
AI agents frequently need to wait for UI state changes: a modal to appear, a loading spinner to disappear, a specific button to become available. Today agents must implement their own polling loop: snapshot, check, sleep, retry. This burns tokens, adds latency, and duplicates logic across every agent workflow.
Proposed shape
Key design points
snapshot,tap,type, etc.Why small
The polling loop is straightforward, the selector infrastructure already exists, and this is purely a CLI orchestration feature - no new platform APIs or accessibility tree changes needed.