Skip to content

Commit 9a415cb

Browse files
small fixes
1 parent ddc5ddb commit 9a415cb

3 files changed

Lines changed: 23 additions & 16 deletions

File tree

src/McpResponse.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -699,9 +699,11 @@ export class McpResponse implements Response {
699699
};
700700
pages?: object[];
701701
pagination?: object;
702-
heapSnapshot?: object[];
703-
heapSnapshotStats?: object;
704-
heapSnapshotStaticData?: object;
702+
heapSnapshot?: {
703+
stats?: object;
704+
staticData?: object;
705+
};
706+
heapSnapshotData?: object[];
705707
extensionServiceWorkers?: object[];
706708
extensionPages?: object[];
707709
} = {};
@@ -904,11 +906,13 @@ Call ${handleDialog.name} to handle it before continuing.`);
904906
const staticData = this.#heapSnapshotOptions.staticData;
905907
if (stats) {
906908
response.push(`Statistics: ${JSON.stringify(stats, null, 2)}`);
907-
structuredContent.heapSnapshotStats = stats;
909+
structuredContent.heapSnapshot = structuredContent.heapSnapshot || {};
910+
structuredContent.heapSnapshot.stats = stats;
908911
}
909912
if (staticData) {
910913
response.push(`Static Data: ${JSON.stringify(staticData, null, 2)}`);
911-
structuredContent.heapSnapshotStaticData = staticData;
914+
structuredContent.heapSnapshot = structuredContent.heapSnapshot || {};
915+
structuredContent.heapSnapshot.staticData = staticData;
912916
}
913917
const aggregates = this.#heapSnapshotOptions.aggregates;
914918
if (aggregates) {
@@ -926,7 +930,7 @@ Call ${handleDialog.name} to handle it before continuing.`);
926930
const formatter = new HeapSnapshotFormatter(paginatedRecord);
927931

928932
response.push(formatter.toString());
929-
structuredContent.heapSnapshot = formatter.toJSON();
933+
structuredContent.heapSnapshotData = formatter.toJSON();
930934
}
931935
}
932936

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
exports[`HeapSnapshotFormatter > toString > formats data as CSV and sorts by self size 1`] = `
2+
className,count,selfSize,maxRetainedSize
3+
"ObjectA",10,100,1000
4+
"ObjectB",5,50,500
5+
`;

tests/formatters/HeapSnapshotFormatter.test.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,10 @@ describe('HeapSnapshotFormatter', () => {
3434
};
3535

3636
describe('toString', () => {
37-
it('formats data as CSV and sorts by self size', () => {
37+
it('formats data as CSV and sorts by self size', t => {
3838
const formatter = new HeapSnapshotFormatter(mockAggregates);
3939
const result = formatter.toString();
40-
const expected = [
41-
'className,count,selfSize,maxRetainedSize',
42-
'"ObjectA",10,100,1000',
43-
'"ObjectB",5,50,500',
44-
].join('\n');
45-
assert.strictEqual(result, expected);
40+
t.assert.snapshot?.(result);
4641
});
4742
});
4843

@@ -76,12 +71,15 @@ describe('HeapSnapshotFormatter', () => {
7671
ObjectB: {
7772
name: 'ObjectB',
7873
self: 50,
79-
} as unknown as DevTools.HeapSnapshotModel.HeapSnapshotModel.AggregatedInfo,
74+
},
8075
ObjectA: {
8176
name: 'ObjectA',
8277
self: 100,
83-
} as unknown as DevTools.HeapSnapshotModel.HeapSnapshotModel.AggregatedInfo,
84-
};
78+
},
79+
} as unknown as Record<
80+
string,
81+
DevTools.HeapSnapshotModel.HeapSnapshotModel.AggregatedInfo
82+
>;
8583

8684
const result = HeapSnapshotFormatter.sort(unsortedAggregates);
8785
assert.strictEqual(result.length, 2);

0 commit comments

Comments
 (0)