Skip to content

fix(emulator): stop only the named simulator's stream helper (STA-10307) - #28176

Merged
Jinwoo-H merged 2 commits into
mainfrom
sta-10307-emulator-shutdown-kill-all
Oct 13, 2026
Merged

Jinwoo-H merged 2 commits into
mainfrom
sta-10307-emulator-shutdown-kill-all

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​75 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​65
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​7 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​6

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 during attach, 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 --kill ended 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> -q through a single serveSimKillArgs builder, 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> -q only works as long as nothing ends up between the flag and the device. I considered dropping serve-sim's --kill and 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

  • I manually tested these changes locally. I ran the bundled serve-sim 0.1.47 on macOS with fake helpers in an isolated TMPDIR: --kill -q A killed A and B, while --kill A -q / --kill=A -q killed only A. No real simulators were touched.
  • Automated tests added/updated:
    • New serve-sim-kill-contract.test.ts. It runs on macOS and Linux (no lsof or xcrun needed) and is skipped on Windows.
    • I mutation-checked it: with the old args, the test fails.
    • Updated the expected kill arguments in emulator-bridge.test.ts and ios-emulator-backend.test.ts; both mocks now use the real builder.
    • pnpm test src/main/emulator: 236 tests pass. pnpm tc:node and check:code-quality:changed pass.

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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

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.
@coderabbitai

coderabbitai Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 66d1f8b1-52f9-4cda-b12f-026fa2bb1b21
📥 Commits

Reviewing files that changed from the base of the PR and between e713bcb and 71d8648.

📒 Files selected for processing (5)
  • src/main/emulator/backends/ios-emulator-backend.test.ts
  • src/main/emulator/backends/ios-emulator-backend.ts
  • src/main/emulator/emulator-bridge.test.ts
  • src/main/emulator/serve-sim-execution.ts
  • src/main/emulator/serve-sim-kill-contract.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

📝 Walkthrough

The change adds serveSimKillArgs to construct device-qualified serve-sim kill arguments and uses it when stopping an iOS helper. Tests update mocked expectations and add a non-Windows integration test that checks whether killing one device’s helper leaves another device’s helper and state file intact.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 71d86

Shutdown now binds the device ID to --kill, so serve-sim targets the requested simulator instead of taking the all-streams path. No actionable merge risk was identified.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main fix: limiting iOS stream-helper shutdown to the named simulator.
Description check Passed The description is detailed and mostly complete. It explains the problem, user-visible behavior, implementation, rationale, testing, platform impact, and checklist status. It references Linear issue S…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Jinwoo-H
Jinwoo-H merged commit cbeb537 into main Oct 13, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant