@@ -240,4 +240,35 @@ describe('ExitPlanModeTool', () => {
240240 expect ( tool . description ) . toContain ( 'Help me implement yank mode for vim' ) ;
241241 } ) ;
242242 } ) ;
243+
244+ describe ( 'YOLO mode' , ( ) => {
245+ it ( 'should exit plan mode without onConfirm being called when approval mode is YOLO' , async ( ) => {
246+ // Simulate YOLO: scheduler sets approvalMode=YOLO but never calls onConfirm
247+ approvalMode = ApprovalMode . YOLO ;
248+ const params : ExitPlanModeParams = { plan : 'YOLO test plan' } ;
249+ const signal = new AbortController ( ) . signal ;
250+
251+ const invocation = tool . build ( params ) ;
252+ // Do NOT call onConfirm — this mirrors what the YOLO scheduler does
253+ const result = await invocation . execute ( signal ) ;
254+
255+ expect ( result . llmContent ) . toContain (
256+ 'User has approved your plan. You can now start coding' ,
257+ ) ;
258+ expect ( result . llmContent ) . not . toContain ( 'not approved' ) ;
259+ } ) ;
260+
261+ it ( 'should not downgrade approval mode to AUTO_EDIT when YOLO' , async ( ) => {
262+ approvalMode = ApprovalMode . YOLO ;
263+ const params : ExitPlanModeParams = { plan : 'YOLO test plan' } ;
264+ const signal = new AbortController ( ) . signal ;
265+
266+ const invocation = tool . build ( params ) ;
267+ await invocation . execute ( signal ) ;
268+
269+ // Approval mode must remain YOLO — do not downgrade to AUTO_EDIT
270+ expect ( mockConfig . setApprovalMode ) . not . toHaveBeenCalled ( ) ;
271+ expect ( approvalMode ) . toBe ( ApprovalMode . YOLO ) ;
272+ } ) ;
273+ } ) ;
243274} ) ;
0 commit comments