Skip to content

Commit 1c71e45

Browse files
committed
fix(simulator-runtime): forward launch args to log capture
Allow launch_app_logs_sim to pass args through startLogCapture and ensure the log capture helper includes them in the underlying simctl launch.
1 parent b4bde24 commit 1c71e45

3 files changed

Lines changed: 26 additions & 18 deletions

File tree

src/mcp/tools/simulator/__tests__/launch_app_logs_sim.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ describe('launch_app_logs_sim tool', () => {
132132
simulatorUuid: 'test-uuid-123',
133133
bundleId: 'com.example.testapp',
134134
captureConsole: true,
135+
args: ['--debug'],
135136
});
136137
});
137138

src/mcp/tools/simulator/launch_app_logs_sim.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type LogCaptureFunction = (
1111
simulatorUuid: string;
1212
bundleId: string;
1313
captureConsole?: boolean;
14+
args?: string[];
1415
},
1516
executor: CommandExecutor,
1617
) => Promise<{ sessionId: string; logFilePath: string; processes: unknown[]; error?: string }>;
@@ -36,14 +37,14 @@ export async function launch_app_logs_simLogic(
3637
): Promise<ToolResponse> {
3738
log('info', `Starting app launch with logs for simulator ${params.simulatorId}`);
3839

39-
const { sessionId, error } = await logCaptureFunction(
40-
{
41-
simulatorUuid: params.simulatorId,
42-
bundleId: params.bundleId,
43-
captureConsole: true,
44-
},
45-
executor,
46-
);
40+
const captureParams = {
41+
simulatorUuid: params.simulatorId,
42+
bundleId: params.bundleId,
43+
captureConsole: true,
44+
...(params.args && params.args.length > 0 ? { args: params.args } : {}),
45+
} as const;
46+
47+
const { sessionId, error } = await logCaptureFunction(captureParams, executor);
4748
if (error) {
4849
return {
4950
content: [createTextContent(`App was launched but log capture failed: ${error}`)],

src/utils/log_capture.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ export async function startLogCapture(
3232
simulatorUuid: string;
3333
bundleId: string;
3434
captureConsole?: boolean;
35+
args?: string[];
3536
},
3637
executor: CommandExecutor = getDefaultCommandExecutor(),
3738
): Promise<{ sessionId: string; logFilePath: string; processes: ChildProcess[]; error?: string }> {
3839
// Clean up old logs before starting a new session
3940
await cleanOldLogs();
4041

41-
const { simulatorUuid, bundleId, captureConsole = false } = params;
42+
const { simulatorUuid, bundleId, captureConsole = false, args = [] } = params;
4243
const logSessionId = uuidv4();
4344
const logFileName = `${LOG_FILE_PREFIX}${logSessionId}.log`;
4445
const logFilePath = path.join(os.tmpdir(), logFileName);
@@ -51,16 +52,21 @@ export async function startLogCapture(
5152
logStream.write('\n--- Log capture for bundle ID: ' + bundleId + ' ---\n');
5253

5354
if (captureConsole) {
55+
const launchCommand = [
56+
'xcrun',
57+
'simctl',
58+
'launch',
59+
'--console-pty',
60+
'--terminate-running-process',
61+
simulatorUuid,
62+
bundleId,
63+
];
64+
if (args.length > 0) {
65+
launchCommand.push(...args);
66+
}
67+
5468
const stdoutLogResult = await executor(
55-
[
56-
'xcrun',
57-
'simctl',
58-
'launch',
59-
'--console-pty',
60-
'--terminate-running-process',
61-
simulatorUuid,
62-
bundleId,
63-
],
69+
launchCommand,
6470
'Console Log Capture',
6571
true, // useShell
6672
undefined, // env

0 commit comments

Comments
 (0)