From 0ece7ca4fbb1accd51ea66fc79634e89f3be6c2e Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Sat, 8 Mar 2025 00:56:51 +0200 Subject: [PATCH 1/2] impl: auto-connect to toolbox backend The auto connect happens only when: - workspace is running - the user clicks on one of the environments in the main page - there isn't already an established connection --- .../com/coder/toolbox/CoderRemoteEnvironment.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt b/src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt index 5aa09aa..f12b551 100644 --- a/src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt +++ b/src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt @@ -106,13 +106,24 @@ class CoderRemoteEnvironment( override suspend fun getContentsView(): EnvironmentContentsView = EnvironmentView(client.url, workspace, agent) + override val connectionRequest: MutableStateFlow? = MutableStateFlow(false) + /** * Does nothing. In theory, we could do something like start the workspace * when you click into the workspace, but you would still need to press * "connect" anyway before the content is populated so there does not seem * to be much value. */ - override fun setVisible(visibilityState: EnvironmentVisibilityState) {} + override fun setVisible(visibilityState: EnvironmentVisibilityState) { + if (wsRawStatus.ready() && visibilityState.contentsVisible == true && visibilityState.isBackendConnected == false) { + context.logger.info("Connecting to $id...") + context.cs.launch { + connectionRequest?.update { + true + } + } + } + } /** * Immediately send the state to the listener and store for updates. From b583229a920eb8244acf97be6c96437acd109e84 Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Sat, 8 Mar 2025 00:59:50 +0200 Subject: [PATCH 2/2] chore: remove outdated comments - jetbrains already fixed the issues related to info and cancel pop-ups shown only on the main screen --- .../com/coder/toolbox/CoderRemoteEnvironment.kt | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt b/src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt index f12b551..ac5d890 100644 --- a/src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt +++ b/src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt @@ -125,23 +125,8 @@ class CoderRemoteEnvironment( } } - /** - * Immediately send the state to the listener and store for updates. - */ -// override fun addStateListener(consumer: EnvironmentStateConsumer): Boolean { -// // TODO@JB: It would be ideal if we could have the workspace state and -// // the connected state listed separately, since right now the -// // connected state can mask the workspace state. -// // TODO@JB: You can still press connect if the environment is -// // unreachable. Is that expected? -// consumer.consume(status.toRemoteEnvironmentState(serviceLocator)) -// return super.addStateListener(consumer) -// } - override fun onDelete() { context.cs.launch { - // TODO info and cancel pop-ups only appear on the main page where all environments are listed. - // However, #showSnackbar works on other pages. Until JetBrains fixes this issue we are going to use the snackbar val shouldDelete = if (wsRawStatus.canStop()) { context.ui.showOkCancelPopup( context.i18n.ptrl("Delete running workspace?"), 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