refactor(6/12): migrate simulator tools to event-based handlers#324
Open
cameroncooke wants to merge 4 commits intorefactor/runtime-handler-contractfrom
Open
refactor(6/12): migrate simulator tools to event-based handlers#324cameroncooke wants to merge 4 commits intorefactor/runtime-handler-contractfrom
cameroncooke wants to merge 4 commits intorefactor/runtime-handler-contractfrom
Conversation
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Malformed JSON mock embeds command args in device array
- Removed the incorrectly placed '-derivedDataPath' and DERIVED_DATA_DIR strings from the devices array in both test cases, restoring valid simctl JSON structure.
Or push these changes by commenting:
@cursor push 4dad9e6f53
Preview (4dad9e6f53)
diff --git a/src/mcp/tools/simulator/__tests__/build_run_sim.test.ts b/src/mcp/tools/simulator/__tests__/build_run_sim.test.ts
--- a/src/mcp/tools/simulator/__tests__/build_run_sim.test.ts
+++ b/src/mcp/tools/simulator/__tests__/build_run_sim.test.ts
@@ -194,8 +194,6 @@
state: 'Booted',
isAvailable: true,
},
- '-derivedDataPath',
- DERIVED_DATA_DIR,
],
},
}),
@@ -277,8 +275,6 @@
state: 'Booted',
isAvailable: true,
},
- '-derivedDataPath',
- DERIVED_DATA_DIR,
],
},
}),This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
Reviewed by Cursor Bugbot for commit daf00b3. Configure here.
089f6a3 to
fa1ece2
Compare
daf00b3 to
d9e9216
Compare
fa1ece2 to
e6e44bb
Compare
d9e9216 to
90f6699
Compare
e6e44bb to
8208efa
Compare
6ad5269 to
c6bb094
Compare
8208efa to
3d0b705
Compare
This was referenced Apr 9, 2026
Collaborator
Author
This was referenced Apr 9, 2026
c6bb094 to
ea1dcfb
Compare
3d0b705 to
a798b24
Compare
ea1dcfb to
c4d9441
Compare
a798b24 to
84180f1
Compare
c4d9441 to
cfb41d8
Compare
1a1c722 to
9396aff
Compare
5e38f0a to
c802970
Compare
9396aff to
fef58c3
Compare
c802970 to
f5b95e6
Compare
fef58c3 to
03324df
Compare
f5b95e6 to
3a2b3da
Compare
589573e to
886a46f
Compare
3a2b3da to
9f921b2
Compare
886a46f to
a42228b
Compare
25b8d8d to
8d84711
Compare
a42228b to
696acb9
Compare
696acb9 to
0384076
Compare
8d84711 to
a7d936d
Compare
…ased handler contract
The simulatorId parameter was not being passed to inferPlatform, causing platform detection to fall back to scheme-based inference even when a specific simulator UUID was provided. This broke non-iOS simulator detection (e.g. watchOS, tvOS) when specified by UUID.
Replace 12 identical local runLogic definitions with the shared import from test-helpers.ts.
063044a to
7735495
Compare
c7b7e13 to
2f4bcad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
This is PR 6 of 12 in a stacked PR series that decouples the rendering pipeline from MCP transport. Depends on PR 5 (handler contract change).
Migrates all simulator and simulator-management tool handlers from the old
return toolResponse([...])pattern to the newctx.emit(event)pattern introduced in PR 5. This is the largest tool migration PR because simulators are the primary development target.Tools migrated (36 files)
Simulator tools:
boot_sim,build_sim,build_run_sim,get_sim_app_path,install_app_sim,launch_app_sim,list_sims,open_sim,record_sim_video,stop_app_sim,test_sim,screenshotSimulator management tools:
erase_sims,reset_sim_location,set_sim_appearance,set_sim_location,sim_statusbarPattern of change
Each handler follows the same mechanical transformation:
```typescript
// Before
async function handler(params) {
const result = await buildForSimulator(params);
return toolResponse([header('Build', [...]), statusLine('success', '...')]);
}
// After
async function handler(params, ctx) {
const result = await buildForSimulator(params, ctx);
ctx.emit(header('Build', [...]));
ctx.emit(statusLine('success', '...'));
}
```
Build/test tools additionally pass
ctx.emitto the xcodebuild pipeline so events stream in real-time during compilation.test_simdelegates tosimulator-test-execution.tsandtest-preflight.tsfrom PR 4.Supporting changes
simulator-utils.ts: Updated to work with the new handler contextsimulator-resolver.ts: Simplified resolver that integrates with the step modules from PR 4Stack navigation
Test plan
npx vitest runpasses -- all simulator tool tests updated