From b1e05ffe61a0d2bc935c8d8ed47635476ca50d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Kondratek?= Date: Tue, 22 Oct 2024 19:56:40 +0200 Subject: [PATCH] Move to the new `extensionConfiguration_change` endpoint --- .../kotlin/com/sourcegraph/cody/agent/CodyAgentServer.kt | 7 ++++--- .../sourcegraph/cody/config/CodyAuthenticationManager.kt | 4 ++-- .../cody/config/CodySettingsFileChangeListener.kt | 2 +- .../cody/config/notification/CodySettingChangeListener.kt | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/com/sourcegraph/cody/agent/CodyAgentServer.kt b/src/main/kotlin/com/sourcegraph/cody/agent/CodyAgentServer.kt index f882c485b9..148bc7810d 100644 --- a/src/main/kotlin/com/sourcegraph/cody/agent/CodyAgentServer.kt +++ b/src/main/kotlin/com/sourcegraph/cody/agent/CodyAgentServer.kt @@ -33,6 +33,7 @@ import com.sourcegraph.cody.agent.protocol_generated.EditTask_UndoParams import com.sourcegraph.cody.agent.protocol_generated.ExecuteCommandParams import com.sourcegraph.cody.agent.protocol_generated.ExtensionConfiguration import com.sourcegraph.cody.agent.protocol_generated.Null +import com.sourcegraph.cody.agent.protocol_generated.ProtocolAuthStatus import com.sourcegraph.cody.agent.protocol_generated.ServerInfo import java.util.concurrent.CompletableFuture import org.eclipse.lsp4j.jsonrpc.services.JsonNotification @@ -75,12 +76,12 @@ interface _SubsetGeneratedCodyAgentServer { @JsonRequest("extensionConfiguration/getSettingsSchema") fun extensionConfiguration_getSettingsSchema(params: Null?): CompletableFuture + @JsonNotification("extensionConfiguration/change") + fun extensionConfiguration_change(params: ExtensionConfiguration): CompletableFuture + // // ============= // // Notifications // // ============= - - @JsonNotification("extensionConfiguration/didChange") - fun extensionConfiguration_didChange(params: ExtensionConfiguration) } // TODO: Requests waiting to be migrated & tested for compatibility. Avoid placing new protocol diff --git a/src/main/kotlin/com/sourcegraph/cody/config/CodyAuthenticationManager.kt b/src/main/kotlin/com/sourcegraph/cody/config/CodyAuthenticationManager.kt index 7b86b87751..ce09999085 100644 --- a/src/main/kotlin/com/sourcegraph/cody/config/CodyAuthenticationManager.kt +++ b/src/main/kotlin/com/sourcegraph/cody/config/CodyAuthenticationManager.kt @@ -229,7 +229,7 @@ class CodyAuthenticationManager : ProjectManager.getInstance().openProjects.forEach { project -> CodyAgentService.withAgentRestartIfNeeded(project) { agent -> if (!project.isDisposed) { - agent.server.extensionConfiguration_didChange(ConfigUtil.getAgentConfiguration(project)) + agent.server.extensionConfiguration_change(ConfigUtil.getAgentConfiguration(project)) publisher(project).afterAction(AccountSettingChangeContext(accessTokenChanged = true)) } } @@ -253,7 +253,7 @@ class CodyAuthenticationManager : ProjectManager.getInstance().openProjects.forEach { project -> CodyAgentService.withAgentRestartIfNeeded(project) { agent -> if (!project.isDisposed) { - agent.server.extensionConfiguration_didChange(ConfigUtil.getAgentConfiguration(project)) + agent.server.extensionConfiguration_change(ConfigUtil.getAgentConfiguration(project)) if (serverUrlChanged || tierChanged || accountChanged) { publisher(project) .afterAction( diff --git a/src/main/kotlin/com/sourcegraph/cody/config/CodySettingsFileChangeListener.kt b/src/main/kotlin/com/sourcegraph/cody/config/CodySettingsFileChangeListener.kt index ab1fdf9aab..9c3964031c 100644 --- a/src/main/kotlin/com/sourcegraph/cody/config/CodySettingsFileChangeListener.kt +++ b/src/main/kotlin/com/sourcegraph/cody/config/CodySettingsFileChangeListener.kt @@ -18,7 +18,7 @@ class CodySettingsFileChangeListener(private val project: Project) : FileDocumen // TODO: it seams that some of the settings changes (like enabling/disabling autocomplete) // requires agent restart to take effect. CodyAgentService.withAgentRestartIfNeeded(project) { - it.server.extensionConfiguration_didChange( + it.server.extensionConfiguration_change( ConfigUtil.getAgentConfiguration(project, document.text)) } } diff --git a/src/main/kotlin/com/sourcegraph/cody/config/notification/CodySettingChangeListener.kt b/src/main/kotlin/com/sourcegraph/cody/config/notification/CodySettingChangeListener.kt index d58819d6f5..3582f9d098 100644 --- a/src/main/kotlin/com/sourcegraph/cody/config/notification/CodySettingChangeListener.kt +++ b/src/main/kotlin/com/sourcegraph/cody/config/notification/CodySettingChangeListener.kt @@ -33,7 +33,7 @@ class CodySettingChangeListener(project: Project) : ChangeListener(project) { // Notify Cody Agent about config changes. CodyAgentService.withAgentRestartIfNeeded(project) { agent -> if (ConfigUtil.isCodyEnabled()) { - agent.server.extensionConfiguration_didChange( + agent.server.extensionConfiguration_change( ConfigUtil.getAgentConfiguration(project)) } }