Skip to content

Commit 6ab431e

Browse files
authored
impl: poll workspaces when Toolbox screen becomes visible (#176)
Some users complained that Coder Toolbox has a noticeable delay in rendering the workspaces status compared with the web Dashboard, even though they have the same polling frequency, which is every 5 seconds. However, the web Dashboard also reacts and when the tab receives focus from the user which improves the experience. This PR tries to implement the same behavior, when Coder Toolbox screen becomes visible the polling is triggered immediately which should result in a status update.
1 parent fc97059 commit 6ab431e

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Changed
6+
7+
- workspaces status is now refresh every time Coder Toolbox becomes visible
8+
59
## 0.6.2 - 2025-08-14
610

711
### Changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
version=0.6.2
1+
version=0.6.3
22
group=com.coder.toolbox
33
name=coder-toolbox

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ class CoderRemoteProvider(
5454

5555
private val settings = context.settingsStore.readOnly()
5656

57-
// Create our services from the Toolbox ones.
5857
private val triggerSshConfig = Channel<Boolean>(Channel.CONFLATED)
58+
private val triggerProviderVisible = Channel<Boolean>(Channel.CONFLATED)
5959
private val settingsPage: CoderSettingsPage = CoderSettingsPage(context, triggerSshConfig)
6060
private val dialogUi = DialogUi(context)
6161

@@ -177,14 +177,19 @@ class CoderRemoteProvider(
177177

178178
select {
179179
onTimeout(POLL_INTERVAL) {
180-
context.logger.trace("workspace poller waked up by the $POLL_INTERVAL timeout")
180+
context.logger.debug("workspace poller waked up by the $POLL_INTERVAL timeout")
181181
}
182182
triggerSshConfig.onReceive { shouldTrigger ->
183183
if (shouldTrigger) {
184-
context.logger.trace("workspace poller waked up because it should reconfigure the ssh configurations")
184+
context.logger.debug("workspace poller waked up because it should reconfigure the ssh configurations")
185185
cli.configSsh(lastEnvironments.map { it.asPairOfWorkspaceAndAgent() }.toSet())
186186
}
187187
}
188+
triggerProviderVisible.onReceive { isCoderProviderVisible ->
189+
if (isCoderProviderVisible) {
190+
context.logger.debug("workspace poller waked up by Coder Toolbox which is currently visible, fetching latest workspace statuses")
191+
}
192+
}
188193
}
189194
lastPollTime = TimeSource.Monotonic.markNow()
190195
}
@@ -293,6 +298,11 @@ class CoderRemoteProvider(
293298
visibilityState.update {
294299
visibility
295300
}
301+
if (visibility.providerVisible) {
302+
context.cs.launch {
303+
triggerProviderVisible.send(true)
304+
}
305+
}
296306
}
297307

298308
/**

0 commit comments

Comments
 (0)