@@ -77,6 +77,64 @@ function firstStringField(
7777 return "" ;
7878}
7979
80+ function formatCollabAgentLabel ( agent : {
81+ threadId : string ;
82+ nickname ?: string ;
83+ role ?: string ;
84+ } ) {
85+ const nickname = agent . nickname ?. trim ( ) ;
86+ const role = agent . role ?. trim ( ) ;
87+ if ( nickname && role ) {
88+ return `${ nickname } [${ role } ]` ;
89+ }
90+ if ( nickname ) {
91+ return nickname ;
92+ }
93+ if ( role ) {
94+ return `${ agent . threadId } [${ role } ]` ;
95+ }
96+ return agent . threadId ;
97+ }
98+
99+ function summarizeCollabLabel ( title : string , status ?: string ) {
100+ const tool = title . replace ( / ^ c o l l a b : \s * / i, "" ) . trim ( ) . toLowerCase ( ) ;
101+ const tone = statusToneFromText ( status ) ;
102+ if ( tool . includes ( "wait" ) ) {
103+ return tone === "processing" ? "waiting for" : "waited for" ;
104+ }
105+ if ( tool . includes ( "resume" ) ) {
106+ return tone === "processing" ? "resuming" : "resumed" ;
107+ }
108+ if ( tool . includes ( "close" ) ) {
109+ return tone === "processing" ? "closing" : "closed" ;
110+ }
111+ if ( tool . includes ( "spawn" ) ) {
112+ return tone === "processing" ? "spawning" : "spawned" ;
113+ }
114+ if ( tool . includes ( "send" ) || tool . includes ( "interaction" ) ) {
115+ return tone === "processing" ? "sending to" : "sent to" ;
116+ }
117+ return "sub-agent" ;
118+ }
119+
120+ function summarizeCollabReceiver (
121+ item : Extract < ConversationItem , { kind : "tool" } > ,
122+ ) {
123+ const receivers =
124+ item . collabReceivers && item . collabReceivers . length > 0
125+ ? item . collabReceivers
126+ : item . collabReceiver
127+ ? [ item . collabReceiver ]
128+ : [ ] ;
129+ if ( receivers . length === 0 ) {
130+ return item . title || "" ;
131+ }
132+ if ( receivers . length === 1 ) {
133+ return formatCollabAgentLabel ( receivers [ 0 ] ) ;
134+ }
135+ return `${ formatCollabAgentLabel ( receivers [ 0 ] ) } +${ receivers . length - 1 } ` ;
136+ }
137+
80138export function toolNameFromTitle ( title : string ) {
81139 if ( ! title . toLowerCase ( ) . startsWith ( "tool:" ) ) {
82140 return "" ;
@@ -302,6 +360,15 @@ export function buildToolSummary(
302360 } ;
303361 }
304362
363+ if ( item . toolType === "collabToolCall" ) {
364+ return {
365+ label : summarizeCollabLabel ( item . title , item . status ) ,
366+ value : summarizeCollabReceiver ( item ) ,
367+ detail : item . detail || "" ,
368+ output : item . output || "" ,
369+ } ;
370+ }
371+
305372 if ( item . toolType === "mcpToolCall" ) {
306373 const toolName = toolNameFromTitle ( item . title ) ;
307374 const args = parseToolArgs ( item . detail ) ;
0 commit comments