@@ -47,6 +47,7 @@ import kotlinx.coroutines.selects.onTimeout
4747import kotlinx.coroutines.selects.select
4848import java.net.URI
4949import java.net.URL
50+ import java.util.concurrent.atomic.AtomicBoolean
5051import kotlin.coroutines.cancellation.CancellationException
5152import kotlin.time.Duration.Companion.seconds
5253import kotlin.time.TimeSource
@@ -78,6 +79,7 @@ class CoderRemoteProvider(
7879 private var firstRun = true
7980
8081 private val isInitialized: MutableStateFlow <Boolean > = MutableStateFlow (false )
82+ private val isHandlingUri: AtomicBoolean = AtomicBoolean (false )
8183 private val coderHeaderPage = NewEnvironmentPage (context.i18n.pnotr(context.deploymentUrl.toString()))
8284 private val settingsPage: CoderSettingsPage = CoderSettingsPage (context, triggerSshConfig) {
8385 client?.let { restClient ->
@@ -354,13 +356,11 @@ class CoderRemoteProvider(
354356 context.logAndShowInfo(" URI will not be handled" , " No query parameters were provided" )
355357 return
356358 }
359+ isHandlingUri.set(true )
357360 // this switches to the main plugin screen, even
358361 // if last opened provider was not Coder
359362 context.envPageManager.showPluginEnvironmentsPage()
360363 coderHeaderPage.isBusy.update { true }
361- if (shouldDoAutoSetup()) {
362- isInitialized.waitForTrue()
363- }
364364 context.logger.info(" Handling $uri ..." )
365365 val newUrl = resolveDeploymentUrl(params)?.toURL() ? : return
366366 val newToken = if (context.settingsStore.requiresMTlsAuth) null else resolveToken(params) ? : return
@@ -386,8 +386,9 @@ class CoderRemoteProvider(
386386 beforeShow()
387387 }
388388 }
389- // TODO - do I really need these two lines? I'm anyway doing a workspace call
389+ // force the poll loop to run
390390 triggerProviderVisible.send(true )
391+ // wait for environments to be populated
391392 isInitialized.waitForTrue()
392393
393394 linkHandler.handle(params, newUrl, this .client!! , this .cli!! )
@@ -405,6 +406,7 @@ class CoderRemoteProvider(
405406 context.envPageManager.showPluginEnvironmentsPage()
406407 } finally {
407408 coderHeaderPage.isBusy.update { false }
409+ isHandlingUri.set(false )
408410 }
409411 }
410412
@@ -467,6 +469,9 @@ class CoderRemoteProvider(
467469 * list.
468470 */
469471 override fun getOverrideUiPage (): UiPage ? {
472+ if (isHandlingUri.get()) {
473+ return null
474+ }
470475 // Show the setup page if we have not configured the client yet.
471476 if (client == null ) {
472477 // When coming back to the application, initializeSession immediately.
0 commit comments