Skip to content

Commit cbdc9bd

Browse files
committed
Tweak open browser logic
Currently if you launch the Coder plugin from Gateway and it automatically picks up a token from the config or from your last launch but it is invalid it will open a browser window for a new token which I think could be jarring. We should only open a browser window when the user explicitly wants that by pressing connect for example.
1 parent 9eaeb0f commit cbdc9bd

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,7 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
420420
return // User aborted.
421421
}
422422
localWizardModel.token = pastedToken
423-
// If the token ends up being invalid we will ask for it again; pass
424-
// false so we do not keep endlessly opening the browser.
425-
connect(false)
423+
connect()
426424
}
427425

428426
/**
@@ -435,7 +433,7 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
435433
*
436434
* If the token is invalid abort and start over from askTokenAndConnect().
437435
*/
438-
private fun connect(openBrowser: Boolean = true) {
436+
private fun connect() {
439437
// Clear out old deployment details.
440438
poller?.cancel()
441439
listTableModelOfWorkspaces.items = emptyList()
@@ -471,7 +469,7 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
471469
triggerWorkspacePolling(false)
472470
} catch (e: AuthenticationResponseException) {
473471
logger.error("Token was rejected by $deploymentURL; has your token expired?", e)
474-
askTokenAndConnect(openBrowser)
472+
askTokenAndConnect(false) // Try again but no more opening browser windows.
475473
} catch (e: SocketTimeoutException) {
476474
logger.error("Unable to connect to $deploymentURL; is it up?", e)
477475
} catch (e: ResponseException) {

0 commit comments

Comments
 (0)