Skip to content

Commit 033bcf9

Browse files
fix(server): batch, replay and test keep device selectors for their open steps
agent-device hands a batch, replay or test command's selectors to each of its steps. Stripping them sent an open step to the daemon's default device instead of the bound one, so these commands now keep them as main did. AI-assisted; verified with the tests and tools listed above.
1 parent c30bfbc commit 033bcf9

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

‎apps/server/src/device/AgentDeviceShim.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,16 @@ const VALUE_FLAGS: ReadonlyArray<string> = [
152152
];
153153

154154
/**
155-
* agent-device 0.21.31 commands that pick their device from selectors: open, those that check its
156-
* claim themselves, and read-only listings. Any other command given a selector and a session the
157-
* daemon does not hold runs on that device without a claim check, even while another session holds it.
155+
* agent-device 0.21.36 commands that pick their device from selectors: open, those that check its
156+
* claim themselves, read-only listings, and batch/replay/test, whose steps inherit them (an open step
157+
* needs them). Any other command given a selector and a session the daemon does not hold runs on that
158+
* device without a claim check, even while another session holds it.
158159
*/
159160
const SELECTING_COMMANDS: ReadonlyArray<string> = [
160161
"open",
162+
"batch",
163+
"replay",
164+
"test",
161165
"launch",
162166
"relaunch",
163167
"apps",

‎apps/server/src/device/AgentDeviceTarget.test.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,16 +221,20 @@ exec '${process.execPath.replaceAll("'", "'\"'\"'")}' "$@"
221221
["--platform=android", "close", "com.example"],
222222
["close", "com.example"],
223223
],
224-
[
225-
["batch", "--steps-file", "/s.json", "--device", "Pixel", "--target", "mobile"],
226-
["batch", "--steps-file", "/s.json"],
227-
],
228224
];
229225
for (const [args, passed] of unselected) {
230226
expect(yield* Effect.promise(() => launch(args))).toEqual([...passed, ...owned]);
231227
}
232228
// Commands that choose a device take its selectors; those that mutate it check its claim.
233-
for (const args of [["open", "com.example"], ["Relaunch"], ["apps"], ["install", "a.app"]]) {
229+
// batch, replay and test pass them to their steps, so an open step opens the bound device.
230+
for (const args of [
231+
["open", "com.example"],
232+
["Relaunch"],
233+
["apps"],
234+
["install", "a.app"],
235+
["batch", "--steps-file", "/s.json"],
236+
["replay", "flow.ad"],
237+
]) {
234238
expect(yield* Effect.promise(() => launch(args))).toEqual([...args, ...selected]);
235239
}
236240
// agent-device 0.21.31 rejects these flags with "unknown option" or "not supported for command".

0 commit comments

Comments
 (0)