@@ -4,7 +4,7 @@ import { LLMClient, RequestExecutor } from "@opencode/ai/route"
44import { Document , Event , Info } from "@opencode/schema/config"
55import { ConfigPolicy } from "@opencode/schema/config/policy"
66import { Money } from "@opencode/schema/money"
7- import { Effect , Layer , Schema , Stream } from "effect"
7+ import { Effect , Fiber , Layer , Schema , Stream } from "effect"
88import { TestClock } from "effect/testing"
99import { HttpClient , HttpClientRequest , HttpClientResponse } from "effect/http"
1010import { Agent } from "@opencode/core/agent"
@@ -1103,6 +1103,30 @@ describe("OpencodePlugin", () => {
11031103 ) ,
11041104 )
11051105
1106+ it . effect ( "activates when the Console accepts the config request but never answers" , ( ) =>
1107+ Effect . gen ( function * ( ) {
1108+ const credentials = yield * Credential . Service
1109+ const integrations = yield * Integration . Service
1110+ const state = { requests : 0 }
1111+ const hanging = {
1112+ fetch : ( ) => {
1113+ state . requests ++
1114+ return new Promise < Response > ( ( ) => { } )
1115+ } ,
1116+ }
1117+ yield * credentials . create ( {
1118+ integrationID : Integration . ID . make ( "opencode" ) ,
1119+ value : Credential . Key . make ( { type : "key" , key : "secret" , metadata : { server : "https://console.example" } } ) ,
1120+ } )
1121+ const activation = yield * addPlugin ( ) . pipe ( inProcess ( hanging ) , Effect . forkChild ( { startImmediately : true } ) )
1122+ // Four attempts of 5 seconds each, with 1, 2 and 4 seconds of backoff between them.
1123+ yield * TestClock . adjust ( "1 second" ) . pipe ( Effect . repeat ( { times : 29 } ) )
1124+ yield * Fiber . join ( activation )
1125+ expect ( state . requests ) . toBe ( 4 )
1126+ expect ( ( yield * integrations . get ( Integration . ID . make ( "opencode" ) ) ) ?. connections ) . toHaveLength ( 1 )
1127+ } ) ,
1128+ )
1129+
11061130 it . effect ( "reports a Console session rejected before its token expires as signed out" , ( ) =>
11071131 Effect . acquireUseRelease (
11081132 Effect . sync ( ( ) => {
0 commit comments