- Notifications
You must be signed in to change notification settings - Fork4
impl: enhanced workflow for network disruptions#162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
acd4f22f255edb3679ec4d11599e325e1deFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2,6 +2,10 @@ | ||
| ## Unreleased | ||
| ### Changed | ||
| - improved workflow when network connection is flaky | ||
| ## 0.5.2 - 2025-07-22 | ||
| ### Fixed | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| version=0.6.0 | ||
| group=com.coder.toolbox | ||
| name=coder-toolbox |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -68,6 +68,13 @@ class CoderRemoteEnvironment( | ||
| private val proxyCommandHandle = SshCommandProcessHandle(context) | ||
| private var pollJob: Job? = null | ||
| init { | ||
| if (context.settingsStore.shouldAutoConnect(id)) { | ||
| context.logger.info("resuming SSH connection to $id — last session was still active.") | ||
| startSshConnection() | ||
| } | ||
| } | ||
| fun asPairOfWorkspaceAndAgent(): Pair<Workspace, WorkspaceAgent> = Pair(workspace, agent) | ||
| private fun getAvailableActions(): List<ActionDescription> { | ||
| @@ -158,6 +165,7 @@ class CoderRemoteEnvironment( | ||
| override fun beforeConnection() { | ||
| context.logger.info("Connecting to $id...") | ||
| isConnected.update { true } | ||
| context.settingsStore.updateAutoConnect(this.id, true) | ||
| pollJob = pollNetworkMetrics() | ||
| } | ||
| @@ -180,12 +188,9 @@ class CoderRemoteEnvironment( | ||
| } | ||
| context.logger.debug("Loading metrics from ${metricsFile.absolutePath} for $id") | ||
| try { | ||
| val metrics = networkMetricsMarshaller.fromJson(metricsFile.readText()) ?: return@launch | ||
| context.logger.debug("$id metrics: $metrics") | ||
| additionalEnvironmentInformation[context.i18n.ptrl("Network Status")] =metrics.toPretty() | ||
| } catch (e: Exception) { | ||
| context.logger.error( | ||
| e, | ||
| @@ -203,6 +208,10 @@ class CoderRemoteEnvironment( | ||
| pollJob?.cancel() | ||
| this.connectionRequest.update { false } | ||
| isConnected.update { false } | ||
| if (isManual) { | ||
| // if the user manually disconnects the ssh connection we should not connect automatically | ||
| context.settingsStore.updateAutoConnect(this.id, false) | ||
| } | ||
Comment on lines +211 to +214 Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Why this choice? If the user manually disconnects and then connects again, we should still try to resume the last active connection if possible. CollaboratorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. If you take a look at
| ||
| context.logger.info("Disconnected from $id") | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -142,6 +142,10 @@ class CoderSettingsStore( | ||
| } | ||
| } | ||
| override fun shouldAutoConnect(workspaceId: String): Boolean { | ||
| return store["$SSH_AUTO_CONNECT_PREFIX$workspaceId"]?.toBooleanStrictOrNull() ?: false | ||
matifali marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| } | ||
| // a readonly cast | ||
| fun readOnly(): ReadOnlyCoderSettings = this | ||
| @@ -213,6 +217,10 @@ class CoderSettingsStore( | ||
| store[SSH_CONFIG_OPTIONS] = options | ||
| } | ||
| fun updateAutoConnect(workspaceId: String, autoConnect: Boolean) { | ||
| store["$SSH_AUTO_CONNECT_PREFIX$workspaceId"] = autoConnect.toString() | ||
| } | ||
| private fun getDefaultGlobalDataDir(): Path { | ||
| return when (getOS()) { | ||
| OS.WINDOWS -> Paths.get(env.get("LOCALAPPDATA"), "coder-toolbox") | ||
Uh oh!
There was an error while loading.Please reload this page.