Skip to content

Commit 0c3e9f6

Browse files
authoredApr 7, 2025
feat(intellij): use ide proxy settings for tabby agent config (#4103)
* feat(intellij): add ide proxy configuration support to client provided config * fix(intellij): revert command line for buildDependencies task
1 parent 2007671 commit 0c3e9f6

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed
 

‎clients/intellij/build.gradle.kts

-1
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,3 @@ tasks {
100100
}
101101
}
102102
}
103-

‎clients/intellij/src/main/kotlin/com/tabbyml/intellijtabby/lsp/ConfigurationSync.kt

+25-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.tabbyml.intellijtabby.lsp.protocol.server.LanguageServer
1212
import com.tabbyml.intellijtabby.settings.KeymapSettings
1313
import com.tabbyml.intellijtabby.settings.SettingsService
1414
import com.tabbyml.intellijtabby.settings.SettingsState
15+
import java.util.Base64
1516

1617
class ConfigurationSync(private val project: Project) : Disposable {
1718
private val messageBusConnection = project.messageBus.connect()
@@ -43,6 +44,23 @@ class ConfigurationSync(private val project: Project) : Disposable {
4344
)
4445
return buildClientProvidedConfig(cached)
4546
}
47+
private fun getProxyUrl(): String? {
48+
val proxySettings = com.intellij.util.net.HttpConfigurable.getInstance()
49+
return if (proxySettings.USE_HTTP_PROXY) {
50+
"http://${proxySettings.PROXY_HOST}:${proxySettings.PROXY_PORT}"
51+
} else {
52+
null
53+
}
54+
}
55+
56+
private fun getProxyAuthorization(): String? {
57+
val proxySettings = com.intellij.util.net.HttpConfigurable.getInstance()
58+
return if (!proxySettings.proxyLogin.isNullOrEmpty() && !proxySettings.plainProxyPassword.isNullOrEmpty()) {
59+
"Basic " + Base64.getEncoder().encodeToString("${proxySettings.proxyLogin}:${proxySettings.plainProxyPassword}".toByteArray())
60+
} else {
61+
null
62+
}
63+
}
4664

4765
fun startSync(server: LanguageServer) {
4866
messageBusConnection.subscribe(SettingsService.Listener.TOPIC, object : SettingsService.Listener {
@@ -74,11 +92,17 @@ class ConfigurationSync(private val project: Project) : Disposable {
7492
private fun buildClientProvidedConfig(data: SettingsData): ClientProvidedConfig {
7593
val settings = data.settings
7694
val keymap = data.keymap
95+
val proxyUrl = getProxyUrl()
96+
val proxyAuthorization = getProxyAuthorization()
7797
return ClientProvidedConfig(
7898
server = ClientProvidedConfig.ServerConfig(
7999
endpoint = settings.serverEndpoint,
80100
token = settings.serverToken,
81101
),
102+
proxy = ClientProvidedConfig.ProxyConfig(
103+
url = proxyUrl,
104+
authorization = proxyAuthorization,
105+
),
82106
inlineCompletion = ClientProvidedConfig.InlineCompletionConfig(
83107
triggerMode = when (settings.completionTriggerMode) {
84108
SettingsState.TriggerMode.AUTOMATIC -> ClientProvidedConfig.InlineCompletionConfig.TriggerMode.AUTO
@@ -100,4 +124,4 @@ class ConfigurationSync(private val project: Project) : Disposable {
100124
override fun dispose() {
101125
messageBusConnection.dispose()
102126
}
103-
}
127+
}

0 commit comments

Comments
 (0)