@@ -68,6 +68,7 @@ interface WorkLogEntry {
6868 detail ?: string ;
6969 command ?: string ;
7070 rawCommand ?: string ;
71+ output ?: string ;
7172 changedFiles ?: ReadonlyArray < string > ;
7273 tone : "thinking" | "tool" | "info" | "error" ;
7374 toolTitle ?: string ;
@@ -408,6 +409,10 @@ function toDerivedWorkLogEntry(activity: OrchestrationThreadActivity): DerivedWo
408409 if ( commandPreview . rawCommand ) {
409410 entry . rawCommand = commandPreview . rawCommand ;
410411 }
412+ const output = extractPersistedToolResult ( payload ) ;
413+ if ( output && output !== entry . detail && output !== commandPreview . command ) {
414+ entry . output = output ;
415+ }
411416 if ( changedFiles . length > 0 ) {
412417 entry . changedFiles = changedFiles ;
413418 }
@@ -497,6 +502,7 @@ function mergeDerivedWorkLogEntries(
497502 const detail = next . detail ?? previous . detail ;
498503 const command = next . command ?? previous . command ;
499504 const rawCommand = next . rawCommand ?? previous . rawCommand ;
505+ const output = next . output ?? previous . output ;
500506 const toolTitle = next . toolTitle ?? previous . toolTitle ;
501507 const itemType = next . itemType ?? previous . itemType ;
502508 const requestKind = next . requestKind ?? previous . requestKind ;
@@ -509,6 +515,7 @@ function mergeDerivedWorkLogEntries(
509515 ...( detail ? { detail } : { } ) ,
510516 ...( command ? { command } : { } ) ,
511517 ...( rawCommand ? { rawCommand } : { } ) ,
518+ ...( output ? { output } : { } ) ,
512519 ...( changedFiles . length > 0 ? { changedFiles } : { } ) ,
513520 ...( toolTitle ? { toolTitle } : { } ) ,
514521 ...( itemType ? { itemType } : { } ) ,
@@ -659,7 +666,7 @@ function buildWorkEntryExpandedBody(entry: WorkLogEntry): string | null {
659666 appendUniqueBlock ( `MCP call\n${ JSON . stringify ( entry . toolData , null , 2 ) } ` ) ;
660667 }
661668 appendUniqueBlock ( entry . rawCommand ?? entry . command ) ;
662- appendUniqueBlock ( entry . detail ) ;
669+ appendUniqueBlock ( entry . output ?? entry . detail ) ;
663670 if ( ( entry . changedFiles ?. length ?? 0 ) > 0 ) {
664671 appendUniqueBlock ( entry . changedFiles ! . join ( "\n" ) ) ;
665672 }
@@ -671,6 +678,7 @@ function workEntryHasExpandedBody(entry: WorkLogEntry): boolean {
671678 return (
672679 ( entry . itemType === "mcp_tool_call" && entry . toolData !== undefined ) ||
673680 Boolean ( ( entry . rawCommand ?? entry . command ) ?. trim ( ) ) ||
681+ Boolean ( entry . output ?. trim ( ) ) ||
674682 Boolean ( entry . detail ?. trim ( ) ) ||
675683 ( entry . changedFiles ?. some ( ( path ) => path . trim ( ) . length > 0 ) ?? false )
676684 ) ;
@@ -728,6 +736,54 @@ function asTrimmedString(value: unknown): string | null {
728736 return trimmed . length > 0 ? trimmed : null ;
729737}
730738
739+ function extractToolResultText ( result : unknown ) : string | null {
740+ const direct = asTrimmedString ( result ) ;
741+ if ( direct ) {
742+ return direct ;
743+ }
744+
745+ const record = asRecord ( result ) ;
746+ if ( ! record ) {
747+ return null ;
748+ }
749+
750+ const content = record . content ;
751+ const contentText = asTrimmedString ( content ) ;
752+ if ( contentText ) {
753+ return contentText ;
754+ }
755+
756+ if ( ! Array . isArray ( content ) ) {
757+ return null ;
758+ }
759+
760+ const chunks : string [ ] = [ ] ;
761+ for ( const entryValue of content ) {
762+ const text = asTrimmedString ( entryValue ) ?? asTrimmedString ( asRecord ( entryValue ) ?. text ) ;
763+ if ( text ) {
764+ chunks . push ( text ) ;
765+ }
766+ }
767+ return chunks . length > 0 ? chunks . join ( "\n" ) : null ;
768+ }
769+
770+ function extractPersistedToolResult ( payload : Record < string , unknown > | null ) : string | null {
771+ const data = asRecord ( payload ?. data ) ;
772+ const item = asRecord ( data ?. item ) ;
773+ const candidates = [ data ?. result , item ?. result ] ;
774+ for ( const candidate of candidates ) {
775+ const text = extractToolResultText ( candidate ) ;
776+ if ( ! text ) {
777+ continue ;
778+ }
779+ const output = stripTrailingExitCode ( text ) . output ;
780+ if ( output ) {
781+ return output ;
782+ }
783+ }
784+ return null ;
785+ }
786+
731787function trimMatchingOuterQuotes ( value : string ) : string {
732788 const trimmed = value . trim ( ) ;
733789 if (
@@ -886,11 +942,13 @@ function extractToolCommand(payload: Record<string, unknown> | null): {
886942 const itemInput = asRecord ( item ?. input ) ;
887943 const itemType = asTrimmedString ( payload ?. itemType ) ;
888944 const detail = asTrimmedString ( payload ?. detail ) ;
945+ const dataInput = asRecord ( data ?. input ) ;
889946 const candidates : unknown [ ] = [
890947 item ?. command ,
891948 itemInput ?. command ,
892949 itemResult ?. command ,
893950 data ?. command ,
951+ dataInput ?. command ,
894952 itemType === "command_execution" && detail ? stripTrailingExitCode ( detail ) . output : null ,
895953 ] ;
896954
0 commit comments