@@ -354,7 +354,12 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
354
354
localWizardModel.token = token
355
355
}
356
356
if (! url.isNullOrBlank() && ! token.isNullOrBlank()) {
357
- connect()
357
+ // It could be jarring to suddenly ask for a token when you are
358
+ // just trying to launch the Coder plugin so in this case where
359
+ // we are trying to automatically connect to the last deployment
360
+ // (or the deployment in the CLI config) do not ask for the
361
+ // token again until they explicitly press connect.
362
+ connect(false )
358
363
}
359
364
}
360
365
updateWorkspaceActions()
@@ -431,9 +436,10 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
431
436
* Existing workspaces will be immediately cleared before attempting to
432
437
* connect to the new deployment.
433
438
*
434
- * If the token is invalid abort and start over from askTokenAndConnect().
439
+ * If the token is invalid abort and start over from askTokenAndConnect()
440
+ * unless retry is false.
435
441
*/
436
- private fun connect () {
442
+ private fun connect (retry : Boolean = true ) {
437
443
// Clear out old deployment details.
438
444
poller?.cancel()
439
445
listTableModelOfWorkspaces.items = emptyList()
@@ -469,7 +475,9 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
469
475
triggerWorkspacePolling(false )
470
476
} catch (e: AuthenticationResponseException ) {
471
477
logger.error(" Token was rejected by $deploymentURL ; has your token expired?" , e)
472
- askTokenAndConnect(false ) // Try again but no more opening browser windows.
478
+ if (retry) {
479
+ askTokenAndConnect(false ) // Try again but no more opening browser windows.
480
+ }
473
481
} catch (e: SocketTimeoutException ) {
474
482
logger.error(" Unable to connect to $deploymentURL ; is it up?" , e)
475
483
} catch (e: ResponseException ) {
0 commit comments