Skip to content

impl: poll workspaces when Toolbox screen becomes visible #176

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Changed

- workspaces status is now refresh every time Coder Toolbox becomes visible

## 0.6.2 - 2025-08-14

### Changed
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=0.6.2
version=0.6.3
group=com.coder.toolbox
name=coder-toolbox
16 changes: 13 additions & 3 deletions src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class CoderRemoteProvider(

private val settings = context.settingsStore.readOnly()

// Create our services from the Toolbox ones.
private val triggerSshConfig = Channel<Boolean>(Channel.CONFLATED)
private val triggerProviderVisible = Channel<Boolean>(Channel.CONFLATED)
private val settingsPage: CoderSettingsPage = CoderSettingsPage(context, triggerSshConfig)
private val dialogUi = DialogUi(context)

Expand Down Expand Up @@ -177,14 +177,19 @@ class CoderRemoteProvider(

select {
onTimeout(POLL_INTERVAL) {
context.logger.trace("workspace poller waked up by the $POLL_INTERVAL timeout")
context.logger.debug("workspace poller waked up by the $POLL_INTERVAL timeout")
}
triggerSshConfig.onReceive { shouldTrigger ->
if (shouldTrigger) {
context.logger.trace("workspace poller waked up because it should reconfigure the ssh configurations")
context.logger.debug("workspace poller waked up because it should reconfigure the ssh configurations")
cli.configSsh(lastEnvironments.map { it.asPairOfWorkspaceAndAgent() }.toSet())
}
}
triggerProviderVisible.onReceive { isCoderProviderVisible ->
if (isCoderProviderVisible) {
context.logger.debug("workspace poller waked up by Coder Toolbox which is currently visible, fetching latest workspace statuses")
}
}
}
lastPollTime = TimeSource.Monotonic.markNow()
}
Expand Down Expand Up @@ -293,6 +298,11 @@ class CoderRemoteProvider(
visibilityState.update {
visibility
}
if (visibility.providerVisible) {
context.cs.launch {
triggerProviderVisible.send(true)
}
}
}

/**
Expand Down
Loading