(params: {
req: DaemonRequest;
sessionName: string;
sessionStore: SessionStore;
logPath: string;
device: DeviceInfo;
openTarget?: string;
openPositionals: string[];
appName?: string;
surface: SessionSurface;
appBundleId?: string;
runtime: SessionRuntimeHints | undefined;
existingSession?: SessionState;
})
| 134 | |
| 135 | // fallow-ignore-next-line complexity |
| 136 | async function completeOpenCommand(params: { |
| 137 | req: DaemonRequest; |
| 138 | sessionName: string; |
| 139 | sessionStore: SessionStore; |
| 140 | logPath: string; |
| 141 | device: DeviceInfo; |
| 142 | openTarget?: string; |
| 143 | openPositionals: string[]; |
| 144 | appName?: string; |
| 145 | surface: SessionSurface; |
| 146 | appBundleId?: string; |
| 147 | runtime: SessionRuntimeHints | undefined; |
| 148 | existingSession?: SessionState; |
| 149 | }): Promise<DaemonResponse> { |
| 150 | const { |
| 151 | req, |
| 152 | sessionName, |
| 153 | sessionStore, |
| 154 | logPath, |
| 155 | device, |
| 156 | openTarget, |
| 157 | openPositionals, |
| 158 | appName, |
| 159 | surface, |
| 160 | appBundleId, |
| 161 | runtime, |
| 162 | existingSession, |
| 163 | } = params; |
| 164 | const shouldRelaunch = req.flags?.relaunch === true; |
| 165 | const traceLogPath = existingSession?.trace?.outPath; |
| 166 | let sessionAppBundleId = appBundleId; |
| 167 | const openCommandStartedAtMs = Date.now(); |
| 168 | const timing: OpenTiming = {}; |
| 169 | |
| 170 | const shouldPrewarmIosRunner = |
| 171 | isIosFamily(device) && |
| 172 | surface === 'app' && |
| 173 | openPositionals.length > 0 && |
| 174 | Boolean(sessionAppBundleId); |
| 175 | const runnerPrewarmOptions = buildAppleRunnerSessionOptions({ |
| 176 | req, |
| 177 | logPath, |
| 178 | appBundleId: sessionAppBundleId, |
| 179 | traceLogPath, |
| 180 | }); |
| 181 | const shouldPrewarmRunnerBeforeOpen = req.flags?.maestro?.prewarmRunnerBeforeOpen === true; |
| 182 | let runnerPrewarm: Promise<void> | undefined; |
| 183 | // Tracked separately from `runnerPrewarm`: prewarmIosRunnerSession may |
| 184 | // return undefined (prewarm unavailable), and one attempt is one attempt. |
| 185 | let runnerPrewarmScheduled = false; |
| 186 | let runnerPrewarmAwaited = false; |
| 187 | const schedulePrewarm = ( |
| 188 | options: Parameters<typeof prewarmIosRunnerSession>[1] = runnerPrewarmOptions, |
| 189 | ): void => { |
| 190 | runnerPrewarmScheduled = true; |
| 191 | timing.runnerPrewarmKind = 'session'; |
| 192 | timing.runnerPrewarmScheduled = true; |
| 193 | runnerPrewarm = prewarmIosRunnerSession(device, options); |
no test coverage detected