feat: act on the app's own controls in-process (elementActionRequest) - #4
Merged
Conversation
Where launch parameters put an app into a state, a plan sometimes needs to drive its UI — MacPacker's search field has to be focused for the search screenshot. Doing that from outside would mean synthesizing input, which needs the Accessibility grant; doing it inside the target does not, because a process may read and drive its own accessibility tree freely. elementActionRequest names a control by accessibility identifier and says what to do to it. ElementLocator resolves it with the same in-process self read as screenFrame, and replies with elementActionResult saying whether it worked and, if not, why — so a plan naming a control the app does not expose fails legibly instead of producing a screenshot of the wrong thing. One action kind, focus. Neither the kit nor SandboxPilot learns anything about any app's UI: the identifier comes from whoever wrote the plan.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Launch parameters put an app into a state. Some screenshots also need its UI driven — MacPacker's search field has to be focused for the search shot, which until now the app did itself on seeing
-SearchQuery, i.e. screenshot-shaped behaviour living in shipping window code.Driving it from outside would mean synthesizing input, which needs the Accessibility grant. Driving it inside the target does not: a process may read and drive its own accessibility tree freely. That is the same trick
ElementLocator.screenFramealready uses for element frames — this just adds acting to looking.What
elementActionRequestnames a control by accessibility identifier and says what to do to it.ElementLocator.performresolves it with the same in-process self-read and replieselementActionResult— whether it worked, and if not why, so a plan naming a control the app doesn't expose fails legibly instead of producing a screenshot of the wrong thing.One kind,
focus. Add another when a plan needs one.Neither side learns anything about any app's UI: the identifier comes from whoever wrote the plan. The app's only obligation is ordinary accessibility —
.accessibilityIdentifier(_:)on the control.Verified
swift test: 10 tests in 3 suites, all passing — both new message shapes round-trip, and acting on an unknown identifier reports why rather than silently succeeding.Consumers build clean against this branch (SandboxPilot and MacPacker).
Not yet verified end to end: that a real
focusreaches a real control. This machine has no Accessibility/Automation grant for the harnesses that could check it independently — the XCUITest runner fails with "Timed out while enabling automation mode" — so it needs a run of MacPacker's04-searchscenario through a SandboxPilot built from this branch. Worth doing before tagging.Needs a 1.4.0 tag after merge; LeanBytes/SandboxPilot#32 and sarensw/MacPacker#182 both pin it.