Skip to content

Commit 21a703d

Browse files
committed
Fix: use agent's home directory if available
- the project text field in the IDEs&Project panel is filled with `/home/coder/workspace` value. - the home directory depends on the workspace template and the correct value can be found on the WorkspaceAgent data model - if the value is missing from the agent - the code should not assume that coder/workspace exists. - resolves #27
1 parent 2edaf7c commit 21a703d

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

src/main/kotlin/com/coder/gateway/models/WorkspaceAgentModel.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ data class WorkspaceAgentModel(
1212
val buildTransition: WorkspaceBuildTransition,
1313

1414
val agentOS: OS?,
15-
val agentArch: Arch?
15+
val agentArch: Arch?,
16+
val homeDirectory: String?
1617
)

src/main/kotlin/com/coder/gateway/sdk/v2/models/WorkspaceAgent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ data class WorkspaceAgent(
1919
@SerializedName("environment_variables") val envVariables: Map<String, String>,
2020
@SerializedName("operating_system") val operatingSystem: String,
2121
@SerializedName("startup_script") val startupScript: String,
22-
@SerializedName("directory") val directory: String,
22+
@SerializedName("directory") val directory: String?,
2323
@SerializedName("apps") val apps: List<WorkspaceApp>
2424
)

src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,7 @@ class CoderLocateRemoteProjectStepView(private val disableNextAction: () -> Unit
8282
label("Project directory:")
8383
tfProject = textField()
8484
.resizableColumn()
85-
.horizontalAlign(HorizontalAlign.FILL)
86-
.applyToComponent {
87-
this.text = "/home/coder/workspace/"
88-
}.component
85+
.horizontalAlign(HorizontalAlign.FILL).component
8986
cell()
9087
}.topGap(TopGap.NONE).bottomGap(BottomGap.NONE).layout(RowLayout.PARENT_GRID)
9188
row {
@@ -111,6 +108,7 @@ class CoderLocateRemoteProjectStepView(private val disableNextAction: () -> Unit
111108
return
112109
}
113110

111+
tfProject.text = if (selectedWorkspace.homeDirectory.isNullOrBlank()) "/home" else selectedWorkspace.homeDirectory
114112
titleLabel.text = CoderGatewayBundle.message("gateway.connector.view.coder.remoteproject.choose.text", selectedWorkspace.name)
115113
terminalLink.url = "${coderClient.coderURL}/@${coderClient.me.username}/${selectedWorkspace.name}.coder/terminal"
116114

src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ class CoderWorkspacesStepView : CoderWorkspacesWizardStep, Disposable {
7373
workspace.latestBuild.job.status,
7474
workspace.latestBuild.workspaceTransition,
7575
OS.from(agent.operatingSystem),
76-
Arch.from(agent.architecture)
77-
76+
Arch.from(agent.architecture),
77+
agent.directory
7878
)
7979
}
8080
}

0 commit comments

Comments
 (0)