Description
Part of #1237.
Scope
An operator sets drivers.ios.deviceSet: default and ios.simulator.headless: false on a worker and restarts the daemon. From then on, every simulator Simlock makes ready shows on the Mac: in DeviceHub's main window when DeviceHub is installed, else in its own Simulator.app window, without taking the keyboard focus. When Simlock starts either app itself, closing a window or quitting the app leaves the simulators running. A window that cannot be opened is a warning in the daemon log, never a failed lease. ios.simulator.headless: false with Simlock's own device set turns iOS off with a refusal simlock doctor shows. The configuration reference and the worker configuration page describe all of it.
In short
After this PR, a worker with ios.simulator.headless: false runs open -g right after each simulator boots, on every makeReady (prepare: a new simulator for a lease or the warm pool; recover: a reboot while leased). It first asks for DeviceHub by bundle id, which starts it with -shutdownStartedDevicesOnQuit NO if it is not running. If DeviceHub is there, it sends devices://manage/select?id=<udid>, which switches DeviceHub's main window to that simulator. If DeviceHub is not installed, it opens Simulator.app for that simulator with -DetachOnWindowClose YES -DetachOnAppQuit YES. -g keeps the front app in front. The setting unset or true changes nothing.
flowchart LR
B[simctl boot + bootstatus, as today] --> H{ios.simulator.headless}
H -->|true| R[ready, as today]
H -->|false| D[open -g -b com.apple.dt.Devices - new]
D -->|exit 0| S[open -g devices://manage/select - new] --> R
D -->|exit not 0| A[open -g -b com.apple.iphonesimulator - new] --> R
S & A & D -->|failed| W[warn in daemon log - new] --> R
$ simlock config set ios.simulator.headless false
Updated ios.simulator.headless in ~/.simlock/config.json; takes effect on daemon restart.
The refusal, with drivers.ios.deviceSet simlock or unset (invalid-device-set; root is the configured value, or simlock when unset; checked after the existing device set refusals, so a bad value or default with deviceRoot still gets today's message; word for word): Refusing the ios device set: ios.simulator.headless is false, which needs drivers.ios.deviceSet "default". Set drivers.ios.deviceSet to "default", or ios.simulator.headless to true.
The daemon log line when the window step fails, at warn: Could not open a window for iOS simulator with deviceId and detail (the failed open's stderr, trimmed, or timed out).
ios.simulator.headless |
drivers.ios.deviceSet |
Today | After |
|---|---|---|---|
| unset | any | loads; no window | loads as true; no window |
true |
any | Unknown config key warning; no window |
loads; no window |
false |
default |
Unknown config key warning; no window |
loads; a window per simulator |
false |
simlock or unset |
Unknown config key warning; no window |
iOS refused with the message above |
"no" |
any | Unknown config key warning |
invalid config naming ios.simulator.headless, as any non-boolean |
If this goes wrong, an operator with headless off sees no window, or loses the keyboard focus to DeviceHub at every boot.
Technical spec
Facts
Commit 0aa6a58, and #1238's body where named. "This session" is the spec session of 2026-11-03 on Xcode 27.0 (27A266a) with DeviceHub, and Xcode 26.4.1's Simulator.app, iOS 26.4 and 27.0 runtimes.
| # | Fact | Source |
|---|---|---|
| F1 | Every boot of a device for a lease or the warm pool goes through iOS makeReady (purpose prepare or recover), which calls #bootAndWait and then returns #asIs, #skipApply or #readBack |
src/drivers/ios/index.ts:761-787, src/drivers/ios/index.ts:799-817, src/core/managed-device-lifecycle.ts:71-100, src/core/managed-device-lifecycle.ts:159-176 |
| F2 | #1238 adds the ios.simulator block (audio, default true) to the config type, defaults, validator and contract shape, passes it to the iOS driver, and adds a step after boot in makeReady whose failure is a warn log through a callback |
#1238 body (Modules touched, Contract and event changes) |
| F3 | ios config today: defaultMode, defaultModels, slim; android.emulator.headless is a boolean, default false, checked by booleanValue; an unknown key warns Unknown config key: "<path>" |
src/core/config.ts:365-397, src/core/config.ts:998-1012, src/core/config.ts:1162-1178, src/core/validation.ts:41 |
| F4 | The contract's config shape mirrors the config and is config.get's answer; a contract shape change goes with a protocol bump |
src/contract/schemas.ts:1012-1047, .agents/scripts/protocol-bump-check.mjs:2-9 |
| F5 | IosSimctlDriver.create reads drivers.ios.deviceSet first and refuses a bad value or default with deviceRoot by throwing OwnedRootError with reason invalid-device-set; the daemon catches it, logs Skipped iOS driver: device root rejected and starts without iOS |
src/drivers/ios/index.ts:341-346, src/drivers/ios/index.ts:1670-1688, src/daemon/main.ts:1451-1461, src/core/device-root.ts:20 |
| F6 | driver.root-rejected carries the reason; invalid-device-set is described as a bad drivers.ios.deviceSet value or a conflict with drivers.ios.deviceRoot |
docs/internal/EVENTS.md:152 |
| F7 | ProcessRunner.run takes timeoutMs; the iOS driver's command timeout is 30 s; no non-test code in src/ runs macOS open |
src/ports/process-runner.ts:36-37, src/ports/process-runner.ts:166-171, src/drivers/ios/index.ts:69; git grep -nE '"open",' origin/main -- src (3 non-test hits, all the lease state "open": src/contract/schemas.ts:348, src/core/lease-request-store.ts:111, src/core/registry-rows.ts:56) |
| F8 | The daemon logs a slim skip at warn through the driver's onSlimSkipped callback |
src/daemon/main.ts:1433-1439, src/drivers/ios/index.ts:196 |
| F9 | DeviceHub lists only Xcode's device set; a simulator in another set fails to open with CoreDeviceError 1000 | this session: a custom-set simulator was absent from xcrun devicectl list devices, and open "devices://device/open?id=<udid>" failed with error 1000 |
| F10 | open -g "devices://manage/select?id=<udid>" switches DeviceHub's main window to that simulator; the front app stays in front; deleting the simulator leaves the main window at "No Selection", no other window |
this session: window list via CGWindowListCopyWindowInfo before and after (title simui-sel-b), NSWorkspace.frontmostApplication unchanged, then title Devices and a capture reading "No Selection" |
| F11 | After the main window is closed with DeviceHub running, manage/select reopens it on the old simulator and switches no more until DeviceHub restarts |
this session: two select calls left the title at iPhone 17 Pro; after kill -KILL and relaunch, select switched to simui-mw4 |
| F12 | open -g -b com.apple.dt.Devices --args -shutdownStartedDevicesOnQuit NO starts DeviceHub with that argument and returns 0; quitting it then logs shutdownDevices=false and every simulator stays booted; without the argument a quit logged shutdownDevices=true and shut down every booted simulator |
this session: ps -o command= showed the argument; log stream line prepareForApplicationTermination(shutdownDevices:): shutdownDevices=false; simctl list showed both simulators Booted |
| F13 | open -g -b <bundle id> --args … returns 0 at once when the app already runs (the arguments are dropped); for an app that is not installed it prints LSCopyApplicationURLsForBundleIdentifier() failed … and exits 1 |
this session: open -g -b com.apple.dt.Devices --args … on a running DeviceHub → rc=0 secs=0, its ps arguments unchanged; open -g -b com.example.nosuchapp.simlock → exit 1 |
| F14 | open -g -b com.apple.iphonesimulator --args -CurrentDeviceUDID <udid> -DetachOnWindowClose YES -DetachOnAppQuit YES starts Simulator.app on that simulator; closing its window and quitting the app then leave simulators booted, with no panel; Simulator.app closes a deleted simulator's window itself; a running Simulator.app opens a window for every simulator in Xcode's set that simctl boots |
this session, Xcode 26.4.1 Simulator.app: ax list window titles, simctl list Booted after close and quit, the window gone after simctl delete |
| F15 | open -g with the DeviceHub link opened its window from a launchd job in the Background session while the user was logged in; the daemon service is a gui/<uid> launch agent |
this session: job output session Background … open=0 and the window listed; src/ports/service-manager.ts:222 |
| F16 | A slim simulator (every slim category off) draws its home screen in the window | this session: window capture of a simulator booted after writing all 168 overrides |
| F17 | The health check reboots a leased simulator seen stopped on 2 probes 30 s apart, by default | src/leasing/lease-health-monitor.ts:219-227, src/leasing/lease-health-monitor.ts:263-266, src/core/config.ts:990-996 |
| F18 | The configuration reference lists android.emulator.headless and drivers.ios.deviceSet; the worker configuration page lists android.emulator.headless in its table and has a "Run Android emulators headless" section |
website/src/content/docs/docs/reference/configuration.mdx:200, website/src/content/docs/docs/reference/configuration.mdx:205, website/src/content/docs/docs/worker/configuration.mdx:105, website/src/content/docs/docs/worker/configuration.mdx:150-156 |
| F19 | A slow-lane test already runs a daemon with drivers: { ios: { deviceSet: "default" } } |
e2e/slow-agent-device.test.ts:757-772 |
| F20 | While DeviceHub's main window showed a simulator, Simlock's capture helper (built from main) streamed it (--codec mjpeg --duration 4: exit 0, 639672 bytes, "direct IOSurface") and its --input tap on the Settings icon opened Settings; on two other simulators taps did nothing with and without any window or viewer app running, so that miss is not caused by the window |
this session: simlock-screen-capture <udid> --codec mjpeg … and --input with a framed 0x03 touch, simctl io screenshot before and after |
| F21 | open -g "devices://device/open?id=<udid>" sent while DeviceHub was not running started it and opened the window, with the front app unchanged |
this session: pgrep -x DeviceHub empty, then the link, then the window listed and NSWorkspace.frontmostApplication unchanged |
| F22 | OwnedRootError takes a message, a reason, a path and a platform; the path becomes root in driver.root-rejected and the daemon log |
src/core/device-root.ts:30-37, src/daemon/main.ts:1559-1570 |
| F23 | The website names the causes of invalid-device-set on three pages |
website/src/content/docs/docs/using-devices/build-and-run.mdx:70, website/src/content/docs/docs/worker/cleanup.mdx:102, website/src/content/docs/docs/reference/events.mdx:190 |
| F24 | The toolchain's machine table names, per kind of slow-lane line, the checks a machine must pass; the lane script runs its machine check once before any test, and only it exits 69 | docs/internal/agent-rules/toolchain.md:157, docs/internal/agent-rules/toolchain.md:171-182, scripts/slow-e2e.sh:150, scripts/slow-e2e.sh:244-246 |
| F25 | After open -g "devices://manage/select?id=<udid>", DeviceHub's lastSelectedDeviceIdentifier (in defaults read com.apple.dt.Devices, no permission needed) holds that UDID in quotes as data; the front app can be read with osascript -l JavaScript and NSWorkspace.sharedWorkspace.frontmostApplication |
this session: defaults read com.apple.dt.Devices lastSelectedDeviceIdentifier → {length = 38, bytes = 0x22323543 33453245 …} ("25C3E2E3-…", the selected simulator) |
Modules touched
Searches: headless, simulator, emulator.audio, invalid-device-set, onSlimSkipped in src/core/config.ts, src/contract/schemas.ts, src/daemon/main.ts, src/drivers/ios/, docs/internal/EVENTS.md, website/.
src/core/config.ts—ios.simulator.headless: type, defaulttrue, validator.src/contract/schemas.ts— the config shape gainsios.simulator.headless; this PR bumps the protocol by one (src/contract/protocol.ts).src/daemon/main.ts— passes the value to the iOS driver; exportslogWindowFailure(logger), the failure callback that logs the warning.src/drivers/ios/index.ts— theheadlessoption, the refusal increate, the window step inmakeReady;src/drivers/ios/AGENTS.mdsays them.docs/internal/EVENTS.md— thedriver.root-rejectedrow names the newinvalid-device-setcause.docs/internal/agent-rules/toolchain.md— a machine-table row fore2e/slow-ios-window.test.ts.website/src/content/docs/docs/using-devices/build-and-run.mdx,website/src/content/docs/docs/worker/cleanup.mdx,website/src/content/docs/docs/reference/events.mdx— their lists ofinvalid-device-setcauses gain the new one (F23).website/src/content/docs/docs/reference/configuration.mdx,website/src/content/docs/docs/worker/configuration.mdx— the key, the device set rule, closing and quitting.e2e/slow-ios-window.test.ts— new slow-lane file.
flowchart LR
CFG[core/config - changed] --> MAIN[daemon/main - changed]
MAIN --> CREATE[drivers/ios create: refusal - changed]
MAIN --> DRV[drivers/ios makeReady: window step - changed]
DRV --> OPEN[open -g: DeviceHub or Simulator.app]
DRV -->|onWindowFailed| LOG[logWindowFailure: daemon log warn]
Contract and event changes
configSchema.ios.simulatorgainsheadless: z.boolean(), required in the output (the loaded config always has it). This PR bumps the protocol by one.- Config file
ios.simulator.headless: boolean; any other type is an invalid config naming the key, asandroid.emulator.headless(F3). driver.root-rejected: no new reason;invalid-device-setgains a cause, and itsEVENTS.mdrow says so (F6).- No new event: a window failure is a log line, as a slim skip (F8).
Other code on the same state
Searches: "open", (3 hits, all the lease state, F7), devices://, iphonesimulator, com.apple.dt.Devices (0 hits) in src/ and e2e/.
- ios.simulator.audio keeps every simulator silent #1238's volume step runs after the same boot; the two steps are independent, and each logs its own failure.
- A Simulator.app the operator runs opens windows by itself for simulators in Xcode's set, whatever this setting says (F14); out of scope.
- The health check reboots a simulator that a window close or app quit shut down (F17); the reboot is a
recovermakeReady, so the window step runs again. - Simlock's screen stream and input helper read and drive the same simulator a window shows; both kept working with DeviceHub showing it (F20). Neither takes anything from the other; the slow lane checks the stream with the window up. It does not tap: taps failed on two simulators for a reason not yet known, window or not (F20), so a tap case would fail for reasons this task does not cause.
Failure modes
| Call | Outcome | What happens | Limit, counted from |
|---|---|---|---|
open -g -b com.apple.dt.Devices --args -shutdownStartedDevicesOnQuit NO |
exit 0 | send the DeviceHub link | 30 s, from the call |
| same | exit not 0 (DeviceHub not installed, F13) | open Simulator.app instead | as above |
| same | timed out or could not start | no window; warning, detail timed out or the error |
as above |
open -g devices://manage/select?id=<udid> |
exit 0 | device ready | 30 s, from the call |
| same | exit not 0, timed out or could not start | device ready; warning with the stderr or timed out |
as above |
open -g -b com.apple.iphonesimulator --args -CurrentDeviceUDID <udid> -DetachOnWindowClose YES -DetachOnAppQuit YES |
exit 0 | device ready | 30 s, from the call |
| same | exit not 0, timed out or could not start | device ready; warning with the stderr or timed out |
as above |
Two simulators made ready at once on the Simulator.app path: the first open starts Simulator.app, the second returns 0 with its -CurrentDeviceUDID dropped (F13); that simulator was booted before Simulator.app ran, so it may get no window and no warning. Not tested: Simulator.app is the fallback for Macs without DeviceHub, and the next boot of that simulator gets a window.
No state written by Simlock: the window belongs to DeviceHub or Simulator.app. A daemon restart mid-step leaves a booted simulator with or without a window; its next boot runs the step again.
Rules in play
- Feature Outcome: "A window that cannot be opened never stops a lease" —
makeReadynever throws for the window step. - Feature Non-goals: "Changing any user-wide macOS or Xcode setting" — the step passes per-launch arguments only and writes no defaults (
docs/internal/adr/0048-an-ios-worker-may-keep-its-simulators-in-xcodes-device-set.md:33: "Simlock never writes it"). src/drivers/ios/AGENTS.md:27: "A value other thansimlockordefault, ordefaultwithdrivers.ios.deviceRoot, refuses iOS (invalid-device-set)" — the new conflict refuses iOS the same way.src/core/config.ts:381-387: "the core validates each value's type and hands the block to the driver without interpreting it" — the driver reads the boolean.- Architecture rule 9 ("Every external API sits behind a port",
docs/internal/ARCHITECTURE.md:119) —openruns throughProcessRunner.
Tests
Seam: the iOS driver's create and makeReady with a scripted process runner, modelled on src/drivers/ios/index.test.ts (device set cases and "slim mode"); config on loadConfig and config.get, modelled on src/core/config.test.ts; the log bridge modelled on emitSlimDiagnostic's test in src/daemon/main.test.ts; slow lane modelled on e2e/slow-agent-device.test.ts.
- An operator sets
ios.simulator.headlessand the daemon loads it and answers it inconfig.get; cases: unset →true;true;false;"no"→ invalid config naming the key. - A daemon starts with
ios.simulator.headless: falseand a device set, and iOS starts or is refused; cases:false+default→ starts;false+simlock→ refused,invalid-device-setand the message word for word;false+ unset → refused;true+simlock→ starts. - Simlock makes a simulator ready with
ios.simulator.headless: falseand shows it in a window without taking focus; cases: DeviceHub installed →open -g -b com.apple.dt.Devices --args -shutdownStartedDevicesOnQuit NO, thenopen -g devices://manage/select?id=<udid>; DeviceHub not installed →open -g -b com.apple.iphonesimulator --args -CurrentDeviceUDID <udid> -DetachOnWindowClose YES -DetachOnAppQuit YES; prepare; recover; slim;true→ noopencall. - Opening the window fails and the simulator is still made ready, with the failure reported; cases: select exits non-zero; Simulator.app exits non-zero; a call times out; a call cannot start — each gives one
onWindowFailedwith the device and the stderr,timed outor the error. - The daemon logs a window failure; cases: one failure → one
warnlineCould not open a window for iOS simulatorwithdeviceIdanddetail. - A leased simulator on Xcode 27 with
ios.simulator.headless: falseshows in DeviceHub's main window; cases: first lease with DeviceHub not running (DeviceHub'slastSelectedDeviceIdentifiernames the leased UDID within 30 s, F25); front app unchanged; a screen stream gives frames with the window up (slow lane,e2e/slow-ios-window.test.ts).
Done when
- The Tests lines pass; the last in the slow lane (
e2e/slow-ios-window.test.ts).docs/internal/agent-rules/toolchain.md's machine table gains its row: the iOS check;mdfind "kMDItemCFBundleIdentifier == 'com.apple.dt.Devices'"prints a path;stat -f %Su /dev/consoleis notroot(someone is logged in);pgrep -x DeviceHubfinds nothing (the test starts DeviceHub itself with-shutdownStartedDevicesOnQuit NOand quits it at the end, F11, F12). The verifier runs these before the lane; the test itself only asserts. - The configuration reference lists
ios.simulator.headlessbesideandroid.emulator.headless: boolean, defaulttrue, "falseshows each simulator Simlock boots in DeviceHub's main window, or in Simulator.app when DeviceHub is not installed. Needsdrivers.ios.deviceSet: default; with Simlock's own set, iOS is turned off andsimlock doctorsays why.", Worker; and thedrivers.ios.deviceSetrow names the new conflict. - The worker configuration page lists the key in its table and has a "Watch iOS simulators in a window" section: the two commands; the main window shows the newest simulator and the others are in its list; closing the main window stops it following new simulators until DeviceHub restarts; when you started DeviceHub or Simulator.app yourself, quitting DeviceHub or closing a Simulator.app window shuts simulators down and Simlock reboots them within about a minute, losing what ran on them.
src/drivers/ios/AGENTS.mdsays the window step, its warning and the refusal;docs/internal/EVENTS.mdrow fordriver.root-rejectednames the new cause.- The website build and its HTTP API check pass (the config shape changed).
Out of scope
- Windows for Simlock's own device set, one DeviceHub window per simulator, window placement, Android, physical devices, a per-lease option, user-wide defaults.
Depends on
- iOS: every simulator is a copy of a seed, and every virtual device serves one lease #1204
- ios.simulator.audio keeps every simulator silent #1238
Written by an agent.
Activity
test: shows a simulator in Simulator.app when DeviceHub is not instal…
feat(ios): fall back to Simulator.app when DeviceHub is not installed (…
test: makes the simulator ready and reports the failure when opening …
feat(ios): report a window that could not be opened and keep the simu…
test: refuses iOS when ios.simulator.headless is false with Simlock's…
feat(ios): refuse headless false with Simlock's own device set (#1239)
test: loads ios.simulator.headless and answers it in config.get (#1239)
feat(config): ios.simulator.headless is a boolean, default true, answ…
test: logs a window failure as a warning with the device id and the d…
feat(daemon): pass ios.simulator.headless to the iOS driver and log a…
8 remaining items
fix(e2e): read DeviceHub's selected simulator from the exported defau…
refactor(ios): move the headless window and failure logs out of the s…
docs(ios): list boot-courtesies.ts and ios-driver-logging.ts in the m…
test: correct index.ts's shrink-only length (#1239)
V3RON commentedon Nov 5, 2026
Handoff
Done: PR #1290 reviewed (round 1 and two fix-checks, 0 blocking). The slow lane passes at bfaea76, and both slow-lane lines are ticked. The CI fix moved new code out of five files that had grown past their listed length.
Not done: not merged. The gate refused a second time, so the run parked as the delivery skill says.
Findings: the gate printed
not merged: CI not green on PR #1290: fail Quality;fail Unit tests;. Triage:reach src/docs-manuals.test.ts > each manual and flow doc fits in 150 lines(run 41992957730). The CI fix added file lines tosrc/daemon/AGENTS.mdorsrc/drivers/ios/AGENTS.md, and one of them is now over 150 lines.Blocked on: a maintainer decision to continue: one fix run that trims that manual, a fix-check, then the gate.
Written by an agent.
docs(daemon): keep the manual within 150 lines (#1239)
feat(ios): ios.simulator.headless false shows each simulator in a win…