Repository navigation
fix(emulator): stop only the named simulator's stream helper (STA-10307) - #28176
Conversation
serve-sim declares --kill [device] with an optional value, so the old ['--kill', '-q', udid] left it unset and serve-sim killed every stream. Bind the device with --kill=<udid> and pin the behaviour with a contract test that runs the bundled serve-sim against fake helpers.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
ELI5
When Orca stopped one iOS simulator's live stream, it accidentally stopped the streams for every simulator on the Mac. Now it stops only the one you asked for.
What Changed
Before:
orca emulator kill/shutdown --device <A>stopped the stream helpers for every simulator, including ones other worktrees or agents were using. Their simulators stayed booted, but their panes went dead until someone re-attached. The same thing happened when you closed a simulator pane, switched devices duringattach, cleaned up after a failed start, or quit Orca. Because re-attaching also runs that cleanup, one lane's shutdown could set off a chain of re-attaches that kept killing everyone's streams.After: only the named device's helper stops.
Mechanism: Orca stopped a helper by running
serve-sim --kill -q <udid>. serve-sim declares-k, --kill [device]with an optional value, and its argument parser (commander) won't take a dash-prefixed token as that value. So--killended up with no device and the UDID became a stray argument. serve-sim's kill with no device stops every stream it knows about. Orca now passes--kill=<udid> -qthrough a singleserveSimKillArgsbuilder, so the device is attached to the flag no matter what order the other arguments come in.Why
The
=form can't be misparsed even if someone reorders the arguments later. A separate--kill <udid> -qonly works as long as nothing ends up between the flag and the device. I considered dropping serve-sim's--killand only killing processes ourselves, but that would lose serve-sim's state-file cleanup and its port-holder reaping. A guard against an empty UDID isn't needed: every caller passes an id that was already resolved.The bug comes from serve-sim's CLI behaviour, not our code. So the new contract test runs the bundled serve-sim against two fake helpers in an isolated
TMPDIR, kills A, and checks that B and B's state file survive. A future serve-sim upgrade that changes this behaviour will fail CI.Linear: STA-10307
Visual Proof
N/A. This changes which background processes get stopped and has no UI change. The contract test is the before/after: with the old argument order it fails (B is killed), and with the new order it passes.
Testing
TMPDIR:--kill -q Akilled A and B, while--kill A -q/--kill=A -qkilled only A. No real simulators were touched.serve-sim-kill-contract.test.ts. It runs on macOS and Linux (nolsoforxcrunneeded) and is skipped on Windows.emulator-bridge.test.tsandios-emulator-backend.test.ts; both mocks now use the real builder.pnpm test src/main/emulator: 236 tests pass.pnpm tc:nodeandcheck:code-quality:changedpass.Review
An independent Opus review found no must-fix issues. I applied its three optional cleanups: mocks use the real builder, the test asserts on B's state file, and two comments were reworded.
Agent skill upstream boundary
Notes
adb -s <serial> …).stopHelperForDeviceand keeps the old argument order, so it will need a rebase.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)