MCPcopy Index your code
hub / github.com/callstack/agent-device / completeOpenCommand

Function completeOpenCommand

src/daemon/handlers/session-open.ts:136–365  ·  view source on GitHub ↗
(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;
})

Source from the content-addressed store, hash-verified

134
135// fallow-ignore-next-line complexity
136async 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);

Callers 1

handleOpenCommandFunction · 0.85

Calls 15

isIosFamilyFunction · 0.90
isIosSimulatorFunction · 0.90
contextFromFlagsFunction · 0.90
applyRuntimeHintsToAppFunction · 0.90
dispatchCommandFunction · 0.90
settleIosSimulatorFunction · 0.90
isRequestCanceledFunction · 0.90
errorResponseFunction · 0.90

Tested by

no test coverage detected