@@ -17,6 +17,7 @@ import path from "path"
1717import { isBinaryFile } from "isbinaryfile"
1818
1919import { readFileTool , ReadFileTool } from "../ReadFileTool"
20+ import { Task } from "../../task/Task"
2021import { formatResponse } from "../../prompts/responses"
2122import {
2223 validateImageForProcessing ,
@@ -649,6 +650,43 @@ describe("ReadFileTool", () => {
649650 expect ( mockTask . say ) . toHaveBeenCalledWith ( "user_feedback" , "This file contains secrets" , undefined )
650651 expect ( formatResponse . toolDeniedWithFeedback ) . toHaveBeenCalledWith ( "This file contains secrets" )
651652 } )
653+
654+ it ( "denies batch reads and reports queued message feedback without parsing it as permissions" , async ( ) => {
655+ const task = Object . create ( Task . prototype ) as Task
656+ Object . defineProperty ( task , "cwd" , { value : "/test/workspace" , writable : true } )
657+ Object . assign ( task , createMockTask ( ) )
658+ const queuedImages = [ "data:image/png;base64,queued" ]
659+ task . ask = vi . fn ( ) . mockResolvedValue ( {
660+ response : "messageResponse" ,
661+ text : "Read a different file instead" ,
662+ images : queuedImages ,
663+ } )
664+ const fileResults = [
665+ { path : "one.ts" , status : "pending" as const , entry : { path : "one.ts" , mode : "slice" as const } } ,
666+ { path : "two.ts" , status : "pending" as const , entry : { path : "two.ts" , mode : "slice" as const } } ,
667+ ]
668+ const updates = new Map < string , Record < string , unknown > > ( )
669+ const parseSpy = vi . spyOn ( JSON , "parse" )
670+
671+ await readFileTool [ "requestApproval" ] ( task , fileResults , ( filePath , update ) => {
672+ updates . set ( filePath , update )
673+ } )
674+
675+ expect ( parseSpy ) . not . toHaveBeenCalled ( )
676+ expect ( task . say ) . toHaveBeenCalledWith ( "user_feedback" , "Read a different file instead" , queuedImages )
677+ expect ( task . didRejectTool ) . toBe ( true )
678+ expect ( updates . get ( "one.ts" ) ) . toMatchObject ( {
679+ status : "denied" ,
680+ feedbackText : "Read a different file instead" ,
681+ feedbackImages : queuedImages ,
682+ } )
683+ expect ( updates . get ( "two.ts" ) ) . toMatchObject ( {
684+ status : "denied" ,
685+ feedbackText : "Read a different file instead" ,
686+ feedbackImages : queuedImages ,
687+ } )
688+ parseSpy . mockRestore ( )
689+ } )
652690 } )
653691
654692 describe ( "output structure" , ( ) => {
0 commit comments