- Notifications
You must be signed in to change notification settings - Fork1
fix: update&start outdated workspaces#128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
e53595b
25e6c44
fd55a2c
db82812
02b60e8
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -3,6 +3,7 @@ package com.coder.toolbox | ||
import com.coder.toolbox.store.CoderSecretsStore | ||
import com.coder.toolbox.store.CoderSettingsStore | ||
import com.coder.toolbox.util.toURL | ||
import com.coder.toolbox.views.CoderPage | ||
import com.jetbrains.toolbox.api.core.diagnostics.Logger | ||
import com.jetbrains.toolbox.api.core.os.LocalDesktopManager | ||
import com.jetbrains.toolbox.api.localization.LocalizableStringFactory | ||
@@ -13,8 +14,10 @@ import com.jetbrains.toolbox.api.remoteDev.states.EnvironmentStateColorPalette | ||
import com.jetbrains.toolbox.api.remoteDev.ui.EnvironmentUiPageManager | ||
import com.jetbrains.toolbox.api.ui.ToolboxUi | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.delay | ||
import java.net.URL | ||
import java.util.UUID | ||
import kotlin.time.Duration.Companion.milliseconds | ||
@Suppress("UnstableApiUsage") | ||
data class CoderToolboxContext( | ||
@@ -88,4 +91,26 @@ data class CoderToolboxContext( | ||
i18n.ptrl("OK") | ||
) | ||
} | ||
/** | ||
* Forces the title bar on the main page to be refreshed | ||
*/ | ||
suspend fun refreshMainPage() { | ||
// the url/title on the main page is only refreshed if | ||
// we're navigating to the main env page from another page. | ||
// If TBX is already on the main page the title is not refreshed | ||
// hence we force a navigation from a blank page. | ||
ui.showUiPage(CoderPage.emptyPage(this)) | ||
// Toolbox uses an internal shared flow with a buffer of 4 items and a DROP_OLDEST strategy. | ||
// Both showUiPage and showPluginEnvironmentsPage send events to this flow. | ||
// If we emit two events back-to-back, the first one often gets dropped and only the second is shown. | ||
// To reduce this risk, we add a small delay to let the UI coroutine process the first event. | ||
// Simply yielding the coroutine isn't reliable, especially right after Toolbox starts via URI handling. | ||
// Based on my testing, a 5–10 ms delay is enough to ensure the blank page is processed, | ||
// while still short enough to be invisible to users. | ||
delay(10.milliseconds) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Could you add a comment for why we need to do a delay here for the uneducated? 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Thank you for the feedback, I've addressed it in the code, but here is a summary: From testing and decompiling the Toolbox code, it seems that TBX uses an internal shared flow with a buffer of 4 items and a DROP_OLDEST strategy. Both showUiPage and showPluginEnvironmentsPage send events to this flow. If we emit two events back-to-back, the first one often gets dropped and only the second is shown. To reduce this risk, we add a small delay to let the UI coroutine process the first event. Simply yielding the coroutine isn't reliable, especially right after Toolbox starts via URI handling. Based on my testing, a 5–10 ms delay is enough to ensure the blank page is processed, while still short enough to be invisible to users. In fact the whole thing is necessary because the url/title on the main page is only refreshed if we're navigating to the main env page from another page. If TBX is already on the main page the title is not refreshed hence we force a navigation from a blank page. We've raised a ticket in the past, once that is fixed the blank page workaround will no longer be needed and as a consequence the delay will be dropped as well. | ||
envPageManager.showPluginEnvironmentsPage() | ||
} | ||
} |
Uh oh!
There was an error while loading.Please reload this page.