Skip to content

Commit 203db88

Browse files
committed
impl: workspace status reporting (color and icons)
There were a couple of discrepancies in the status reporting especially around icons and colors: - offline workspaces are marked by a new "offline" icon and a gray color (instead of a half pie icon with a red color) - stopping state now has a gray progress spinner - same for deleting state which previously used the offline icon instead of the spinner. - there was no progress while establishing the SSH connection. Now we have a "SSHing" label with a circular progress bar while connecting to the SSH.
1 parent dd2166f commit 203db88

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

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+
- improved workspace status reporting (icon and colors) when it is stopping, deleting, stopped or when we are
8+
establishing the SSH connection.
9+
510
## 0.2.2 - 2025-05-21
611

712
### Added

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ class CoderRemoteEnvironment(
157157

158158
override fun beforeConnection() {
159159
context.logger.info("Connecting to $id...")
160+
context.cs.launch {
161+
state.update {
162+
wsRawStatus.toSshConnectingEnvState(context)
163+
}
164+
}
160165
isConnected.update { true }
161166
pollJob = pollNetworkMetrics()
162167
}

src/main/kotlin/com/coder/toolbox/models/WorkspaceAndAgentStatus.kt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import com.jetbrains.toolbox.api.remoteDev.states.CustomRemoteEnvironmentState
1111
import com.jetbrains.toolbox.api.remoteDev.states.EnvironmentStateIcons
1212
import com.jetbrains.toolbox.api.remoteDev.states.StandardRemoteEnvironmentState
1313

14+
15+
private val CircularSpinner: EnvironmentStateIcons = EnvironmentStateIcons.Connecting
16+
1417
/**
1518
* WorkspaceAndAgentStatus represents the combined status of a single agent and
1619
* its workspace (or just the workspace if there are no agents).
@@ -71,7 +74,7 @@ enum class WorkspaceAndAgentStatus(val label: String, val description: String) {
7174
private fun getStateColor(context: CoderToolboxContext): StateColor {
7275
return if (ready()) context.envStateColorPalette.getColor(StandardRemoteEnvironmentState.Active)
7376
else if (unhealthy()) context.envStateColorPalette.getColor(StandardRemoteEnvironmentState.Unhealthy)
74-
else if (canStart()) context.envStateColorPalette.getColor(StandardRemoteEnvironmentState.Failed)
77+
else if (canStart() || this == STOPPING) context.envStateColorPalette.getColor(StandardRemoteEnvironmentState.Hibernating)
7578
else if (pending()) context.envStateColorPalette.getColor(StandardRemoteEnvironmentState.Activating)
7679
else if (this == DELETING) context.envStateColorPalette.getColor(StandardRemoteEnvironmentState.Deleting)
7780
else if (this == DELETED) context.envStateColorPalette.getColor(StandardRemoteEnvironmentState.Deleted)
@@ -80,12 +83,21 @@ enum class WorkspaceAndAgentStatus(val label: String, val description: String) {
8083

8184
private fun getStateIcon(): EnvironmentStateIcons {
8285
return if (ready() || unhealthy()) EnvironmentStateIcons.Active
83-
else if (canStart()) EnvironmentStateIcons.Hibernated
84-
else if (pending()) EnvironmentStateIcons.Connecting
85-
else if (this == DELETING || this == DELETED) EnvironmentStateIcons.Offline
86+
else if (canStart()) EnvironmentStateIcons.Offline
87+
else if (pending() || this == DELETING || this == DELETED || this == STOPPING) CircularSpinner
8688
else EnvironmentStateIcons.NoIcon
8789
}
8890

91+
fun toSshConnectingEnvState(context: CoderToolboxContext): CustomRemoteEnvironmentState {
92+
val existingState = toRemoteEnvironmentState(context)
93+
return CustomRemoteEnvironmentState(
94+
"SSHing",
95+
existingState.color,
96+
existingState.isReachable,
97+
EnvironmentStateIcons.Connecting
98+
)
99+
}
100+
89101
/**
90102
* Return true if the agent is in a connectable state.
91103
*/

0 commit comments

Comments
 (0)