@@ -23,6 +23,7 @@ import {
2323} from './formatters/networkFormatter.js' ;
2424import { formatSnapshotNode } from './formatters/snapshotFormatter.js' ;
2525import { getIssueDescription } from './issue-descriptions.js' ;
26+ import { logger } from './logger.js' ;
2627import type { McpContext } from './McpContext.js' ;
2728import type {
2829 ConsoleMessage ,
@@ -283,57 +284,58 @@ export class McpResponse implements Response {
283284 } ) ;
284285 }
285286
286- consoleListData = await Promise . all (
287- messages . map ( async ( item ) : Promise < ConsoleMessageData > => {
288- const consoleMessageStableId =
289- context . getConsoleMessageStableId ( item ) ;
290- if ( 'args' in item ) {
291- const consoleMessage = item as ConsoleMessage ;
292- return {
293- consoleMessageStableId,
294- type : consoleMessage . type ( ) ,
295- message : consoleMessage . text ( ) ,
296- args : await Promise . all (
297- consoleMessage . args ( ) . map ( async arg => {
298- const stringArg = await arg . jsonValue ( ) . catch ( ( ) => {
299- // Ignore errors.
300- } ) ;
301- return typeof stringArg === 'object'
302- ? JSON . stringify ( stringArg )
303- : String ( stringArg ) ;
304- } ) ,
305- ) ,
306- } ;
307- }
308- if ( item instanceof AggregatedIssue ) {
309- const count = item . getAggregatedIssuesCount ( ) ;
310- const filename = item . getDescription ( ) ?. file ;
311- const rawMarkdown = filename ? getIssueDescription ( filename ) : null ;
312- if ( ! rawMarkdown ) {
287+ consoleListData = (
288+ await Promise . all (
289+ messages . map ( async ( item ) : Promise < ConsoleMessageData | null > => {
290+ const consoleMessageStableId =
291+ context . getConsoleMessageStableId ( item ) ;
292+ if ( 'args' in item ) {
293+ const consoleMessage = item as ConsoleMessage ;
294+ return {
295+ consoleMessageStableId,
296+ type : consoleMessage . type ( ) ,
297+ message : consoleMessage . text ( ) ,
298+ args : await Promise . all (
299+ consoleMessage . args ( ) . map ( async arg => {
300+ const stringArg = await arg . jsonValue ( ) . catch ( ( ) => {
301+ // Ignore errors.
302+ } ) ;
303+ return typeof stringArg === 'object'
304+ ? JSON . stringify ( stringArg )
305+ : String ( stringArg ) ;
306+ } ) ,
307+ ) ,
308+ } ;
309+ }
310+ if ( item instanceof AggregatedIssue ) {
311+ const count = item . getAggregatedIssuesCount ( ) ;
312+ const filename = item . getDescription ( ) ?. file ;
313+ const rawMarkdown = filename
314+ ? getIssueDescription ( filename )
315+ : null ;
316+ if ( ! rawMarkdown ) {
317+ logger ( `no markdown ${ filename } found for issue:` + item . code ) ;
318+ return null ;
319+ }
320+ const markdownAst = Marked . Marked . lexer ( rawMarkdown ) ;
321+ const title = findTitleFromMarkdownAst ( markdownAst ) ;
313322 return {
314323 consoleMessageStableId,
315324 type : 'issue' ,
316- message : `${ item . code ( ) } (count: ${ count } )` ,
325+ message : `${ title } ` ,
326+ count,
317327 args : [ ] ,
318328 } ;
319329 }
320- const markdownAst = Marked . Marked . lexer ( rawMarkdown ) ;
321- const title = findTitleFromMarkdownAst ( markdownAst ) ;
322330 return {
323331 consoleMessageStableId,
324- type : 'issue ' ,
325- message : ` ${ title } (count: ${ count } )` ,
332+ type : 'error ' ,
333+ message : ( item as Error ) . message ,
326334 args : [ ] ,
327335 } ;
328- }
329- return {
330- consoleMessageStableId,
331- type : 'error' ,
332- message : ( item as Error ) . message ,
333- args : [ ] ,
334- } ;
335- } ) ,
336- ) ;
336+ } ) ,
337+ )
338+ ) . filter ( item => item !== null ) ;
337339 }
338340
339341 return this . format ( toolName , context , {
0 commit comments