Skip to content

Commit 5bb8241

Browse files
committed
chore: remove workaround related to url refreshing
With the new API we don't need to generate a new page with a new title (the deployment URL) so we can remove the existing workaround that triggered a redraw of the new UI page.
1 parent c75289b commit 5bb8241

File tree

2 files changed

+1
-26
lines changed

2 files changed

+1
-26
lines changed

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

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.coder.toolbox
33
import com.coder.toolbox.store.CoderSecretsStore
44
import com.coder.toolbox.store.CoderSettingsStore
55
import com.coder.toolbox.util.toURL
6-
import com.coder.toolbox.views.CoderPage
76
import com.jetbrains.toolbox.api.core.diagnostics.Logger
87
import com.jetbrains.toolbox.api.core.os.LocalDesktopManager
98
import com.jetbrains.toolbox.api.localization.LocalizableStringFactory
@@ -14,10 +13,8 @@ import com.jetbrains.toolbox.api.remoteDev.states.EnvironmentStateColorPalette
1413
import com.jetbrains.toolbox.api.remoteDev.ui.EnvironmentUiPageManager
1514
import com.jetbrains.toolbox.api.ui.ToolboxUi
1615
import kotlinx.coroutines.CoroutineScope
17-
import kotlinx.coroutines.delay
1816
import java.net.URL
1917
import java.util.UUID
20-
import kotlin.time.Duration.Companion.milliseconds
2118

2219
@Suppress("UnstableApiUsage")
2320
data class CoderToolboxContext(
@@ -91,26 +88,4 @@ data class CoderToolboxContext(
9188
i18n.ptrl("OK")
9289
)
9390
}
94-
95-
/**
96-
* Forces the title bar on the main page to be refreshed
97-
*/
98-
suspend fun refreshMainPage() {
99-
// the url/title on the main page is only refreshed if
100-
// we're navigating to the main env page from another page.
101-
// If TBX is already on the main page the title is not refreshed
102-
// hence we force a navigation from a blank page.
103-
ui.showUiPage(CoderPage.emptyPage(this))
104-
105-
106-
// Toolbox uses an internal shared flow with a buffer of 4 items and a DROP_OLDEST strategy.
107-
// Both showUiPage and showPluginEnvironmentsPage send events to this flow.
108-
// If we emit two events back-to-back, the first one often gets dropped and only the second is shown.
109-
// To reduce this risk, we add a small delay to let the UI coroutine process the first event.
110-
// Simply yielding the coroutine isn't reliable, especially right after Toolbox starts via URI handling.
111-
// Based on my testing, a 5–10 ms delay is enough to ensure the blank page is processed,
112-
// while still short enough to be invisible to users.
113-
delay(10.milliseconds)
114-
envPageManager.showPluginEnvironmentsPage()
115-
}
11691
}

src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ open class CoderProtocolHandler(
7272
try {
7373
markAsBusy()
7474
reInitialize(restClient, cli)
75-
context.refreshMainPage()
75+
context.envPageManager.showPluginEnvironmentsPage()
7676
if (!prepareWorkspace(workspace, restClient, workspaceName, deploymentURL)) return
7777
// we resolve the agent after the workspace is started otherwise we can get misleading
7878
// errors like: no agent available while workspace is starting or stopping

0 commit comments

Comments
 (0)