@@ -345,3 +345,50 @@ describe("canUseTool MCP approval enforcement", () => {
345345 ) ;
346346 } ) ;
347347} ) ;
348+
349+ describe ( "canUseTool auto mode hands-off approval" , ( ) => {
350+ beforeEach ( ( ) => {
351+ clearMcpToolMetadataCache ( ) ;
352+ } ) ;
353+
354+ // Auto mode advertises hands-off approval; it must not prompt for the write
355+ // and shell tools that drive every real task.
356+ it . each ( [ "Bash" , "BashOutput" , "KillShell" , "Edit" , "Write" , "NotebookEdit" ] ) (
357+ "auto-allows %s in auto mode without prompting" ,
358+ async ( toolName ) => {
359+ const context = createContext ( toolName , {
360+ session : {
361+ permissionMode : "auto" ,
362+ settingsManager : {
363+ getRepoRoot : vi . fn ( ) . mockReturnValue ( "/repo" ) ,
364+ } ,
365+ } ,
366+ } ) ;
367+
368+ const result = await canUseTool ( context ) ;
369+
370+ expect ( result . behavior ) . toBe ( "allow" ) ;
371+ expect ( context . client . requestPermission ) . not . toHaveBeenCalled ( ) ;
372+ } ,
373+ ) ;
374+
375+ // Guard against the fix leaking into default mode, where these tools should
376+ // still go through the manual permission prompt.
377+ it . each ( [ "Bash" , "Edit" , "Write" ] ) (
378+ "still prompts for %s in default mode" ,
379+ async ( toolName ) => {
380+ const context = createContext ( toolName , {
381+ session : {
382+ permissionMode : "default" ,
383+ settingsManager : {
384+ getRepoRoot : vi . fn ( ) . mockReturnValue ( "/repo" ) ,
385+ } ,
386+ } ,
387+ } ) ;
388+
389+ await canUseTool ( context ) ;
390+
391+ expect ( context . client . requestPermission ) . toHaveBeenCalled ( ) ;
392+ } ,
393+ ) ;
394+ } ) ;
0 commit comments