🐛 fix a handful of jetbrains bugs
This commit is contained in:
parent
2587fa4679
commit
ca493ff195
8 changed files with 92 additions and 33 deletions
|
|
@ -38,6 +38,7 @@ import {
|
|||
getContinueDotEnv,
|
||||
migrate,
|
||||
} from "../util/paths";
|
||||
import { defaultConfig } from "./default";
|
||||
const { execSync } = require("child_process");
|
||||
|
||||
function resolveSerializedConfig(filepath: string): SerializedContinueConfig {
|
||||
|
|
@ -73,7 +74,14 @@ function loadSerializedConfig(
|
|||
ideType: IdeType,
|
||||
): SerializedContinueConfig {
|
||||
const configPath = getConfigJsonPath(ideType);
|
||||
let config = resolveSerializedConfig(configPath);
|
||||
let config: SerializedContinueConfig;
|
||||
try {
|
||||
config = resolveSerializedConfig(configPath);
|
||||
} catch (e) {
|
||||
console.log("config.json is invalid. Falling back to default.");
|
||||
config = defaultConfig;
|
||||
}
|
||||
|
||||
if (config.allowAnonymousTelemetry === undefined) {
|
||||
config.allowAnonymousTelemetry = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,14 @@ export type Protocol = {
|
|||
{ model: SerializedContinueConfig["models"][number] },
|
||||
void,
|
||||
];
|
||||
"config/updateRemoteConfigSettings": [
|
||||
{
|
||||
remoteConfigServerUrl: string;
|
||||
remoteConfigSyncPeriod: number;
|
||||
userToken: string;
|
||||
},
|
||||
void,
|
||||
];
|
||||
"config/getBrowserSerialized": [
|
||||
undefined,
|
||||
Promise<BrowserSerializedContinueConfig>,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ pluginGroup = com.github.continuedev.continueintellijextension
|
|||
pluginName = continue-intellij-extension
|
||||
pluginRepositoryUrl = https://github.com/continuedev/continue
|
||||
# SemVer format -> https://semver.org
|
||||
pluginVersion = 0.0.34
|
||||
pluginVersion = 0.0.35
|
||||
|
||||
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
|
||||
pluginSinceBuild = 223
|
||||
|
|
|
|||
|
|
@ -223,6 +223,8 @@ class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware {
|
|||
}
|
||||
val target = "$os-$arch"
|
||||
|
||||
println("Identified OS: $os, Arch: $arch")
|
||||
|
||||
val corePath = Paths.get(pluginPath.toString(), "core").toString()
|
||||
val targetPath = Paths.get(corePath, target).toString()
|
||||
val continueCorePath = Paths.get(targetPath, "pkg" + (if (os == "win32") ".exe" else "")).toString()
|
||||
|
|
@ -238,7 +240,10 @@ class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware {
|
|||
Files.copy(nodeSqlite3Path, coreNodeSqlite3Path)
|
||||
}
|
||||
|
||||
val coreMessenger = CoreMessenger(continueCorePath, ideProtocolClient);
|
||||
// esbuild needs permissions
|
||||
val esbuildPath = Paths.get(targetPath, "esbuild"+ (if (os == "win32") ".exe" else "")).toString()
|
||||
|
||||
val coreMessenger = CoreMessenger(esbuildPath, continueCorePath, ideProtocolClient);
|
||||
continuePluginService.coreMessenger = coreMessenger
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import java.nio.file.Files
|
|||
import java.nio.file.Paths
|
||||
import java.nio.file.attribute.PosixFilePermission
|
||||
|
||||
class CoreMessenger(continueCorePath: String, ideProtocolClient: IdeProtocolClient) {
|
||||
class CoreMessenger(esbuildPath: String, continueCorePath: String, ideProtocolClient: IdeProtocolClient) {
|
||||
private val writer: OutputStreamWriter
|
||||
private val reader: BufferedReader
|
||||
private val process: Process
|
||||
|
|
@ -135,6 +135,7 @@ class CoreMessenger(continueCorePath: String, ideProtocolClient: IdeProtocolClie
|
|||
init {
|
||||
// Set proper permissions
|
||||
setPermissions(continueCorePath)
|
||||
setPermissions(esbuildPath)
|
||||
|
||||
// Start the subprocess
|
||||
val processBuilder = ProcessBuilder(continueCorePath)
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ class AsyncFileSaveListener : AsyncFileListener {
|
|||
return object : AsyncFileListener.ChangeApplier {
|
||||
override fun afterVfsChange() {
|
||||
val config = readConfigJson()
|
||||
ideProtocolClient.configUpdate(config)
|
||||
ideProtocolClient.configUpdate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -389,7 +389,7 @@ class IdeProtocolClient (
|
|||
it
|
||||
}
|
||||
|
||||
configUpdate(updatedConfig)
|
||||
configUpdate()
|
||||
setFileOpen(getConfigJsonPath())
|
||||
}
|
||||
"deleteModel" -> {
|
||||
|
|
@ -401,7 +401,7 @@ class IdeProtocolClient (
|
|||
config["models"] = models
|
||||
config
|
||||
}
|
||||
configUpdate(configJson)
|
||||
configUpdate()
|
||||
}
|
||||
"addOpenAIKey" -> {
|
||||
val updatedConfig = editConfigJson { config ->
|
||||
|
|
@ -420,7 +420,7 @@ class IdeProtocolClient (
|
|||
config["models"] = models
|
||||
config
|
||||
}
|
||||
configUpdate(updatedConfig)
|
||||
configUpdate()
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -435,9 +435,8 @@ class IdeProtocolClient (
|
|||
}
|
||||
}
|
||||
|
||||
fun configUpdate(config: Map<String, Any>) {
|
||||
fun configUpdate() {
|
||||
continuePluginService.coreMessenger?.request("config/reload", null, null) { _ -> }
|
||||
continuePluginService.sendToWebview("configUpdate", config)
|
||||
}
|
||||
|
||||
private fun editConfigJson(callback: (config: MutableMap<String, Any>) -> Map<String, Any>): Map<String, Any> {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@ import javax.swing.JTextField
|
|||
|
||||
class ContinueSettingsComponent: DumbAware {
|
||||
val panel: JPanel = JPanel(GridBagLayout())
|
||||
val remoteConfigServerUrl: JTextField = JTextField()
|
||||
val remoteConfigSyncPeriod: JTextField = JTextField()
|
||||
val userToken: JTextField = JTextField()
|
||||
|
||||
init {
|
||||
val constraints = GridBagConstraints()
|
||||
|
|
@ -26,13 +29,25 @@ class ContinueSettingsComponent: DumbAware {
|
|||
constraints.gridx = 0
|
||||
constraints.gridy = GridBagConstraints.RELATIVE
|
||||
|
||||
panel.add(JLabel("Remote Config Server URL:"), constraints)
|
||||
constraints.gridy++
|
||||
constraints.gridy++
|
||||
panel.add(remoteConfigServerUrl, constraints)
|
||||
constraints.gridy++
|
||||
panel.add(JLabel("Remote Config Sync Period (in minutes):"), constraints)
|
||||
constraints.gridy++
|
||||
panel.add(remoteConfigSyncPeriod, constraints)
|
||||
constraints.gridy++
|
||||
panel.add(JLabel("User Token:"), constraints)
|
||||
constraints.gridy++
|
||||
panel.add(userToken, constraints)
|
||||
constraints.gridy++
|
||||
|
||||
// Add a "filler" component that takes up all remaining vertical space
|
||||
constraints.weighty = 1.0
|
||||
val filler = JPanel()
|
||||
panel.add(filler, constraints)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@State(
|
||||
|
|
@ -43,6 +58,9 @@ open class ContinueExtensionSettings : PersistentStateComponent<ContinueExtensio
|
|||
|
||||
class ContinueState {
|
||||
var shownWelcomeDialog: Boolean = false
|
||||
var remoteConfigServerUrl: String? = null
|
||||
var remoteConfigSyncPeriod: Int = 60
|
||||
var userToken: String? = null
|
||||
}
|
||||
|
||||
var continueState: ContinueState = ContinueState()
|
||||
|
|
@ -70,18 +88,28 @@ class ContinueExtensionConfigurable : Configurable {
|
|||
}
|
||||
|
||||
override fun isModified(): Boolean {
|
||||
val settings = ServiceManager.getService(ContinueExtensionSettings::class.java)
|
||||
return false;
|
||||
val settings = ContinueExtensionSettings.instance
|
||||
val modified = mySettingsComponent?.remoteConfigServerUrl?.text != settings.continueState.remoteConfigServerUrl ||
|
||||
mySettingsComponent?.remoteConfigSyncPeriod?.text?.toInt() != settings.continueState.remoteConfigSyncPeriod ||
|
||||
mySettingsComponent?.userToken?.text != settings.continueState.userToken
|
||||
return modified;
|
||||
}
|
||||
|
||||
override fun apply() {
|
||||
val settings =
|
||||
ServiceManager.getService(ContinueExtensionSettings::class.java)
|
||||
val settings = ContinueExtensionSettings.instance
|
||||
settings.continueState.remoteConfigServerUrl = mySettingsComponent?.remoteConfigServerUrl?.text
|
||||
settings.continueState.remoteConfigSyncPeriod = mySettingsComponent?.remoteConfigSyncPeriod?.text?.toInt() ?: 60
|
||||
settings.continueState.userToken = mySettingsComponent?.userToken?.text
|
||||
|
||||
val continuePluginService = ServiceManager.getService(ContinuePluginService::class.java)
|
||||
continuePluginService.coreMessenger?.request("config/updateRemoteConfigSettings", settings.continueState, null) { _ -> }
|
||||
}
|
||||
|
||||
override fun reset() {
|
||||
val settings =
|
||||
ServiceManager.getService(ContinueExtensionSettings::class.java)
|
||||
val settings = ContinueExtensionSettings.instance
|
||||
mySettingsComponent?.remoteConfigServerUrl?.text = settings.continueState.remoteConfigServerUrl
|
||||
mySettingsComponent?.remoteConfigSyncPeriod?.text = settings.continueState.remoteConfigSyncPeriod.toString()
|
||||
mySettingsComponent?.userToken?.text = settings.continueState.userToken
|
||||
}
|
||||
|
||||
override fun disposeUIResources() {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { ConfigHandler } from "core/config/handler";
|
|||
import { addModel, addOpenAIKey, deleteModel } from "core/config/util";
|
||||
import { indexDocs } from "core/indexing/docs";
|
||||
import TransformersJsEmbeddingsProvider from "core/indexing/embeddings/TransformersJsEmbeddingsProvider";
|
||||
import { CodebaseIndexer } from "core/indexing/indexCodebase";
|
||||
import { CodebaseIndexer, PauseToken } from "core/indexing/indexCodebase";
|
||||
import { logDevData } from "core/util/devdata";
|
||||
import historyManager from "core/util/history";
|
||||
import { Message } from "core/util/messenger";
|
||||
|
|
@ -32,8 +32,17 @@ export class Core {
|
|||
constructor(messenger: IpcMessenger, ide: IDE) {
|
||||
this.messenger = messenger;
|
||||
this.ide = ide;
|
||||
this.configHandler = new ConfigHandler(this.ide);
|
||||
this.codebaseIndexer = new CodebaseIndexer(this.configHandler, this.ide);
|
||||
this.configHandler = new ConfigHandler(
|
||||
this.ide,
|
||||
undefined,
|
||||
(text: string) => {},
|
||||
() => {},
|
||||
);
|
||||
this.codebaseIndexer = new CodebaseIndexer(
|
||||
this.configHandler,
|
||||
this.ide,
|
||||
new PauseToken(false),
|
||||
);
|
||||
|
||||
const on = this.messenger.on.bind(this.messenger);
|
||||
|
||||
|
|
@ -87,13 +96,14 @@ export class Core {
|
|||
this.configHandler.reloadConfig();
|
||||
return this.configHandler.getSerializedConfig();
|
||||
});
|
||||
on("config/updateRemoteConfigSettings", (msg) => {});
|
||||
|
||||
// Context providers
|
||||
on("context/addDocs", async (msg) => {
|
||||
for await (const _ of indexDocs(
|
||||
msg.data.title,
|
||||
new URL(msg.data.url),
|
||||
new TransformersJsEmbeddingsProvider()
|
||||
new TransformersJsEmbeddingsProvider(),
|
||||
)) {
|
||||
}
|
||||
});
|
||||
|
|
@ -108,7 +118,7 @@ export class Core {
|
|||
const config = await this.config();
|
||||
const llm = await this.getSelectedModel();
|
||||
const provider = config.contextProviders?.find(
|
||||
(provider) => provider.description.title === msg.data.name
|
||||
(provider) => provider.description.title === msg.data.name,
|
||||
);
|
||||
if (!provider) return [];
|
||||
|
||||
|
|
@ -136,12 +146,12 @@ export class Core {
|
|||
async function* llmStreamChat(
|
||||
configHandler: ConfigHandler,
|
||||
abortedMessageIds: Set<string>,
|
||||
msg: Message<Protocol["llm/streamChat"][0]>
|
||||
msg: Message<Protocol["llm/streamChat"][0]>,
|
||||
) {
|
||||
const model = await configHandler.llmFromTitle(msg.data.title);
|
||||
const gen = model.streamChat(
|
||||
msg.data.messages,
|
||||
msg.data.completionOptions
|
||||
msg.data.completionOptions,
|
||||
);
|
||||
let next = await gen.next();
|
||||
while (!next.done) {
|
||||
|
|
@ -158,19 +168,19 @@ export class Core {
|
|||
}
|
||||
|
||||
on("llm/streamChat", (msg) =>
|
||||
llmStreamChat(this.configHandler, this.abortedMessageIds, msg)
|
||||
llmStreamChat(this.configHandler, this.abortedMessageIds, msg),
|
||||
);
|
||||
|
||||
async function* llmStreamComplete(
|
||||
configHandler: ConfigHandler,
|
||||
abortedMessageIds: Set<string>,
|
||||
|
||||
msg: Message<Protocol["llm/streamComplete"][0]>
|
||||
msg: Message<Protocol["llm/streamComplete"][0]>,
|
||||
) {
|
||||
const model = await configHandler.llmFromTitle(msg.data.title);
|
||||
const gen = model.streamComplete(
|
||||
msg.data.prompt,
|
||||
msg.data.completionOptions
|
||||
msg.data.completionOptions,
|
||||
);
|
||||
let next = await gen.next();
|
||||
while (!next.done) {
|
||||
|
|
@ -187,13 +197,13 @@ export class Core {
|
|||
}
|
||||
|
||||
on("llm/streamComplete", (msg) =>
|
||||
llmStreamComplete(this.configHandler, this.abortedMessageIds, msg)
|
||||
llmStreamComplete(this.configHandler, this.abortedMessageIds, msg),
|
||||
);
|
||||
|
||||
async function* runNodeJsSlashCommand(
|
||||
configHandler: ConfigHandler,
|
||||
abortedMessageIds: Set<string>,
|
||||
msg: Message<Protocol["command/run"][0]>
|
||||
msg: Message<Protocol["command/run"][0]>,
|
||||
) {
|
||||
const {
|
||||
input,
|
||||
|
|
@ -209,7 +219,7 @@ export class Core {
|
|||
const config = await configHandler.loadConfig();
|
||||
const llm = await configHandler.llmFromTitle(modelTitle);
|
||||
const slashCommand = config.slashCommands?.find(
|
||||
(sc) => sc.name === slashCommandName
|
||||
(sc) => sc.name === slashCommandName,
|
||||
);
|
||||
if (!slashCommand) {
|
||||
throw new Error(`Unknown slash command ${slashCommandName}`);
|
||||
|
|
@ -239,13 +249,13 @@ export class Core {
|
|||
yield { done: true, content: "" };
|
||||
}
|
||||
on("command/run", (msg) =>
|
||||
runNodeJsSlashCommand(this.configHandler, this.abortedMessageIds, msg)
|
||||
runNodeJsSlashCommand(this.configHandler, this.abortedMessageIds, msg),
|
||||
);
|
||||
}
|
||||
|
||||
public invoke<T extends keyof Protocol>(
|
||||
method: keyof Protocol,
|
||||
data: Protocol[T][0]
|
||||
data: Protocol[T][0],
|
||||
): Protocol[T][1] {
|
||||
const response = this.messenger.invoke(method, data);
|
||||
return response;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue