Skip to content

Commit 081ba79

Browse files
authored
fix: derive deployment target from workspace agent OS (#347)
Overrides WithDeploymentSettings to map the agent's reported operating system to a DeploymentTarget, falling back to AUTO when unknown. This would "relieve" most of the pressure on Toolbox to determine the remote environment OS before starting to deploy the TBX agent, and of course that leaves less room for error.
1 parent 5d00b11 commit 081ba79

3 files changed

Lines changed: 26 additions & 2 deletions

File tree

‎CHANGELOG.md‎

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

33
## Unreleased
44

5+
### Changed
6+
7+
- deployment target OS is now derived from the workspace agent's reported OS, falling back to automatic detection when
8+
unknown
9+
510
## 0.9.2 - 2026-08-06
611

712
### Fixed

‎gradle.properties‎

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

‎src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import com.coder.toolbox.sdk.ex.APIResponseException
1010
import com.coder.toolbox.sdk.v2.models.NetworkMetrics
1111
import com.coder.toolbox.sdk.v2.models.Workspace
1212
import com.coder.toolbox.sdk.v2.models.WorkspaceAgent
13+
import com.coder.toolbox.util.OS
1314
import com.coder.toolbox.util.waitForFalseWithTimeout
1415
import com.coder.toolbox.util.withPath
1516
import com.coder.toolbox.views.Action
@@ -21,7 +22,10 @@ import com.jetbrains.toolbox.api.remoteDev.AfterDisconnectHook
2122
import com.jetbrains.toolbox.api.remoteDev.BeforeConnectionHook
2223
import com.jetbrains.toolbox.api.remoteDev.EnvironmentVisibilityState
2324
import com.jetbrains.toolbox.api.remoteDev.RemoteProviderEnvironment
25+
import com.jetbrains.toolbox.api.remoteDev.deploy.DeploymentSettings
26+
import com.jetbrains.toolbox.api.remoteDev.deploy.DeploymentTarget
2427
import com.jetbrains.toolbox.api.remoteDev.environments.EnvironmentContentsView
28+
import com.jetbrains.toolbox.api.remoteDev.environments.WithDeploymentSettings
2529
import com.jetbrains.toolbox.api.remoteDev.states.EnvironmentDescription
2630
import com.jetbrains.toolbox.api.remoteDev.states.RemoteEnvironmentState
2731
import com.jetbrains.toolbox.api.ui.actions.ActionDescription
@@ -48,6 +52,13 @@ private val POLL_INTERVAL = 5.seconds
4852
private fun environmentId(workspace: Workspace, agent: WorkspaceAgent?): String =
4953
agent?.let { "${workspace.name}.${it.name}" } ?: workspace.name
5054

55+
private fun OS?.toDeploymentTarget(): DeploymentTarget = when (this) {
56+
OS.LINUX -> DeploymentTarget.LINUX
57+
OS.MAC -> DeploymentTarget.MACOS
58+
OS.WINDOWS -> DeploymentTarget.WINDOWS
59+
else -> DeploymentTarget.AUTO
60+
}
61+
5162
/**
5263
* Represents a workspace, or a workspace and agent combination when an agent is available.
5364
*
@@ -60,7 +71,8 @@ class CoderRemoteEnvironment(
6071
private val workspaceRefreshTrigger: Channel<Boolean>,
6172
private var workspace: Workspace,
6273
private var agent: WorkspaceAgent?,
63-
) : RemoteProviderEnvironment(environmentId(workspace, agent)), BeforeConnectionHook, AfterDisconnectHook {
74+
) : RemoteProviderEnvironment(environmentId(workspace, agent)), BeforeConnectionHook, AfterDisconnectHook,
75+
WithDeploymentSettings {
6476
private var environmentStatus = WorkspaceAndAgentStatus.from(workspace, agent)
6577

6678
override var name: String = environmentId(workspace, agent)
@@ -74,6 +86,13 @@ class CoderRemoteEnvironment(
7486
override val additionalEnvironmentInformation: MutableMap<LocalizableString, String> = mutableMapOf()
7587
override val actionsList: MutableStateFlow<List<ActionDescription>> = MutableStateFlow(emptyList())
7688

89+
/**
90+
* Derives the deployment target from the agent's reported OS, falling back to
91+
* AUTO (automatic remote OS detection) when the agent or its OS is unknown.
92+
*/
93+
override val deploymentSettings: DeploymentSettings
94+
get() = DeploymentSettings.Default.copy(deploymentTarget = agent?.operatingSystem.toDeploymentTarget())
95+
7796
private val networkMetricsMarshaller = Moshi.Builder().build().adapter(NetworkMetrics::class.java)
7897
private val proxyCommandHandle = SshCommandProcessHandle(context)
7998
private var pollJob: Job? = null

0 commit comments

Comments
 (0)