@@ -5,6 +5,7 @@ let createPromptSubmit: typeof import("./submit").createPromptSubmit
55
66const createdClients : string [ ] = [ ]
77const createdSessions : string [ ] = [ ]
8+ const enabledAutoAccept : Array < { sessionID : string ; directory : string } > = [ ]
89const sentShell : string [ ] = [ ]
910const syncedDirectories : string [ ] = [ ]
1011
@@ -69,6 +70,14 @@ beforeAll(async () => {
6970 } ) ,
7071 } ) )
7172
73+ mock . module ( "@/context/permission" , ( ) => ( {
74+ usePermission : ( ) => ( {
75+ enableAutoAccept ( sessionID : string , directory : string ) {
76+ enabledAutoAccept . push ( { sessionID, directory } )
77+ } ,
78+ } ) ,
79+ } ) )
80+
7281 mock . module ( "@/context/prompt" , ( ) => ( {
7382 usePrompt : ( ) => ( {
7483 current : ( ) => promptValue ,
@@ -145,6 +154,7 @@ beforeAll(async () => {
145154beforeEach ( ( ) => {
146155 createdClients . length = 0
147156 createdSessions . length = 0
157+ enabledAutoAccept . length = 0
148158 sentShell . length = 0
149159 syncedDirectories . length = 0
150160 selected = "/repo/worktree-a"
@@ -156,6 +166,7 @@ describe("prompt submit worktree selection", () => {
156166 info : ( ) => undefined ,
157167 imageAttachments : ( ) => [ ] ,
158168 commentCount : ( ) => 0 ,
169+ autoAccept : ( ) => false ,
159170 mode : ( ) => "shell" ,
160171 working : ( ) => false ,
161172 editor : ( ) => undefined ,
@@ -181,4 +192,31 @@ describe("prompt submit worktree selection", () => {
181192 expect ( sentShell ) . toEqual ( [ "/repo/worktree-a" , "/repo/worktree-b" ] )
182193 expect ( syncedDirectories ) . toEqual ( [ "/repo/worktree-a" , "/repo/worktree-b" ] )
183194 } )
195+
196+ test ( "applies auto-accept to newly created sessions" , async ( ) => {
197+ const submit = createPromptSubmit ( {
198+ info : ( ) => undefined ,
199+ imageAttachments : ( ) => [ ] ,
200+ commentCount : ( ) => 0 ,
201+ autoAccept : ( ) => true ,
202+ mode : ( ) => "shell" ,
203+ working : ( ) => false ,
204+ editor : ( ) => undefined ,
205+ queueScroll : ( ) => undefined ,
206+ promptLength : ( value ) => value . reduce ( ( sum , part ) => sum + ( "content" in part ? part . content . length : 0 ) , 0 ) ,
207+ addToHistory : ( ) => undefined ,
208+ resetHistoryNavigation : ( ) => undefined ,
209+ setMode : ( ) => undefined ,
210+ setPopover : ( ) => undefined ,
211+ newSessionWorktree : ( ) => selected ,
212+ onNewSessionWorktreeReset : ( ) => undefined ,
213+ onSubmit : ( ) => undefined ,
214+ } )
215+
216+ const event = { preventDefault : ( ) => undefined } as unknown as Event
217+
218+ await submit . handleSubmit ( event )
219+
220+ expect ( enabledAutoAccept ) . toEqual ( [ { sessionID : "session-1" , directory : "/repo/worktree-a" } ] )
221+ } )
184222} )
0 commit comments