diff --git a/plugins/terminal/frontend/resources/intellij.terminal.frontend.xml b/plugins/terminal/frontend/resources/intellij.terminal.frontend.xml
index faf8aae8573a..4606e0d1173a 100644
--- a/plugins/terminal/frontend/resources/intellij.terminal.frontend.xml
+++ b/plugins/terminal/frontend/resources/intellij.terminal.frontend.xml
@@ -11,6 +11,8 @@
interface="com.intellij.terminal.frontend.action.TerminalEscapeHandler" dynamic="true"/>
+
@@ -50,10 +52,6 @@
serviceInterface="com.intellij.terminal.frontend.session.TerminalActivityTracker"
serviceImplementation="com.intellij.terminal.frontend.session.TerminalNoOpActivityTracker"
open="true"/>
-
+
+
diff --git a/plugins/terminal/frontend/src/com/intellij/terminal/frontend/view/portForwarding/TerminalPortForwardingManager.kt b/plugins/terminal/frontend/src/com/intellij/terminal/frontend/view/portForwarding/TerminalPortForwardingManager.kt
index 999db2505eb2..bfad0dd49299 100644
--- a/plugins/terminal/frontend/src/com/intellij/terminal/frontend/view/portForwarding/TerminalPortForwardingManager.kt
+++ b/plugins/terminal/frontend/src/com/intellij/terminal/frontend/view/portForwarding/TerminalPortForwardingManager.kt
@@ -4,11 +4,12 @@ package com.intellij.terminal.frontend.view.portForwarding
import com.intellij.openapi.actionSystem.DataKey
import com.intellij.platform.eel.EelDescriptor
import com.intellij.platform.eel.EelMachine
+import com.intellij.openapi.extensions.ExtensionPointName
import kotlinx.coroutines.flow.Flow
import org.jetbrains.annotations.ApiStatus
/**
- * Application-level service that performs TCP port forwarding from the IDE host environment to any
+ * Application-level extension that performs TCP port forwarding from the IDE host environment to any
* EEL environment and tracks the active forwardings so multiple terminals on the same physical
* machine share a single tunnel per remote port.
*
@@ -45,7 +46,19 @@ interface TerminalPortForwardingManager {
fun stopForwarding(eelMachine: EelMachine, remotePort: Int)
companion object {
+ private val EP_NAME: ExtensionPointName =
+ ExtensionPointName.create("org.jetbrains.plugins.terminal.portForwardingManager")
+
+ val DATA_KEY: DataKey = DataKey.create("TerminalPortForwardingManager")
+
+ /**
+ * Returns the highest-priority registered implementation: [TerminalPortForwardingManagerImpl] in the monolith,
+ * or the Remote Dev thin-client implementation (declared with `order="first"`) when the RD client is loaded.
+ */
@JvmStatic
- fun getInstance(): TerminalPortForwardingManager = service()
+ fun getInstance(): TerminalPortForwardingManager {
+ return EP_NAME.findFirstSafe { true }
+ ?: error("No ${TerminalPortForwardingManager::class.simpleName} implementation is registered")
+ }
}
}
\ No newline at end of file