Skip to content

Commit f12352b

Browse files
authored
fix: render account name immediately after login (#244)
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.
1 parent 22b6813 commit f12352b

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Fixed
66

77
- mTLS certificate refresh and http request retrying logic
8+
- account name is now rendered immediately after login
89

910
## 0.8.2 - 2026-01-06
1011

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ import java.util.concurrent.atomic.AtomicBoolean
5151
import kotlin.coroutines.cancellation.CancellationException
5252
import kotlin.time.Duration.Companion.seconds
5353
import kotlin.time.TimeSource
54-
import com.jetbrains.toolbox.api.ui.components.AccountDropdownField as DropDownMenu
5554
import com.jetbrains.toolbox.api.ui.components.AccountDropdownField as dropDownFactory
5655

5756
private val POLL_INTERVAL = 5.seconds
@@ -102,6 +101,10 @@ class CoderRemoteProvider(
102101
override val environments: MutableStateFlow<LoadableState<List<CoderRemoteEnvironment>>> = MutableStateFlow(
103102
LoadableState.Loading
104103
)
104+
private val accountDropdownField = dropDownFactory(context.i18n.pnotr("")) {
105+
logout()
106+
context.envPageManager.showPluginEnvironmentsPage()
107+
}
105108

106109
private val errorBuffer = mutableListOf<Throwable>()
107110

@@ -229,16 +232,7 @@ class CoderRemoteProvider(
229232
/**
230233
* A dropdown that appears at the top of the environment list to the right.
231234
*/
232-
override fun getAccountDropDown(): DropDownMenu? {
233-
val username = client?.me?.username
234-
if (username != null) {
235-
return dropDownFactory(context.i18n.pnotr(username)) {
236-
logout()
237-
context.envPageManager.showPluginEnvironmentsPage()
238-
}
239-
}
240-
return null
241-
}
235+
override fun getAccountDropDown() = accountDropdownField
242236

243237
override val additionalPluginActions: StateFlow<List<ActionDescription>> = MutableStateFlow(
244238
listOf(
@@ -528,11 +522,15 @@ class CoderRemoteProvider(
528522
this.cli = cli
529523
environments.showLoadingMessage()
530524
if (context.settingsStore.useAppNameAsTitle) {
525+
context.logger.info("Displaying ${client.appName} as main page title")
531526
coderHeaderPage.setTitle(context.i18n.pnotr(client.appName))
532527
} else {
528+
context.logger.info("Displaying ${client.url} as main page title")
533529
coderHeaderPage.setTitle(context.i18n.pnotr(client.url.toString()))
534530
}
535-
context.logger.info("Displaying ${client.url} in the UI")
531+
accountDropdownField.labelState.update {
532+
context.i18n.pnotr(client.me.username)
533+
}
536534
pollJob = poll(client, cli)
537535
context.logger.info("Workspace poll job with name ${pollJob.toString()} was created")
538536
}

0 commit comments

Comments
 (0)