Skip to content

Commit

Permalink
Move to the new extensionConfiguration_change endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mkondratek committed Oct 22, 2024
1 parent 96ea1c6 commit b1e05ff
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/main/kotlin/com/sourcegraph/cody/agent/CodyAgentServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -75,12 +76,12 @@ interface _SubsetGeneratedCodyAgentServer {
@JsonRequest("extensionConfiguration/getSettingsSchema")
fun extensionConfiguration_getSettingsSchema(params: Null?): CompletableFuture<String>

@JsonNotification("extensionConfiguration/change")
fun extensionConfiguration_change(params: ExtensionConfiguration): CompletableFuture<ProtocolAuthStatus?>

// // =============
// // Notifications
// // =============

@JsonNotification("extensionConfiguration/didChange")
fun extensionConfiguration_didChange(params: ExtensionConfiguration)
}

// TODO: Requests waiting to be migrated & tested for compatibility. Avoid placing new protocol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Expand Down

0 comments on commit b1e05ff

Please sign in to comment.