@@ -671,11 +671,23 @@ it.effect(
671671 const providerThreadId = ProviderThreadId . make ( "provider_thread_recovery_cancel" ) ;
672672 const providerTurnId = ProviderTurnId . make ( "provider_turn_recovery_cancel" ) ;
673673 const providerSessionId = ProviderSessionId . make ( "provider_session_recovery_cancel" ) ;
674+ const assistantItemId = TurnItemId . make ( "turn_item_recovery_cancel_assistant" ) ;
675+ const reasoningItemId = TurnItemId . make ( "turn_item_recovery_cancel_reasoning" ) ;
676+ const commandItemId = TurnItemId . make ( "turn_item_recovery_cancel" ) ;
677+ const asyncQuestionNodeId = NodeId . make ( "node_recovery_cancel_async_question" ) ;
678+ const asyncQuestionItemId = TurnItemId . make ( "turn_item_recovery_cancel_async_question" ) ;
674679 let committedInput : Parameters < EventSink . EventSinkV2 [ "Service" ] [ "commitCommand" ] > [ 0 ] | null =
675680 null ;
676681 const projection = {
677682 thread : { id : threadId } ,
678- runtimeRequests : [ ] ,
683+ runtimeRequests : [
684+ {
685+ id : RuntimeRequestId . make ( "request_recovery_cancel_async_question" ) ,
686+ nodeId : asyncQuestionNodeId ,
687+ status : "pending" ,
688+ responseCapability : { type : "message" } ,
689+ } ,
690+ ] ,
679691 providerSessions : [
680692 {
681693 id : providerSessionId ,
@@ -716,15 +728,42 @@ it.effect(
716728 status : "running" ,
717729 } ,
718730 ] ,
719- nodes : [ { id : rootNodeId , runId, status : "running" } ] ,
731+ nodes : [
732+ { id : rootNodeId , runId, status : "running" } ,
733+ { id : asyncQuestionNodeId , runId, status : "waiting" } ,
734+ ] ,
720735 subagents : [ ] ,
721736 messages : [ { id : MessageId . make ( "message_recovery_cancel" ) , runId, streaming : true } ] ,
722737 turnItems : [
723738 {
724- id : TurnItemId . make ( "turn_item_recovery_cancel" ) ,
739+ id : commandItemId ,
740+ runId,
741+ nodeId : rootNodeId ,
742+ type : "command_execution" ,
743+ status : "running" ,
744+ } ,
745+ {
746+ id : assistantItemId ,
747+ runId,
748+ nodeId : rootNodeId ,
749+ type : "assistant_message" ,
750+ status : "running" ,
751+ streaming : true ,
752+ } ,
753+ {
754+ id : reasoningItemId ,
725755 runId,
726756 nodeId : rootNodeId ,
757+ type : "reasoning" ,
727758 status : "running" ,
759+ streaming : true ,
760+ } ,
761+ {
762+ id : asyncQuestionItemId ,
763+ runId,
764+ nodeId : asyncQuestionNodeId ,
765+ type : "user_input_request" ,
766+ status : "waiting" ,
728767 } ,
729768 ] ,
730769 } as unknown as OrchestrationV2ThreadProjection ;
@@ -779,12 +818,58 @@ it.effect(
779818 [ "provider-turn.updated" , "cancelled" ] ,
780819 [ "message.updated" , null ] ,
781820 [ "turn-item.updated" , "cancelled" ] ,
821+ [ "turn-item.updated" , "cancelled" ] ,
822+ [ "turn-item.updated" , "cancelled" ] ,
782823 [ "provider-thread.updated" , "idle" ] ,
783824 [ "provider-session.updated" , "stopped" ] ,
784825 ] ,
785826 ) ;
786827 const messageEvent = events . find ( ( event ) => event . type === "message.updated" ) ;
787828 assert . isFalse ( messageEvent ?. type === "message.updated" && messageEvent . payload . streaming ) ;
829+ const turnItemEventById = ( id : TurnItemId ) =>
830+ events . find ( ( event ) => event . type === "turn-item.updated" && event . payload . id === id ) ;
831+ const commandEvent = turnItemEventById ( commandItemId ) ;
832+ assert . equal (
833+ commandEvent ?. type === "turn-item.updated" ? commandEvent . payload . status : null ,
834+ "cancelled" ,
835+ ) ;
836+ assert . equal (
837+ commandEvent ?. type === "turn-item.updated" ? commandEvent . payload . type : null ,
838+ "command_execution" ,
839+ ) ;
840+ assert . isFalse (
841+ commandEvent ?. type === "turn-item.updated" && "streaming" in commandEvent . payload ,
842+ ) ;
843+ const assistantEvent = turnItemEventById ( assistantItemId ) ;
844+ assert . equal (
845+ assistantEvent ?. type === "turn-item.updated" ? assistantEvent . payload . status : null ,
846+ "cancelled" ,
847+ ) ;
848+ assert . equal (
849+ assistantEvent ?. type === "turn-item.updated" &&
850+ assistantEvent . payload . type === "assistant_message"
851+ ? assistantEvent . payload . streaming
852+ : null ,
853+ false ,
854+ ) ;
855+ const reasoningEvent = turnItemEventById ( reasoningItemId ) ;
856+ assert . equal (
857+ reasoningEvent ?. type === "turn-item.updated" ? reasoningEvent . payload . status : null ,
858+ "cancelled" ,
859+ ) ;
860+ assert . equal (
861+ reasoningEvent ?. type === "turn-item.updated" && reasoningEvent . payload . type === "reasoning"
862+ ? reasoningEvent . payload . streaming
863+ : null ,
864+ false ,
865+ ) ;
866+ assert . isUndefined ( turnItemEventById ( asyncQuestionItemId ) ) ;
867+ assert . isUndefined ( events . find ( ( event ) => event . type === "runtime-request.updated" ) ) ;
868+ assert . isUndefined (
869+ events . find (
870+ ( event ) => event . type === "node.updated" && event . payload . id === asyncQuestionNodeId ,
871+ ) ,
872+ ) ;
788873 } ) . pipe ( Effect . provide ( layer ) ) ;
789874 } ,
790875) ;
0 commit comments