@@ -288,8 +288,6 @@ function getToolDisplayNameByState(toolCall: any): string {
288288 * don't go through createToolCall()
289289 */
290290function ensureToolCallDisplayNames ( messages : CopilotMessage [ ] ) : CopilotMessage [ ] {
291- console . log ( '[DEBUG] ensureToolCallDisplayNames called, processing' , messages . length , 'messages' )
292-
293291 return messages . map ( ( message : CopilotMessage ) => {
294292 if ( message . role === 'assistant' && ( message . toolCalls || message . contentBlocks ) ) {
295293 // Check for workflow tools before recalculating
@@ -307,11 +305,6 @@ function ensureToolCallDisplayNames(messages: CopilotMessage[]): CopilotMessage[
307305 )
308306
309307 if ( hasWorkflowTools ) {
310- console . log (
311- '[DEBUG] ensureToolCallDisplayNames found workflow tools in message:' ,
312- message . id
313- )
314-
315308 // Log current states before recalculation
316309 const workflowToolStates = message . contentBlocks
317310 ?. filter (
@@ -325,11 +318,6 @@ function ensureToolCallDisplayNames(messages: CopilotMessage[]): CopilotMessage[
325318 state : ( b as any ) . toolCall . state ,
326319 displayName : ( b as any ) . toolCall . displayName ,
327320 } ) )
328-
329- console . log (
330- '[DEBUG] Current workflow tool states before recalculation:' ,
331- workflowToolStates
332- )
333321 }
334322
335323 return {
@@ -408,7 +396,8 @@ function handleToolFailure(toolCall: any, error: string): void {
408396 return
409397 }
410398
411- toolCall . state = 'errored'
399+ // Check if error message is exactly 'skipped' to set 'rejected' state instead of 'errored'
400+ toolCall . state = error === 'skipped' ? 'rejected' : 'errored'
412401 toolCall . error = error
413402
414403 // Update displayName to match the error state
@@ -488,7 +477,12 @@ function setToolCallState(
488477 break
489478
490479 case 'rejected' :
491- // User rejected the tool
480+ // User rejected the tool or tool was skipped
481+ toolCall . endTime = Date . now ( )
482+ toolCall . duration = toolCall . endTime - toolCall . startTime
483+ if ( error ) {
484+ toolCall . error = error
485+ }
492486 break
493487
494488 case 'background' :
@@ -687,7 +681,7 @@ const sseHandlers: Record<string, SSEHandler> = {
687681
688682 // Handle tool result events - simplified
689683 tool_result : ( data , context , get , set ) => {
690- const { toolCallId, result, success } = data
684+ const { toolCallId, result, success, error } = data
691685
692686 if ( ! toolCallId ) return
693687
@@ -729,15 +723,11 @@ const sseHandlers: Record<string, SSEHandler> = {
729723 if ( toolSupportsReadyForReview ( toolCall . name ) ) {
730724 processWorkflowToolResult ( toolCall , parsedResult , get )
731725 }
732-
733- // COMMENTED OUT OLD LOGIC:
734- // finalizeToolCall(toolCall, true, parsedResult, get)
735726 } else {
736- // NEW LOGIC: Use centralized state management
737- setToolCallState ( toolCall , 'errored' , { error : result || 'Tool execution failed' } )
727+ const errorMessage = error || result || 'Tool execution failed'
728+ const targetState = errorMessage === 'skipped' ? 'rejected' : 'errored'
738729
739- // COMMENTED OUT OLD LOGIC:
740- // handleToolFailure(toolCall, result || 'Tool execution failed')
730+ setToolCallState ( toolCall , targetState , { error : errorMessage } )
741731 }
742732
743733 // Update both contentBlocks and toolCalls atomically before UI update
@@ -792,24 +782,13 @@ const sseHandlers: Record<string, SSEHandler> = {
792782 const toolData = data . data
793783 if ( ! toolData ) return
794784
795- // Log the raw tool data from LLM stream
796- if ( toolData . name === 'run_workflow' ) {
797- console . log ( '🔍 LLM tool call data:' , JSON . stringify ( toolData , null , 2 ) )
798- console . log ( '🔍 LLM arguments field:' , JSON . stringify ( toolData . arguments , null , 2 ) )
799- }
800-
801785 // Check if tool call already exists
802786 const existingToolCall = context . toolCalls . find ( ( tc ) => tc . id === toolData . id )
803787
804788 if ( existingToolCall ) {
805789 // Update existing tool call with new arguments (for partial -> complete transition)
806790 existingToolCall . input = toolData . arguments || { }
807791
808- // Log the updated tool call
809- if ( toolData . name === 'run_workflow' ) {
810- console . log ( '🔍 Updated existing tool call:' , JSON . stringify ( existingToolCall , null , 2 ) )
811- }
812-
813792 // Update the content block as well
814793 updateContentBlockToolCall ( context . contentBlocks , toolData . id , existingToolCall )
815794 updateStreamingMessage ( set , context )
@@ -818,11 +797,6 @@ const sseHandlers: Record<string, SSEHandler> = {
818797
819798 const toolCall = createToolCall ( toolData . id , toolData . name , toolData . arguments )
820799
821- // Log the created tool call
822- if ( toolData . name === 'run_workflow' ) {
823- console . log ( '🔍 Created tool call:' , JSON . stringify ( toolCall , null , 2 ) )
824- }
825-
826800 context . toolCalls . push ( toolCall )
827801
828802 context . contentBlocks . push ( {
0 commit comments