@@ -87,7 +87,7 @@ it.live("refresh discovers both clones while list alone never discovers external
8787 } ) ,
8888)
8989
90- it . live ( "remove uses bundled Git without loading configuration and enforces project ownership" , ( ) =>
90+ it . live ( "remove loads canonical strategies and enforces project ownership" , ( ) =>
9191 Effect . gen ( function * ( ) {
9292 const tmp = yield * Effect . acquireDisposable ( Effect . promise ( ( ) => tmpdir ( "opencode-worktree-remove-" ) ) )
9393 const directory = path . join ( tmp . path , "repo" )
@@ -107,13 +107,12 @@ it.live("remove uses bundled Git without loading configuration and enforces proj
107107 yield * Effect . promise ( async ( ) => {
108108 const session = await api . session . create ( { location : { directory : linked } } )
109109 const foreign = await api . session . create ( { location : { directory : other } } )
110- const loaded = await api . debug . location . list ( )
111110 await expect (
112111 api . worktree . remove ( { projectID : foreign . projectID , directory : linked , force : true } ) ,
113112 ) . rejects . toMatchObject ( { name : "WorktreeError" } )
114113 expect ( await fs . stat ( linked ) . then ( ( stat ) => stat . isDirectory ( ) ) ) . toBe ( true )
115114 await api . worktree . remove ( { projectID : session . projectID , directory : linked , force : false } )
116- expect ( await api . debug . location . list ( ) ) . toEqual ( loaded )
115+ expect ( await api . debug . location . list ( ) ) . toContainEqual ( { directory } )
117116 expect ( await api . worktree . list ( { projectID : session . projectID } ) ) . toEqual ( [ { directory } ] )
118117 } )
119118 } ) ,
@@ -212,7 +211,7 @@ it.live(
212211)
213212
214213it . live (
215- "uses canonical plugins for shared clones and remove only uses already-loaded strategies " ,
214+ "uses canonical plugins for shared clones and recorded strategy removal " ,
216215 ( ) =>
217216 Effect . gen ( function * ( ) {
218217 const tmp = yield * Effect . acquireDisposable ( Effect . promise ( ( ) => tmpdir ( "opencode-worktree-plugins-" ) ) )
@@ -261,21 +260,7 @@ it.live(
261260
262261 await Bun . write ( path . join ( custom . directory , "dirty.txt" ) , "keep me" )
263262 await api . debug . location . evict ( { location : { directory : first } } )
264- const loaded = await api . debug . location . list ( )
265263 const remove = new URL ( "/api/worktree" , server . base )
266- const unavailable = await fetch ( remove , {
267- method : "DELETE" ,
268- headers : { ...server . headers , "content-type" : "application/json" } ,
269- body : JSON . stringify ( { projectID, directory : custom . directory , force : true } ) ,
270- } )
271- expect ( unavailable . status ) . toBe ( 400 )
272- expect ( await unavailable . json ( ) ) . toMatchObject ( {
273- data : { message : "Worktree strategy unavailable: test-copy" } ,
274- } )
275- expect ( await Bun . file ( path . join ( custom . directory , "dirty.txt" ) ) . text ( ) ) . toBe ( "keep me" )
276- expect ( await api . worktree . list ( { projectID } ) ) . toEqual ( rows )
277- expect ( await api . debug . location . list ( ) ) . toEqual ( loaded )
278- await api . worktree . refresh ( { projectID } )
279264 const failure = await fetch ( remove , {
280265 method : "DELETE" ,
281266 headers : { ...server . headers , "content-type" : "application/json" } ,
@@ -284,6 +269,8 @@ it.live(
284269 expect ( failure . status ) . toBe ( 400 )
285270 expect ( await failure . json ( ) ) . toMatchObject ( { data : { forceRequired : true } } )
286271 expect ( await Bun . file ( path . join ( custom . directory , "dirty.txt" ) ) . text ( ) ) . toBe ( "keep me" )
272+ expect ( await api . worktree . list ( { projectID } ) ) . toEqual ( rows )
273+ expect ( await api . debug . location . list ( ) ) . toContainEqual ( { directory : first } )
287274
288275 await api . worktree . remove ( {
289276 projectID,
0 commit comments