@@ -1185,6 +1185,36 @@ describe('CopilotCLISession', () => {
11851185 expect ( toolsService . invokeToolCalls [ 0 ] . input ) . toMatchObject ( { message : summary } ) ;
11861186 } ) ;
11871187
1188+ it ( 'sets autoApproveEdits when user confirms with autoApprove permission level' , async ( ) => {
1189+ const result = { value : undefined as unknown } ;
1190+ setupSendWithExitPlanMode ( { summary : 'Here is the plan' , actions : [ 'exit_only' ] } , result ) ;
1191+ toolsService . setConfirmationResult ( 'yes' ) ;
1192+ const session = await createSession ( ) ;
1193+ session . setPermissionLevel ( 'autoApprove' ) ;
1194+ const stream = new MockChatResponseStream ( ) ;
1195+ session . attachStream ( stream ) ;
1196+ const mockToken = { } as ChatParticipantToolToken ;
1197+
1198+ await session . handleRequest ( { id : '' , toolInvocationToken : mockToken } , { prompt : 'Plan' } , [ ] , undefined , authInfo , CancellationToken . None ) ;
1199+
1200+ expect ( result . value ) . toEqual ( { approved : true , selectedAction : 'exit_only' , autoApproveEdits : true } ) ;
1201+ } ) ;
1202+
1203+ it ( 'does not set autoApproveEdits when user rejects with autoApprove permission level' , async ( ) => {
1204+ const result = { value : undefined as unknown } ;
1205+ setupSendWithExitPlanMode ( { summary : 'Here is the plan' , actions : [ 'exit_only' ] } , result ) ;
1206+ toolsService . setConfirmationResult ( 'no' ) ;
1207+ const session = await createSession ( ) ;
1208+ session . setPermissionLevel ( 'autoApprove' ) ;
1209+ const stream = new MockChatResponseStream ( ) ;
1210+ session . attachStream ( stream ) ;
1211+ const mockToken = { } as ChatParticipantToolToken ;
1212+
1213+ await session . handleRequest ( { id : '' , toolInvocationToken : mockToken } , { prompt : 'Plan' } , [ ] , undefined , authInfo , CancellationToken . None ) ;
1214+
1215+ expect ( result . value ) . toEqual ( { approved : false } ) ;
1216+ } ) ;
1217+
11881218 it ( 'denies when user rejects via confirmation tool in non-autopilot mode' , async ( ) => {
11891219 const result = { value : undefined as unknown } ;
11901220 setupSendWithExitPlanMode ( { summary : 'Here is the plan' , actions : [ 'exit_only' ] } , result ) ;
@@ -1196,7 +1226,7 @@ describe('CopilotCLISession', () => {
11961226
11971227 await session . handleRequest ( { id : '' , toolInvocationToken : mockToken } , { prompt : 'Plan' } , [ ] , undefined , authInfo , CancellationToken . None ) ;
11981228
1199- expect ( result . value ) . toEqual ( { approved : false , selectedAction : 'exit_only' } ) ;
1229+ expect ( result . value ) . toEqual ( { approved : false } ) ;
12001230 } ) ;
12011231
12021232 it ( 'denies when confirmation tool throws in non-autopilot mode' , async ( ) => {
@@ -1210,7 +1240,7 @@ describe('CopilotCLISession', () => {
12101240
12111241 await session . handleRequest ( { id : '' , toolInvocationToken : mockToken } , { prompt : 'Plan' } , [ ] , undefined , authInfo , CancellationToken . None ) ;
12121242
1213- expect ( result . value ) . toEqual ( { approved : false , selectedAction : 'exit_only' } ) ;
1243+ expect ( result . value ) . toEqual ( { approved : false } ) ;
12141244 } ) ;
12151245 } ) ;
12161246} ) ;
0 commit comments