Skip to content

Commit fcb9dc7

Browse files
authored
impl: workspace status reporting (color and icons) (#118)
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. - failed workspaces used to render a gray offline icon instead of a red warning (exclamation mark) sign. - 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 fcb9dc7

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
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 failed, 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: 22 additions & 8 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).
@@ -69,23 +72,34 @@ enum class WorkspaceAndAgentStatus(val label: String, val description: String) {
6972
}
7073

7174
private fun getStateColor(context: CoderToolboxContext): StateColor {
72-
return if (ready()) context.envStateColorPalette.getColor(StandardRemoteEnvironmentState.Active)
73-
else if (unhealthy()) context.envStateColorPalette.getColor(StandardRemoteEnvironmentState.Unhealthy)
74-
else if (canStart()) context.envStateColorPalette.getColor(StandardRemoteEnvironmentState.Failed)
75-
else if (pending()) context.envStateColorPalette.getColor(StandardRemoteEnvironmentState.Activating)
75+
return if (this == FAILED) context.envStateColorPalette.getColor(StandardRemoteEnvironmentState.FailedToStart)
7676
else if (this == DELETING) context.envStateColorPalette.getColor(StandardRemoteEnvironmentState.Deleting)
7777
else if (this == DELETED) context.envStateColorPalette.getColor(StandardRemoteEnvironmentState.Deleted)
78+
else if (ready()) context.envStateColorPalette.getColor(StandardRemoteEnvironmentState.Active)
79+
else if (unhealthy()) context.envStateColorPalette.getColor(StandardRemoteEnvironmentState.Unhealthy)
80+
else if (canStart() || this == STOPPING) context.envStateColorPalette.getColor(StandardRemoteEnvironmentState.Hibernating)
81+
else if (pending()) context.envStateColorPalette.getColor(StandardRemoteEnvironmentState.Activating)
7882
else context.envStateColorPalette.getColor(StandardRemoteEnvironmentState.Unreachable)
7983
}
8084

8185
private fun getStateIcon(): EnvironmentStateIcons {
82-
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+
return if (this == FAILED) EnvironmentStateIcons.Error
87+
else if (pending() || this == DELETING || this == DELETED || this == STOPPING) CircularSpinner
88+
else if (ready() || unhealthy()) EnvironmentStateIcons.Active
89+
else if (canStart()) EnvironmentStateIcons.Offline
8690
else EnvironmentStateIcons.NoIcon
8791
}
8892

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy