@@ -8,7 +8,7 @@ import { it } from "../../core/test/lib/effect"
88import { createRoutes } from "../src/routes"
99
1010it . live (
11- "provider reads stay nonblocking while authentication discovery waits for plugins " ,
11+ "agent and provider lists wait for plugins while single provider reads stay nonblocking " ,
1212 ( ) =>
1313 Effect . gen ( function * ( ) {
1414 const tmp = yield * tmpdirScoped ( "opencode-provider-endpoints-" )
@@ -32,6 +32,7 @@ it.live(
3232 models : { chat : { } } ,
3333 } ,
3434 } ,
35+ agents : { reviewer : { description : "Reviews changes" } } ,
3536 } ) ,
3637 } ,
3738 } ) . pipe ( Layer . provide ( HttpServer . layerServices ) ) ,
@@ -62,22 +63,35 @@ it.live(
6263 } ) ,
6364 )
6465 } )
65- // Config providers activate after SDK plugins; reads must return the current snapshot without waiting.
66- const list = yield * request ( "GET" , "/api/provider" ) . pipe ( Effect . timeout ( "2 seconds" ) )
66+ // Config providers and agents activate after SDK plugins, so the lists wait rather than answer with a partial
67+ // catalog that a client would cache as loaded.
68+ const providers = yield * request ( "GET" , "/api/provider" ) . pipe ( Effect . forkScoped )
69+ const agents = yield * request ( "GET" , "/api/agent" ) . pipe ( Effect . forkScoped )
6770 yield * Deferred . await ( started )
6871 const integrations = yield * request ( "GET" , "/api/integration" ) . pipe ( Effect . forkScoped )
69- expect ( list . status ) . toBe ( 200 )
70- expect ( yield * Effect . promise ( ( ) => list . json ( ) ) ) . toMatchObject ( {
71- location : { directory : tmp . path } ,
72- data : expect . not . arrayContaining ( [ expect . objectContaining ( { id : "custom" } ) ] ) ,
73- } )
7472 const get = yield * request ( "GET" , "/api/provider/custom" ) . pipe ( Effect . timeout ( "2 seconds" ) )
7573 expect ( get . status ) . toBe ( 404 )
7674 expect ( yield * Effect . promise ( ( ) => get . json ( ) ) ) . toMatchObject ( {
7775 _tag : "ProviderNotFoundError" ,
7876 providerID : "custom" ,
7977 } )
78+ expect ( providers . pollUnsafe ( ) ) . toBeUndefined ( )
79+ expect ( agents . pollUnsafe ( ) ) . toBeUndefined ( )
8080 yield * Deferred . succeed ( release , undefined )
81+ const list = yield * Fiber . join ( providers )
82+ expect ( list . status ) . toBe ( 200 )
83+ expect ( yield * Effect . promise ( ( ) => list . json ( ) ) ) . toMatchObject ( {
84+ location : { directory : tmp . path } ,
85+ data : expect . arrayContaining ( [ expect . objectContaining ( { id : "custom" } ) ] ) ,
86+ } )
87+ const agentList = yield * Fiber . join ( agents )
88+ expect ( agentList . status ) . toBe ( 200 )
89+ expect ( yield * Effect . promise ( ( ) => agentList . json ( ) ) ) . toMatchObject ( {
90+ data : expect . arrayContaining ( [
91+ expect . objectContaining ( { id : "build" } ) ,
92+ expect . objectContaining ( { id : "reviewer" } ) ,
93+ ] ) ,
94+ } )
8195 const discovered = yield * Fiber . join ( integrations )
8296 expect ( discovered . status ) . toBe ( 200 )
8397 expect ( yield * Effect . promise ( ( ) => discovered . json ( ) ) ) . toMatchObject ( {
0 commit comments