From 0968cbfddbd4ce4a8b2e6d60bd1ac9c1884be758 Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Wed, 2 Apr 2025 22:09:47 +0300 Subject: [PATCH 1/2] refactor: simplify equals implementation --- src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt b/src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt index 62fe4bb..8319cdc 100644 --- a/src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt +++ b/src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt @@ -194,10 +194,9 @@ class CoderRemoteEnvironment( */ override fun equals(other: Any?): Boolean { if (other == null) return false - if (this === other) return true // Note the triple === + if (this === other) return true if (other !is CoderRemoteEnvironment) return false - if (id != other.id) return false - return true + return id == other.id } /** From 282a2decf8bef8f48224cb755c0ee4d855ba5be7 Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Wed, 2 Apr 2025 22:37:36 +0300 Subject: [PATCH 2/2] 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 --- CHANGELOG.md | 4 ++++ .../kotlin/com/coder/toolbox/CoderRemoteProvider.kt | 11 +++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8988ddb..cd981fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Fixed + +- SSH config is regenerated correctly when Workspaces are added or removed + ## 0.1.0 - 2025-04-01 ### Added diff --git a/src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt b/src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt index fef85ff..4ce1bc7 100644 --- a/src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt +++ b/src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt @@ -113,12 +113,11 @@ class CoderRemoteProvider( return@launch } - // Reconfigure if a new environment is found. - // TODO@JB: Should we use the add/remove listeners instead? - val newEnvironments = resolvedEnvironments.subtract(lastEnvironments) - if (newEnvironments.isNotEmpty()) { - context.logger.info("Found new environment(s), reconfiguring CLI: $newEnvironments") - cli.configSsh(newEnvironments.map { it.name }.toSet()) + + // Reconfigure if environments changed. + if (lastEnvironments.size != resolvedEnvironments.size || lastEnvironments != resolvedEnvironments) { + context.logger.info("Workspaces have changed, reconfiguring CLI: $resolvedEnvironments") + cli.configSsh(resolvedEnvironments.map { it.name }.toSet()) } environments.update { 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