Skip to content

Commit aa24f03

Browse files
committed
fix: compiler errors (1)
- due to new API for remote environment model
1 parent 7a6b512 commit aa24f03

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import com.jetbrains.toolbox.api.remoteDev.states.EnvironmentStateConsumer
1616
import com.jetbrains.toolbox.api.ui.ToolboxUi
1717
import kotlinx.coroutines.CoroutineScope
1818
import kotlinx.coroutines.launch
19-
import java.util.concurrent.CompletableFuture
2019

2120
/**
2221
* Represents an agent and workspace combination.
@@ -29,12 +28,12 @@ class CoderRemoteEnvironment(
2928
private var workspace: Workspace,
3029
private var agent: WorkspaceAgent,
3130
private var cs: CoroutineScope,
32-
) : AbstractRemoteProviderEnvironment() {
31+
) : AbstractRemoteProviderEnvironment("${workspace.name}.${agent.name}") {
3332
private var status = WorkspaceAndAgentStatus.from(workspace, agent)
3433

3534
private val ui: ToolboxUi = serviceLocator.getService(ToolboxUi::class.java)
36-
override fun getId(): String = "${workspace.name}.${agent.name}"
37-
override fun getName(): String = "${workspace.name}.${agent.name}"
35+
36+
override var name: String = "${workspace.name}.${agent.name}"
3837

3938
init {
4039
actionsList.add(
@@ -105,12 +104,11 @@ class CoderRemoteEnvironment(
105104
* The contents are provided by the SSH view provided by Toolbox, all we
106105
* have to do is provide it a host name.
107106
*/
108-
override fun getContentsView(): CompletableFuture<EnvironmentContentsView> =
109-
CompletableFuture.completedFuture(EnvironmentView(client.url, workspace, agent))
107+
override suspend fun getContentsView(): EnvironmentContentsView = EnvironmentView(client.url, workspace, agent)
110108

111109
/**
112-
* Does nothing. In theory we could do something like start the workspace
113-
* when you click into the workspace but you would still need to press
110+
* Does nothing. In theory, we could do something like start the workspace
111+
* when you click into the workspace, but you would still need to press
114112
* "connect" anyway before the content is populated so there does not seem
115113
* to be much value.
116114
*/
@@ -140,12 +138,12 @@ class CoderRemoteEnvironment(
140138
if (other == null) return false
141139
if (this === other) return true // Note the triple ===
142140
if (other !is CoderRemoteEnvironment) return false
143-
if (getId() != other.getId()) return false
141+
if (id != other.id) return false
144142
return true
145143
}
146144

147145
/**
148146
* Companion to equals, for sets.
149147
*/
150-
override fun hashCode(): Int = getId().hashCode()
148+
override fun hashCode(): Int = id.hashCode()
151149
}

src/main/kotlin/com/coder/toolbox/browser/BrowserUtil.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import org.zeroturnaround.exec.ProcessExecutor
66

77
class BrowserUtil {
88
companion object {
9-
fun browse(url: String, errorHandler: (BrowserException) -> Unit) {
9+
suspend fun browse(url: String, errorHandler: suspend (BrowserException) -> Unit) {
1010
val os = getOS()
1111
if (os == null) {
1212
errorHandler(BrowserException("Failed to open the URL because we can't detect the OS"))
@@ -19,7 +19,7 @@ class BrowserUtil {
1919
}
2020
}
2121

22-
private fun linuxBrowse(url: String, errorHandler: (BrowserException) -> Unit) {
22+
private suspend fun linuxBrowse(url: String, errorHandler: suspend (BrowserException) -> Unit) {
2323
try {
2424
if (OS.LINUX.getDesktopEnvironment()?.uppercase()?.contains("GNOME") == true) {
2525
exec("gnome-open", url)
@@ -36,15 +36,15 @@ class BrowserUtil {
3636
}
3737
}
3838

39-
private fun macBrowse(url: String, errorHandler: (BrowserException) -> Unit) {
39+
private suspend fun macBrowse(url: String, errorHandler: suspend (BrowserException) -> Unit) {
4040
try {
4141
exec("open", url)
4242
} catch (e: Exception) {
4343
errorHandler(BrowserException("Failed to open URL because an error was encountered.", e))
4444
}
4545
}
4646

47-
private fun windowsBrowse(url: String, errorHandler: (BrowserException) -> Unit) {
47+
private suspend fun windowsBrowse(url: String, errorHandler: suspend (BrowserException) -> Unit) {
4848
try {
4949
exec("cmd", "start \"$url\"")
5050
} catch (e: Exception) {

0 commit comments

Comments
 (0)