Skip to content

refactor(ios): one simctl --set builder and one simulator state parser - #2824

Merged
thymikee merged 3 commits into
fix/2784-simctl-spawn-scoped-setfrom
refactor/2794-simctl-set-builder
Sep 23, 2026
Merged

thymikee merged 3 commits into
fix/2784-simctl-spawn-scoped-setfrom
refactor/2794-simctl-set-builder

Conversation

@thymikee

Copy link
Copy Markdown
Member

Summary

Stacked on #2818.

Closes #2794. core/simctl.ts now builds every simctl --set prefix: scopeSimctlArgs* for the appleTools host seam and buildSimctlArgs* for xcrun. Every direct run goes through runSimctlForDevice.

Removed:

  • the runSimctl/simctlArgs alias. apps-simctl.ts is deleted and its one helper moved into its only caller.
  • simulator-state.ts's builder.
  • the screenshot and status-bar shims.
  • the inline prefixes in network, logs and log-predicate.

The two state parsers now share readSimctlDeviceState in core/simctl-device-list.ts, and the snapshot target's runtime reads through the same raw reader. Inventory keeps its own strict projection.

No argv changes: existing argv tests are unchanged apart from two vi.mock paths. One discrepancy: former simulator-state.ts call sites now trim the set path and skip non-simulators, but they run on simulators only. ADR 0023's dated hop trace was left as is. 25 files touched.

Validation

Tested SHA 47edaa927e46de4353be426dd5e2c962260c6ddd. Passed:

  • pnpm check:affected --run: 13 checks; 3133 related tests
  • pnpm check:fallow
  • pnpm check:production-exports
  • pnpm check:layering
  • git grep "'--set'": only core/simctl.ts among production files

No live device: argv is unchanged, so the Apple CI lanes cover this.

Review (8 findings): fixed 2, the misnamed apps-simctl.ts and a wrong throw doc. Rejected 6, which were pre-existing behaviour, an intentional strict inventory, differing transports, or an argv-test constraint.

Risk: host-seam modules (inventory, shutdown, logs) now statically reach tool-provider through core/simctl.ts. That is about 12 more modules, all already resident in the daemon.

🤖 Generated with Claude Code

thymikee and others added 2 commits September 23, 2026 16:17
… the state parsers

Every simctl call site now scopes its argv through core/simctl.ts
(scopeSimctlArgs/scopeSimctlArgsForDevice for the host tool seam,
buildSimctlArgs/buildSimctlArgsForDevice for xcrun), and every direct run
goes through runSimctlForDevice. The runSimctl/simctlArgs alias in
apps-simctl.ts, the simulator-state.ts builder, and the screenshot shims
are gone.

The two `simctl list devices -j` state parsers collapse into
readSimctlDeviceState; the snapshot target's runtime projection shares
its raw reader. Inventory keeps its strict projection.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
apps-simctl.ts held nothing simctl-related once its runner alias was
gone; the devicectl uninstall path is its only consumer. Also states the
device-list reader's real throw contract.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 23, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
Installed (including dependencies) 4.79 MB 4.79 MB -537 B
Package (unpacked) 4.79 MB 4.79 MB -537 B
Package (download) 1.43 MB 1.43 MB -154 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 27.8 ms 27.0 ms -0.7 ms
CLI --help 79.5 ms 77.9 ms -1.6 ms

@thymikee
thymikee added this pull request to stack #2827 September 23, 2026 15:26
@thymikee

Copy link
Copy Markdown
Member Author

Reviewed at 47edaa9. The consolidation reads well: every --set prefix now comes from core/simctl.ts, and the rewritten call sites produce the same argv for every reachable input. The diff is already small (+1 production line net, with one file, one alias and three shims deleted). The one smaller shape I see: could readSimctlDevicesByRuntime and readSimctlDeviceState live in core/simctl.ts instead of a new simctl-device-list.ts? Is there a reason they need their own file?

That same move would fix the Coverage failure, which this diff causes. The eager-closure budget test names the new edge core/simulator.ts -> core/simctl-device-list.ts, added at https://github.com/callstack/agent-device/blob/47edaa9/packages/platform-apple/src/core/simulator.ts#L16. It grows the closure of simulator-facade.ts from 24 to 25 modules. core/simulator.ts, simulator-state.ts and snapshot-target.ts already import core/simctl.ts, so moving the readers there adds no new edge.

A small note: simulator-state.ts now reaches runXcrun statically through core/simctl.ts only to get an argv builder. The PR body calls this out, and it stays inside the budgets.

Smoke Tests and both CodeQL jobs were still running when I looked. Smoke Tests exercises the simctl routes this PR rewrites, so please check its result when it finishes.

…ctl module

Extracting the shared simctl-list-devices parser into its own module added a
new static edge to platform-apple/src/core/simulator.ts, tripping the
simulator-facade eager-closure budget (24 -> 25). Fold the parser into
core/simctl.ts, which simulator.ts already evaluates, instead of giving it a
new file.
@thymikee

Copy link
Copy Markdown
Member Author

Reviewed at c8cb34e. The code looks right, with no findings in the diff.

The evidence question from the earlier review is still open. Smoke Tests at this commit fails in smoke:automation-input step 7 (wait text Agent Device Tester, wait_capture_stalled with one capture). That route goes through scopeSimctlArgsForDevice and runSimctlForDevice, which this PR rewrites. The argv and parse results look the same before and after, so this looks like the known first-capture stall (#2838 targets it), but the run does not prove it.

The next step is a green iOS Smoke run at c8cb34e, or a re-run that gets past step 7.

@thymikee
thymikee merged commit 3395242 into main Sep 23, 2026
17 of 19 checks passed
@thymikee
thymikee deleted the refactor/2794-simctl-set-builder branch September 23, 2026 16:55
@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-09-23 16:56 UTC

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.

refactor(platform-apple): one simctl --set builder and one simulator state parser

1 participant