@@ -329,10 +329,14 @@ function buildNamedProgressLine(
329329 } ) ;
330330 const display = resolveToolDisplay ( { name : normalizedName } ) ;
331331 const prefix = `${ display . emoji } ${ display . label } ` ;
332- const compactCommandPrefix =
332+ const compactCommandDetail =
333333 ( display . name === "exec" || display . name === "bash" ) && text . startsWith ( `${ display . emoji } ` )
334334 ? text . slice ( display . emoji . length + 1 ) . trim ( )
335335 : undefined ;
336+ const compactCommandPrefix =
337+ compactCommandDetail && compactCommandDetail !== display . label
338+ ? compactCommandDetail
339+ : undefined ;
336340 const detail = text . startsWith ( `${ prefix } : ` )
337341 ? text . slice ( prefix . length + 2 ) . trim ( )
338342 : compactCommandPrefix ;
@@ -423,6 +427,39 @@ function patchMetas(input: Extract<ChannelProgressDraftLineInput, { event: "patc
423427 return compactStrings ( [ input . summary , ...fileMetas , input . title ] ) ;
424428}
425429
430+ function buildCommandOutputProgressLine (
431+ input : Extract < ChannelProgressDraftLineInput , { event : "command-output" } > ,
432+ status : string | undefined ,
433+ options ?: ChannelProgressLineOptions ,
434+ ) : ChannelProgressDraftLine | undefined {
435+ const name = input . name ?? "exec" ;
436+ const correlationKey = resolveCommandProgressCorrelationKey ( input ) ;
437+ const detail = options ?. commandText === "status" ? [ ] : compactStrings ( [ input . title ] ) ;
438+ const line = buildNamedProgressLine ( input . event , name , detail , options , {
439+ correlationKey,
440+ id : resolveProgressDraftLineId ( input , { useToolCallIdFallback : true } ) ,
441+ status,
442+ } ) ;
443+ if ( ! line || ! status ) {
444+ return line ;
445+ }
446+ if ( ! line . detail || line . detail === status ) {
447+ const statusLine = {
448+ ...line ,
449+ detail : status ,
450+ text : formatToolAggregate ( name , [ status ] , { markdown : options ?. markdown } ) ,
451+ } ;
452+ setProgressDraftLineCorrelationKey ( statusLine , correlationKey ) ;
453+ return statusLine ;
454+ }
455+ const statusLine = {
456+ ...line ,
457+ text : formatToolAggregate ( name , [ status , line . detail ] , { markdown : options ?. markdown } ) ,
458+ } ;
459+ setProgressDraftLineCorrelationKey ( statusLine , correlationKey ) ;
460+ return statusLine ;
461+ }
462+
426463function shouldPrefixProgressLine ( line : string ) : boolean {
427464 return ! EMOJI_PREFIX_RE . test ( line ) ;
428465}
@@ -571,17 +608,7 @@ export function buildChannelProgressDraftLine(
571608 : input . exitCode != null
572609 ? `exit ${ input . exitCode } `
573610 : input . status ;
574- return buildNamedProgressLine (
575- input . event ,
576- input . name ?? "exec" ,
577- [ status , input . title ] ,
578- options ,
579- {
580- correlationKey : resolveCommandProgressCorrelationKey ( input ) ,
581- id : resolveProgressDraftLineId ( input , { useToolCallIdFallback : true } ) ,
582- status,
583- } ,
584- ) ;
611+ return buildCommandOutputProgressLine ( input , status , options ) ;
585612 }
586613 case "patch" : {
587614 if ( input . phase !== undefined && input . phase !== "end" ) {
@@ -1027,15 +1054,22 @@ function getProgressDraftLineText(line: string | ChannelProgressDraftLine): stri
10271054 const prefix = icon ? `${ icon } ` : "" ;
10281055 const label = line . label . trim ( ) ;
10291056 const detail = line . detail ?. trim ( ) ;
1057+ const status = line . status ?. trim ( ) ;
10301058 if ( detail ) {
10311059 const compactCommandLine =
10321060 line . toolName === "exec" || line . toolName === "bash" || line . toolName === "shell" ;
1061+ if ( line . kind === "command-output" && status && detail !== status ) {
1062+ const outputDetail = detail . startsWith ( `${ status } ;` ) ? detail : `${ status } ; ${ detail } ` ;
1063+ if ( compactCommandLine ) {
1064+ return `${ prefix } ${ outputDetail } ` ;
1065+ }
1066+ return label ? `${ prefix } ${ label } : ${ outputDetail } ` : `${ prefix } ${ outputDetail } ` ;
1067+ }
10331068 if ( line . kind !== "patch" && label && ! compactCommandLine ) {
10341069 return `${ prefix } ${ label } : ${ detail } ` ;
10351070 }
10361071 return `${ prefix } ${ detail } ` ;
10371072 }
1038- const status = line . status ?. trim ( ) ;
10391073 if ( status ) {
10401074 if ( label ) {
10411075 return `${ prefix } ${ label } : ${ status } ` ;
@@ -1054,7 +1088,8 @@ export function normalizeChannelProgressDraftLineIdentity(
10541088 line : string | ChannelProgressDraftLine | undefined ,
10551089) : string {
10561090 const text = typeof line === "string" ? line : line ?. text ;
1057- return text ?. replace ( / \s + / g, " " ) . trim ( ) ?? "" ;
1091+ const status = typeof line === "object" ? line . status : undefined ;
1092+ return compactStrings ( [ text , status ] ) . join ( " " ) ;
10581093}
10591094
10601095export function mergeChannelProgressDraftLine < TLine extends string | ChannelProgressDraftLine > (
0 commit comments