truetrue
diff --git a/extensions/intellij/CONTRIBUTING.md b/extensions/intellij/CONTRIBUTING.md
index 9757bc430..fc1fdaa24 100644
--- a/extensions/intellij/CONTRIBUTING.md
+++ b/extensions/intellij/CONTRIBUTING.md
@@ -101,6 +101,32 @@ allow for changes to your `config.json` and other files during development, with
When using the `Run Continue` task, we automatically tail both prompt logs and IDE logs.
+#### Viewing more IDE logs
+
+You can selectively increase the log granularity (e.g., debug-level logs) as follows:
+
+- Navigate to `Help | Diagnostic Tools | Debug Log Settings...`
+- Add a line in the format: `com.intellij.diagnostic:debug`
+
+You can find more information about this feature in [official docs](https://youtrack.jetbrains.com/articles/SUPPORT-A-43/How-to-enable-debug-logging-in-IntelliJ-IDEA).
+
+### Developing `build.plugin.kts`
+
+If in doubt, check out the
+official [IntelliJ Platform Plugin Template](https://github.com/JetBrains/intellij-platform-plugin-template).
+These templates are the most up-to-date examples of how to correctly customize the plugin build scripts.
+
+Also, check out
+the [useful recipes](https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-recipes.html)
+for common problems.
+
+### Adding new extensions in `plugin.xml`
+
+There's a tool called [JetBrains Platform Explorer](https://plugins.jetbrains.com/intellij-platform-explorer) that
+aggregates plugin metadata and allows you to filter by specific
+extension points. If you're having trouble implementing a feature that's not officially documented,
+you can learn from other open source plugins.
+
### Reloading changes
- `extensions/intellij`: Attempt to reload changed classes by selecting
diff --git a/extensions/intellij/build.gradle.kts b/extensions/intellij/build.gradle.kts
index 8dc8ce738..8692b35f4 100644
--- a/extensions/intellij/build.gradle.kts
+++ b/extensions/intellij/build.gradle.kts
@@ -1,77 +1,75 @@
import org.jetbrains.changelog.markdownToHTML
-
-fun properties(key: String) = providers.gradleProperty(key)
+import org.jetbrains.intellij.platform.gradle.TestFrameworkType
+import org.jetbrains.intellij.platform.gradle.tasks.PrepareSandboxTask
fun environment(key: String) = providers.environmentVariable(key)
-fun Sync.prepareSandbox() {
- from("../../binary/bin") { into("${intellij.pluginName.get()}/core/") }
-}
-
val remoteRobotVersion = "0.11.23"
+val platformType: String by project
+val platformVersion: String by project
+val pluginGroup: String by project
+val pluginVersion: String by project
+val pluginSinceBuild: String by project
+val pluginRepositoryUrl: String by project
val isEap get() = environment("RELEASE_CHANNEL").orNull == "eap"
-val pluginVersion = properties("pluginVersion").get()
plugins {
- id("java")
- kotlin("jvm") version "1.9.0"
- id("org.jetbrains.intellij") version "1.15.0"
+ kotlin("jvm") version "1.8.0"
+ id("org.jetbrains.intellij.platform") version "2.6.0"
id("org.jetbrains.changelog") version "2.1.2"
id("org.jetbrains.qodana") version "0.1.13"
id("org.jetbrains.kotlinx.kover") version "0.7.3"
- kotlin("plugin.serialization") version "1.8.0"
id("io.sentry.jvm.gradle") version "5.8.0"
}
-group = properties("pluginGroup").get()
+group = pluginGroup
version = if (isEap) "$pluginVersion-eap" else pluginVersion
repositories {
mavenCentral()
- maven { url = uri("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies") }
+ intellijPlatform {
+ defaultRepositories()
+ }
}
dependencies {
- implementation("org.jetbrains.kotlin:kotlin-stdlib:1.4.32")
- implementation("com.posthog.java:posthog:1.+")
- implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0")
+ intellijPlatform {
+ create(platformType, platformVersion)
+ plugins(listOf("org.jetbrains.plugins.terminal:223.8214.6"))
+ testFramework(TestFrameworkType.Platform)
+ }
+ implementation("com.posthog.java:posthog:1.2.0")
+
testImplementation("com.intellij.remoterobot:remote-robot:$remoteRobotVersion")
testImplementation("com.intellij.remoterobot:remote-fixtures:$remoteRobotVersion")
testImplementation("io.mockk:mockk:1.14.2")
- testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
- testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")
testImplementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
testImplementation("com.automation-remarks:video-recorder-junit5:2.0")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3")
- testImplementation(kotlin("test"))
+ testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.10.0") // required to run both JUnit 5 and JUnit 3
}
-// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for
-// 2022.2+.
kotlin { jvmToolchain(17) }
-// Configure Gradle IntelliJ Plugin - read more:
-// https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
-intellij {
- pluginName = properties("pluginName")
- version = properties("platformVersion")
- type = properties("platformType")
-
- // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
- plugins =
- properties("platformPlugins").map {
- it.split(',').map(String::trim).filter(String::isNotEmpty)
+intellijPlatform {
+ pluginConfiguration {
+ ideaVersion {
+ sinceBuild = pluginSinceBuild
}
+ }
+ pluginVerification {
+ ides {
+ ide("IC", "2025.1.4")
+ ide("IC", "2022.3.3")
+ }
+ }
}
-// Configure Gradle Changelog Plugin - read more:
-// https://github.com/JetBrains/gradle-changelog-plugin
changelog {
groups.empty()
- repositoryUrl = properties("pluginRepositoryUrl")
+ repositoryUrl = pluginRepositoryUrl
}
-// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin
qodana {
cachePath = provider { file(".qodana").canonicalPath }
reportPath = provider { file("build/reports/inspections").canonicalPath }
@@ -79,75 +77,52 @@ qodana {
showReport = environment("QODANA_SHOW_REPORT").map { it.toBoolean() }.getOrElse(false)
}
-// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
koverReport { defaults { xml { onCheck = true } } }
+intellijPlatformTesting {
+ runIde {
+ register("runIdeForUiTests") {
+ task {
+ environment(
+ "CONTINUE_GLOBAL_DIR",
+ "${rootProject.projectDir}/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/test-continue"
+ )
+ jvmArgumentProviders += CommandLineArgumentProvider {
+ listOf(
+ "-Drobot-server.port=8082",
+ "-Dide.mac.message.dialogs.as.sheets=false",
+ "-Djb.privacy.policy.text=",
+ "-Djb.consents.confirmation.enabled=false",
+ "-Dide.mac.file.chooser.native=false",
+ "-DjbScreenMenuBar.enabled=false",
+ "-Dapple.laf.useScreenMenuBar=false",
+ "-Didea.trust.all.projects=true",
+ "-Dide.show.tips.on.startup.default.value=false",
+ "-Dide.browser.jcef.jsQueryPoolSize=10000",
+ "-Dide.browser.jcef.contextMenu.devTools.enabled=true"
+ )
+ }
+ }
+ plugins {
+ robotServerPlugin()
+ }
+ }
+ }
+}
+
tasks {
- downloadRobotServerPlugin {
- version = remoteRobotVersion
- }
-
- prepareSandbox {
- prepareSandbox()
- }
-
- prepareTestingSandbox {
- prepareSandbox()
- }
-
- prepareUiTestingSandbox {
- prepareSandbox()
- }
-
- wrapper {
- gradleVersion = properties("gradleVersion").get()
+ withType {
+ from("../../binary/bin") {
+ into(pluginName.map { "$it/core" })
+ }
}
patchPluginXml {
- sinceBuild = properties("pluginSinceBuild")
- untilBuild = properties("pluginUntilBuild")
- pluginDescription =
- providers.fileContents(layout.projectDirectory.file("README.md")).asText.map {
- val start = ""
- val end = ""
-
- with(it.lines()) {
- if (!containsAll(listOf(start, end))) {
- throw GradleException(
- "Plugin description section not found in README.md:\n$start ... $end"
- )
- }
- subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML)
- }
- }
- }
-
- // Configure UI tests plugin
- // Read more: https://github.com/JetBrains/intellij-ui-test-robot
- runIdeForUiTests {
- environment(
- "CONTINUE_GLOBAL_DIR",
- "${rootProject.projectDir}/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/test-continue"
- )
- systemProperty("robot-server.port", "8082")
- systemProperty("ide.mac.message.dialogs.as.sheets", "false")
- systemProperty("jb.privacy.policy.text", "")
- systemProperty("jb.consents.confirmation.enabled", "false")
- systemProperty("ide.mac.file.chooser.native", "false")
- systemProperty("jbScreenMenuBar.enabled", "false")
- systemProperty("apple.laf.useScreenMenuBar", "false")
- systemProperty("idea.trust.all.projects", "true")
- systemProperty("ide.show.tips.on.startup.default.value", "false")
- systemProperty("ide.browser.jcef.jsQueryPoolSize", "10000")
- systemProperty("ide.browser.jcef.contextMenu.devTools.enabled", "true")
-
- // This is to ensure we load the GUI with OSR enabled. We have logic that
- // renders with OSR disabled below a particular IDE version.
- // See ContinueExtensionSettingsService.kt for more info.
- // Currently commented out however since test fail in CI with this version
-// intellij {
-// version = "2024.1"
-// }
+ pluginDescription = providers.fileContents(layout.projectDirectory.file("README.md")).asText.get()
+ .substringAfter("")
+ .substringBefore("")
+ .let(::markdownToHTML)
+ check(pluginDescription.get().isNotEmpty()) { "Plugin description section not found in README.md" }
}
signPlugin {
@@ -164,8 +139,10 @@ tasks {
}
runIde {
- val dir = "${rootProject.projectDir.parentFile.parentFile.absolutePath}/manual-testing-sandbox"
- args = listOf(dir, "$dir/test.kt")
+ val openProject = "$projectDir/../../manual-testing-sandbox"
+ argumentProviders += CommandLineArgumentProvider {
+ listOf(openProject, "$openProject/test.kt")
+ }
}
test {
diff --git a/extensions/intellij/gradle.properties b/extensions/intellij/gradle.properties
index a1c5d01c1..69bb623a6 100644
--- a/extensions/intellij/gradle.properties
+++ b/extensions/intellij/gradle.properties
@@ -1,26 +1,9 @@
-# IntelliJ Platform Artifacts Repositories -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html
pluginGroup=com.github.continuedev.continueintellijextension
-pluginName=continue-intellij-extension
pluginRepositoryUrl=https://github.com/continuedev/continue
-# SemVer format -> https://semver.org
-pluginVersion=1.0.30
-# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
+pluginVersion=1.0.33
pluginSinceBuild=223
-# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType=IC
platformVersion=2022.3.3
-# org.gradle.java.home=/opt/homebrew/opt/openjdk@17
-#platformVersion = LATEST-EAP-SNAPSHOT
-# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
-# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
-platformPlugins=org.jetbrains.plugins.terminal
-# Gradle Releases -> https://github.com/gradle/gradle/releases
-gradleVersion=8.3
-# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
kotlin.stdlib.default.dependency=false
-# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html
org.gradle.configuration-cache=true
-# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
org.gradle.caching=true
-# Enable Gradle Kotlin DSL Lazy Property Assignment -> https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:assignment
-systemProp.org.gradle.unsafe.kotlin.assignment=true
diff --git a/extensions/intellij/gradle/wrapper/gradle-wrapper.jar b/extensions/intellij/gradle/wrapper/gradle-wrapper.jar
index 7f93135c4..d64cd4917 100644
Binary files a/extensions/intellij/gradle/wrapper/gradle-wrapper.jar and b/extensions/intellij/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/extensions/intellij/gradle/wrapper/gradle-wrapper.properties b/extensions/intellij/gradle/wrapper/gradle-wrapper.properties
index ab1b658ea..d4081da47 100644
--- a/extensions/intellij/gradle/wrapper/gradle-wrapper.properties
+++ b/extensions/intellij/gradle/wrapper/gradle-wrapper.properties
@@ -1,8 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-#org.gradle.java.home=/opt/homebrew/opt/openjdk@17
\ No newline at end of file
diff --git a/extensions/intellij/gradlew b/extensions/intellij/gradlew
index 0adc8e1a5..1aa94a426 100755
--- a/extensions/intellij/gradlew
+++ b/extensions/intellij/gradlew
@@ -145,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC3045
+ # shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -153,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC3045
+ # shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -202,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
-# Collect all arguments for the java command;
-# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
-# shell script including quotes and variable substitutions, so put them in
-# double quotes to make sure that they get re-expanded; and
-# * put everything else in single quotes, so that it's not re-expanded.
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt
index c6df8eddd..b9eec734c 100644
--- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt
@@ -10,7 +10,7 @@ import com.intellij.openapi.fileEditor.FileEditorManager
class RestartContinueProcess : AnAction() {
override fun actionPerformed(e: AnActionEvent) {
val pluginService = getContinuePluginService(e.project) ?: return
- pluginService.coreMessengerManager?.restart()
+ pluginService.coreMessengerManager?.coreMessenger?.restart()
}
}
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/auth/ContinueAuthService.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/auth/ContinueAuthService.kt
index 4538b8771..e52a69711 100644
--- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/auth/ContinueAuthService.kt
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/auth/ContinueAuthService.kt
@@ -112,8 +112,10 @@ class ContinueAuthService {
val jsonBody = gson.toJson(mapOf("refreshToken" to refreshToken))
val url = getControlPlaneUrl() + "/auth/refresh"
val response = HttpRequests.post(url, HttpRequests.JSON_CONTENT_TYPE)
- .connect { connection -> connection.write(jsonBody.toByteArray()) }
- .toString()
+ .connect {
+ connection -> connection.write(jsonBody.toByteArray())
+ connection.readString()
+ }
return gson.fromJson(response, RefreshTokenResponse::class.java)
}
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt
index 02fedb3b3..1945bf546 100644
--- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt
@@ -6,7 +6,6 @@ class MessageTypes {
"readRangeInFile",
"isTelemetryEnabled",
"getUniqueId",
- "getWorkspaceConfigs",
"getDiff",
"getTerminalContents",
"getWorkspaceDirs",
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/ApplyToFileHandler.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/ApplyToFileHandler.kt
index 28b648d4a..856215be2 100644
--- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/ApplyToFileHandler.kt
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/ApplyToFileHandler.kt
@@ -29,6 +29,9 @@ class ApplyToFileHandler(
private val diffStreamService: DiffStreamService
) {
+ // Store the original file content before applying changes
+ private val originalFileContent: String? = editorUtils?.getDocumentText()
+
suspend fun handleApplyToFile() {
// Notify webview that we're starting to stream
notifyStreamStarted()
@@ -111,6 +114,7 @@ class ApplyToFileHandler(
numDiffs = numDiffs,
filepath = params.filepath,
fileContent = params.text,
+ originalFileContent = originalFileContent,
toolCallId = params.toolCallId.toString()
)
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt
index 1c0ab242a..1e8e78208 100644
--- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt
@@ -17,11 +17,11 @@ class CoreMessenger(
private val project: Project,
private val ideProtocolClient: IdeProtocolClient,
val coroutineScope: CoroutineScope,
- private val onExit: () -> Unit
+ private val onUnexpectedExit: () -> Unit
) {
private val gson = Gson()
private val responseListeners = mutableMapOf Unit>()
- private val process = startContinueProcess()
+ private var process = startContinueProcess()
private val log = Logger.getInstance(CoreMessenger::class.java)
fun request(messageType: String, data: Any?, messageId: String?, onResponse: (Any?) -> Unit) {
@@ -36,7 +36,7 @@ class CoreMessenger(
val process = if (isTcp)
ContinueSocketProcess()
else
- ContinueBinaryProcess(onExit)
+ ContinueBinaryProcess(onUnexpectedExit)
return ContinueProcessHandler(coroutineScope, process, ::handleMessage)
}
@@ -81,7 +81,15 @@ class CoreMessenger(
null
}
- fun killSubProcess() {
+ fun restart() {
+ log.warn("Restarting Continue process")
+ responseListeners.clear()
+ process.close()
+ process = startContinueProcess()
+ }
+
+ fun close() {
+ log.warn("Closing Continue process")
process.close()
}
}
\ No newline at end of file
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessengerManager.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessengerManager.kt
index 3dbf9c2d5..71b367e20 100644
--- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessengerManager.kt
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessengerManager.kt
@@ -9,37 +9,34 @@ import com.intellij.openapi.project.Project
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
+import kotlin.time.Duration.Companion.seconds
class CoreMessengerManager(
- private val project: Project,
- private val ideProtocolClient: IdeProtocolClient,
+ project: Project,
+ ideProtocolClient: IdeProtocolClient,
private val coroutineScope: CoroutineScope
) {
- var coreMessenger: CoreMessenger = createCoreMessenger()
- private var lastBackoffInterval = 0.5
+ val coreMessenger = CoreMessenger(project, ideProtocolClient, coroutineScope, ::onUnexpectedExit)
+ private var backoffIntervalSeconds = 1
private val log = Logger.getInstance(CoreMessengerManager::class.java)
init {
setupAnonymousTelemetry()
}
- fun restart() {
+ private fun onUnexpectedExit() {
coroutineScope.launch {
try {
- coreMessenger.killSubProcess()
- lastBackoffInterval *= 2
- log.warn("Continue process exited, retrying in $lastBackoffInterval seconds")
- delay((lastBackoffInterval * 1000).toLong())
- coreMessenger = createCoreMessenger()
+ delay(backoffIntervalSeconds.seconds)
+ backoffIntervalSeconds *= 2
+ log.warn("Continue process terminated externally, retrying in $backoffIntervalSeconds seconds")
+ coreMessenger.restart()
} catch (e: Exception) {
service().capture("jetbrains_core_start_error", mapOf("error" to e))
}
}
}
- private fun createCoreMessenger() =
- CoreMessenger(project, ideProtocolClient, coroutineScope, ::restart)
-
private fun setupAnonymousTelemetry() {
coreMessenger.request("config/getSerializedProfileInfo", null, null) { response ->
val allowAnonymousTelemetry =
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt
index 08a5e8d18..693dfe15c 100644
--- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt
@@ -8,12 +8,13 @@ import com.github.continuedev.continueintellijextension.editor.DiffStreamService
import com.github.continuedev.continueintellijextension.editor.EditorUtils
import com.github.continuedev.continueintellijextension.error.ContinueErrorService
import com.github.continuedev.continueintellijextension.protocol.*
-import com.github.continuedev.continueintellijextension.services.*
-import com.github.continuedev.continueintellijextension.utils.*
+import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings
+import com.github.continuedev.continueintellijextension.services.ContinuePluginService
+import com.github.continuedev.continueintellijextension.utils.getMachineUniqueID
+import com.github.continuedev.continueintellijextension.utils.uuid
import com.google.gson.Gson
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.command.WriteCommandAction
-import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.components.service
import com.intellij.openapi.editor.SelectionModel
import com.intellij.openapi.fileEditor.FileEditorManager
@@ -21,7 +22,10 @@ import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.openapi.wm.ToolWindowManager
-import kotlinx.coroutines.*
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.launch
import java.awt.Toolkit
import java.awt.datatransfer.StringSelection
@@ -192,11 +196,6 @@ class IdeProtocolClient(
respond(tags)
}
- "getWorkspaceConfigs" -> {
- val configs = ide.getWorkspaceConfigs()
- respond(configs)
- }
-
"getTerminalContents" -> {
val contents = ide.getTerminalContents()
respond(contents)
@@ -323,7 +322,11 @@ class IdeProtocolClient(
}
"runCommand" -> {
- // Running commands not yet supported in JetBrains
+ val params = Gson().fromJson(
+ dataElement.toString(),
+ RunCommandParams::class.java
+ )
+ ide.runCommand(params.command, params.options)
respond(null)
}
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt
index 5a3778d30..542d9c338 100644
--- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt
@@ -1,9 +1,9 @@
-
package com.github.continuedev.continueintellijextension.`continue`
import com.github.continuedev.continueintellijextension.*
import com.github.continuedev.continueintellijextension.constants.ContinueConstants
import com.github.continuedev.continueintellijextension.constants.getContinueGlobalPath
+import com.github.continuedev.continueintellijextension.`continue`.file.FileUtils
import com.github.continuedev.continueintellijextension.error.ContinueErrorService
import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings
import com.github.continuedev.continueintellijextension.services.ContinuePluginService
@@ -27,19 +27,19 @@ import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.guessProjectDir
-import com.intellij.openapi.util.IconLoader
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.openapi.vfs.VirtualFileManager
+import com.intellij.openapi.wm.ToolWindowManager
import com.intellij.psi.PsiDocumentManager
import com.intellij.testFramework.LightVirtualFile
import kotlinx.coroutines.*
+import org.jetbrains.plugins.terminal.ShellTerminalWidget
+import org.jetbrains.plugins.terminal.TerminalView
import java.awt.Toolkit
import java.awt.datatransfer.DataFlavor
import java.io.BufferedReader
import java.io.File
-import java.io.FileInputStream
import java.io.InputStreamReader
-import java.nio.charset.Charset
class IntelliJIDE(
private val project: Project,
@@ -48,13 +48,13 @@ class IntelliJIDE(
) : IDE {
private val gitService = GitService(project, continuePluginService)
-
+ private val fileUtils = FileUtils()
private val ripgrep: String = getRipgrepPath()
init {
try {
val os = getOS()
-
+
if (os == OS.LINUX || os == OS.MAC) {
val file = File(ripgrep)
if (!file.canExecute()) {
@@ -135,7 +135,33 @@ class IntelliJIDE(
}
override suspend fun getTerminalContents(): String {
- return ""
+ return withContext(Dispatchers.EDT) {
+ try {
+ val toolWindow = ToolWindowManager.getInstance(project).getToolWindow("Terminal")
+
+ val terminalView = TerminalView.getInstance(project)
+ // Find the first terminal widget selected, whatever its state, running command or not.
+ val widget = terminalView.getWidgets().filterIsInstance().firstOrNull {
+ toolWindow?.getContentManager()?.getContent(it)?.isSelected ?: false
+ }
+
+ if (widget != null) {
+ val textBuffer = widget.terminalTextBuffer
+ val stringBuilder = StringBuilder()
+ // Iterate through all lines in the buffer (history + screen)
+ for (i in 0 until textBuffer.historyLinesCount + textBuffer.screenLinesCount) {
+ stringBuilder.append(textBuffer.getLine(i).text).append('\n')
+ }
+ stringBuilder.toString()
+ } else {
+ "" // Return empty if no terminal is available
+ }
+ } catch (e: Exception) {
+ println("Error getting terminal contents: ${e.message}")
+ e.printStackTrace()
+ "" // Return empty on error
+ }
+ }
}
override suspend fun getDebugLocals(threadIndex: Int): String {
@@ -154,39 +180,11 @@ class IntelliJIDE(
return workspaceDirectories().toList()
}
- override suspend fun getWorkspaceConfigs(): List {
- val workspaceDirs = this.getWorkspaceDirs()
+ override suspend fun fileExists(filepath: String): Boolean =
+ fileUtils.fileExists(filepath)
- val configs = mutableListOf()
-
- for (workspaceDir in workspaceDirs) {
- val dir = VirtualFileManager.getInstance().findFileByUrl(workspaceDir)
- if (dir != null) {
- val contents = dir.children.mapNotNull { it.toUriOrNull() }
-
- // Find any .continuerc.json files
- for (file in contents) {
- if (file.endsWith(".continuerc.json")) {
- val fileContent = UriUtils.uriToFile(file).readText()
- configs.add(fileContent)
- }
- }
- }
- }
-
- return configs as List
- }
-
- override suspend fun fileExists(filepath: String): Boolean {
- val file = UriUtils.uriToFile(filepath)
- return file.exists()
- }
-
- override suspend fun writeFile(path: String, contents: String) {
- val file = UriUtils.uriToFile(path)
- file.parentFile?.mkdirs()
- file.writeText(contents)
- }
+ override suspend fun writeFile(path: String, contents: String) =
+ fileUtils.writeFile(path, contents)
override suspend fun showVirtualFile(title: String, contents: String) {
val virtualFile = LightVirtualFile(title, contents)
@@ -220,8 +218,65 @@ class IntelliJIDE(
}
}
- override suspend fun runCommand(command: String) {
- throw NotImplementedError("runCommand not implemented in IntelliJ")
+ override suspend fun runCommand(command: String, options: TerminalOptions?) {
+ val terminalOptions =
+ options ?: TerminalOptions(reuseTerminal = true, terminalName = null, waitForCompletion = false)
+
+ ApplicationManager.getApplication().invokeLater {
+ try {
+ val toolWindow = ToolWindowManager.getInstance(project).getToolWindow("Terminal")
+ toolWindow?.activate({
+ try {
+ val terminalView = TerminalView.getInstance(project)
+ var widget: ShellTerminalWidget? = null
+
+ // 1. Handle reuseTerminal option
+ if (terminalOptions.reuseTerminal == true && terminalView.getWidgets().isNotEmpty()) {
+ // 2. Find by terminalName if provided
+ if (terminalOptions.terminalName != null) {
+ widget = terminalView.getWidgets().filterIsInstance()
+ .firstOrNull {
+ toolWindow.contentManager.getContent(it).tabName == terminalOptions.terminalName
+ && !it.hasRunningCommands()
+ }
+ } else {
+ // 3. Find active terminal, or fall back to the first one
+ widget = terminalView.getWidgets().filterIsInstance()
+ .firstOrNull { toolWindow.contentManager.getContent(it).isSelected }
+ ?: terminalView.getWidgets().filterIsInstance().firstOrNull {
+ !it.hasRunningCommands()
+ }
+ }
+ }
+
+ // 4. Create a new terminal if needed
+ if (widget == null) {
+ widget = terminalView.createLocalShellWidget(
+ project.basePath,
+ terminalOptions.terminalName,
+ true
+ )
+ } else {
+ // Ensure the found widget is visible
+ val content = toolWindow.contentManager.getContent(widget)
+ if (content != null) {
+ toolWindow.contentManager.setSelectedContent(content, true)
+ }
+ }
+
+ // 5. Show and send text
+ widget.ttyConnector?.write(command)
+
+ } catch (e: Exception) {
+ println("Error during terminal widget handling: ${e.message}")
+ e.printStackTrace()
+ }
+ }, true)
+ } catch (e: Exception) {
+ println("Error activating terminal tool window: ${e.message}")
+ e.printStackTrace()
+ }
+ }
}
override suspend fun saveFile(filepath: String) {
@@ -237,38 +292,8 @@ class IntelliJIDE(
}
}
- override suspend fun readFile(filepath: String): String {
- return try {
- val content = ApplicationManager.getApplication().runReadAction {
- val virtualFile = LocalFileSystem.getInstance().findFileByPath(UriUtils.parseUri(filepath).path)
- if (virtualFile != null && FileDocumentManager.getInstance().isFileModified(virtualFile)) {
- return@runReadAction FileDocumentManager.getInstance().getDocument(virtualFile)?.text
- }
- return@runReadAction null
- }
-
- if (content != null) {
- content
- } else {
- val file = UriUtils.uriToFile(filepath)
- if (!file.exists() || file.isDirectory) return ""
- withContext(Dispatchers.IO) {
- FileInputStream(file).use { fis ->
- val sizeToRead = minOf(100000, file.length()).toInt()
- val buffer = ByteArray(sizeToRead)
- val bytesRead = fis.read(buffer, 0, sizeToRead)
- if (bytesRead <= 0) return@use ""
- String(buffer, 0, bytesRead, Charset.forName("UTF-8"))
- // `\r` takes up unnecessary tokens
- .lineSequence().joinToString("\n")
- }
- }
- }
- } catch (e: Exception) {
- e.printStackTrace()
- ""
- }
- }
+ override suspend fun readFile(filepath: String): String =
+ fileUtils.readFile(filepath)
override suspend fun readRangeInFile(filepath: String, range: Range): String {
val fullContents = readFile(filepath)
@@ -343,7 +368,7 @@ class IntelliJIDE(
}
val command = GeneralCommandLine(commandArgs)
-
+
command.setWorkDirectory(project.basePath)
val results = ExecUtil.execAndGetOutput(command).stdout
return results.split("\n")
@@ -357,11 +382,12 @@ class IntelliJIDE(
throw NotImplementedError("Ripgrep not supported, this workspace is remote")
}
}
+
override suspend fun getSearchResults(query: String, maxResults: Int?): String {
val ideInfo = this.getIdeInfo()
if (ideInfo.remoteName == "local") {
try {
- val commandArgs = mutableListOf(
+ val commandArgs = mutableListOf(
ripgrep,
"-i",
"--ignore-file",
@@ -372,20 +398,20 @@ class IntelliJIDE(
"2",
"--heading"
)
-
+
// Conditionally add maxResults flag
if (maxResults != null) {
commandArgs.add("-m")
commandArgs.add(maxResults.toString())
}
-
+
// Add the search query and path
commandArgs.add("-e")
commandArgs.add(query)
commandArgs.add(".")
val command = GeneralCommandLine(commandArgs)
-
+
command.setWorkDirectory(project.basePath)
return ExecUtil.execAndGetOutput(command).stdout
} catch (exception: Exception) {
@@ -576,13 +602,8 @@ class IntelliJIDE(
}
}
- override suspend fun listDir(dir: String): List> {
- val files = UriUtils.uriToFile(dir).listFiles()?.map {
- listOf(it.name, if (it.isDirectory) FileType.DIRECTORY.value else FileType.FILE.value)
- } ?: emptyList()
-
- return files
- }
+ override suspend fun listDir(dir: String): List> =
+ fileUtils.listDir(dir)
override suspend fun getFileStats(files: List): Map {
return files.associateWith { file ->
@@ -594,6 +615,14 @@ class IntelliJIDE(
throw NotImplementedError("gotoDefinition not implemented yet")
}
+ override suspend fun gotoTypeDefinition(location: Location): List {
+ throw NotImplementedError("gotoTypeDefinition not implemented yet")
+ }
+
+ override suspend fun getSignatureHelp(location: Location): SignatureHelp? {
+ throw NotImplementedError("getSignatureHelp not implemented yet")
+ }
+
override suspend fun getReferences(location: Location): List {
throw NotImplementedError("getReferences not implemented yet")
}
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/file/FileUtils.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/file/FileUtils.kt
new file mode 100644
index 000000000..bfd60dfe2
--- /dev/null
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/file/FileUtils.kt
@@ -0,0 +1,69 @@
+package com.github.continuedev.continueintellijextension.`continue`.file
+
+import com.github.continuedev.continueintellijextension.FileType
+import com.github.continuedev.continueintellijextension.`continue`.UriUtils
+import com.intellij.openapi.application.ApplicationManager
+import com.intellij.openapi.fileEditor.FileDocumentManager
+import com.intellij.openapi.vfs.LocalFileSystem
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.withContext
+import java.io.FileInputStream
+import java.nio.charset.Charset
+
+class FileUtils {
+ // todo: use VFS (it's moved from IntellijIde)
+
+ fun fileExists(uri: String): Boolean {
+ val file = UriUtils.uriToFile(uri)
+ return file.exists()
+ }
+
+ fun writeFile(uri: String, contents: String) {
+ val file = UriUtils.uriToFile(uri)
+ file.parentFile?.mkdirs()
+ file.writeText(contents)
+ }
+
+ fun listDir(dir: String): List> {
+ val files = UriUtils.uriToFile(dir).listFiles()?.map {
+ listOf(it.name, if (it.isDirectory) FileType.DIRECTORY.value else FileType.FILE.value)
+ } ?: emptyList()
+
+ return files
+ }
+
+ fun readFile(uri: String): String {
+ return try {
+ val content = ApplicationManager.getApplication().runReadAction {
+ val virtualFile = LocalFileSystem.getInstance().findFileByPath(UriUtils.parseUri(uri).path)
+ if (virtualFile != null && FileDocumentManager.getInstance().isFileModified(virtualFile)) {
+ return@runReadAction FileDocumentManager.getInstance().getDocument(virtualFile)?.text
+ }
+ return@runReadAction null
+ }
+
+ if (content != null) {
+ content
+ } else {
+ val file = UriUtils.uriToFile(uri)
+ if (!file.exists() || file.isDirectory) return ""
+ FileInputStream(file).use { fis ->
+ val sizeToRead = minOf(100000, file.length()).toInt()
+ val buffer = ByteArray(sizeToRead)
+ val bytesRead = fis.read(buffer, 0, sizeToRead)
+ if (bytesRead <= 0) return@use ""
+ val content = String(buffer, 0, bytesRead, Charset.forName("UTF-8"))
+ // Remove `\r` characters but preserve trailing newlines to prevent line count discrepancies
+ val contentWithoutCR = content.replace("\r\n", "\n").replace("\r", "\n")
+ contentWithoutCR
+ }
+ }
+ } catch (e: Exception) {
+ e.printStackTrace()
+ ""
+ }
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/process/ContinueBinaryProcess.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/process/ContinueBinaryProcess.kt
index eb45cc4da..6ef0c335b 100644
--- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/process/ContinueBinaryProcess.kt
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/process/ContinueBinaryProcess.kt
@@ -1,5 +1,7 @@
package com.github.continuedev.continueintellijextension.`continue`.process
+import com.github.continuedev.continueintellijextension.proxy.ProxySettings
+import com.github.continuedev.continueintellijextension.error.ContinueErrorService
import com.github.continuedev.continueintellijextension.services.TelemetryService
import com.github.continuedev.continueintellijextension.utils.OS
import com.github.continuedev.continueintellijextension.utils.getContinueBinaryPath
@@ -14,7 +16,9 @@ import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.attribute.PosixFilePermission
-class ContinueBinaryProcess(private val onExit: () -> Unit) : ContinueProcess {
+class ContinueBinaryProcess(
+ private val onUnexpectedExit: () -> Unit
+) : ContinueProcess {
private val process = startBinaryProcess()
override val input: InputStream = process.inputStream
@@ -28,11 +32,16 @@ class ContinueBinaryProcess(private val onExit: () -> Unit) : ContinueProcess {
runBlocking(Dispatchers.IO) {
setPermissions()
}
- return ProcessBuilder(path).directory(File(path).parentFile)
- .start()
- .apply { onExit().thenRun(onExit).thenRun { reportErrorTelemetry() } }
- }
+ val builder = ProcessBuilder(path)
+ val proxySettings = ProxySettings.getSettings()
+ if (proxySettings.enabled)
+ builder.environment() += "HTTP_PROXY" to proxySettings.proxy
+ return builder
+ .directory(File(path).parentFile)
+ .start()
+ .apply { onExit().thenRun(onUnexpectedExit).thenRun(::reportErrorTelemetry) }
+ }
private fun reportErrorTelemetry() {
var err = process.errorStream?.bufferedReader()?.readText()?.trim()
@@ -44,11 +53,8 @@ class ContinueBinaryProcess(private val onExit: () -> Unit) : ContinueProcess {
err = err.substring(doneIndex + delimiter.length)
}
}
-
- println("Core process exited with output: $err")
-
- val telemetryService = service()
- telemetryService.capture("jetbrains_core_exit", mapOf("error" to err))
+ service().reportMessage("Core process exited with output: $err")
+ service().capture("jetbrains_core_exit", mapOf("error" to err))
}
private companion object {
@@ -67,6 +73,7 @@ class ContinueBinaryProcess(private val onExit: () -> Unit) : ContinueProcess {
elevatePermissions()
}
+ // todo: consider setting permissions ahead-of-time during build/packaging, not at runtime
private fun elevatePermissions() {
val path = getContinueBinaryPath()
val permissions = setOf(
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/process/ContinueProcessHandler.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/process/ContinueProcessHandler.kt
index 68ec83bf6..8e918b2c3 100644
--- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/process/ContinueProcessHandler.kt
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/process/ContinueProcessHandler.kt
@@ -2,6 +2,7 @@ package com.github.continuedev.continueintellijextension.`continue`.process
import com.github.continuedev.continueintellijextension.error.ContinueErrorService
import com.intellij.openapi.components.service
+import com.intellij.openapi.diagnostic.Logger
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel
import java.io.BufferedReader
@@ -19,6 +20,7 @@ class ContinueProcessHandler(
private val pendingWrites = Channel(Channel.UNLIMITED)
private val writer = OutputStreamWriter(process.output)
private val reader = BufferedReader(InputStreamReader(process.input))
+ private val log = Logger.getInstance(ContinueProcessHandler::class.java)
init {
scope.launch(Dispatchers.IO) {
@@ -27,6 +29,7 @@ class ContinueProcessHandler(
val line = reader.readLine()
if (line != null && line.isNotEmpty()) {
try {
+ log.debug("Handle: $line")
handleMessage(line)
} catch (e: Exception) {
service().report(e, "Error handling message: $line")
@@ -40,6 +43,7 @@ class ContinueProcessHandler(
}
scope.launch(Dispatchers.IO) {
for (message in pendingWrites) {
+ log.debug("Write: $message")
writer.write(message)
writer.write("\r\n")
writer.flush()
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/error/ContinueErrorService.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/error/ContinueErrorService.kt
index 21f920ef9..35e23d8a2 100644
--- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/error/ContinueErrorService.kt
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/error/ContinueErrorService.kt
@@ -6,6 +6,7 @@ import com.intellij.openapi.components.Service
import com.intellij.openapi.diagnostic.Attachment
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.extensions.PluginId
+import com.intellij.openapi.util.SystemInfo
import com.intellij.ui.jcef.JBCefApp
import io.sentry.Hint
import io.sentry.Sentry
@@ -26,6 +27,8 @@ class ContinueErrorService {
config.setTag("ide_version", ApplicationInfo.getInstance().build.asString())
config.setTag("jcef_supported", JBCefApp.isSupported().toString())
config.setTag("plugin_version", PluginManagerCore.getPlugin(PluginId.getId(PLUGIN_ID))?.version)
+ config.setTag("system", SystemInfo.OS_NAME)
+ config.setTag("system_version", SystemInfo.OS_VERSION)
}
}
@@ -39,7 +42,14 @@ class ContinueErrorService {
sentryEvent.message = Message().apply { this.message = message }
val hint = Hint.withAttachments(attachments?.map { SentryAttachment(it.bytes, it.path) })
Sentry.captureEvent(sentryEvent, hint)
- log.warn("Problem sent to Sentry: $message", throwable)
+ log.warn("Exception sent to Sentry: $message", throwable)
+ }
+
+ fun reportMessage(
+ message: String,
+ ) {
+ Sentry.captureMessage(message)
+ log.warn("Message sent to Sentry: $message")
}
private companion object {
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ide.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ide.kt
index bf377e675..bc199b35a 100644
--- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ide.kt
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ide.kt
@@ -1,6 +1,7 @@
package com.github.continuedev.continueintellijextension.protocol
-import com.github.continuedev.continueintellijextension.*
+import com.github.continuedev.continueintellijextension.Range
+import com.github.continuedev.continueintellijextension.TerminalOptions
data class GetControlPlaneSessionInfoParams(val silent: Boolean, val useOnboarding: Boolean)
@@ -59,4 +60,6 @@ data class GetGitRootPathParams(val dir: String)
data class ListDirParams(val dir: String)
-data class GetFileStatsParams(val files: List)
\ No newline at end of file
+data class GetFileStatsParams(val files: List)
+
+data class RunCommandParams(val command: String, val options: TerminalOptions?)
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/proxy/ProxyPoolingActivity.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/proxy/ProxyPoolingActivity.kt
new file mode 100644
index 000000000..0d88d0bdd
--- /dev/null
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/proxy/ProxyPoolingActivity.kt
@@ -0,0 +1,36 @@
+package com.github.continuedev.continueintellijextension.proxy
+
+import com.github.continuedev.continueintellijextension.services.ContinuePluginService
+import com.intellij.openapi.components.service
+import com.intellij.openapi.diagnostic.Logger
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.startup.StartupActivity
+import kotlinx.coroutines.*
+import kotlin.time.Duration.Companion.seconds
+
+class ProxyPoolingActivity : StartupActivity {
+ private val scope = CoroutineScope(Dispatchers.Default)
+ private var lastSettings = ProxySettings.getSettings()
+ private val log = Logger.getInstance(ProxyPoolingActivity::class.java)
+
+ override fun runActivity(project: Project) {
+ scope.launch {
+ while (isActive) {
+ val newSettings = ProxySettings.getSettings()
+ if (newSettings != lastSettings) {
+ onSettingsChanged(project)
+ lastSettings = newSettings
+ }
+ delay(2.seconds)
+ }
+ }
+ }
+
+ private fun onSettingsChanged(project: Project) {
+ log.warn("Proxy settings changed, restarting")
+ project.service().coreMessengerManager?.coreMessenger?.restart()
+ }
+}
+
+
+
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/proxy/ProxySettings.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/proxy/ProxySettings.kt
new file mode 100644
index 000000000..70c66637c
--- /dev/null
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/proxy/ProxySettings.kt
@@ -0,0 +1,20 @@
+package com.github.continuedev.continueintellijextension.proxy
+
+import com.intellij.util.net.HttpConfigurable
+
+data class ProxySettings(
+ val enabled: Boolean,
+ val proxy: String,
+) {
+
+ companion object {
+ fun getSettings(): ProxySettings {
+ val settings = HttpConfigurable.getInstance()
+ return ProxySettings(
+ enabled = settings.USE_HTTP_PROXY,
+ proxy = "${settings.PROXY_HOST}:${settings.PROXY_PORT}"
+ )
+ }
+ }
+
+}
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinuePluginService.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinuePluginService.kt
index 6ebb8f41f..102981715 100644
--- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinuePluginService.kt
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinuePluginService.kt
@@ -33,7 +33,7 @@ class ContinuePluginService : Disposable, DumbAware {
coroutineScope.cancel()
coreMessenger?.coroutineScope?.let {
it.cancel()
- coreMessenger?.killSubProcess()
+ coreMessenger?.close()
}
}
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinuePluginToolWindowFactory.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinuePluginToolWindowFactory.kt
index 4afa1cb45..256dba81e 100644
--- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinuePluginToolWindowFactory.kt
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinuePluginToolWindowFactory.kt
@@ -2,62 +2,69 @@ package com.github.continuedev.continueintellijextension.toolWindow
import com.github.continuedev.continueintellijextension.services.ContinuePluginService
import com.intellij.openapi.actionSystem.ActionManager
-import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.components.service
import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.project.Project
import com.intellij.openapi.wm.ToolWindow
import com.intellij.openapi.wm.ToolWindowFactory
import com.intellij.ui.content.ContentFactory
+import com.intellij.ui.dsl.builder.AlignX
+import com.intellij.ui.dsl.builder.panel
+import com.intellij.ui.jcef.JBCefApp
+import com.intellij.util.ui.JBUI.Borders.empty
import javax.swing.JComponent
+import javax.swing.JPanel
const val JS_QUERY_POOL_SIZE = "200"
class ContinuePluginToolWindowFactory : ToolWindowFactory, DumbAware {
- override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
- val continueToolWindow = ContinuePluginWindow(project)
- val content =
- ContentFactory.getInstance().createContent(continueToolWindow.content, null, false)
- toolWindow.contentManager.addContent(content)
- val titleActions = mutableListOf()
- createTitleActions(titleActions)
-
- // Add MaximizeToolWindow action
- val action = ActionManager.getInstance().getAction("MaximizeToolWindow")
- if (action != null) {
- titleActions.add(action)
+ override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
+ val inner = if (JBCefApp.isSupported())
+ ContinuePluginWindow(project).content
+ else
+ createNotSupportedPanel()
+ val content = ContentFactory.getInstance().createContent(inner, null, false)
+ toolWindow.contentManager.addContent(content)
+ toolWindow.setTitleActions(
+ listOf(
+ ActionManager.getInstance().getAction("ContinueSidebarActionsGroup"),
+ ActionManager.getInstance().getAction("MaximizeToolWindow")
+ )
+ )
}
- toolWindow.setTitleActions(titleActions)
- }
+ override fun shouldBeAvailable(project: Project) = true
- private fun createTitleActions(titleActions: MutableList) {
- val action = ActionManager.getInstance().getAction("ContinueSidebarActionsGroup")
- if (action != null) {
- titleActions.add(action)
- }
- }
-
- override fun shouldBeAvailable(project: Project) = true
-
- class ContinuePluginWindow(project: Project) {
- private val defaultGUIUrl = "http://continue/index.html"
-
- init {
- System.setProperty("ide.browser.jcef.jsQueryPoolSize", JS_QUERY_POOL_SIZE)
- System.setProperty("ide.browser.jcef.contextMenu.devTools.enabled", "true")
- System.setProperty("ide.browser.jcef.out-of-process.enabled", "false")
+ private fun createNotSupportedPanel(): JPanel {
+ val html = ContinuePluginToolWindowFactory::class.java.classLoader
+ .getResourceAsStream("jcef_error.html")
+ .bufferedReader()
+ .readText()
+ return panel {
+ row {
+ text(html)
+ }
+ }.withBorder(empty(10))
}
- val browser: ContinueBrowser by lazy {
- val url = System.getenv("GUI_URL")?.toString() ?: defaultGUIUrl
+ class ContinuePluginWindow(project: Project) {
+ private val defaultGUIUrl = "http://continue/index.html"
- val browser = ContinueBrowser(project, url)
- project.service().continuePluginWindow = this
- browser
+ init {
+ System.setProperty("ide.browser.jcef.jsQueryPoolSize", JS_QUERY_POOL_SIZE)
+ System.setProperty("ide.browser.jcef.contextMenu.devTools.enabled", "true")
+ System.setProperty("ide.browser.jcef.out-of-process.enabled", "false")
+ }
+
+ val browser: ContinueBrowser by lazy {
+ val url = System.getenv("GUI_URL") ?: defaultGUIUrl
+
+ val browser = ContinueBrowser(project, url)
+ project.service().continuePluginWindow = this
+ browser
+ }
+
+ val content: JComponent
+ get() = browser.browser.component
}
-
- val content: JComponent
- get() = browser.browser.component
- }
}
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt
index 3566bf345..cddcd035b 100644
--- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt
@@ -16,11 +16,6 @@ enum class FileType(val value: Int) {
SYMBOLIC_LINK(64)
}
-enum class ConfigMergeType {
- MERGE,
- OVERWRITE
-}
-
data class Position(val line: Int, val character: Int)
data class Range(val start: Position, val end: Position)
@@ -64,6 +59,68 @@ data class RangeInFileWithContents(
val contents: String
)
+/**
+ * Signature help represents the signature of something
+ * callable. There can be multiple signatures but only one
+ * active and only one active parameter.
+ */
+data class SignatureHelp(
+ /**
+ * One or more signatures.
+ */
+ val signatures: List,
+
+ /**
+ * The active signature.
+ */
+ val activeSignature: Int,
+
+ /**
+ * The active parameter of the active signature.
+ */
+ val activeParameter: Int
+)
+
+/**
+ * Represents the signature of something callable. A signature
+ * can have a label, like a function-name, a doc-comment, and
+ * a set of parameters.
+ */
+data class SignatureInformation(
+ /**
+ * The label of this signature. Will be shown in
+ * the UI.
+ */
+ val label: String,
+
+ /**
+ * The parameters of this signature.
+ */
+ val parameters: List,
+
+ /**
+ * The index of the active parameter.
+ *
+ * If provided, this is used in place of [SignatureHelp.activeParameter].
+ */
+ val activeParameter: Int? = null
+)
+
+/**
+ * Represents a parameter of a callable-signature. A parameter can
+ * have a label and a doc-comment.
+ */
+data class ParameterInformation(
+ /**
+ * The label of this signature.
+ *
+ * Either a string or inclusive start and exclusive end offsets within its containing
+ * [SignatureInformation.label] signature label. *Note*: A label of type string must be
+ * a substring of its containing signature information's [SignatureInformation.label] label.
+ */
+ val label: String // Note: Kotlin doesn't have union types, so this represents the string case
+)
+
data class DocumentSymbol(
val name: String,
val kind: String,
@@ -94,11 +151,12 @@ data class IdeSettings(
val continueTestEnvironment: String
)
-data class ContinueRcJson(
- val mergeBehavior: ConfigMergeType
+data class TerminalOptions(
+ val reuseTerminal: Boolean?,
+ val terminalName: String?,
+ val waitForCompletion: Boolean?
)
-
interface IDE {
suspend fun getIdeInfo(): IdeInfo
@@ -127,8 +185,6 @@ interface IDE {
suspend fun getWorkspaceDirs(): List
- suspend fun getWorkspaceConfigs(): List
-
suspend fun fileExists(filepath: String): Boolean
suspend fun writeFile(path: String, contents: String)
@@ -141,7 +197,7 @@ interface IDE {
suspend fun openUrl(url: String)
- suspend fun runCommand(command: String)
+ suspend fun runCommand(command: String, options: TerminalOptions?)
suspend fun saveFile(filepath: String)
@@ -199,6 +255,8 @@ interface IDE {
// LSP
suspend fun gotoDefinition(location: Location): List
+ suspend fun gotoTypeDefinition(location: Location): List
+ suspend fun getSignatureHelp(location: Location): SignatureHelp?
suspend fun getReferences(location: Location): List
suspend fun getDocumentSymbols(textDocumentIdentifier: String): List
@@ -230,6 +288,7 @@ data class ApplyState(
val numDiffs: Int? = null,
val filepath: String? = null,
val fileContent: String? = null,
+ val originalFileContent: String? = null,
val toolCallId: String? = null
)
@@ -262,4 +321,4 @@ data class ShowFilePayload(
sealed class FimResult {
data class FimEdit(val fimText: String) : FimResult()
object NotFimEdit : FimResult()
-}
\ No newline at end of file
+}
diff --git a/extensions/intellij/src/main/resources/META-INF/plugin.xml b/extensions/intellij/src/main/resources/META-INF/plugin.xml
index 951338698..0191d8f60 100644
--- a/extensions/intellij/src/main/resources/META-INF/plugin.xml
+++ b/extensions/intellij/src/main/resources/META-INF/plugin.xml
@@ -7,15 +7,13 @@
GitHub]]>
com.intellij.modules.platform
+ org.jetbrains.plugins.terminal
com.intellij.modules.json
-
-
-
@@ -39,6 +37,7 @@
+
+
+
+
Continue Chat is Unable to Load
+
+
Continue Chat requires a JRE that supports the Java Chromium Embedded Framework (JCEF) to render our webview. You can
+ still use Autocomplete and Edit.
+
How to Fix It?
+
You can manually switch to a JRE that supports JCEF:
+
+
In the main menu, go to Help | Find Action or press
+ Ctrl + Shift + A.
+
+
Find and select the Choose Boot Java Runtime for the IDE action.
+
Select the runtime that comes with JCEF support and click OK.
+
Restart with the new runtime.
+
+
Runtimes that support JCEF are usually called JetBrains Runtime and have the -jcef suffix,
+ for example 21.0.3+13-509.11-jcef.
+
+You can find more information in the JetBrains documentation.
+
\ No newline at end of file
diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/ApplyToFileHandlerTest.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/ApplyToFileHandlerTest.kt
index 4e12e270e..0a018a18f 100644
--- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/ApplyToFileHandlerTest.kt
+++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/ApplyToFileHandlerTest.kt
@@ -12,13 +12,12 @@ import com.github.continuedev.continueintellijextension.services.ContinuePluginS
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import io.mockk.*
+import junit.framework.TestCase
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
-import org.junit.jupiter.api.BeforeEach
-import org.junit.jupiter.api.Test
@ExperimentalCoroutinesApi
-class ApplyToFileHandlerTest {
+class ApplyToFileHandlerTest : TestCase() {
// Mock all dependencies
private val mockProject = mockk(relaxed = true)
private val mockContinuePluginService = mockk(relaxed = true)
@@ -39,8 +38,7 @@ class ApplyToFileHandlerTest {
"tool-call-123"
)
- @BeforeEach
- fun setUp() {
+ override fun setUp() {
// Common setup
every { mockEditorUtils.editor } returns mockEditor
every { mockContinuePluginService.coreMessenger } returns mockCoreMessenger
@@ -56,8 +54,7 @@ class ApplyToFileHandlerTest {
)
}
- @Test
- fun `should insert text directly when document is empty`() = runTest {
+ fun `test should insert text directly when document is empty`() = runTest {
// Given
every { mockEditorUtils.isDocumentEmpty() } returns true
diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/CheckFimTest.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/CheckFimTest.kt
index b23bcf7ec..da819ad67 100644
--- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/CheckFimTest.kt
+++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/CheckFimTest.kt
@@ -1,48 +1,39 @@
package com.github.continuedev.continueintellijextension.unit
import com.github.continuedev.continueintellijextension.FimResult
-import com.github.continuedev.continueintellijextension.`continue`.UriUtils
import com.github.continuedev.continueintellijextension.utils.checkFim
-import org.junit.jupiter.api.Disabled
-import org.junit.jupiter.api.Test
-import java.io.File
-import kotlin.test.assertEquals
+import junit.framework.TestCase
-class CheckFimTest {
- @Test
- fun testFim() {
+class CheckFimTest : TestCase() {
+ fun `test FIM`() {
val oldEditRange = "hello world"
val newEditRange = "hello this world"
val cursorPosition = Pair(0, 6)
assertEquals(checkFim(oldEditRange, newEditRange, cursorPosition), FimResult.FimEdit("this "))
}
- @Test
- fun testMultilineFim() {
+ fun `test multiline FIM`() {
val oldEditRange = "hello {\n world\n}"
val newEditRange = "hello {\n print()\n world\n}"
val cursorPosition = Pair(1, 2)
assertEquals(checkFim(oldEditRange, newEditRange, cursorPosition), FimResult.FimEdit("print()\n "))
}
- @Test
- fun testNotFim() {
+ fun `test not FIM`() {
val oldEditRange = "hello world"
val newEditRange = "hello this world"
val cursorPosition = Pair(0, 8)
assertEquals(checkFim(oldEditRange, newEditRange, cursorPosition), FimResult.NotFimEdit)
}
- @Test
- fun testMultilineNotFim() {
+ fun `test multiline not FIM`() {
val oldEditRange = "hello {\n world\n}"
val newEditRange = "hello {\n world\n}\nprint()"
val cursorPosition = Pair(1, 2)
assertEquals(checkFim(oldEditRange, newEditRange, cursorPosition), FimResult.NotFimEdit)
}
- @Test
- fun testFimEdge() {
+ fun `test FIM edge`() {
val oldEditRange = ""
val newEditRange = ""
val cursorPosition = Pair(0, 0)
diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/FileUtilsTest.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/FileUtilsTest.kt
new file mode 100644
index 000000000..3ec25afba
--- /dev/null
+++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/FileUtilsTest.kt
@@ -0,0 +1,77 @@
+package com.github.continuedev.continueintellijextension.unit
+
+import com.github.continuedev.continueintellijextension.FileType
+import com.github.continuedev.continueintellijextension.`continue`.file.FileUtils
+import com.intellij.testFramework.UsefulTestCase
+import com.intellij.testFramework.fixtures.CodeInsightTestFixture
+import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
+
+class FileUtilsTest : UsefulTestCase() {
+ val fileUtils = FileUtils()
+ val myFixture = setupRealFilesFixture()
+ val tmpFixture get() = myFixture.tempDirFixture
+ val tmpDir get() = myFixture.tempDirPath
+
+ override fun setUp() =
+ myFixture.setUp()
+
+ override fun tearDown() =
+ myFixture.tearDown()
+
+ fun `test fileExists`() {
+ val file = tmpFixture.createFile("test.txt", "")
+ val uri = "file://${file.path}"
+ assertTrue(fileUtils.fileExists(uri))
+ }
+
+ fun `test fileExists inside directory`() {
+ val file = tmpFixture.createFile("dir/dir2/file.txt", "")
+ val uri = "file://${file.path}"
+ assertTrue(fileUtils.fileExists(uri))
+ }
+
+ fun `test fileExists fails when file doesn't exists`() {
+ val uri = "file:///tmp/aaaa.txt"
+ assertFalse(fileUtils.fileExists(uri))
+ }
+
+ fun `test readFile`() {
+ val uri = "file://$tmpDir/bbbb.txt"
+ tmpFixture.createFile("bbbb.txt", "contents")
+ val text = fileUtils.readFile(uri)
+ assertEquals("contents", text)
+ }
+
+ fun `test listDir`() {
+ tmpFixture.createFile("a.txt", "a")
+ tmpFixture.createFile("b.txt", "b")
+ tmpFixture.createFile("c.txt", "c")
+ tmpFixture.createFile("dir/invisibleA.txt", "d")
+ tmpFixture.createFile("dir/invisibleB.txt", "e")
+
+ val result = fileUtils.listDir("file://$tmpDir")
+
+ assertTrue(result.any { it[0] == "a.txt" && it[1] == FileType.FILE.value })
+ assertTrue(result.any { it[0] == "b.txt" && it[1] == FileType.FILE.value })
+ assertTrue(result.any { it[0] == "c.txt" && it[1] == FileType.FILE.value })
+ assertTrue(result.any { it[0] == "dir" && it[1] == FileType.DIRECTORY.value })
+ assertTrue(result.any { it[0] == "dir" && it[1] == FileType.DIRECTORY.value })
+ assertFalse(result.any { it[0] == "invisibleA.txt" })
+ assertFalse(result.any { it[0] == "invisibleB.txt" })
+ assertEquals(4, result.size)
+ }
+
+ private companion object {
+
+ // note: with this, files will actually exist inside /tmp/unitTest/ dir, otherwise it's virtual
+ fun setupRealFilesFixture(): CodeInsightTestFixture {
+ val factory = IdeaTestFixtureFactory.getFixtureFactory()
+ return factory.createCodeInsightFixture(
+ factory.createLightFixtureBuilder("my_continue_project").fixture,
+ factory.createTempDirTestFixture()
+ )
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/UriUtilsTest.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/UriUtilsTest.kt
index 9b4690d79..170446f61 100644
--- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/UriUtilsTest.kt
+++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/UriUtilsTest.kt
@@ -1,64 +1,48 @@
package com.github.continuedev.continueintellijextension.unit
import com.github.continuedev.continueintellijextension.`continue`.UriUtils
-import org.junit.jupiter.api.Disabled
-import org.junit.jupiter.api.Test
+import junit.framework.TestCase
import java.io.File
-import kotlin.test.assertEquals
-class UriUtilsTest {
- @Test
- fun testUriToFile() {
+class UriUtilsTest : TestCase() {
+ fun `test URI to File`() {
val uri = "file:///path/to/file"
val file = UriUtils.uriToFile(uri)
assertEquals(File("/path/to/file"), file)
}
- @Disabled("Not working")
- @Test
- fun testUriToFileWithWindowsPath() {
- val uri = "file:///C:/path/to/file"
- val file = UriUtils.uriToFile(uri)
- assertEquals(File("C:/path/to/file"), file)
- }
+ // fixme it's not working
+ // fun `test Windows path`() {
+ // val uri = "file:///C:/path/to/file"
+ // val file = UriUtils.uriToFile(uri)
+ // assertEquals(File("C:/path/to/file"), file)
+ // }
- @Test
- fun shouldHandleAuthorityComponent() {
- val uri = "file://C:/path/to/file"
- val file = UriUtils.uriToFile(uri)
- assertEquals(File("/C:/path/to/file"), file)
- }
-
- @Test
- fun testUriToFileWithSpaces() {
+ fun `test spaces`() {
val uri = "file:///path/to/file%20with%20spaces"
val file = UriUtils.uriToFile(uri)
assertEquals(File("/path/to/file with spaces"), file)
}
- @Test
- fun testUriToFileWithSpecialCharacters() {
+ fun `test special characters`() {
val uri = "file:///path/to/file%23with%25special%26chars"
val file = UriUtils.uriToFile(uri)
assertEquals(File("/path/to/file#with%special&chars"), file)
}
- @Test
- fun testUriToFileWithQueryParams() {
+ fun `test query params`() {
val uri = "file:///path/to/file?param=value"
val file = UriUtils.uriToFile(uri)
assertEquals(File("/path/to/file"), file)
}
- @Test
- fun testUriToFileWithWSLPath() {
+ fun `test WSL path`() {
val uri = "file:///wsl$/Ubuntu/home/user/file.txt"
val file = UriUtils.uriToFile(uri)
assertEquals(File("/wsl$/Ubuntu/home/user/file.txt"), file)
}
- @Test
- fun testUriToFileWithWSLLocalhostPath() {
+ fun `test WSL localhost path`() {
val uri = "file:///wsl.localhost/Ubuntu/home/user/file.txt"
val file = UriUtils.uriToFile(uri)
assertEquals(File("/wsl.localhost/Ubuntu/home/user/file.txt"), file)
diff --git a/extensions/vscode/e2e/tests/GUI.test.ts b/extensions/vscode/e2e/tests/GUI.test.ts
index e53f2129a..66481cb14 100644
--- a/extensions/vscode/e2e/tests/GUI.test.ts
+++ b/extensions/vscode/e2e/tests/GUI.test.ts
@@ -7,7 +7,7 @@ import {
WebDriver,
WebElement,
WebView,
- until,
+ until
} from "vscode-extension-tester";
import { GlobalActions } from "../actions/Global.actions";
@@ -299,8 +299,6 @@ describe("GUI Test", () => {
expect(await statusMessage.getText()).contain(
"Continue viewed the git diff",
);
- // wait for 30 seconds, promise
- await new Promise((resolve) => setTimeout(resolve, 30000));
}).timeout(DEFAULT_TIMEOUT.MD * 100);
it("should call tool after approval", async () => {
@@ -367,8 +365,9 @@ describe("GUI Test", () => {
}).timeout(DEFAULT_TIMEOUT.MD);
});
- describe("Repeat back the system message", () => {
+ describe("should repeat back the system message", () => {
it("should repeat back the system message", async () => {
+ await GUIActions.selectModeFromDropdown(view, "Chat");
await GUIActions.selectModelFromDropdown(view, "SYSTEM MESSAGE MOCK LLM");
const [messageInput] = await GUISelectors.getMessageInputFields(view);
await messageInput.sendKeys("Hello");
@@ -376,8 +375,8 @@ describe("GUI Test", () => {
await TestUtils.waitForSuccess(() =>
GUISelectors.getThreadMessageByText(view, "TEST_SYS_MSG"),
);
- });
- });
+ }).timeout(DEFAULT_TIMEOUT.XL * 1000);
+ })
describe("Chat Paths", () => {
it("Send many messages โ chat auto scrolls โ go to history โ open previous chat โ it is scrolled to the bottom", async () => {
diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json
index 8780ab1e2..0f419444a 100644
--- a/extensions/vscode/package-lock.json
+++ b/extensions/vscode/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "continue",
- "version": "1.1.63",
+ "version": "1.1.68",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "continue",
- "version": "1.1.63",
+ "version": "1.1.68",
"license": "Apache-2.0",
"dependencies": {
"@continuedev/config-types": "^1.0.14",
@@ -129,6 +129,7 @@
"handlebars": "^4.7.8",
"http-proxy-agent": "^7.0.1",
"https-proxy-agent": "^7.0.3",
+ "iconv-lite": "^0.6.3",
"ignore": "^5.3.1",
"is-localhost-ip": "^2.0.0",
"jinja-js": "0.1.8",
@@ -142,7 +143,7 @@
"node-html-markdown": "^1.3.0",
"ollama": "^0.4.6",
"onnxruntime-node": "1.14.0",
- "openai": "^4.76.0",
+ "openai": "^4.104.0",
"p-limit": "^6.1.0",
"partial-json": "^0.1.7",
"pg": "^8.11.3",
diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json
index 2bec49ee7..2ad79ed49 100644
--- a/extensions/vscode/package.json
+++ b/extensions/vscode/package.json
@@ -2,7 +2,7 @@
"name": "continue",
"icon": "media/icon.png",
"author": "Continue Dev, Inc",
- "version": "1.1.66",
+ "version": "1.1.69",
"repository": {
"type": "git",
"url": "https://github.com/continuedev/continue"
diff --git a/extensions/vscode/scripts/download-copy-sqlite-esbuild.js b/extensions/vscode/scripts/download-copy-sqlite-esbuild.js
index ea6f8ebd9..b595c3bdf 100644
--- a/extensions/vscode/scripts/download-copy-sqlite-esbuild.js
+++ b/extensions/vscode/scripts/download-copy-sqlite-esbuild.js
@@ -1,83 +1,40 @@
const { fork } = require("child_process");
const fs = require("fs");
-const https = require("https");
const path = require("path");
+const { ProxyAgent } = require("undici");
const { rimrafSync } = require("rimraf");
const { execCmdSync } = require("../../../scripts/util");
/**
- * download a file using nodejs http
+ * download a file using fetch API
* @param {string} url
* @param {string} outputPath
- * @param {number} maxRedirects
*/
-async function downloadFile(url, outputPath, maxRedirects = 5) {
- return new Promise((resolve, reject) => {
- const downloadWithRedirects = (currentUrl, redirectCount = 0) => {
- if (redirectCount > maxRedirects) {
- return reject(new Error(`Too many redirects (${maxRedirects})`));
- }
+async function downloadFile(url, outputPath) {
+ // Use proxy if set in environment variables
+ const proxy = process.env.https_proxy || process.env.HTTPS_PROXY;
+ const agent = proxy ? new ProxyAgent(proxy) : undefined;
- const request = https.get(currentUrl, (response) => {
- if (
- response.statusCode >= 300 &&
- response.statusCode < 400 &&
- response.headers.location
- ) {
- return downloadWithRedirects(
- response.headers.location,
- redirectCount + 1,
- );
- }
-
- if (response.statusCode !== 200) {
- return reject(
- new Error(`HTTP ${response.statusCode}: ${response.statusMessage}`),
- );
- }
-
- const outputDir = path.dirname(outputPath);
- if (!fs.existsSync(outputDir)) {
- fs.mkdirSync(outputDir, { recursive: true });
- }
-
- const writeStream = fs.createWriteStream(outputPath);
-
- const totalSize = parseInt(response.headers["content-length"], 10);
- let downloadedSize = 0;
-
- response.on("data", (chunk) => {
- downloadedSize += chunk.length;
- if (totalSize) {
- const percent = ((downloadedSize / totalSize) * 100).toFixed(1);
- process.stdout.write(
- `\rDownloading: ${percent}% (${downloadedSize}/${totalSize} bytes)`,
- );
- }
- });
-
- response.pipe(writeStream);
-
- writeStream.on("finish", () => {
- console.log(`\nDownload completed: ${outputPath}`);
- resolve(outputPath);
- });
-
- writeStream.on("error", reject);
- response.on("error", reject);
- });
-
- request.on("error", reject);
- request.setTimeout(30000, () => {
- request.destroy();
- reject(new Error("Request timeout"));
- });
- };
-
- downloadWithRedirects(url);
+ const response = await fetch(url, {
+ redirect: "follow", // Automatically follow redirects
+ dispatcher: agent,
});
+
+ if (!response.ok) {
+ throw new Error(`Failed to download file, status code: ${response.status}`);
+ }
+
+ // Create output directory if it doesn't exist
+ const outputDir = path.dirname(outputPath);
+ if (!fs.existsSync(outputDir)) {
+ fs.mkdirSync(outputDir, { recursive: true });
+ }
+
+ // Get the response as an array buffer and write it to the file
+ const buffer = await response.arrayBuffer();
+ fs.writeFileSync(outputPath, Buffer.from(buffer));
}
/**
diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts
index 43be229e3..bc1f8c2da 100644
--- a/extensions/vscode/src/VsCodeIde.ts
+++ b/extensions/vscode/src/VsCodeIde.ts
@@ -6,7 +6,11 @@ import { EXTENSION_NAME } from "core/control-plane/env";
import * as URI from "uri-js";
import * as vscode from "vscode";
-import { executeGotoProvider, executeSymbolProvider } from "./autocomplete/lsp";
+import {
+ executeGotoProvider,
+ executeSignatureHelpProvider,
+ executeSymbolProvider,
+} from "./autocomplete/lsp";
import { Repository } from "./otherExtensions/git";
import { SecretStorage } from "./stubs/SecretStorage";
import { VsCodeIdeUtils } from "./util/ideUtils";
@@ -14,7 +18,6 @@ import { getExtensionUri, openEditorAndRevealRange } from "./util/vscode";
import { VsCodeWebviewProtocol } from "./webviewProtocol";
import type {
- ContinueRcJson,
DocumentSymbol,
FileStatsMap,
FileType,
@@ -25,6 +28,7 @@ import type {
Location,
Problem,
RangeInFile,
+ SignatureHelp,
TerminalOptions,
Thread,
} from "core";
@@ -88,6 +92,28 @@ class VsCodeIde implements IDE {
return result;
}
+ async gotoTypeDefinition(location: Location): Promise {
+ const result = await executeGotoProvider({
+ uri: vscode.Uri.parse(location.filepath),
+ line: location.position.line,
+ character: location.position.character,
+ name: "vscode.executeTypeDefinitionProvider",
+ });
+
+ return result;
+ }
+
+ async getSignatureHelp(location: Location): Promise {
+ const result = await executeSignatureHelpProvider({
+ uri: vscode.Uri.parse(location.filepath),
+ line: location.position.line,
+ character: location.position.character,
+ name: "vscode.executeSignatureHelpProvider",
+ });
+
+ return result;
+ }
+
async getReferences(location: Location): Promise {
const result = await executeGotoProvider({
uri: vscode.Uri.parse(location.filepath),
@@ -104,7 +130,7 @@ class VsCodeIde implements IDE {
): Promise {
const result = await executeSymbolProvider({
uri: vscode.Uri.parse(textDocumentIdentifier),
- name: "vscode.executeDocumentSymbolProvider"
+ name: "vscode.executeDocumentSymbolProvider",
});
return result;
@@ -263,32 +289,6 @@ class VsCodeIde implements IDE {
return await this.ideUtils.getAvailableThreads();
}
- async getWorkspaceConfigs() {
- const workspaceDirs =
- vscode.workspace.workspaceFolders?.map((folder) => folder.uri) || [];
- const configs: ContinueRcJson[] = [];
- for (const workspaceDir of workspaceDirs) {
- const files = await this.ideUtils.readDirectory(workspaceDir);
- if (files === null) {
- //Unlikely, but just in case...
- continue;
- }
- for (const [filename, type] of files) {
- if (
- (type === vscode.FileType.File ||
- type === vscode.FileType.SymbolicLink) &&
- filename === ".continuerc.json"
- ) {
- const contents = await this.readFile(
- vscode.Uri.joinPath(workspaceDir, filename).toString(),
- );
- configs.push(JSON.parse(contents));
- }
- }
- }
- return configs;
- }
-
async getWorkspaceDirs(): Promise {
return this.ideUtils.getWorkspaceDirectories().map((uri) => uri.toString());
}
diff --git a/extensions/vscode/src/activation/NextEditWindowManager.ts b/extensions/vscode/src/activation/NextEditWindowManager.ts
index 00e340e17..89a43f765 100644
--- a/extensions/vscode/src/activation/NextEditWindowManager.ts
+++ b/extensions/vscode/src/activation/NextEditWindowManager.ts
@@ -6,10 +6,6 @@ import * as vscode from "vscode";
import { DiffChar, DiffLine } from "core";
import { CodeRenderer } from "core/codeRenderer/CodeRenderer";
import { myersCharDiff } from "core/diff/myers";
-import {
- NEXT_EDIT_EDITABLE_REGION_BOTTOM_MARGIN,
- NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
-} from "core/nextEdit/constants";
import { getOffsetPositionAtLastNewLine } from "core/nextEdit/diff/diff";
import { NextEditLoggingService } from "core/nextEdit/NextEditLoggingService";
import { NextEditProvider } from "core/nextEdit/NextEditProvider";
@@ -118,6 +114,9 @@ export class NextEditWindowManager {
// Track for logging purposes.
private loggingService: NextEditLoggingService;
private mostRecentCompletionId: string | null = null;
+ // Helps us skip redundant calculations. No need for cleanup because this always gets reassigned with new values at showNextEditWindow, and we don't reuse windows.
+ private editableRegionStartLine: number = 0;
+ private editableRegionEndLine: number = 0;
// Disposables
private disposables: vscode.Disposable[] = [];
@@ -265,6 +264,7 @@ export class NextEditWindowManager {
editor: vscode.TextEditor,
currCursorPos: vscode.Position,
editableRegionStartLine: number,
+ editableRegionEndLine: number,
oldEditRangeSlice: string,
newEditRangeSlice: string,
diffLines: DiffLine[],
@@ -276,11 +276,15 @@ export class NextEditWindowManager {
// Clear any existing decorations first (very important to prevent overlapping).
await this.hideAllNextEditWindows();
+ this.editableRegionStartLine = editableRegionStartLine;
+ this.editableRegionEndLine = editableRegionEndLine;
+
// Store the current tooltip text for accepting later.
this.currentTooltipText = newEditRangeSlice;
// How far away is the current line from the start of the editable region?
- const lineOffsetAtCursorPos = currCursorPos.line - editableRegionStartLine;
+ const lineOffsetAtCursorPos =
+ currCursorPos.line - this.editableRegionStartLine;
// How long is the line at the current cursor position?
const lineContentAtCursorPos =
@@ -295,7 +299,7 @@ export class NextEditWindowManager {
// Calculate the actual line number in the editor by adding the startPos offset
// to the line number from the diff calculation.
this.finalCursorPos = new vscode.Position(
- editableRegionStartLine + offset.line,
+ this.editableRegionStartLine + offset.line,
offset.character,
);
@@ -305,13 +309,13 @@ export class NextEditWindowManager {
currCursorPos,
oldEditRangeSlice,
newEditRangeSlice,
- editableRegionStartLine,
+ this.editableRegionStartLine,
diffLines,
);
const diffChars = myersCharDiff(oldEditRangeSlice, newEditRangeSlice);
- this.renderDeletes(editor, editableRegionStartLine, diffChars);
+ this.renderDeletions(editor, diffChars);
// Reserve tab and esc to either accept or reject the displayed next edit contents.
await NextEditWindowManager.reserveTabAndEsc();
@@ -321,6 +325,8 @@ export class NextEditWindowManager {
* Hide all tooltips in all editors.
*/
public async hideAllNextEditWindows() {
+ await NextEditWindowManager.freeTabAndEsc();
+
if (this.currentDecoration) {
vscode.window.visibleTextEditors.forEach((editor) => {
editor.setDecorations(this.currentDecoration!, []);
@@ -343,12 +349,10 @@ export class NextEditWindowManager {
// Clear the current tooltip text.
this.currentTooltipText = null;
}
-
- await NextEditWindowManager.freeTabAndEsc();
}
public async hideAllNextEditWindowsAndResetCompletionId() {
- this.hideAllNextEditWindows();
+ await this.hideAllNextEditWindows();
// Log with accept = false.
await vscode.commands.executeCommand(
@@ -356,6 +360,7 @@ export class NextEditWindowManager {
this.mostRecentCompletionId,
this.loggingService,
);
+
this.mostRecentCompletionId = null;
}
@@ -373,6 +378,10 @@ export class NextEditWindowManager {
const position = editor.selection.active;
let success = false;
+
+ // Hide windows first for a snappier feel.
+ await this.hideAllNextEditWindows();
+
if (this.textApplier) {
success = await this.textApplier.applyText(
editor,
@@ -381,20 +390,15 @@ export class NextEditWindowManager {
this.finalCursorPos,
);
} else {
- // Define the editable region.
- const editableRegionStartLine = Math.max(
- 0,
- position.line - NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
- );
- const editableRegionEndLine = Math.min(
- editor.document.lineCount - 1,
- position.line + NEXT_EDIT_EDITABLE_REGION_BOTTOM_MARGIN,
- );
- const startPos = new vscode.Position(editableRegionStartLine, 0);
- const endPosChar = editor.document.lineAt(editableRegionEndLine).text
+ // Define the range to replace.
+ const startPos = new vscode.Position(this.editableRegionStartLine, 0);
+ const endPosChar = editor.document.lineAt(this.editableRegionEndLine).text
.length;
- const endPos = new vscode.Position(editableRegionEndLine, endPosChar);
+ const endPos = new vscode.Position(
+ this.editableRegionEndLine,
+ endPosChar,
+ );
const editRange = new vscode.Range(startPos, endPos);
success = await editor.edit((editBuilder) => {
@@ -409,23 +413,19 @@ export class NextEditWindowManager {
// .update("editor.inlineSuggest.enabled", false, true);
}
- if (success) {
+ if (success && this.finalCursorPos) {
// Move cursor to the final position if available.
- if (this.finalCursorPos) {
- editor.selection = new vscode.Selection(
- this.finalCursorPos,
- this.finalCursorPos,
- );
-
- // Reenable inline suggestions after we move the cursor.
- // await vscode.workspace
- // .getConfiguration()
- // .update("editor.inlineSuggest.enabled", true, true);
-
- await this.hideAllNextEditWindows();
- }
+ editor.selection = new vscode.Selection(
+ this.finalCursorPos,
+ this.finalCursorPos,
+ );
}
+ // Reenable inline suggestions after we move the cursor.
+ // await vscode.workspace
+ // .getConfiguration()
+ // .update("editor.inlineSuggest.enabled", true, true);
+
// Log with accept = true.
await vscode.commands.executeCommand(
"continue.logNextEditOutcomeAccept",
@@ -458,7 +458,7 @@ export class NextEditWindowManager {
*/
private setupListeners() {
// Theme change listener.
- vscode.workspace.onDidChangeConfiguration((e) => {
+ vscode.workspace.onDidChangeConfiguration(async (e) => {
if (
e.affectsConfiguration("workbench.colorTheme") ||
e.affectsConfiguration("editor.fontSize") ||
@@ -471,7 +471,7 @@ export class NextEditWindowManager {
e.affectsConfiguration("workbench.preferredHighContrastLightColorTheme")
) {
this.theme = getThemeString();
- this.codeRenderer.setTheme(this.theme);
+ await this.codeRenderer.setTheme(this.theme);
console.log(
"Theme updated:",
this.theme ? "Theme exists" : "Theme is undefined",
@@ -483,9 +483,9 @@ export class NextEditWindowManager {
});
// Listen for active color theme changes.
- vscode.window.onDidChangeActiveColorTheme(() => {
+ vscode.window.onDidChangeActiveColorTheme(async () => {
this.theme = getThemeString();
- this.codeRenderer.setTheme(this.theme);
+ await this.codeRenderer.setTheme(this.theme);
console.log(
"Active theme changed:",
this.theme ? "Theme exists" : "Theme is undefined",
@@ -499,10 +499,11 @@ export class NextEditWindowManager {
this.activeEditor &&
!vscode.window.visibleTextEditors.includes(this.activeEditor)
) {
- if (this.mostRecentCompletionId)
+ if (this.mostRecentCompletionId) {
this.loggingService.cancelRejectionTimeout(
this.mostRecentCompletionId,
);
+ }
await this.hideAllNextEditWindows();
}
});
@@ -512,10 +513,11 @@ export class NextEditWindowManager {
// If the selection changed in our active editor, hide the tooltip.
if (this.activeEditor && e.textEditor === this.activeEditor) {
// If the cursor moved because of something other than accepting next edit, stop logging it.
- if (!this.accepted && this.mostRecentCompletionId)
+ if (!this.accepted && this.mostRecentCompletionId) {
this.loggingService.cancelRejectionTimeout(
this.mostRecentCompletionId,
);
+ }
await this.hideAllNextEditWindows();
}
});
@@ -751,7 +753,6 @@ export class NextEditWindowManager {
}
// Store the decoration and editor.
- await this.hideAllNextEditWindows();
this.currentDecoration = decoration; // TODO: This might be redundant.
this.disposables.push(decoration);
this.activeEditor = editor;
@@ -790,13 +791,7 @@ export class NextEditWindowManager {
);
}
- private renderDeletes(
- editor: vscode.TextEditor,
- editableRegionStartLine: number,
- // oldEditRangeSlice: string,
- // newEditRangeSlice: string,
- oldDiffChars: DiffChar[],
- ) {
+ private renderDeletions(editor: vscode.TextEditor, oldDiffChars: DiffChar[]) {
const charsToDelete: vscode.DecorationOptions[] = [];
// const diffChars = myersCharDiff(oldEditRangeSlice, newEditRangeSlice);
@@ -807,11 +802,11 @@ export class NextEditWindowManager {
charsToDelete.push({
range: new vscode.Range(
new vscode.Position(
- editableRegionStartLine + diff.oldLineIndex!,
+ this.editableRegionStartLine + diff.oldLineIndex!,
diff.oldCharIndexInLine!,
),
new vscode.Position(
- editableRegionStartLine + diff.oldLineIndex!,
+ this.editableRegionStartLine + diff.oldLineIndex!,
diff.oldCharIndexInLine! + diff.char.length,
),
),
diff --git a/extensions/vscode/src/apply/ApplyManager.ts b/extensions/vscode/src/apply/ApplyManager.ts
index 1ac84c368..c12d6323a 100644
--- a/extensions/vscode/src/apply/ApplyManager.ts
+++ b/extensions/vscode/src/apply/ApplyManager.ts
@@ -29,13 +29,6 @@ export class ApplyManager {
toolCallId,
isSearchAndReplace,
}: ApplyToFilePayload) {
- await this.webviewProtocol.request("updateApplyState", {
- streamId,
- status: "streaming",
- fileContent: text,
- toolCallId,
- });
-
if (filepath) {
await this.ensureFileOpen(filepath);
}
@@ -46,6 +39,17 @@ export class ApplyManager {
return;
}
+ // Capture the original file content before applying changes
+ const originalFileContent = activeTextEditor.document.getText();
+
+ await this.webviewProtocol.request("updateApplyState", {
+ streamId,
+ status: "streaming",
+ fileContent: text,
+ originalFileContent,
+ toolCallId,
+ });
+
const hasExistingDocument = !!activeTextEditor.document.getText().trim();
if (hasExistingDocument) {
diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts
index 5e22b5c7e..4be4b7cef 100644
--- a/extensions/vscode/src/autocomplete/completionProvider.ts
+++ b/extensions/vscode/src/autocomplete/completionProvider.ts
@@ -538,6 +538,7 @@ export class ContinueCompletionProvider
editor,
currCursorPos,
editableRegionStartLine,
+ editableRegionEndLine,
oldEditRangeSlice,
newEditRangeSlice,
diffLines,
diff --git a/extensions/vscode/src/autocomplete/lsp.ts b/extensions/vscode/src/autocomplete/lsp.ts
index fbf69932d..32e8b03f5 100644
--- a/extensions/vscode/src/autocomplete/lsp.ts
+++ b/extensions/vscode/src/autocomplete/lsp.ts
@@ -19,6 +19,7 @@ import type {
Range,
RangeInFile,
RangeInFileWithContents,
+ SignatureHelp,
} from "core";
import type Parser from "web-tree-sitter";
@@ -29,6 +30,8 @@ type GotoProviderName =
| "vscode.executeImplementationProvider"
| "vscode.executeReferenceProvider";
+type SignatureHelpProviderName = "vscode.executeSignatureHelpProvider";
+
interface GotoInput {
uri: vscode.Uri;
line: number;
@@ -39,8 +42,19 @@ function gotoInputKey(input: GotoInput) {
return `${input.name}${input.uri.toString()}${input.line}${input.character}`;
}
+interface SignatureHelpInput {
+ uri: vscode.Uri;
+ line: number;
+ character: number;
+ name: SignatureHelpProviderName;
+}
+function signatureHelpKey(input: SignatureHelpInput) {
+ return `${input.name}${input.uri.toString()}${input.line}${input.character}`;
+}
+
const MAX_CACHE_SIZE = 500;
const gotoCache = new Map();
+const signatureHelpCache = new Map();
export async function executeGotoProvider(
input: GotoInput,
@@ -389,6 +403,39 @@ export const getDefinitionsFromLsp: GetLspDefinitionsFunction = async (
}
};
+export async function executeSignatureHelpProvider(
+ input: SignatureHelpInput,
+): Promise {
+ const cacheKey = signatureHelpKey(input);
+ const cached = signatureHelpCache.get(cacheKey);
+ if (cached) {
+ return cached;
+ }
+
+ try {
+ const definitions = (await vscode.commands.executeCommand(
+ input.name,
+ input.uri,
+ new vscode.Position(input.line, input.character),
+ )) as SignatureHelp;
+
+ // Add to cache
+ if (signatureHelpCache.size >= MAX_CACHE_SIZE) {
+ // Remove the oldest item from the cache
+ const oldestKey = signatureHelpCache.keys().next().value;
+ if (oldestKey) {
+ signatureHelpCache.delete(oldestKey);
+ }
+ }
+ signatureHelpCache.set(cacheKey, definitions);
+
+ return definitions;
+ } catch (e) {
+ console.warn(`Error executing ${input.name}:`, e);
+ return null;
+ }
+}
+
type SymbolProviderName = "vscode.executeDocumentSymbolProvider";
interface SymbolInput {
diff --git a/extensions/vscode/src/diff/vertical/handler.ts b/extensions/vscode/src/diff/vertical/handler.ts
index 339f9e84b..869e5962d 100644
--- a/extensions/vscode/src/diff/vertical/handler.ts
+++ b/extensions/vscode/src/diff/vertical/handler.ts
@@ -315,11 +315,12 @@ export class VerticalDiffHandler implements vscode.Disposable {
// newline separated, because myersDiff() would consider
// ["A"] => "A" and ["A", ""] => "A\n" to be the same single line.
// "A\n" and "A\n\n" are unambiguous.
- const oldFileContent =
- diffLines
- .filter((line) => line.type === "same" || line.type === "old")
- .map((line) => line.line)
- .join("\n") + "\n";
+ const oldContentWithoutTrailingNewline = diffLines
+ .filter((line) => line.type === "same" || line.type === "old")
+ .map((line) => line.line)
+ .join("\n");
+
+ const oldFileContent = oldContentWithoutTrailingNewline + "\n";
const newFileContent =
diffLines
@@ -329,9 +330,16 @@ export class VerticalDiffHandler implements vscode.Disposable {
const myersDiffs = myersDiff(oldFileContent, newFileContent);
- const replaceContent = myersDiffs
- .map((diff) => (diff.type === "old" ? "" : diff.line))
- .join("\n");
+ // Preserve the trailing newline behavior by checking the original document content
+ const originalDocumentContent = this.editor.document.getText(this.range);
+ const originalContentEndsWithNewline =
+ originalDocumentContent.endsWith("\n");
+
+ // Add trailing newline only if the original file had one to prevent line count discrepancies
+ const replaceContent =
+ myersDiffs
+ .map((diff) => (diff.type === "old" ? "" : diff.line))
+ .join("\n") + (originalContentEndsWithNewline ? "\n" : "");
// Then, we insert our diff lines
await this.editor.edit((editBuilder) => {
diff --git a/extensions/vscode/src/extension/EditOutcomeTracker.ts b/extensions/vscode/src/extension/EditOutcomeTracker.ts
index c69dbac72..69ac452fa 100644
--- a/extensions/vscode/src/extension/EditOutcomeTracker.ts
+++ b/extensions/vscode/src/extension/EditOutcomeTracker.ts
@@ -65,6 +65,7 @@ class EditOutcomeTracker {
newCodeLines: pendingEdit.newCodeLines,
lineChange: pendingEdit.lineChange,
accepted,
+ filepath: pendingEdit.filepath,
},
});
diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts
index a114a542c..2ecd1c205 100644
--- a/extensions/vscode/src/extension/VsCodeMessenger.ts
+++ b/extensions/vscode/src/extension/VsCodeMessenger.ts
@@ -426,10 +426,6 @@ export class VsCodeMessenger {
return await ide.isTelemetryEnabled();
});
- this.onWebviewOrCore("getWorkspaceConfigs", async (msg) => {
- return await ide.getWorkspaceConfigs();
- });
-
this.onWebviewOrCore("getUniqueId", async (msg) => {
return await ide.getUniqueId();
});
diff --git a/extensions/vscode/src/lang-server/codeLens/providers/DownloadYamlExtensionCodeLensProvider.ts b/extensions/vscode/src/lang-server/codeLens/providers/DownloadYamlExtensionCodeLensProvider.ts
index dd46ad401..58b167e66 100644
--- a/extensions/vscode/src/lang-server/codeLens/providers/DownloadYamlExtensionCodeLensProvider.ts
+++ b/extensions/vscode/src/lang-server/codeLens/providers/DownloadYamlExtensionCodeLensProvider.ts
@@ -15,20 +15,34 @@ export class DownloadYamlExtensionCodeLensProvider
if (!document.uri.fsPath.includes(".continue")) {
return [];
}
- if (this.yamlExtensionDownloaded()) {
- return [];
- }
- const codeLens: vscode.CodeLens = {
+ const codeLenses: vscode.CodeLens[] = [];
+
+ // Always show documentation link
+ const docCodeLens: vscode.CodeLens = {
range: new vscode.Range(0, 0, 0, 0),
command: {
- title: "Download YAML extension for Intellisense",
- command: "workbench.extensions.installExtension",
- arguments: ["redhat.vscode-yaml"],
+ title: "๐ View Continue Reference",
+ command: "vscode.open",
+ arguments: [vscode.Uri.parse("https://docs.continue.dev/reference")],
},
isResolved: true,
};
+ codeLenses.push(docCodeLens);
- return [codeLens];
+ if (!this.yamlExtensionDownloaded()) {
+ const codeLens: vscode.CodeLens = {
+ range: new vscode.Range(0, 0, 0, 0),
+ command: {
+ title: "Download YAML extension for Intellisense",
+ command: "workbench.extensions.installExtension",
+ arguments: ["redhat.vscode-yaml"],
+ },
+ isResolved: true,
+ };
+ codeLenses.push(codeLens);
+ }
+
+ return codeLenses;
}
}
diff --git a/extensions/vscode/tree-sitter/static-context-queries/hole-queries/typescript.scm b/extensions/vscode/tree-sitter/static-context-queries/hole-queries/typescript.scm
new file mode 100644
index 000000000..02de34466
--- /dev/null
+++ b/extensions/vscode/tree-sitter/static-context-queries/hole-queries/typescript.scm
@@ -0,0 +1,59 @@
+;; Capture the variable/function name
+(variable_declarator
+ name: (identifier) @function.name
+ type: (type_annotation
+ (function_type) @function.type))
+
+;; Capture the full parameter list
+(function_type
+ parameters: (formal_parameters) @function.params)
+
+;; Capture the type identifiers used in the parameters
+(formal_parameters
+ (required_parameter
+ type: (type_annotation
+ (type_identifier) @param.type))
+ (required_parameter
+ type: (type_annotation
+ (type_identifier) @param.type)))
+
+;; Capture the return type of the function
+(function_type
+ return_type: (type_identifier) @return.type)
+
+;; Capture any parse errors (e.g., the `@`)
+(ERROR) @error.node
+
+;; Capture the entire function declaration line
+(lexical_declaration) @function.decl
+
+;; Matches import declarations like: import { A, B } from "module";
+(import_statement
+ (import_clause
+ (named_imports
+ (import_specifier
+ name: (identifier) @import.name)))
+ source: (string) @import.source)
+
+;; Capture standalone function declarations
+(function_declaration
+ name: (identifier) @function.name) @function.decl
+
+;; Capture the function signature including parameters and return type
+(function_declaration
+ parameters: (formal_parameters) @function.params
+ return_type: (type_annotation)? @function.type)
+
+;; For function expressions or arrow functions
+(function_type
+ parameters: (formal_parameters) @function.params) @function.decl
+
+;; For arrow functions
+(arrow_function
+ parameters: (formal_parameters) @function.params) @function.decl
+
+;; For function signatures without a body (like in your example)
+(function_signature
+ name: (identifier) @function.name
+ parameters: (formal_parameters) @function.params
+ return_type: (type_annotation)? @function.type) @function.decl
diff --git a/extensions/vscode/tree-sitter/static-context-queries/relevant-headers-queries/typescript-get-toplevel-headers.scm b/extensions/vscode/tree-sitter/static-context-queries/relevant-headers-queries/typescript-get-toplevel-headers.scm
new file mode 100644
index 000000000..02b0bda77
--- /dev/null
+++ b/extensions/vscode/tree-sitter/static-context-queries/relevant-headers-queries/typescript-get-toplevel-headers.scm
@@ -0,0 +1,22 @@
+;; Match top-level `var`, `let`, or `const` declarations
+(lexical_declaration
+ (variable_declarator
+ name: (identifier) @top.var.name
+ type: (type_annotation
+ (_) @top.var.type))) @top.var.decl
+
+(variable_declaration
+ (variable_declarator
+ name: (identifier) @top.var.name
+ type: (type_annotation
+ (_) @top.var.type))) @top.var.decl
+
+;; Match function declarations
+(function_declaration
+ name: (identifier) @top.fn.name
+ parameters: (formal_parameters
+ (required_parameter
+ pattern: (identifier) @top.fn.param.name
+ type: (type_annotation (_) @top.fn.param.type)))*
+
+ return_type: (type_annotation (_) @top.fn.type)?) @top.fn.decl
diff --git a/extensions/vscode/tree-sitter/static-context-queries/relevant-types-queries/typescript-extract-identifiers.scm b/extensions/vscode/tree-sitter/static-context-queries/relevant-types-queries/typescript-extract-identifiers.scm
new file mode 100644
index 000000000..b5051cb77
--- /dev/null
+++ b/extensions/vscode/tree-sitter/static-context-queries/relevant-types-queries/typescript-extract-identifiers.scm
@@ -0,0 +1,10 @@
+;; Capture the type alias name (left-hand side)
+; (type_alias_declaration
+; name: (type_identifier) @type.name)
+
+;; Capture all identifiers on the right-hand side (value), recursively
+; (type_alias_declaration
+; value: (_) @type.value)
+
+;; Match all identifiers inside the type value โ deeply nested
+(type_identifier) @type.identifier
diff --git a/extensions/vscode/tree-sitter/static-context-queries/relevant-types-queries/typescript-find-typedecl-given-typeidentifier.scm b/extensions/vscode/tree-sitter/static-context-queries/relevant-types-queries/typescript-find-typedecl-given-typeidentifier.scm
new file mode 100644
index 000000000..b26180e05
--- /dev/null
+++ b/extensions/vscode/tree-sitter/static-context-queries/relevant-types-queries/typescript-find-typedecl-given-typeidentifier.scm
@@ -0,0 +1,11 @@
+(type_alias_declaration
+ name: (type_identifier) @type.identifier
+ value: (_) @type.value)
+
+(interface_declaration
+ name: (type_identifier) @type.identifier
+ body: (_) @type.value)
+
+(enum_declaration
+ name: (type_identifier) @type.identifier
+ body: (_) @type.value)
diff --git a/gui/package-lock.json b/gui/package-lock.json
index d611543e2..c9ad23ed0 100644
--- a/gui/package-lock.json
+++ b/gui/package-lock.json
@@ -140,6 +140,7 @@
"handlebars": "^4.7.8",
"http-proxy-agent": "^7.0.1",
"https-proxy-agent": "^7.0.3",
+ "iconv-lite": "^0.6.3",
"ignore": "^5.3.1",
"is-localhost-ip": "^2.0.0",
"jinja-js": "0.1.8",
@@ -153,7 +154,7 @@
"node-html-markdown": "^1.3.0",
"ollama": "^0.4.6",
"onnxruntime-node": "1.14.0",
- "openai": "^4.76.0",
+ "openai": "^4.104.0",
"p-limit": "^6.1.0",
"partial-json": "^0.1.7",
"pg": "^8.11.3",
diff --git a/gui/src/components/AssistantAndOrgListbox/AccountOption.tsx b/gui/src/components/AssistantAndOrgListbox/AccountOption.tsx
deleted file mode 100644
index 98e8adbc5..000000000
--- a/gui/src/components/AssistantAndOrgListbox/AccountOption.tsx
+++ /dev/null
@@ -1,51 +0,0 @@
-import {
- ArrowRightEndOnRectangleIcon,
- UserCircleIcon as UserCircleIconOutline,
-} from "@heroicons/react/24/outline";
-import { isOnPremSession } from "core/control-plane/AuthTypes";
-import { useAuth } from "../../context/Auth";
-import { ListboxOption, useFontSize } from "../ui";
-
-interface AccountOptionProps {
- onClose: () => void;
-}
-
-export function AccountOption({ onClose }: AccountOptionProps) {
- const { session, logout, login } = useAuth();
- const tinyFont = useFontSize(-4);
-
- // No account option for on-prem deployments
- if (session && isOnPremSession(session)) {
- return null;
- }
-
- async function handleClick() {
- if (session) {
- logout();
- } else {
- await login(false);
- }
- onClose();
- }
-
- return (
-
-