@@ -376,6 +376,105 @@ describe("buildThreadFeed", () => {
376376 expect ( group . activities [ 0 ] ?. getFullDetail ( ) ) . toBe ( `printf hello\n\n${ output } ` ) ;
377377 } ) ;
378378
379+ it ( "does not duplicate MCP summarized result as a separate output block" , ( ) => {
380+ const turnId = TurnId . make ( "turn-mcp-result" ) ;
381+ const item = {
382+ server : "repository" ,
383+ tool : "search" ,
384+ arguments : { query : "work log" } ,
385+ result : { content : "first line of output" } ,
386+ } ;
387+ const thread = makeThread ( {
388+ id : ThreadId . make ( "thread-mcp-result" ) ,
389+ projectId : ProjectId . make ( "project-1" ) ,
390+ title : "MCP result" ,
391+ latestTurn : {
392+ turnId,
393+ state : "completed" ,
394+ requestedAt : "2026-04-01T00:00:00.000Z" ,
395+ startedAt : "2026-04-01T00:00:01.000Z" ,
396+ completedAt : "2026-04-01T00:00:03.000Z" ,
397+ assistantMessageId : null ,
398+ } ,
399+ activities : [
400+ makeActivity ( {
401+ id : EventId . make ( "mcp-result-completed" ) ,
402+ kind : "tool.completed" ,
403+ tone : "tool" ,
404+ summary : "Call repository tool" ,
405+ createdAt : "2026-04-01T00:00:02.000Z" ,
406+ turnId,
407+ payload : {
408+ title : "Call repository tool" ,
409+ itemType : "mcp_tool_call" ,
410+ detail : "repository.search" ,
411+ status : "completed" ,
412+ data : { item } ,
413+ } ,
414+ } ) ,
415+ ] ,
416+ } ) ;
417+
418+ const group = buildThreadFeed ( thread ) [ 0 ] ;
419+ expect ( group ) . toMatchObject ( { type : "activity-group" } ) ;
420+ if ( ! group || group . type !== "activity-group" ) {
421+ return ;
422+ }
423+
424+ expect ( group . activities [ 0 ] ?. getFullDetail ( ) ) . toBe (
425+ `MCP call\n${ JSON . stringify ( item , null , 2 ) } \n\nrepository.search` ,
426+ ) ;
427+ expect ( group . activities [ 0 ] ?. status ) . toBe ( "success" ) ;
428+ } ) ;
429+
430+ it ( "does not mark completed commands failed from stdout phrases" , ( ) => {
431+ const turnId = TurnId . make ( "turn-stdout-phrases" ) ;
432+ const output = "this tutorial mentions command not found, ENOENT, and exit code 1" ;
433+ const thread = makeThread ( {
434+ id : ThreadId . make ( "thread-stdout-phrases" ) ,
435+ projectId : ProjectId . make ( "project-1" ) ,
436+ title : "Stdout phrases" ,
437+ latestTurn : {
438+ turnId,
439+ state : "completed" ,
440+ requestedAt : "2026-04-01T00:00:00.000Z" ,
441+ startedAt : "2026-04-01T00:00:01.000Z" ,
442+ completedAt : "2026-04-01T00:00:03.000Z" ,
443+ assistantMessageId : null ,
444+ } ,
445+ activities : [
446+ makeActivity ( {
447+ id : EventId . make ( "bash-stdout-phrases" ) ,
448+ kind : "tool.completed" ,
449+ tone : "tool" ,
450+ summary : "Command run" ,
451+ createdAt : "2026-04-01T00:00:02.000Z" ,
452+ turnId,
453+ payload : {
454+ title : "Command run" ,
455+ itemType : "command_execution" ,
456+ detail : "cat notes.txt" ,
457+ status : "completed" ,
458+ data : {
459+ toolName : "Bash" ,
460+ input : { command : "cat notes.txt" } ,
461+ result : { content : output , is_error : false } ,
462+ } ,
463+ } ,
464+ } ) ,
465+ ] ,
466+ } ) ;
467+
468+ const group = buildThreadFeed ( thread ) [ 0 ] ;
469+ expect ( group ) . toMatchObject ( { type : "activity-group" } ) ;
470+ if ( ! group || group . type !== "activity-group" ) {
471+ return ;
472+ }
473+
474+ expect ( group . activities [ 0 ] ?. status ) . toBe ( "success" ) ;
475+ expect ( group . activities [ 0 ] ?. getFullDetail ( ) ) . toBe ( `cat notes.txt\n\n${ output } ` ) ;
476+ } ) ;
477+
379478 it ( "defers large tool output expansion until a work row is opened or copied" , ( ) => {
380479 let serializedToolOutputs = 0 ;
381480 const activities = Array . from ( { length : 5_000 } , ( _ , index ) =>
0 commit comments