Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita461bdb

Browse files
authored
impl: auto-connect to toolbox backend (#24)
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
1 parent2a9f5e1 commita461bdb

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

‎src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt‎

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,31 +110,27 @@ class CoderRemoteEnvironment(
110110
overridesuspend
111111
fungetContentsView():EnvironmentContentsView=EnvironmentView(client.url, workspace, agent)
112112

113+
overrideval 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-
overridefunsetVisible(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+
overridefunsetVisible(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
overridefunonDelete() {
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

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp