@@ -15,8 +15,8 @@ import kotlinx.coroutines.delay
1515import kotlinx.coroutines.flow.StateFlow
1616import kotlinx.coroutines.flow.first
1717import kotlinx.coroutines.launch
18+ import kotlinx.coroutines.runBlocking
1819import kotlinx.coroutines.time.withTimeout
19- import kotlinx.coroutines.yield
2020import okhttp3.OkHttpClient
2121import java.net.HttpURLConnection
2222import java.net.URI
@@ -152,21 +152,21 @@ open class CoderProtocolHandler(
152152 reInitialize(restClient, cli)
153153
154154 val environmentId = " ${workspace.name} .${agent.name} "
155- context.cs.launch {
156- context.ui.showWindow( )
157- context.envPageManager.showPluginEnvironmentsPage( true )
158- context.envPageManager.showEnvironmentPage(environmentId, false )
159- val productCode = params.ideProductCode ()
160- val buildNumber = params.ideBuildNumber()
161- if ( ! productCode.isNullOrBlank() && ! buildNumber.isNullOrBlank()) {
155+ context.ui.showWindow()
156+ context.envPageManager.showPluginEnvironmentsPage( true )
157+ context.envPageManager.showEnvironmentPage(environmentId, false )
158+ val productCode = params.ideProductCode( )
159+ val buildNumber = params.ideBuildNumber ()
160+ if ( ! productCode.isNullOrBlank() && ! buildNumber.isNullOrBlank()) {
161+ context.cs.launch {
162162 val ideVersion = " $productCode -$buildNumber "
163163 context.logger.info(" installing $ideVersion on $environmentId " )
164- context.ideOrchestrator.prepareClient(environmentId, ideVersion)
164+ runBlocking {
165+ context.ideOrchestrator.prepareClient(environmentId, ideVersion)
166+ }
167+ context.logger.info(" launching $ideVersion on $environmentId " )
168+ context.ideOrchestrator.connectToIde(environmentId, ideVersion, null )
165169 }
166- // without a yield or a delay(0) the env page does not show up. My assumption is that
167- // the coroutine is finishing too fast without giving enough time to compose main thread
168- // to catch the state change. Yielding gives other coroutines the chance to run
169- yield ()
170170 }
171171 }
172172
0 commit comments