Skip to content

Commit 81a9ff6

Browse files
committed
impl: poll workspaces when Toolbox screen becomes visible
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 81a9ff6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
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

@@ -185,6 +185,11 @@ class CoderRemoteProvider(
185185
cli.configSsh(lastEnvironments.map { it.asPairOfWorkspaceAndAgent() }.toSet())
186186
}
187187
}
188+
triggerProviderVisible.onReceive { isCoderProviderVisible ->
189+
if (isCoderProviderVisible) {
190+
context.logger.info("workspace poller waked up, Coder Toolbox 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)