refactor: split engine device and launch verification modules - #1039
Merged
Merged
Conversation
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
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.
Description
engine/device.ts(1350 lines) mixed iOS simulator ownership, Android emulator ownership and capacity/refusal helpers, andengine/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 addexportto symbols that now cross a module boundary.ANDROID_BOOT_TIMEOUT_MSalso gets a: numberannotation becauseisolatedDeclarationsrequires one on exported constants.ensureOwnedIosDevice,startIosBoot/IosBoot,withIosDeviceNameLock,ownedIosNameSuffix,renameToOwnedName,resetAdoptedSim,takeParkedIosSim,clearIosAdoptionPending,configureOwnedIosSim,ensureIosBooted,sleepengine/device.tsengine/device-ios.tsensureOwnedAndroidDevice,claimAndroidConsolePort,liveAndroidConsolePorts,bootOwnedAvdOnFreshPort,reportAndroidMemoryPressure,androidBootRemedy,waitForAndroidBoot,ensureAndroidBooted, the Android boot timeouts, theAvdBootError/AvdRecoveryErrorre-exportengine/device.tsengine/device-android.tsliveOwnedDeviceCount,workspaceHasLiveDevice,deviceCapacityRefusal,checkDeviceCapacity,deviceTypeMismatch,unknownIosRuntimeRefusal,unknownIosDeviceTypeRefusal,unknownAndroidSystemImageRefusaland their helpersengine/device.tsengine/device-capacity.tsverifyLaunch,verifyReleaseLaunch,verifyAndroidReleaseLaunch,isBundleProof,isBundleRequestProof, theLAUNCH_*/VERIFY_*/STABILITY_WINDOW_MS/RELEASE_VERIFY_WAIT_MSconstants,readMetroRecords,readCollectorRecords,unverifiedLaunchLinesand their private helpersengine/app-install.tsengine/launch-verify.tsengine/device.tskeepsensureOwnedDeviceandensureBooted, which choose the platform, and the types that both platform modules use:OwnedDeviceRecord,DeviceSettings,DeviceFlagsandBootResult. The platform modules import these types withimport type. oxlintimport/no-cycleignores type-only imports, so there is no runtime cycle.engine/device.tsstays the entry point fortest/e2e/native/*.mjs, which importensureOwnedDeviceandensureBooted.A few judgment calls:
parsePidof,parsePsPidandandroidAppProcessstay inapp-install.tsnext toiosAppProcess, andlaunch-verify.tsimportsandroidAppProcess.unverifiedLaunchLinesmoved with verification because it builds the remedy text for an unverified launch. As a result,app-install.tsnow exportsANDROID_DISABLE_AUTO_LAUNCH_EXTRA.launch-verify->app-install.All importers now import from the new modules directly.
device.tshas 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.mjsgets 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.
origin/main, and every original line appears in the split files. Checked withgrep -vxFfin both directions: only import lines and the addedexportkeywords differ.pnpm run typecheck,lint(includingimport/no-cycle),format:check,knipandtest:runtimepass.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.