@@ -316,6 +316,57 @@ it.layer(layer)("OpenCodeDriver runtime selection", (it) => {
316316 } ) . pipe ( Effect . scoped , Effect . provide ( TestClock . layer ( ) ) ) ,
317317 ) ;
318318
319+ it . effect ( "gives up on an event endpoint that never answers" , ( ) =>
320+ Effect . gen ( function * ( ) {
321+ const http = HttpClient . make ( ( request ) => {
322+ const url = new URL ( request . url ) ;
323+ const location = {
324+ directory : url . searchParams . get ( "location[directory]" ) ?? "/work" ,
325+ } ;
326+ const json = ( body : unknown , status = 200 ) =>
327+ HttpClientResponse . fromWeb (
328+ request ,
329+ new Response ( JSON . stringify ( body ) , {
330+ status,
331+ headers : { "content-type" : "application/json" } ,
332+ } ) ,
333+ ) ;
334+ if ( url . pathname === "/api/info" ) {
335+ return Effect . succeed (
336+ json ( { version : "2.0.18" , pid : 2393556 , urls : [ ] , paths : { tmp : "/tmp/opencode" } } ) ,
337+ ) ;
338+ }
339+ if ( url . pathname === "/api/event" ) {
340+ // Accepts the request and then stalls before sending response headers,
341+ // so the subscription never yields a stream.
342+ return Effect . never ;
343+ }
344+ if ( url . pathname === "/api/model" ) {
345+ return Effect . succeed ( json ( { location, data : [ ] } ) ) ;
346+ }
347+ if ( url . pathname === "/api/provider" ) {
348+ return Effect . succeed ( json ( { location, data : [ ] } ) ) ;
349+ }
350+ return Effect . succeed ( json ( { _tag : "NotFoundError" , message : "not recorded" } , 404 ) ) ;
351+ } ) ;
352+ const instance = yield * create (
353+ { serverUrl : "http://127.0.0.1:4096" , serverPassword : "secret" } ,
354+ http ,
355+ ) ;
356+ yield * Effect . yieldNow ;
357+ const refresh = yield * instance . snapshot . refresh . pipe ( Effect . forkChild ) ;
358+ yield * Effect . yieldNow ;
359+ yield * TestClock . adjust ( "40 seconds" ) ;
360+
361+ const unsettled = yield * Fiber . join ( refresh ) ;
362+ assert . strictEqual ( unsettled . status , "warning" ) ;
363+ assert . strictEqual (
364+ unsettled . message ,
365+ "OpenCode 2 is running, but it did not list any models yet." ,
366+ ) ;
367+ } ) . pipe ( Effect . scoped , Effect . provide ( TestClock . layer ( ) ) ) ,
368+ ) ;
369+
319370 it . effect ( "lists an OpenCode 2 workspace's own skills and commands from its server" , ( ) =>
320371 Effect . gen ( function * ( ) {
321372 serverStarts . length = 0 ;
0 commit comments