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

Commita509615

Browse files
authored
fix: ssh connection to a workspace is established only once (#76)
- right now ssh automatically connects to the workspace when a userselects it from the main env. page. However, if the user manuallydisconnects from the hamburger menu, the SSH is no longer automaticallyestablished afterward.- the reason for this behavior was that the connection request flag thattriggered the ssh connection behind the scenes was never reset. In orderto reset we have to know when a user hits the disconnect button.- fortunately Toolbox provides two callbacks, one before establishingthe ssh connection and another one right after disconnect. Even thoughwe don't know the reason for disconnect it's still a good opportunity toreset the request flag.-resolves#38
1 parent35c6259 commita509615

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
##Unreleased
44

5+
###Fixed
6+
7+
- SSH connection to a Workspace is no longer established only once
8+
59
###Changed
610

711
- action buttons on the token input step were swapped to achieve better keyboard navigation

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

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import com.coder.toolbox.sdk.v2.models.WorkspaceAgent
99
importcom.coder.toolbox.util.withPath
1010
importcom.coder.toolbox.views.Action
1111
importcom.coder.toolbox.views.EnvironmentView
12+
importcom.jetbrains.toolbox.api.remoteDev.AfterDisconnectHook
13+
importcom.jetbrains.toolbox.api.remoteDev.BeforeConnectionHook
1214
importcom.jetbrains.toolbox.api.remoteDev.DeleteEnvironmentConfirmationParams
1315
importcom.jetbrains.toolbox.api.remoteDev.EnvironmentVisibilityState
1416
importcom.jetbrains.toolbox.api.remoteDev.RemoteProviderEnvironment
@@ -35,7 +37,7 @@ class CoderRemoteEnvironment(
3537
privatevalclient:CoderRestClient,
3638
privatevarworkspace:Workspace,
3739
privatevaragent:WorkspaceAgent,
38-
) : RemoteProviderEnvironment("${workspace.name}.${agent.name}") {
40+
) : RemoteProviderEnvironment("${workspace.name}.${agent.name}"), BeforeConnectionHook, AfterDisconnectHook {
3941
privatevar wsRawStatus=WorkspaceAndAgentStatus.from(workspace, agent)
4042

4143
overridevar name:String="${workspace.name}.${agent.name}"
@@ -109,6 +111,21 @@ class CoderRemoteEnvironment(
109111
return actions
110112
}
111113

114+
overridefungetBeforeConnectionHooks():List<BeforeConnectionHook>=listOf(this)
115+
116+
overridefungetAfterDisconnectHooks():List<AfterDisconnectHook>=listOf(this)
117+
118+
overridefunbeforeConnection() {
119+
context.logger.info("Connecting to$id...")
120+
this.isConnected=true
121+
}
122+
123+
overridefunafterDisconnect() {
124+
this.connectionRequest.update {false }
125+
this.isConnected=false
126+
context.logger.info("Disconnected from$id")
127+
}
128+
112129
/**
113130
* Update the workspace/agent status to the listeners, if it has changed.
114131
*/
@@ -140,7 +157,8 @@ class CoderRemoteEnvironment(
140157
agent
141158
)
142159

143-
overrideval connectionRequest:MutableStateFlow<Boolean>?=MutableStateFlow(false)
160+
privatevar isConnected=false
161+
overrideval connectionRequest:MutableStateFlow<Boolean>=MutableStateFlow(false)
144162

145163
/**
146164
* Does nothing. In theory, we could do something like start the workspace
@@ -149,10 +167,9 @@ class CoderRemoteEnvironment(
149167
* to be much value.
150168
*/
151169
overridefunsetVisible(visibilityState:EnvironmentVisibilityState) {
152-
if (wsRawStatus.ready()&& visibilityState.contentsVisible==true&& visibilityState.isBackendConnected==false) {
153-
context.logger.info("Connecting to$id...")
170+
if (wsRawStatus.ready()&& visibilityState.contentsVisible==true&& isConnected==false) {
154171
context.cs.launch {
155-
connectionRequest?.update {
172+
connectionRequest.update {
156173
true
157174
}
158175
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp