From bb9b0cff146fd2497e2850ed074efc573b152d5b Mon Sep 17 00:00:00 2001 From: Huiwen Date: Wed, 22 Jan 2025 20:00:09 +0000 Subject: [PATCH 1/2] TRY IT OUT --- .idea/misc.xml | 5 +++-- .../jetbrains/remote/GitpodCLIService.kt | 20 ++++++++----------- ...itpodGatewayClientCustomizationProvider.kt | 3 +++ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 3db8e3375c184e..29a2fcd8ff671c 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,7 +5,8 @@ + - - \ No newline at end of file + + diff --git a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodCLIService.kt b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodCLIService.kt index e4bd69c3efca77..4af7fcd2f13cc7 100644 --- a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodCLIService.kt +++ b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodCLIService.kt @@ -5,6 +5,7 @@ package io.gitpod.jetbrains.remote import com.intellij.codeWithMe.ClientId +import com.intellij.codeWithMe.asContextElement import com.intellij.ide.BrowserUtil import com.intellij.ide.CommandLineProcessor import com.intellij.openapi.client.ClientKind @@ -27,10 +28,7 @@ import io.netty.channel.ChannelHandlerContext import io.netty.handler.codec.http.FullHttpRequest import io.netty.handler.codec.http.QueryStringDecoder import io.prometheus.client.exporter.common.TextFormat -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.delay -import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.* import org.jetbrains.ide.RestService import org.jetbrains.io.response import java.io.OutputStreamWriter @@ -113,14 +111,12 @@ class GitpodCLIService : RestService() { } private fun withClient(request: FullHttpRequest, context: ChannelHandlerContext, action: suspend (project: Project?) -> Unit): String? { - GlobalScope.launch { - getClientSessionAndProjectAsync().let { (session, project) -> - ClientId.withClientId(session.clientId) { - runBlocking { - action(project) - } - sendOk(request, context) - } + val scope = CoroutineScope(Dispatchers.Default) + scope.launch { + val (session, project) = getClientSessionAndProjectAsync() + withContext(session.clientId.asContextElement()) { + action(project) + sendOk(request, context) } } return null diff --git a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodGatewayClientCustomizationProvider.kt b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodGatewayClientCustomizationProvider.kt index c23543ae90280a..e3b062be9a6f01 100644 --- a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodGatewayClientCustomizationProvider.kt +++ b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodGatewayClientCustomizationProvider.kt @@ -12,6 +12,9 @@ import io.gitpod.jetbrains.remote.icons.GitpodIcons import javax.swing.Icon class GitpodGatewayClientCustomizationProvider : GatewayClientCustomizationProvider { + // 1. call frequertly + // 2. can access gitpod instance? + // 3. instance change -> event ? override val icon: Icon = GitpodIcons.Logo override val title: String = System.getenv("JETBRAINS_GITPOD_WORKSPACE_HOST") ?: DefaultGatewayControlCenterProvider().getHostnameShort() From 05966177f439df40691470d1198b1cd1e153ed2f Mon Sep 17 00:00:00 2001 From: Huiwen Date: Wed, 22 Jan 2025 21:13:37 +0000 Subject: [PATCH 2/2] Remove irrelevant code --- .../remote/GitpodGatewayClientCustomizationProvider.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodGatewayClientCustomizationProvider.kt b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodGatewayClientCustomizationProvider.kt index e3b062be9a6f01..c23543ae90280a 100644 --- a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodGatewayClientCustomizationProvider.kt +++ b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodGatewayClientCustomizationProvider.kt @@ -12,9 +12,6 @@ import io.gitpod.jetbrains.remote.icons.GitpodIcons import javax.swing.Icon class GitpodGatewayClientCustomizationProvider : GatewayClientCustomizationProvider { - // 1. call frequertly - // 2. can access gitpod instance? - // 3. instance change -> event ? override val icon: Icon = GitpodIcons.Logo override val title: String = System.getenv("JETBRAINS_GITPOD_WORKSPACE_HOST") ?: DefaultGatewayControlCenterProvider().getHostnameShort()