Skip to content

Commit 6c448a5

Browse files
committed
phase active
1 parent 3426801 commit 6c448a5

File tree

3 files changed

+8
-35
lines changed

3 files changed

+8
-35
lines changed

Diff for: components/ide/jetbrains/toolbox/src/main/kotlin/io/gitpod/toolbox/gateway/GitpodRemoteProvider.kt

+1-6
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ class GitpodRemoteProvider(
4040
future.complete(null)
4141
return@launch
4242
}
43-
Utils.toolboxUi.showWindow()
44-
Utils.toolboxUi.showPluginEnvironmentsPage()
4543
setEnvironmentVisibility(connectParams)
4644
future.complete(null)
4745
}
@@ -64,7 +62,6 @@ class GitpodRemoteProvider(
6462
environmentMap[connectParams.uniqueID] = Pair(workspace, env)
6563
consumer.consumeEnvironments(environmentMap.values.map { it.second })
6664
}
67-
env!!.markActive()
6865
val joinLinkInfo = workspace!!.fetchJoinLink2Info(publicApi.getWorkspaceOwnerToken(workspaceId))
6966
Utils.clientHelper.setAutoConnectOnEnvironmentReady(workspaceId, joinLinkInfo.ideVersion, joinLinkInfo.projectPath)
7067
}
@@ -102,12 +99,10 @@ class GitpodRemoteProvider(
10299

103100
override fun getOverrideUiPage(): UiPage? {
104101
authManger.addLoginListener {
105-
Utils.toolboxUi.showWindow()
106-
Utils.toolboxUi.showPluginEnvironmentsPage()
107102
startup()
103+
Utils.toolboxUi.showPluginEnvironmentsPage()
108104
}
109105
authManger.addLogoutListener {
110-
Utils.toolboxUi.showWindow()
111106
Utils.toolboxUi.showPluginEnvironmentsPage()
112107
}
113108
val account = authManger.getCurrentAccount()

Diff for: components/ide/jetbrains/toolbox/src/main/kotlin/io/gitpod/toolbox/gateway/GitpodRemoteProviderEnvironment.kt

+7-25
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,6 @@ class GitpodRemoteProviderEnvironment(
4242

4343
private val lastWSEnvState = MutableSharedFlow<WorkspaceEnvState>(1, 0, BufferOverflow.DROP_OLDEST)
4444
private var lastPhase: WorkspaceInstanceStatus.Phase = WorkspaceInstanceStatus.Phase.PHASE_UNSPECIFIED
45-
private var isMarkActive = false
46-
set(value) {
47-
if (field != value) {
48-
field = value
49-
lastWSEnvState.tryEmit(WorkspaceEnvState(lastPhase, value))
50-
}
51-
}
52-
53-
fun markActive() {
54-
isMarkActive = true
55-
}
5645

5746
init {
5847
Utils.coroutineScope.launch {
@@ -66,19 +55,19 @@ class GitpodRemoteProviderEnvironment(
6655
}
6756

6857
Utils.coroutineScope.launch {
69-
GitpodLogger.info("connectParams.workspaceId $connectParams")
58+
GitpodLogger.debug("watching workspace ${connectParams.workspaceId}")
7059
watchWorkspaceJob = publicApi.watchWorkspaceStatus(connectParams.workspaceId) { _, status ->
7160
lastPhase = status.phase
72-
GitpodLogger.info("${connectParams.workspaceId} status updated: $lastPhase")
73-
lastWSEnvState.tryEmit(WorkspaceEnvState(status.phase, isMarkActive))
61+
GitpodLogger.debug("${connectParams.workspaceId} status updated: $lastPhase")
62+
lastWSEnvState.tryEmit(WorkspaceEnvState(status.phase))
7463
}
7564
}
7665
}
7766

7867
override fun addStateListener(consumer: EnvironmentStateConsumer): Boolean {
7968
val ok = super.addStateListener(consumer)
8069
Utils.coroutineScope.launch {
81-
lastWSEnvState.tryEmit(WorkspaceEnvState(lastPhase, isMarkActive))
70+
lastWSEnvState.tryEmit(WorkspaceEnvState(lastPhase))
8271
}
8372
return ok
8473
}
@@ -89,9 +78,6 @@ class GitpodRemoteProviderEnvironment(
8978
override fun getContentsView(): CompletableFuture<EnvironmentContentsView> = contentsViewFuture
9079

9180
override fun setVisible(visibilityState: EnvironmentVisibilityState) {
92-
if (visibilityState.contentsVisible && lastPhase == WorkspaceInstanceStatus.Phase.PHASE_RUNNING) {
93-
isMarkActive = true
94-
}
9581
}
9682

9783
override fun getActionList(): ObservableList<ActionDescription> = actionList
@@ -102,14 +88,10 @@ class GitpodRemoteProviderEnvironment(
10288
}
10389

10490

105-
private class WorkspaceEnvState(val phase: WorkspaceInstanceStatus.Phase, val isMarkActive: Boolean) {
91+
private class WorkspaceEnvState(val phase: WorkspaceInstanceStatus.Phase) {
10692

10793
fun getState() = run {
108-
if (isMarkActive && phase == WorkspaceInstanceStatus.Phase.PHASE_RUNNING) {
109-
StandardRemoteEnvironmentState.Active
110-
} else {
111-
phaseToStateMap[phase] ?: StandardRemoteEnvironmentState.Unreachable
112-
}
94+
phaseToStateMap[phase] ?: StandardRemoteEnvironmentState.Unreachable
11395
}
11496

11597
companion object {
@@ -120,7 +102,7 @@ private class WorkspaceEnvState(val phase: WorkspaceInstanceStatus.Phase, val is
120102
WorkspaceInstanceStatus.Phase.PHASE_PENDING to StandardRemoteEnvironmentState.Initializing,
121103
WorkspaceInstanceStatus.Phase.PHASE_CREATING to StandardRemoteEnvironmentState.Initializing,
122104
WorkspaceInstanceStatus.Phase.PHASE_INITIALIZING to StandardRemoteEnvironmentState.Initializing,
123-
WorkspaceInstanceStatus.Phase.PHASE_RUNNING to StandardRemoteEnvironmentState.Inactive,
105+
WorkspaceInstanceStatus.Phase.PHASE_RUNNING to StandardRemoteEnvironmentState.Active,
124106
WorkspaceInstanceStatus.Phase.PHASE_INTERRUPTED to StandardRemoteEnvironmentState.Error,
125107
WorkspaceInstanceStatus.Phase.PHASE_STOPPING to StandardRemoteEnvironmentState.Unreachable,
126108
WorkspaceInstanceStatus.Phase.PHASE_STOPPED to StandardRemoteEnvironmentState.Hibernated,

Diff for: components/ide/jetbrains/toolbox/src/main/kotlin/io/gitpod/toolbox/service/GitpodPublicApiManager.kt

-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ class GitpodPublicApiManager(private val authManger: GitpodAuthManager) {
2525
private var account: GitpodAccount? = null
2626

2727
init {
28-
setup()
29-
authManger.addLoginListener {
30-
setup()
31-
}
3228
authManger.addLogoutListener {
3329
workspaceApi = null
3430
organizationApi = null

0 commit comments

Comments
 (0)