fix jetbrains messaging schema
This commit is contained in:
parent
776fd5cefb
commit
a112c15a3e
4 changed files with 83 additions and 80 deletions
|
|
@ -3,6 +3,7 @@ package com.github.continuedev.continueintellijextension.`continue`
|
|||
import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings
|
||||
import com.github.continuedev.continueintellijextension.services.ContinuePluginService
|
||||
import com.github.continuedev.continueintellijextension.services.TelemetryService
|
||||
import com.github.continuedev.continueintellijextension.toolWindow.MessageTypes
|
||||
import com.google.gson.Gson
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.project.Project
|
||||
|
|
@ -56,7 +57,7 @@ class CoreMessenger(private val project: Project, esbuildPath: String, continueC
|
|||
val data = responseMap["data"]
|
||||
|
||||
// IDE listeners
|
||||
if (ideMessageTypes.contains(messageType)) {
|
||||
if (MessageTypes.ideMessageTypes.contains(messageType)) {
|
||||
ideProtocolClient.handleMessage(json) { data ->
|
||||
val message = gson.toJson(mapOf(
|
||||
"messageId" to messageId,
|
||||
|
|
@ -68,7 +69,7 @@ class CoreMessenger(private val project: Project, esbuildPath: String, continueC
|
|||
}
|
||||
|
||||
// Forward to webview
|
||||
if (PASS_THROUGH_TO_WEBVIEW.contains(messageType)) {
|
||||
if (MessageTypes.PASS_THROUGH_TO_WEBVIEW.contains(messageType)) {
|
||||
// TODO: Currently we aren't set up to receive a response back from the webview
|
||||
// Can circumvent for getDefaultsModelTitle here for now
|
||||
if (messageType == "getDefaultModelTitle") {
|
||||
|
|
@ -88,7 +89,7 @@ class CoreMessenger(private val project: Project, esbuildPath: String, continueC
|
|||
// Responses for messageId
|
||||
responseListeners[messageId]?.let { listener ->
|
||||
listener(data)
|
||||
if (generatorTypes.contains(messageType)) {
|
||||
if (MessageTypes.generatorTypes.contains(messageType)) {
|
||||
val done = (data as Map<String, Boolean?>)["done"]
|
||||
if (done == true) {
|
||||
responseListeners.remove(messageId)
|
||||
|
|
@ -100,64 +101,6 @@ class CoreMessenger(private val project: Project, esbuildPath: String, continueC
|
|||
}
|
||||
}
|
||||
|
||||
private val generatorTypes = listOf(
|
||||
"llm/streamComplete",
|
||||
"llm/streamChat",
|
||||
"command/run",
|
||||
"streamDiffLines"
|
||||
)
|
||||
|
||||
private val ideMessageTypes = listOf(
|
||||
"readRangeInFile",
|
||||
"isTelemetryEnabled",
|
||||
"getUniqueId",
|
||||
"getWorkspaceConfigs",
|
||||
"getDiff",
|
||||
"getTerminalContents",
|
||||
"getWorkspaceDirs",
|
||||
"showLines",
|
||||
"listFolders",
|
||||
"getContinueDir",
|
||||
"writeFile",
|
||||
"fileExists",
|
||||
"showVirtualFile",
|
||||
"openFile",
|
||||
"runCommand",
|
||||
"saveFile",
|
||||
"readFile",
|
||||
"showDiff",
|
||||
"getOpenFiles",
|
||||
"getCurrentFile",
|
||||
"getPinnedFiles",
|
||||
"getSearchResults",
|
||||
"getProblems",
|
||||
"subprocess",
|
||||
"getBranch",
|
||||
"getIdeInfo",
|
||||
"getIdeSettings",
|
||||
"errorPopup",
|
||||
"getRepoName",
|
||||
"listDir",
|
||||
"getGitRootPath",
|
||||
"getLastModified",
|
||||
"insertAtCursor",
|
||||
"applyToFile",
|
||||
"getGitHubAuthToken",
|
||||
"setGitHubAuthToken",
|
||||
"pathSep",
|
||||
"getControlPlaneSessionInfo",
|
||||
"logoutOfControlPlane",
|
||||
"getTerminalContents"
|
||||
)
|
||||
|
||||
private val PASS_THROUGH_TO_WEBVIEW = listOf<String>(
|
||||
"configUpdate",
|
||||
"getDefaultModelTitle",
|
||||
"indexProgress",
|
||||
"refreshSubmenuItems",
|
||||
"didChangeAvailableProfiles"
|
||||
)
|
||||
|
||||
private fun setPermissions(destination: String) {
|
||||
val osName = System.getProperty("os.name").toLowerCase()
|
||||
if (osName.contains("mac") || osName.contains("darwin")) {
|
||||
|
|
|
|||
|
|
@ -1,32 +1,22 @@
|
|||
package com.github.continuedev.continueintellijextension.toolWindow
|
||||
|
||||
import com.github.continuedev.continueintellijextension.activities.showTutorial
|
||||
import com.github.continuedev.continueintellijextension.activities.ContinuePluginStartupActivity
|
||||
import com.github.continuedev.continueintellijextension.constants.getConfigJsonPath
|
||||
import com.github.continuedev.continueintellijextension.constants.getContinueGlobalPath
|
||||
import com.github.continuedev.continueintellijextension.`continue`.*
|
||||
import com.github.continuedev.continueintellijextension.factories.CustomSchemeHandlerFactory
|
||||
import com.github.continuedev.continueintellijextension.services.ContinuePluginService
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonObject
|
||||
import com.google.gson.JsonParser
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.util.io.StreamUtil
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.ui.jcef.*
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import org.cef.CefApp
|
||||
import org.cef.browser.CefBrowser
|
||||
import org.cef.handler.CefLoadHandlerAdapter
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.nio.file.Paths
|
||||
|
||||
class ContinueBrowser(val project: Project, url: String, useOsr: Boolean = false) {
|
||||
private val heightChangeListeners = mutableListOf<(Int) -> Unit>()
|
||||
|
|
@ -118,13 +108,20 @@ class ContinueBrowser(val project: Project, url: String, useOsr: Boolean = false
|
|||
val ide = continuePluginService.ideProtocolClient;
|
||||
|
||||
val respond = fun(data: Any?) {
|
||||
val jsonData = mutableMapOf(
|
||||
"messageId" to messageId,
|
||||
"data" to data,
|
||||
"messageType" to messageType
|
||||
)
|
||||
val jsonString = Gson().toJson(jsonData)
|
||||
sendToWebview(messageType, data, messageId ?: uuid())
|
||||
// This matches the way that we expect receive messages in IdeMessenger.ts (gui)
|
||||
// and the way they are sent in VS Code (webviewProtocol.ts)
|
||||
var result: Map<String, Any?>? = null
|
||||
if (MessageTypes.generatorTypes.contains(messageType)) {
|
||||
result = data as? Map<String, Any?>
|
||||
} else {
|
||||
result = mutableMapOf(
|
||||
"status" to "success",
|
||||
"done" to false,
|
||||
"content" to data
|
||||
)
|
||||
}
|
||||
|
||||
sendToWebview(messageType, result, messageId ?: uuid())
|
||||
}
|
||||
|
||||
if (PASS_THROUGH_TO_CORE.contains(messageType)) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
package com.github.continuedev.continueintellijextension.toolWindow
|
||||
|
||||
class MessageTypes {
|
||||
companion object {
|
||||
val generatorTypes = listOf(
|
||||
"llm/streamComplete",
|
||||
"llm/streamChat",
|
||||
"command/run",
|
||||
"streamDiffLines"
|
||||
)
|
||||
|
||||
val ideMessageTypes = listOf(
|
||||
"readRangeInFile",
|
||||
"isTelemetryEnabled",
|
||||
"getUniqueId",
|
||||
"getWorkspaceConfigs",
|
||||
"getDiff",
|
||||
"getTerminalContents",
|
||||
"getWorkspaceDirs",
|
||||
"showLines",
|
||||
"listFolders",
|
||||
"getContinueDir",
|
||||
"writeFile",
|
||||
"fileExists",
|
||||
"showVirtualFile",
|
||||
"openFile",
|
||||
"runCommand",
|
||||
"saveFile",
|
||||
"readFile",
|
||||
"showDiff",
|
||||
"getOpenFiles",
|
||||
"getCurrentFile",
|
||||
"getPinnedFiles",
|
||||
"getSearchResults",
|
||||
"getProblems",
|
||||
"subprocess",
|
||||
"getBranch",
|
||||
"getIdeInfo",
|
||||
"getIdeSettings",
|
||||
"errorPopup",
|
||||
"getRepoName",
|
||||
"listDir",
|
||||
"getGitRootPath",
|
||||
"getLastModified",
|
||||
"insertAtCursor",
|
||||
"applyToFile",
|
||||
"getGitHubAuthToken",
|
||||
"setGitHubAuthToken",
|
||||
"pathSep",
|
||||
"getControlPlaneSessionInfo",
|
||||
"logoutOfControlPlane",
|
||||
"getTerminalContents"
|
||||
)
|
||||
|
||||
val PASS_THROUGH_TO_WEBVIEW = listOf<String>(
|
||||
"configUpdate",
|
||||
"getDefaultModelTitle",
|
||||
"indexProgress",
|
||||
"refreshSubmenuItems",
|
||||
"didChangeAvailableProfiles"
|
||||
)
|
||||
}
|
||||
}
|
||||
4
extensions/vscode/package-lock.json
generated
4
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.8.48",
|
||||
"version": "0.9.206",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.8.48",
|
||||
"version": "0.9.206",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@electron/rebuild": "^3.2.10",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue