commit
8794906cee
8 changed files with 113 additions and 52 deletions
2
.idea/gradle.xml
generated
2
.idea/gradle.xml
generated
|
|
@ -5,7 +5,7 @@
|
|||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$/extensions/intellij" />
|
||||
<!-- <option name="gradleJvm" value="homebrew-17" />-->
|
||||
<option name="gradleJvm" value="homebrew-17" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$/extensions/intellij" />
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ export type ToIdeFromWebviewOrCoreProtocol = {
|
|||
ControlPlaneSessionInfo | undefined,
|
||||
];
|
||||
logoutOfControlPlane: [undefined, void];
|
||||
closeSidebar: [undefined, void];
|
||||
};
|
||||
|
||||
export type ToWebviewOrCoreFromIdeProtocol = {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
package com.github.continuedev.continueintellijextension.activities
|
||||
|
||||
import IntelliJIDE
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerListener
|
||||
import com.github.continuedev.continueintellijextension.auth.AuthListener
|
||||
|
|
@ -153,11 +154,13 @@ class ContinuePluginStartupActivity : StartupActivity, DumbAware {
|
|||
val connection = ApplicationManager.getApplication().messageBus.connect()
|
||||
connection.subscribe(SettingsListener.TOPIC, object : SettingsListener {
|
||||
override fun settingsUpdated(settings: ContinueExtensionSettings.ContinueState) {
|
||||
continuePluginService.coreMessenger?.request("config/ideSettingsUpdate", mapOf(
|
||||
"remoteConfigServerUrl" to settings.remoteConfigServerUrl,
|
||||
"remoteConfigSyncPeriod" to settings.remoteConfigSyncPeriod,
|
||||
"userToken" to settings.userToken,
|
||||
), null) { _ -> }
|
||||
continuePluginService.coreMessenger?.request(
|
||||
"config/ideSettingsUpdate", mapOf(
|
||||
"remoteConfigServerUrl" to settings.remoteConfigServerUrl,
|
||||
"remoteConfigSyncPeriod" to settings.remoteConfigSyncPeriod,
|
||||
"userToken" to settings.userToken,
|
||||
), null
|
||||
) { _ -> }
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -205,6 +208,7 @@ class ContinuePluginStartupActivity : StartupActivity, DumbAware {
|
|||
continuePluginService.coreMessenger?.request("files/closed", data, null) { _ -> }
|
||||
}
|
||||
}
|
||||
|
||||
override fun fileOpened(source: FileEditorManager, file: VirtualFile) {
|
||||
file.toUriOrNull()?.let { uri ->
|
||||
val data = mapOf("uris" to listOf(uri))
|
||||
|
|
@ -214,7 +218,6 @@ class ContinuePluginStartupActivity : StartupActivity, DumbAware {
|
|||
})
|
||||
|
||||
|
||||
|
||||
// Listen for theme changes
|
||||
connection.subscribe(LafManagerListener.TOPIC, LafManagerListener {
|
||||
val colors = GetTheme().getTheme();
|
||||
|
|
|
|||
|
|
@ -3,12 +3,17 @@ package com.github.continuedev.continueintellijextension.auth
|
|||
import com.intellij.openapi.ui.DialogWrapper
|
||||
import com.intellij.ui.components.JBLabel
|
||||
import com.intellij.ui.components.JBTextField
|
||||
import com.intellij.ui.HyperlinkLabel
|
||||
import javax.swing.JComponent
|
||||
import javax.swing.JPanel
|
||||
import java.awt.BorderLayout
|
||||
import javax.swing.BoxLayout
|
||||
|
||||
class ContinueAuthDialog(private val useOnboarding: Boolean, private val onTokenEntered: (String) -> Unit) :
|
||||
DialogWrapper(true) {
|
||||
class ContinueAuthDialog(
|
||||
private val useOnboarding: Boolean,
|
||||
private val authUrl: String? = null,
|
||||
private val onTokenEntered: (String) -> Unit,
|
||||
) : DialogWrapper(true) {
|
||||
private val tokenField = JBTextField()
|
||||
|
||||
init {
|
||||
|
|
@ -18,9 +23,22 @@ class ContinueAuthDialog(private val useOnboarding: Boolean, private val onToken
|
|||
|
||||
override fun createCenterPanel(): JComponent {
|
||||
val panel = JPanel(BorderLayout())
|
||||
val topPanel = JPanel()
|
||||
topPanel.layout = BoxLayout(topPanel, BoxLayout.Y_AXIS)
|
||||
|
||||
val message =
|
||||
if (useOnboarding) "After onboarding you will be shown an authentication token. Please enter it here:" else "Please enter your Continue authentication token:"
|
||||
panel.add(JBLabel(message), BorderLayout.NORTH)
|
||||
topPanel.add(JBLabel(message))
|
||||
topPanel.add(javax.swing.Box.createVerticalStrut(10))
|
||||
|
||||
if (authUrl != null) {
|
||||
val linkLabel = HyperlinkLabel("Open authentication page")
|
||||
linkLabel.setHyperlinkTarget(authUrl)
|
||||
topPanel.add(linkLabel)
|
||||
topPanel.add(javax.swing.Box.createVerticalStrut(10))
|
||||
}
|
||||
|
||||
panel.add(topPanel, BorderLayout.NORTH)
|
||||
panel.add(tokenField, BorderLayout.CENTER)
|
||||
return panel
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,11 +53,11 @@ class ContinueAuthService {
|
|||
|
||||
fun startAuthFlow(project: Project, useOnboarding: Boolean) {
|
||||
// Open login page
|
||||
openSignInPage(project, useOnboarding)
|
||||
val url = openSignInPage(project, useOnboarding)
|
||||
|
||||
// Open a dialog where the user should paste their sign-in token
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
val dialog = ContinueAuthDialog(useOnboarding) { token ->
|
||||
val dialog = ContinueAuthDialog(useOnboarding, url) { token ->
|
||||
// Store the token
|
||||
updateRefreshToken(token)
|
||||
}
|
||||
|
|
@ -144,18 +144,31 @@ class ContinueAuthService {
|
|||
}
|
||||
|
||||
|
||||
private fun openSignInPage(project: Project, useOnboarding: Boolean) {
|
||||
private fun openSignInPage(project: Project, useOnboarding: Boolean): String? {
|
||||
var authUrl: String? = null
|
||||
val coreMessenger = project.service<ContinuePluginService>().coreMessenger
|
||||
|
||||
// Use a blocking approach to get the URL
|
||||
val latch = java.util.concurrent.CountDownLatch(1)
|
||||
|
||||
coreMessenger?.request(
|
||||
"auth/getAuthUrl", mapOf(
|
||||
"useOnboarding" to useOnboarding
|
||||
), null
|
||||
) { response ->
|
||||
val authUrl = ((response as? Map<*, *>)?.get("content") as? Map<*, *>)?.get("url") as? String
|
||||
if (authUrl != null) {
|
||||
Desktop.browse(java.net.URI(authUrl))
|
||||
}
|
||||
authUrl = ((response as? Map<*, *>)?.get("content") as? Map<*, *>)?.get("url") as? String
|
||||
latch.countDown()
|
||||
}
|
||||
|
||||
// Wait for the response with a reasonable timeout
|
||||
latch.await(5, java.util.concurrent.TimeUnit.SECONDS)
|
||||
|
||||
// Still open the URL in the browser (keeping existing behavior)
|
||||
if (authUrl != null) {
|
||||
Desktop.browse(java.net.URI(authUrl))
|
||||
}
|
||||
|
||||
return authUrl
|
||||
}
|
||||
|
||||
private fun retrieveSecret(key: String): String? {
|
||||
|
|
|
|||
|
|
@ -56,27 +56,34 @@ class CoreMessengerManager(
|
|||
}
|
||||
|
||||
private fun setupCoreMessenger(continueCorePath: String) {
|
||||
coreMessenger = CoreMessenger(project, continueCorePath, ideProtocolClient, coroutineScope)
|
||||
try {
|
||||
coreMessenger = CoreMessenger(project, continueCorePath, ideProtocolClient, coroutineScope)
|
||||
|
||||
coreMessenger?.request("config/getSerializedProfileInfo", null, null) { response ->
|
||||
val responseObject = response as Map<*, *>
|
||||
val responseContent = responseObject["content"] as Map<*, *>
|
||||
val result = responseContent["result"] as Map<*, *>
|
||||
val config = result["config"] as Map<String, Any>
|
||||
coreMessenger?.request("config/getSerializedProfileInfo", null, null) { response ->
|
||||
val responseObject = response as Map<*, *>
|
||||
val responseContent = responseObject["content"] as Map<*, *>
|
||||
val result = responseContent["result"] as Map<*, *>
|
||||
val config = result["config"] as Map<String, Any>
|
||||
|
||||
val allowAnonymousTelemetry = config?.get("allowAnonymousTelemetry") as? Boolean
|
||||
val telemetryService = service<TelemetryService>()
|
||||
if (allowAnonymousTelemetry == true || allowAnonymousTelemetry == null) {
|
||||
telemetryService.setup(getMachineUniqueID())
|
||||
val allowAnonymousTelemetry = config?.get("allowAnonymousTelemetry") as? Boolean
|
||||
val telemetryService = service<TelemetryService>()
|
||||
if (allowAnonymousTelemetry == true || allowAnonymousTelemetry == null) {
|
||||
telemetryService.setup(getMachineUniqueID())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// On exit, use exponential backoff to create another CoreMessenger
|
||||
coreMessenger?.onDidExit {
|
||||
lastBackoffInterval *= 2
|
||||
println("CoreMessenger exited, retrying in $lastBackoffInterval seconds")
|
||||
Thread.sleep((lastBackoffInterval * 1000).toLong())
|
||||
setupCoreMessenger(continueCorePath)
|
||||
// On exit, use exponential backoff to create another CoreMessenger
|
||||
coreMessenger?.onDidExit {
|
||||
lastBackoffInterval *= 2
|
||||
println("CoreMessenger exited, retrying in $lastBackoffInterval seconds")
|
||||
Thread.sleep((lastBackoffInterval * 1000).toLong())
|
||||
setupCoreMessenger(continueCorePath)
|
||||
}
|
||||
} catch (err: Throwable) {
|
||||
val telemetryService = service<TelemetryService>()
|
||||
telemetryService.capture("jetbrains_core_start_error", mapOf("error" to err))
|
||||
|
||||
err.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.intellij.openapi.project.DumbAware
|
|||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.openapi.vfs.VirtualFileManager
|
||||
import com.intellij.openapi.wm.ToolWindowManager
|
||||
import kotlinx.coroutines.*
|
||||
import java.awt.Toolkit
|
||||
import java.awt.datatransfer.StringSelection
|
||||
|
|
@ -334,6 +335,14 @@ class IdeProtocolClient(
|
|||
respond(result)
|
||||
}
|
||||
|
||||
"closeSidebar" -> {
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
val toolWindow = toolWindowManager.getToolWindow("Continue")
|
||||
toolWindow?.hide()
|
||||
}
|
||||
}
|
||||
|
||||
"getSearchResults" -> {
|
||||
val params = Gson().fromJson(
|
||||
dataElement.toString(),
|
||||
|
|
@ -430,24 +439,28 @@ class IdeProtocolClient(
|
|||
)
|
||||
val filepath = params.filepath
|
||||
|
||||
continuePluginService.sendToWebview("updateApplyState", mapOf(
|
||||
"streamId" to params.streamId,
|
||||
"status" to "streaming",
|
||||
"fileContent" to params.text,
|
||||
"toolCallId" to params.toolCallId,
|
||||
"filepath" to filepath
|
||||
))
|
||||
|
||||
|
||||
fun closeStream () {
|
||||
continuePluginService.sendToWebview("updateApplyState", mapOf(
|
||||
"numDiffs" to 0,
|
||||
continuePluginService.sendToWebview(
|
||||
"updateApplyState", mapOf(
|
||||
"streamId" to params.streamId,
|
||||
"status" to "closed",
|
||||
"status" to "streaming",
|
||||
"fileContent" to params.text,
|
||||
"toolCallId" to params.toolCallId,
|
||||
"filepath" to filepath
|
||||
))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
fun closeStream() {
|
||||
continuePluginService.sendToWebview(
|
||||
"updateApplyState", mapOf(
|
||||
"numDiffs" to 0,
|
||||
"streamId" to params.streamId,
|
||||
"status" to "closed",
|
||||
"fileContent" to params.text,
|
||||
"toolCallId" to params.toolCallId,
|
||||
"filepath" to filepath
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
var editor: Editor? = null;
|
||||
|
|
@ -493,7 +506,7 @@ class IdeProtocolClient(
|
|||
|
||||
val selectedModels = config["selectedModelByRole"] as? Map<*, *>
|
||||
var applyCodeBlockModel = selectedModels?.get("apply") as? Map<*, *>
|
||||
|
||||
|
||||
// If "apply" role model is not found, try "chat" role
|
||||
if (applyCodeBlockModel == null) {
|
||||
applyCodeBlockModel = selectedModels?.get("chat") as? Map<*, *>
|
||||
|
|
@ -555,8 +568,8 @@ class IdeProtocolClient(
|
|||
editor,
|
||||
rif?.range?.start?.line ?: 0,
|
||||
rif?.range?.end?.line ?: (editor.document.lineCount - 1),
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
params.streamId,
|
||||
params.toolCallId
|
||||
)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import {
|
|||
import { AppDispatch } from "../../../../redux/store";
|
||||
import { exitEditMode } from "../../../../redux/thunks";
|
||||
import { loadLastSession } from "../../../../redux/thunks/session";
|
||||
import { getFontSize } from "../../../../util";
|
||||
import { getFontSize, isJetBrains } from "../../../../util";
|
||||
import * as ContinueExtensions from "../extensions";
|
||||
import { TipTapEditorProps } from "../TipTapEditor";
|
||||
import { handleImageFile } from "./imageUtils";
|
||||
|
|
@ -267,6 +267,12 @@ export function createEditorConfig(options: {
|
|||
return false;
|
||||
},
|
||||
Escape: () => {
|
||||
// In JetBrains, this is how we close the sidebar when the input box is focused
|
||||
if (isJetBrains()) {
|
||||
ideMessenger.post("closeSidebar", undefined);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (inDropdownRef.current || !isInEditModeRef.current) {
|
||||
ideMessenger.post("focusEditor", undefined);
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue