Skip to content

Commit 048ab31

Browse files
committed
fix: wait for plugin to fully initialize
And only then start validating the parameters. Otherwise, we can end up in a situation where we ask TBX to show a snackbar while TBX is not yet visible/initialized. In that case the UI page doesn't show the snackbar
1 parent 4044e0d commit 048ab31

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,19 @@ open class CoderProtocolHandler(
4545
shouldWaitForAutoLogin: Boolean,
4646
reInitialize: suspend (CoderRestClient, CoderCLIManager) -> Unit
4747
) {
48-
context.popupPluginMainPage()
49-
context.logger.info("Handling $uri...")
5048
val params = uri.toQueryParameters()
5149
if (params.isEmpty()) {
5250
// probably a plugin installation scenario
51+
context.logAndShowInfo("URI will not be handled", "No query parameters were provided")
5352
return
5453
}
5554

55+
if (shouldWaitForAutoLogin) {
56+
isInitialized.waitForTrue()
57+
}
58+
59+
context.logger.info("Handling $uri...")
60+
context.popupPluginMainPage()
5661
val deploymentURL = resolveDeploymentUrl(params) ?: return
5762
val token = resolveToken(params) ?: return
5863
val workspaceName = resolveWorkspaceName(params) ?: return
@@ -66,10 +71,6 @@ open class CoderProtocolHandler(
6671
if (!ensureAgentIsReady(workspace, agent)) return
6772

6873
val cli = configureCli(deploymentURL, restClient)
69-
70-
if (shouldWaitForAutoLogin) {
71-
isInitialized.waitForTrue()
72-
}
7374
reInitialize(restClient, cli)
7475

7576
val environmentId = "${workspace.name}.${agent.name}"

0 commit comments

Comments
 (0)