@@ -110,31 +110,27 @@ class CoderRemoteEnvironment(
110110 override suspend
111111 fun getContentsView (): EnvironmentContentsView = EnvironmentView (client.url, workspace, agent)
112112
113+ override val connectionRequest: MutableStateFlow <Boolean >? = MutableStateFlow (false )
114+
113115 /* *
114116 * Does nothing. In theory, we could do something like start the workspace
115117 * when you click into the workspace, but you would still need to press
116118 * "connect" anyway before the content is populated so there does not seem
117119 * to be much value.
118120 */
119- override fun setVisible (visibilityState : EnvironmentVisibilityState ) {}
120-
121- /* *
122- * Immediately send the state to the listener and store for updates.
123- */
124- // override fun addStateListener(consumer: EnvironmentStateConsumer): Boolean {
125- // // TODO@JB: It would be ideal if we could have the workspace state and
126- // // the connected state listed separately, since right now the
127- // // connected state can mask the workspace state.
128- // // TODO@JB: You can still press connect if the environment is
129- // // unreachable. Is that expected?
130- // consumer.consume(status.toRemoteEnvironmentState(serviceLocator))
131- // return super.addStateListener(consumer)
132- // }
121+ override fun setVisible (visibilityState : EnvironmentVisibilityState ) {
122+ if (wsRawStatus.ready() && visibilityState.contentsVisible == true && visibilityState.isBackendConnected == false ) {
123+ context.logger.info(" Connecting to $id ..." )
124+ context.cs.launch {
125+ connectionRequest?.update {
126+ true
127+ }
128+ }
129+ }
130+ }
133131
134132 override fun onDelete () {
135133 context.cs.launch {
136- // TODO info and cancel pop-ups only appear on the main page where all environments are listed.
137- // However, #showSnackbar works on other pages. Until JetBrains fixes this issue we are going to use the snackbar
138134 val shouldDelete = if (wsRawStatus.canStop()) {
139135 context.ui.showOkCancelPopup(
140136 context.i18n.ptrl(" Delete running workspace?" ),
0 commit comments