Skip to content

Commit bc97f1a

Browse files
committed
Fix verbose flag to use full runtime snapshots in JSON output
The verbose flag was accepted but never used - runtimeSnapshot was hardcoded to 'compact'. Now when --verbose is passed with --output json, runtimeSnapshot is set to 'full' to include full element details instead of the compact representation. Updated tests to verify verbose mode produces full output as expected.
1 parent 6b98258 commit bc97f1a

2 files changed

Lines changed: 17 additions & 12 deletions

File tree

src/cli/__tests__/register-tool-commands.test.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ describe('registerToolCommands', () => {
12121212
expect(output.data.waitMatch.matches).toEqual(['e11|none|text|No matches||']);
12131213
});
12141214

1215-
it('keeps UI action runtime snapshots compact for verbose JSON output', async () => {
1215+
it('renders full UI action runtime snapshots for verbose JSON output', async () => {
12161216
mockInvokeDirectThroughHandler();
12171217
const stdoutChunks = captureStdoutChunks();
12181218

@@ -1271,21 +1271,23 @@ describe('registerToolCommands', () => {
12711271

12721272
const output = JSON.parse(stdoutChunks.join('')) as {
12731273
schema: string;
1274-
data: { capture: { targets: string[]; elements?: unknown[] } };
1274+
data: { capture: { targets?: string[]; elements?: unknown[] } };
12751275
};
12761276
expect(output.schema).toBe('xcodebuildmcp.output.ui-action-result');
12771277
expect(output.data.capture).toEqual(
12781278
expect.objectContaining({
12791279
type: 'runtime-snapshot',
1280-
rs: '1',
1281-
targets: ['e2|tap|button|Continue||'],
1282-
scroll: ['e1|swipe|application|Weather||'],
1280+
protocol: 'rs/1',
1281+
simulatorId: 'SIMULATOR-1',
1282+
screenHash: 'screen-hash',
1283+
seq: 1,
12831284
}),
12841285
);
1285-
expect(output.data.capture.elements).toBeUndefined();
1286+
expect(output.data.capture.elements).toBeDefined();
1287+
expect(output.data.capture.elements).toHaveLength(2);
12861288
});
12871289

1288-
it('keeps capture runtime snapshots compact for verbose JSON output', async () => {
1290+
it('renders full capture runtime snapshots for verbose JSON output', async () => {
12891291
mockInvokeDirectThroughHandler();
12901292
const stdoutChunks: string[] = [];
12911293
vi.spyOn(process.stdout, 'write').mockImplementation((chunk) => {
@@ -1337,17 +1339,20 @@ describe('registerToolCommands', () => {
13371339

13381340
const output = JSON.parse(stdoutChunks.join('')) as {
13391341
schema: string;
1340-
data: { capture: { scroll: string[]; elements?: unknown[] } };
1342+
data: { capture: { scroll?: string[]; elements?: unknown[] } };
13411343
};
13421344
expect(output.schema).toBe('xcodebuildmcp.output.capture-result');
13431345
expect(output.data.capture).toEqual(
13441346
expect.objectContaining({
13451347
type: 'runtime-snapshot',
1346-
rs: '1',
1347-
scroll: ['e1|swipe|application|Weather||'],
1348+
protocol: 'rs/1',
1349+
simulatorId: 'SIMULATOR-1',
1350+
screenHash: 'screen-hash',
1351+
seq: 1,
13481352
}),
13491353
);
1350-
expect(output.data.capture.elements).toBeUndefined();
1354+
expect(output.data.capture.elements).toBeDefined();
1355+
expect(output.data.capture.elements).toHaveLength(1);
13511356
});
13521357

13531358
it('writes one NDJSON line per domain fragment for jsonl output and omits the final envelope', async () => {

src/cli/register-tool-commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function writeJsonOutput(
111111
nextSteps: session.getNextSteps?.(),
112112
nextStepRuntime: session.getNextStepsRuntime?.(),
113113
outputStyle: options.outputStyle,
114-
runtimeSnapshot: 'compact',
114+
runtimeSnapshot: options.verbose ? 'full' : 'compact',
115115
},
116116
)
117117
: toStructuredEnvelope(

0 commit comments

Comments
 (0)