From 972a386cca300a1a0ba1ea1ee5802df92496bbbe Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 1 Mar 2023 11:28:58 -0900 Subject: [PATCH 1/3] Clear workspaces on reconnect and fetch immediately on return My thinking here is that if you try connecting to a new URL you still see the old workspaces until the new connection is successful which could be confusing (the new URL shows in the text field yet the workspaces below it belong to something else and the list will no longer update since the poller was stopped). Also thought it might make sense to fetch immediately if you come back to this step since it is not clear that the data there is possibly stale (especially if you were on a previous/next step for a long time); I think I would assume a fresh fetch when I interact with the next/previous buttons but this is just my personal assumption. Fetching immediately also "fixes" an interesting bug where if you hit back you are unable to connect to a workspace until the next poll goes through. I considered looking more into this but figured it would be best to block the next step on fresh data anyway. --- .../gateway/views/steps/CoderWorkspacesStepView.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt b/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt index cf262a21..785d0aab 100644 --- a/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt +++ b/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt @@ -212,11 +212,13 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : tfUrl = textField().resizableColumn().align(AlignX.FILL).gap(RightGap.SMALL).bindText(localWizardModel::coderURL).applyToComponent { addActionListener { poller?.cancel() + listTableModelOfWorkspaces.items = emptyList() askTokenAndOpenSession(true) } }.component button(CoderGatewayBundle.message("gateway.connector.view.coder.workspaces.connect.text")) { poller?.cancel() + listTableModelOfWorkspaces.items = emptyList() askTokenAndOpenSession(true) }.applyToComponent { background = WelcomeScreenUIManager.getMainAssociatedComponentBackground() @@ -311,7 +313,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : override fun onInit(wizardModel: CoderWorkspacesWizardModel) { enableNextButtonCallback(false) if (localWizardModel.coderURL.isNotBlank() && localWizardModel.token.isNotBlank()) { - triggerWorkspacePolling() + triggerWorkspacePolling(true) } else { val url = appPropertiesService.getValue(CODER_URL_KEY) val token = appPropertiesService.getValue(SESSION_TOKEN) @@ -434,7 +436,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : this.indicator.fraction = 1.0 updateWorkspaceActions() - triggerWorkspacePolling() + triggerWorkspacePolling(false) } } @@ -465,10 +467,13 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : return tokenFromUser } - private fun triggerWorkspacePolling() { + private fun triggerWorkspacePolling(fetchNow: Boolean) { poller?.cancel() poller = cs.launch { + if (fetchNow) { + loadWorkspaces() + } while (isActive) { delay(5000) loadWorkspaces() From 2cab3281a771198cee408642203f78607623a9bf Mon Sep 17 00:00:00 2001 From: Asher Date: Thu, 2 Mar 2023 11:23:36 -0900 Subject: [PATCH 2/3] Clear on init as well Fixes the back button never being available. Plus it makes it so you have to wait for the next fetch which I think makes sense so you are not trying to connect with potentially stale data. --- .../com/coder/gateway/views/steps/CoderWorkspacesStepView.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt b/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt index 785d0aab..f24d9670 100644 --- a/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt +++ b/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt @@ -311,7 +311,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : } override fun onInit(wizardModel: CoderWorkspacesWizardModel) { - enableNextButtonCallback(false) + listTableModelOfWorkspaces.items = emptyList() if (localWizardModel.coderURL.isNotBlank() && localWizardModel.token.isNotBlank()) { triggerWorkspacePolling(true) } else { From e209bd3589354856d143c7f032f51e44f5986cea Mon Sep 17 00:00:00 2001 From: Asher Date: Thu, 2 Mar 2023 11:24:05 -0900 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09c5e1ee..508a85ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,16 @@ - support for Gateway 2023 +### Fixed + +- the "Select IDE and Project" button is no longer disabled for a time after + going back a step + +### Changed + +- initial authentication is now asynchronous which means no hang on the main + screen while that happens and it shows in the progress bar + ## 2.1.7 - 2023-02-28 ### Fixed