Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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.
  • Loading branch information
code-asher committed Mar 2, 2023
commit 972a386cca300a1a0ba1ea1ee5802df92496bbbe
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -434,7 +436,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :

this.indicator.fraction = 1.0
updateWorkspaceActions()
triggerWorkspacePolling()
triggerWorkspacePolling(false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really see the harm in requesting the workspaces a bit earlier.

}
}

Expand Down Expand Up @@ -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()
Expand Down