@@ -140,6 +140,7 @@ describe("releaseManagedTunnelOnShutdown", () => {
140140 readonly address ?: HttpServer . HttpServer [ "Service" ] [ "address" ] ;
141141 readonly respondEffect ?: Effect . Effect < Response > ;
142142 readonly getExisting ?: CliTokenManager . CloudCliTokenManager [ "Service" ] [ "getExisting" ] ;
143+ readonly latestReachability ?: ConnectReachability . ConnectReachability [ "Service" ] [ "latest" ] ;
143144 }
144145
145146 const writeLauncherState = ( update : ServiceUpdateRecord ) =>
@@ -165,7 +166,7 @@ describe("releaseManagedTunnelOnShutdown", () => {
165166 ConnectReachability . ConnectReachability ,
166167 ConnectReachability . ConnectReachability . of ( {
167168 check : Effect . die ( "unused" ) ,
168- latest : Effect . succeedNone ,
169+ latest : harness . latestReachability ?? Effect . succeedNone ,
169170 } ) ,
170171 ) ,
171172 Effect . provideService ( HttpServer . HttpServer , {
@@ -1050,4 +1051,57 @@ describe("releaseManagedTunnelOnShutdown", () => {
10501051 expect ( values . has ( CLOUD_ENDPOINT_RUNTIME_CONFIG ) ) . toBe ( false ) ;
10511052 } ) . pipe ( provideReleaseHarness ( { store : failingStore , applyConfigCalls, requests } ) ) ;
10521053 } ) ;
1054+
1055+ it . effect ( "does not report a not-linked check once the managed tunnel config is stored" , ( ) => {
1056+ const { store } = makeMemorySecretStore ( managedLinkSecrets ) ;
1057+ const notLinked = ConnectReachability . classifyReachability (
1058+ {
1059+ managedTunnelConfigured : false ,
1060+ connector : null ,
1061+ endpoint : null ,
1062+ edgeReachable : null ,
1063+ exitNode : null ,
1064+ } ,
1065+ "2026-10-29T00:00:00.000Z" ,
1066+ ) ;
1067+
1068+ return Effect . gen ( function * ( ) {
1069+ const state = yield * ( yield * CloudLink . CloudLink ) . linkState ( ) ;
1070+
1071+ expect ( state . managedTunnelActive ) . toBe ( true ) ;
1072+ expect ( state . reachability ?. status === "unreachable" && state . reachability . cause ) . not . toBe (
1073+ "not_linked" ,
1074+ ) ;
1075+ } ) . pipe (
1076+ provideReleaseHarness ( {
1077+ store,
1078+ applyConfigCalls : [ ] ,
1079+ requests : [ ] ,
1080+ latestReachability : Effect . succeedSome ( notLinked ) ,
1081+ } ) ,
1082+ ) ;
1083+ } ) ;
1084+
1085+ it . effect ( "reports a check that ran after the managed tunnel config was stored" , ( ) => {
1086+ const { store } = makeMemorySecretStore ( managedLinkSecrets ) ;
1087+ const reachable = {
1088+ status : "reachable" as const ,
1089+ checkedAt : "2026-10-29T00:00:00.000Z" ,
1090+ readyConnections : 4 ,
1091+ protocol : "quic" ,
1092+ } ;
1093+
1094+ return Effect . gen ( function * ( ) {
1095+ const state = yield * ( yield * CloudLink . CloudLink ) . linkState ( ) ;
1096+
1097+ expect ( state . reachability ) . toEqual ( reachable ) ;
1098+ } ) . pipe (
1099+ provideReleaseHarness ( {
1100+ store,
1101+ applyConfigCalls : [ ] ,
1102+ requests : [ ] ,
1103+ latestReachability : Effect . succeedSome ( reachable ) ,
1104+ } ) ,
1105+ ) ;
1106+ } ) ;
10531107} ) ;
0 commit comments