Skip to content

Commit e4ce4c4

Browse files
authored
fix: url refresh after switching deployments (#119)
The main env header page API is quite limiting, in the sense that the title is never allowed to change. Today we display the Coder URL as the title. However, if the user switches between two deployments via log out and then log in, the URL is never refreshed, leading to a confusing UI (URL is old, while workspaces are from the new deployment) JetBrains suggested a workaround in https://youtrack.jetbrains.com/issue/TBX-14421/ by creating a new env page instance with the updated title after each deployment switch. In which case Toolbox redraws the main screen when page state changes. I tested the workaround and indeed it works but with a caveat. The new env page is refreshed only when Toolbox window page is made visible or when navigating from main env page to a single env page and then back to the main page. For some reason, if we call envPageManager.showPluginEnvironmentsPage()`` from the authentication page displayed in getOverrideUiPage() it doesn't trigger the new env refresh giving the false impression that the URL won't change. In fact this was the reason why I missed this workaround in previously. It is interesting that if I first navigate to a blank page - toolboxUi.showUiPage(emptyPage) - and then immediately call envPageManager.showPluginEnvironmentsPage(), doing this rapid sequence seems to do the trick without any visible artifacts (it happens so fast that we can't see the blank page being rendered) - resolves #66
1 parent fcb9dc7 commit e4ce4c4

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
- improved workspace status reporting (icon and colors) when it is failed, stopping, deleting, stopped or when we are
88
establishing the SSH connection.
99

10-
## 0.2.2 - 2025-05-21
10+
### Fixed
1111

12-
### Added
12+
- url on the main page is now refreshed when switching between multiple deployments (via logout/login or URI handling)
13+
14+
## 0.2.2 - 2025-05-21
1315

1416
- render network status in the Settings tab, under `Additional environment information` section.
1517
- quick action for creating new workspaces from the web dashboard.

src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.coder.toolbox.util.DialogUi
99
import com.coder.toolbox.util.withPath
1010
import com.coder.toolbox.views.Action
1111
import com.coder.toolbox.views.AuthWizardPage
12+
import com.coder.toolbox.views.CoderPage
1213
import com.coder.toolbox.views.CoderSettingsPage
1314
import com.coder.toolbox.views.NewEnvironmentPage
1415
import com.coder.toolbox.views.state.AuthWizardState
@@ -340,7 +341,9 @@ class CoderRemoteProvider(
340341
this.client = client
341342
pollJob?.cancel()
342343
environments.showLoadingMessage()
344+
coderHeaderPage = NewEnvironmentPage(context, context.i18n.pnotr(client.url.toString()))
343345
pollJob = poll(client, cli)
346+
context.ui.showUiPage(CoderPage.emptyPage(context))
344347
goToEnvironmentsPage()
345348
}
346349

src/main/kotlin/com/coder/toolbox/views/CoderPage.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ abstract class CoderPage(
5353
)
5454
}
5555
}
56+
57+
companion object {
58+
fun emptyPage(ctx: CoderToolboxContext): UiPage = UiPage(ctx.i18n.pnotr(""))
59+
}
5660
}
5761

5862
/**

0 commit comments

Comments
 (0)