Skip to content

Commit 282a2de

Browse files
committed
fix: improve ssh config logic when workspaces change
- previously, ssh reconfiguration was triggered only when new workspaces were added, and the ssh config was generated only with the additional environments removing the configuration for the previous ones. This means that when a new workspace is created from the web dashboard, the old workspaces are no longer accessible via ssh from Toolbox - now, the logic ensures ssh reconfiguration happens whenever the set of environments changes (including additions or removals), making it more robust, and configuration happens for all valid workspaces. - resolves #14
1 parent 0968cbf commit 282a2de

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

CHANGELOG.md

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

33
## Unreleased
44

5+
### Fixed
6+
7+
- SSH config is regenerated correctly when Workspaces are added or removed
8+
59
## 0.1.0 - 2025-04-01
610

711
### Added

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,11 @@ class CoderRemoteProvider(
113113
return@launch
114114
}
115115

116-
// Reconfigure if a new environment is found.
117-
// TODO@JB: Should we use the add/remove listeners instead?
118-
val newEnvironments = resolvedEnvironments.subtract(lastEnvironments)
119-
if (newEnvironments.isNotEmpty()) {
120-
context.logger.info("Found new environment(s), reconfiguring CLI: $newEnvironments")
121-
cli.configSsh(newEnvironments.map { it.name }.toSet())
116+
117+
// Reconfigure if environments changed.
118+
if (lastEnvironments.size != resolvedEnvironments.size || lastEnvironments != resolvedEnvironments) {
119+
context.logger.info("Workspaces have changed, reconfiguring CLI: $resolvedEnvironments")
120+
cli.configSsh(resolvedEnvironments.map { it.name }.toSet())
122121
}
123122

124123
environments.update {

0 commit comments

Comments
 (0)