From 3a03b585383fa7f55e0614f29e3eabcaba0494e9 Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Wed, 14 Jan 2026 00:11:01 +0200 Subject: [PATCH] fix: render account name immediately after login In the top right corner of the main page there is a dropdown rendering the username. In the recent versions of Toolbox the dropdown is built before we initialize the http client and resolve the username. The fix consists on building the dropdown field with empty data and then push the username label as soon as the user connected. --- CHANGELOG.md | 1 + .../com/coder/toolbox/CoderRemoteProvider.kt | 22 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9aa647f..283a608 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixed - mTLS certificate refresh and http request retrying logic +- account name is now rendered immediately after login ## 0.8.2 - 2026-01-06 diff --git a/src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt b/src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt index 4e85d99..2e2d5f3 100644 --- a/src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt +++ b/src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt @@ -51,7 +51,6 @@ import java.util.concurrent.atomic.AtomicBoolean import kotlin.coroutines.cancellation.CancellationException import kotlin.time.Duration.Companion.seconds import kotlin.time.TimeSource -import com.jetbrains.toolbox.api.ui.components.AccountDropdownField as DropDownMenu import com.jetbrains.toolbox.api.ui.components.AccountDropdownField as dropDownFactory private val POLL_INTERVAL = 5.seconds @@ -102,6 +101,10 @@ class CoderRemoteProvider( override val environments: MutableStateFlow>> = MutableStateFlow( LoadableState.Loading ) + private val accountDropdownField = dropDownFactory(context.i18n.pnotr("")) { + logout() + context.envPageManager.showPluginEnvironmentsPage() + } private val errorBuffer = mutableListOf() @@ -229,16 +232,7 @@ class CoderRemoteProvider( /** * A dropdown that appears at the top of the environment list to the right. */ - override fun getAccountDropDown(): DropDownMenu? { - val username = client?.me?.username - if (username != null) { - return dropDownFactory(context.i18n.pnotr(username)) { - logout() - context.envPageManager.showPluginEnvironmentsPage() - } - } - return null - } + override fun getAccountDropDown() = accountDropdownField override val additionalPluginActions: StateFlow> = MutableStateFlow( listOf( @@ -528,11 +522,15 @@ class CoderRemoteProvider( this.cli = cli environments.showLoadingMessage() if (context.settingsStore.useAppNameAsTitle) { + context.logger.info("Displaying ${client.appName} as main page title") coderHeaderPage.setTitle(context.i18n.pnotr(client.appName)) } else { + context.logger.info("Displaying ${client.url} as main page title") coderHeaderPage.setTitle(context.i18n.pnotr(client.url.toString())) } - context.logger.info("Displaying ${client.url} in the UI") + accountDropdownField.labelState.update { + context.i18n.pnotr(client.me.username) + } pollJob = poll(client, cli) context.logger.info("Workspace poll job with name ${pollJob.toString()} was created") }