fix(mcp-server): fix debug-pack cluster rendering to use correct field names, tighten TelemetryCluster type; fix test mock to include all required fields
This commit is contained in:
parent
6cee9c20af
commit
c04c78aff4
@ -30,19 +30,24 @@ const mockClusters = [
|
|||||||
id: 'abc123:202503',
|
id: 'abc123:202503',
|
||||||
pk: 'lysnrai:ios:keyboard',
|
pk: 'lysnrai:ios:keyboard',
|
||||||
fingerprint: 'abc123',
|
fingerprint: 'abc123',
|
||||||
severity: 'error',
|
severity: 'error' as const,
|
||||||
totalCount: 42,
|
totalCount: 42,
|
||||||
|
firstSeenAt: '2026-03-01T00:00:00Z',
|
||||||
lastSeenAt: '2026-03-05T10:00:00Z',
|
lastSeenAt: '2026-03-05T10:00:00Z',
|
||||||
platform: 'ios',
|
platform: 'ios',
|
||||||
module: 'keyboard',
|
module: 'keyboard',
|
||||||
|
eventName: 'insertText.failed',
|
||||||
sampleMessage: 'insertText returned noop',
|
sampleMessage: 'insertText returned noop',
|
||||||
status: 'open',
|
status: 'open' as const,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
vi.mocked(telemetryClusters).mockResolvedValue({ clusters: mockClusters } as never);
|
vi.mocked(telemetryClusters).mockResolvedValue({
|
||||||
|
clusters: mockClusters,
|
||||||
|
total: mockClusters.length,
|
||||||
|
});
|
||||||
vi.mocked(diagnosticsCreateSession).mockResolvedValue({
|
vi.mocked(diagnosticsCreateSession).mockResolvedValue({
|
||||||
id: 'sess_001',
|
id: 'sess_001',
|
||||||
status: 'active',
|
status: 'active',
|
||||||
|
|||||||
@ -41,7 +41,7 @@ registerTool({
|
|||||||
const generatedAt = new Date().toISOString();
|
const generatedAt = new Date().toISOString();
|
||||||
|
|
||||||
// Step 1: collect error clusters
|
// Step 1: collect error clusters
|
||||||
let clusters: unknown[] = [];
|
let clusters: import('../../lib/platform-client.js').TelemetryCluster[] = [];
|
||||||
let clusterError: string | undefined;
|
let clusterError: string | undefined;
|
||||||
try {
|
try {
|
||||||
const result = await telemetryClusters({ from: args.from, to: args.to }, opts);
|
const result = await telemetryClusters({ from: args.from, to: args.to }, opts);
|
||||||
@ -88,9 +88,11 @@ registerTool({
|
|||||||
lines.push('No error clusters found in the requested time range.');
|
lines.push('No error clusters found in the requested time range.');
|
||||||
} else {
|
} else {
|
||||||
for (const c of clusters.slice(0, 10)) {
|
for (const c of clusters.slice(0, 10)) {
|
||||||
const cl = c as { fingerprint?: string; count?: number; lastSeen?: string };
|
|
||||||
lines.push(
|
lines.push(
|
||||||
`- **${cl.fingerprint ?? '(unknown)'}** — ${cl.count ?? '?'} events, last seen ${cl.lastSeen ?? '?'}`
|
`- **[${c.severity.toUpperCase()}]** \`${c.id}\` — ${c.totalCount} events` +
|
||||||
|
` | platform: ${c.platform} | module: ${c.module}` +
|
||||||
|
` | last seen: ${c.lastSeenAt}` +
|
||||||
|
(c.sampleMessage ? ` | "${c.sampleMessage}"` : '')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (clusters.length > 10) lines.push(`… and ${clusters.length - 10} more clusters`);
|
if (clusters.length > 10) lines.push(`… and ${clusters.length - 10} more clusters`);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user