MCPcopy
hub / github.com/callstack/agent-device / dispatchSnapshotRuntimeCommand

Function dispatchSnapshotRuntimeCommand

src/daemon/snapshot-runtime.ts:108–162  ·  view source on GitHub ↗
(
  params: SnapshotRuntimeCommandParams,
)

Source from the content-addressed store, hash-verified

106 };
107
108async function dispatchSnapshotRuntimeCommand(
109 params: SnapshotRuntimeCommandParams,
110): Promise<DaemonResponse> {
111 const { req, sessionName, logPath, sessionStore } = params;
112 const { session, device } = await resolveSessionDevice(sessionStore, sessionName, req.flags);
113 const unsupported = requireCommandSupported(params.command, device, {
114 message: params.unsupportedMessage,
115 });
116 if (unsupported) return unsupported;
117 const resolvedScope = resolveSnapshotScope(req.flags?.snapshotScope, session);
118 if (!resolvedScope.ok) return resolvedScope;
119 const iosAppSessionGuard = requireIosAppSessionForSnapshot(params.command, session, device);
120 if (iosAppSessionGuard) return iosAppSessionGuard;
121
122 return await withSessionlessRunnerCleanup(session, device, async () => {
123 const runtime = createSnapshotRuntime({
124 req,
125 sessionName,
126 logPath,
127 sessionStore,
128 session,
129 device,
130 snapshotScope: resolvedScope.scope,
131 });
132 let result: Awaited<ReturnType<SnapshotRuntimeCommandParams['execute']>>;
133 try {
134 result = await params.execute({
135 runtime,
136 sessionName,
137 req,
138 snapshotScope: resolvedScope.scope,
139 });
140 } catch (error) {
141 const timeoutResponse = await maybeBuildAndroidSnapshotTimeoutFailure({
142 error,
143 command: params.command,
144 logPath,
145 session,
146 device,
147 });
148 if (!timeoutResponse) throw error;
149 return timeoutResponse;
150 }
151 recordSnapshotRuntimeAction({
152 req,
153 sessionName,
154 sessionStore,
155 result: result.record,
156 });
157 return {
158 ok: true,
159 data: result.data,
160 };
161 });
162}
163
164function requireIosAppSessionForSnapshot(
165 command: 'snapshot' | 'diff',

Callers 2

Calls 9

resolveSessionDeviceFunction · 0.90
requireCommandSupportedFunction · 0.90
resolveSnapshotScopeFunction · 0.90
createSnapshotRuntimeFunction · 0.85
executeMethod · 0.80

Tested by

no test coverage detected