Skip to content

refactor: split engine device and launch verification modules - #1039

Merged
janicduplessis merged 1 commit into
mainfrom
refactor/1023-split-device-modules
Sep 24, 2026
Merged

janicduplessis merged 1 commit into
mainfrom
refactor/1023-split-device-modules

Conversation

@janicduplessis

Copy link
Copy Markdown
Collaborator

Description

engine/device.ts (1350 lines) mixed iOS simulator ownership, Android emulator ownership and capacity/refusal helpers, and engine/app-install.ts (1374 lines) held launch verification next to install and launch. This splits both by concern. It moves code only and should not change behavior.

Solution

Function bodies are byte-identical to origin/main. Apart from import lines, the only edits add export to symbols that now cross a module boundary. ANDROID_BOOT_TIMEOUT_MS also gets a : number annotation because isolatedDeclarations requires one on exported constants.

Moved From To
ensureOwnedIosDevice, startIosBoot/IosBoot, withIosDeviceNameLock, ownedIosNameSuffix, renameToOwnedName, resetAdoptedSim, takeParkedIosSim, clearIosAdoptionPending, configureOwnedIosSim, ensureIosBooted, sleep engine/device.ts engine/device-ios.ts
ensureOwnedAndroidDevice, claimAndroidConsolePort, liveAndroidConsolePorts, bootOwnedAvdOnFreshPort, reportAndroidMemoryPressure, androidBootRemedy, waitForAndroidBoot, ensureAndroidBooted, the Android boot timeouts, the AvdBootError/AvdRecoveryError re-export engine/device.ts engine/device-android.ts
liveOwnedDeviceCount, workspaceHasLiveDevice, deviceCapacityRefusal, checkDeviceCapacity, deviceTypeMismatch, unknownIosRuntimeRefusal, unknownIosDeviceTypeRefusal, unknownAndroidSystemImageRefusal and their helpers engine/device.ts engine/device-capacity.ts
verifyLaunch, verifyReleaseLaunch, verifyAndroidReleaseLaunch, isBundleProof, isBundleRequestProof, the LAUNCH_*/VERIFY_*/STABILITY_WINDOW_MS/RELEASE_VERIFY_WAIT_MS constants, readMetroRecords, readCollectorRecords, unverifiedLaunchLines and their private helpers engine/app-install.ts engine/launch-verify.ts

engine/device.ts keeps ensureOwnedDevice and ensureBooted, which choose the platform, and the types that both platform modules use: OwnedDeviceRecord, DeviceSettings, DeviceFlags and BootResult. The platform modules import these types with import type. oxlint import/no-cycle ignores type-only imports, so there is no runtime cycle. engine/device.ts stays the entry point for test/e2e/native/*.mjs, which import ensureOwnedDevice and ensureBooted.

A few judgment calls:

  • parsePidof, parsePsPid and androidAppProcess stay in app-install.ts next to iosAppProcess, and launch-verify.ts imports androidAppProcess.
  • unverifiedLaunchLines moved with verification because it builds the remedy text for an unverified launch. As a result, app-install.ts now exports ANDROID_DISABLE_AUTO_LAUNCH_EXTRA.
  • The imports go one way, launch-verify -> app-install.

All importers now import from the new modules directly. device.ts has no re-export barrel. No test mocks these modules by path (vi.mock), so each test changes only its import lines. scripts/release-qa-matrix.data.mjs gets entries for the four new files with the same rows as the files they came from. Without them, a change to one of the new files would fall back to requiring every row.

Closes #1023

Test plan

This is a move, so the typechecker and the existing suite are the evidence. There is nothing to run by hand.

  • Every non-import line in the new files is in the original files on origin/main, and every original line appears in the split files. Checked with grep -vxFf in both directions: only import lines and the added export keywords differ.
  • pnpm run typecheck, lint (including import/no-cycle), format:check, knip and test:runtime pass.
  • pnpm test: 4709 passed, 18 skipped. The count is the same as before, and only import paths changed in the tests.
  • node -e "import(...)" loads all six modules directly under Node type stripping, as the e2e scripts do.

Move iOS simulator ownership into engine/device-ios.ts, Android emulator
ownership into engine/device-android.ts, and the capacity and unknown-name
refusal helpers into engine/device-capacity.ts. engine/device.ts keeps the
shared record and settings types plus the ensureOwnedDevice and ensureBooted
platform dispatchers.

Move launch verification, bundle proof helpers, log readers and the
unverified-launch remedy lines from engine/app-install.ts into
engine/launch-verify.ts.

Function bodies are unchanged. Importers, tests and the release QA path
map now point at the new modules.

Closes #1023
@janicduplessis
janicduplessis marked this pull request as ready for review September 24, 2026 18:48
@janicduplessis
janicduplessis merged commit 414073c into main Sep 24, 2026
8 checks passed
@janicduplessis
janicduplessis deleted the refactor/1023-split-device-modules branch September 24, 2026 18:48
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.

Split engine/device.ts and move launch verification out of engine/app-install.ts

1 participant