feat(daemon): scope iOS simulator requests to AGENT_DEVICE_IOS_SIMULATOR_DEVICE_SET

Merged
V3
1mo ago
+185-44

Summary

A supervisor starting the daemon (e.g. Simlock, which keeps its own simulator set) could not tell it "use this simulator set for every request": the set came only per request, from --ios-simulator-device-set or the config key. The AGENT_DEVICE_IOS_SIMULATOR_DEVICE_SET env var used to cover this and was removed in #560.

The daemon now reads AGENT_DEVICE_IOS_SIMULATOR_DEVICE_SET from its own environment:

  • a request that names no set (device listing, target resolution, open, test shards) uses that set;
  • a request naming another set fails with INVALID_ARGS, details.reason: "ios_simulator_device_set_outside_daemon_set"; naming the same set works;
  • without the variable, behavior is unchanged. The macOS host target stays visible.
AGENT_DEVICE_IOS_SIMULATOR_DEVICE_SET=/path/to/set agent-device devices --platform ios

8 files: one resolver, its three request-side callers, tests, docs.

Validation

Live run at head bff2f9fb09 (main 562e798 merged in). I used the built CLI and a daemon with its own state dir, started with AGENT_DEVICE_IOS_SIMULATOR_DEVICE_SET pointing at a private set that held one booted iOS 26.2 simulator. Commands after the first one ran without the variable in the CLI's environment.

  • devices --platform ios listed only the private set's simulator.
  • devices --platform macos --ios-simulator-device-set /other and plain devices both listed the host Mac (host-macos-local), with no INVALID_ARGS.
  • open com.apple.Preferences --platform ios with no set flag returned ios_simulator_device_set: "<private set>".
  • devices --platform ios --ios-simulator-device-set /other returned INVALID_ARGS, details.reason: "ios_simulator_device_set_outside_daemon_set".

Commands and output are in https://github.com/callstack/agent-device/pull/3485#issuecomment-6169691676.

Gates at bff2f9fb09: the targeted device.test.ts and dispatch-resolve.test.ts passed, and so did the daemon session-lifecycle and daemon-port tests (134 tests). pnpm typecheck, pnpm format and pnpm lint passed. The unit tests cover the default, the same-set case, the refusal, and the unset case. The two dispatch-resolve tests fail without the source change. An earlier run at a9d169988 also checked the old path: without the variable, the default set listed and --ios-simulator-device-set still scoped the listing.