Tracked by #713.
Background
src/simulator/manager.ts mixes device discovery, boot/shutdown, screenshots, app lifecycle, UI appearance/rotation, cloning, and errors. Parallel simulator automation benefits from clearer boundaries.
Objective
Split SimulatorManager responsibilities into focused modules without changing public tool behavior.
Scope
- Extract device catalog/discovery.
- Extract lifecycle operations.
- Extract app management operations.
- Extract UI controls and screenshots.
- Move simulator errors into a dedicated module.
Target files and paths
src/simulator/manager.ts
- new
src/simulator/device-catalog.ts
- new
src/simulator/lifecycle.ts
- new
src/simulator/app-manager.ts
- new
src/simulator/ui-controller.ts
- new
src/simulator/errors.ts
tests/unit/*simulator*.test.ts
Implementation steps
- Move error classes first.
- Extract pure discovery/catalog functions.
- Extract boot/shutdown lifecycle logic with tests.
- Extract app lifecycle methods.
- Extract screenshot, appearance, rotation, and status bar operations.
- Keep
SimulatorManager facade until callers migrate.
Acceptance criteria
Verification
npm run lint -- --quiet
- Targeted simulator manager tests
- Manual macOS smoke: list, boot, screenshot, rotate, shutdown.
Dependencies / recommended order
Run after lifecycle polling optimization if both touch boot/shutdown. This is a staged refactor, not a single broad rewrite.
Risks and cautions
- Avoid combining refactor with semantic changes.
- Keep destructive operations explicit and tested.
- Preserve Xcode version compatibility.
Non-goals
- Do not redesign device presets.
- Do not change CLI command names.
- Do not migrate pool orchestration in the first PR.
Ambiguity reducers
- “Facade” means current callers can continue constructing
SimulatorManager.
- “Lifecycle” includes boot, shutdown, erase/delete only when already present.
- Screenshot belongs to UI controller unless a stronger module boundary is documented in the PR.
Validity review
Proceed after higher-priority speed/security work. It is valid for long-term maintainability of multi-device automation.
Implementation detail refinements
- Move error classes first to reduce import churn.
- Add deprecation comments only if public imports move.
- Use dependency injection for
Simctl to keep tests fast.
Verification checklist reinforcement
Tracked by #713.
Background
src/simulator/manager.tsmixes device discovery, boot/shutdown, screenshots, app lifecycle, UI appearance/rotation, cloning, and errors. Parallel simulator automation benefits from clearer boundaries.Objective
Split SimulatorManager responsibilities into focused modules without changing public tool behavior.
Scope
Target files and paths
src/simulator/manager.tssrc/simulator/device-catalog.tssrc/simulator/lifecycle.tssrc/simulator/app-manager.tssrc/simulator/ui-controller.tssrc/simulator/errors.tstests/unit/*simulator*.test.tsImplementation steps
SimulatorManagerfacade until callers migrate.Acceptance criteria
Verification
npm run lint -- --quietDependencies / recommended order
Run after lifecycle polling optimization if both touch boot/shutdown. This is a staged refactor, not a single broad rewrite.
Risks and cautions
Non-goals
Ambiguity reducers
SimulatorManager.Validity review
Proceed after higher-priority speed/security work. It is valid for long-term maintainability of multi-device automation.
Implementation detail refinements
Simctlto keep tests fast.Verification checklist reinforcement