Commit 7317fb4
authored
refactor(7/12): migrate device and macOS tools to event-based handlers (#325)
## Summary
This is **PR 7 of 12** in a stacked PR series that decouples the rendering pipeline from MCP transport. Depends on PR 6 (simulator migrations).
Migrates all device and macOS tool handlers to the new event-based handler contract. Same mechanical transformation pattern as PR 6 but for physical device and macOS desktop targets.
### Tools migrated (31 files)
**Device tools**: `build_device`, `build_run_device`, `get_device_app_path`, `install_app_device`, `launch_app_device`, `list_devices`, `stop_app_device`, `test_device`, `build-settings`
**macOS tools**: `build_macos`, `build_run_macos`, `get_mac_app_path`, `launch_mac_app`, `stop_mac_app`, `test_macos`
### Notable changes
- `test_device.ts` and `test_macos.ts` were the most complex handlers (~250-280 lines each). They've been significantly simplified by delegating to `test-preflight.ts`, `device-steps.ts`/`macos-steps.ts`, and `xcodebuild-pipeline.ts` from PR 4. The handlers are now thin orchestrators that emit events.
- Device and macOS build tools pass `ctx.emit` through to the xcodebuild pipeline for real-time progress streaming.
- `stop_app_device.ts` and `stop_mac_app.ts` updated to emit structured events for process termination results.
## Stack navigation
- PR 1-5/12: Foundation, utilities, runtime contract
- PR 6/12: Simulator tool migrations
- **PR 7/12** (this PR): Device + macOS tool migrations
- PR 8/12: UI automation tool migrations
- PR 9/12: Remaining tool migrations
- PR 10-12/12: Boundaries, config, tests
## Test plan
- [ ] `npx vitest run` passes -- all device and macOS tool tests updated
- [ ] Build tools stream progress events through the xcodebuild pipeline
- [ ] Test tools correctly delegate to test-preflight and platform step modules1 parent 6e51e5b commit 7317fb4
File tree
31 files changed
+2506
-4109
lines changed- src/mcp/tools
- device
- __tests__
- macos
- __tests__
31 files changed
+2506
-4109
lines changedLarge diffs are not rendered by default.
Lines changed: 316 additions & 221 deletions
Large diffs are not rendered by default.
Lines changed: 88 additions & 119 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | 1 | | |
| 2 | + | |
8 | 3 | | |
9 | 4 | | |
10 | 5 | | |
11 | 6 | | |
12 | 7 | | |
13 | 8 | | |
14 | 9 | | |
| 10 | + | |
| 11 | + | |
15 | 12 | | |
16 | 13 | | |
17 | 14 | | |
| |||
107 | 104 | | |
108 | 105 | | |
109 | 106 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
116 | 115 | | |
117 | 116 | | |
118 | 117 | | |
| |||
128 | 127 | | |
129 | 128 | | |
130 | 129 | | |
| 130 | + | |
| 131 | + | |
131 | 132 | | |
132 | 133 | | |
133 | 134 | | |
| |||
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
171 | 174 | | |
172 | 175 | | |
173 | 176 | | |
| |||
183 | 186 | | |
184 | 187 | | |
185 | 188 | | |
| 189 | + | |
| 190 | + | |
186 | 191 | | |
187 | 192 | | |
188 | 193 | | |
| |||
216 | 221 | | |
217 | 222 | | |
218 | 223 | | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
225 | 232 | | |
226 | 233 | | |
227 | 234 | | |
| |||
237 | 244 | | |
238 | 245 | | |
239 | 246 | | |
| 247 | + | |
| 248 | + | |
240 | 249 | | |
241 | 250 | | |
242 | 251 | | |
| |||
251 | 260 | | |
252 | 261 | | |
253 | 262 | | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
| 263 | + | |
| 264 | + | |
264 | 265 | | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
| 266 | + | |
| 267 | + | |
274 | 268 | | |
275 | | - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
276 | 279 | | |
| 280 | + | |
277 | 281 | | |
278 | 282 | | |
279 | 283 | | |
| |||
283 | 287 | | |
284 | 288 | | |
285 | 289 | | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
| 290 | + | |
| 291 | + | |
296 | 292 | | |
297 | | - | |
298 | | - | |
| 293 | + | |
| 294 | + | |
299 | 295 | | |
300 | | - | |
301 | | - | |
302 | | - | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
303 | 302 | | |
304 | 303 | | |
305 | 304 | | |
| |||
308 | 307 | | |
309 | 308 | | |
310 | 309 | | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
| 310 | + | |
| 311 | + | |
321 | 312 | | |
322 | | - | |
323 | | - | |
| 313 | + | |
| 314 | + | |
324 | 315 | | |
325 | | - | |
326 | | - | |
327 | | - | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
328 | 322 | | |
329 | 323 | | |
330 | 324 | | |
| |||
353 | 347 | | |
354 | 348 | | |
355 | 349 | | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
363 | 359 | | |
364 | 360 | | |
365 | 361 | | |
| |||
375 | 371 | | |
376 | 372 | | |
377 | 373 | | |
| 374 | + | |
| 375 | + | |
378 | 376 | | |
379 | 377 | | |
380 | 378 | | |
| |||
393 | 391 | | |
394 | 392 | | |
395 | 393 | | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
| 394 | + | |
| 395 | + | |
406 | 396 | | |
407 | | - | |
408 | | - | |
| 397 | + | |
| 398 | + | |
409 | 399 | | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
| 400 | + | |
| 401 | + | |
426 | 402 | | |
427 | 403 | | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
| 404 | + | |
| 405 | + | |
437 | 406 | | |
438 | 407 | | |
439 | 408 | | |
0 commit comments