@@ -208,6 +208,8 @@ function textFromData(
208208 return text ;
209209}
210210
211+ const CURRENT_TOOL_PROGRESS_LINE_ID = "current-tool" ;
212+
211213function lineWithId < TLine extends ChannelProgressDraftLine | undefined > (
212214 line : TLine ,
213215 id : string | undefined ,
@@ -241,22 +243,23 @@ function formatAgentEventForChannelMirrorLine(
241243 if ( data . suppressChannelProgress === true ) {
242244 return undefined ;
243245 }
244- return buildChannelProgressDraftLineForEntry ( entry , {
245- event : "item" ,
246- itemId : normalizeOptionalString ( data . itemId ) ,
247- itemKind : normalizeOptionalString ( data . kind ) ,
248- title : normalizeOptionalString ( data . title ) ,
249- name : normalizeOptionalString ( data . name ) ,
250- phase : normalizeOptionalString ( data . phase ) ,
251- status : normalizeOptionalString ( data . status ) ,
252- summary : normalizeOptionalString ( data . summary ) ,
253- progressText : normalizeOptionalString ( data . progressText ) ,
254- meta : normalizeOptionalString ( data . meta ) ,
255- } ) ;
246+ return lineWithId (
247+ buildChannelProgressDraftLineForEntry ( entry , {
248+ event : "item" ,
249+ itemKind : normalizeOptionalString ( data . kind ) ,
250+ title : normalizeOptionalString ( data . title ) ,
251+ name : normalizeOptionalString ( data . name ) ,
252+ phase : normalizeOptionalString ( data . phase ) ,
253+ status : normalizeOptionalString ( data . status ) ,
254+ summary : normalizeOptionalString ( data . summary ) ,
255+ progressText : normalizeOptionalString ( data . progressText ) ,
256+ meta : normalizeOptionalString ( data . meta ) ,
257+ } ) ,
258+ CURRENT_TOOL_PROGRESS_LINE_ID ,
259+ ) ;
256260 }
257261
258262 if ( evt . stream === "command_output" ) {
259- const id = normalizeOptionalString ( data . itemId ) ?? normalizeOptionalString ( data . toolCallId ) ;
260263 return lineWithId (
261264 buildChannelProgressDraftLineForEntry ( entry , {
262265 event : "command-output" ,
@@ -266,12 +269,11 @@ function formatAgentEventForChannelMirrorLine(
266269 status : normalizeOptionalString ( data . status ) ,
267270 exitCode : typeof data . exitCode === "number" ? data . exitCode : null ,
268271 } ) ,
269- id ,
272+ CURRENT_TOOL_PROGRESS_LINE_ID ,
270273 ) ;
271274 }
272275
273276 if ( evt . stream === "approval" ) {
274- const id = normalizeOptionalString ( data . approvalId ) ?? normalizeOptionalString ( data . toolCallId ) ;
275277 return lineWithId (
276278 buildChannelProgressDraftLineForEntry ( entry , {
277279 event : "approval" ,
@@ -281,7 +283,7 @@ function formatAgentEventForChannelMirrorLine(
281283 reason : normalizeOptionalString ( data . reason ) ,
282284 message : normalizeOptionalString ( data . message ) ,
283285 } ) ,
284- id ,
286+ CURRENT_TOOL_PROGRESS_LINE_ID ,
285287 ) ;
286288 }
287289
@@ -298,7 +300,6 @@ function formatAgentEventForChannelMirrorLine(
298300 }
299301
300302 if ( evt . stream === "patch" ) {
301- const id = normalizeOptionalString ( data . itemId ) ?? normalizeOptionalString ( data . toolCallId ) ;
302303 const stringArray = ( value : unknown ) : string [ ] | undefined =>
303304 Array . isArray ( value )
304305 ? value . filter ( ( entry ) : entry is string => typeof entry === "string" )
@@ -314,7 +315,7 @@ function formatAgentEventForChannelMirrorLine(
314315 deleted : stringArray ( data . deleted ) ,
315316 summary : normalizeOptionalString ( data . summary ) ,
316317 } ) ,
317- id ,
318+ CURRENT_TOOL_PROGRESS_LINE_ID ,
318319 ) ;
319320 }
320321
0 commit comments