Changesets · Branches · Tags · Compare
| Changeset | 95206ce5cf3cb7b9d7e98a1ee48618e83bf0f0ffd5f99a758a57207d1401cbd7 |
|---|---|
| Author | Jakub Blach <jakubblach@gmail.com> · 2025-07-08 14:27 +02:00 |
| Committer | Jakub Blach <jakubblach@gmail.com> · 2025-07-08 14:27 +02:00 |
| Parents | 62285ff5a158 |
3 files changed
modified extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt +6 −0
| @@ -7,6 +7,12 @@ | ||
| 7 | 7 | import com.intellij.openapi.components.service |
| 8 | 8 | import com.intellij.openapi.fileEditor.FileEditorManager |
| 9 | 9 | |
| 10 | +class RestartContinueProcess : AnAction() { | |
| 11 | + override fun actionPerformed(e: AnActionEvent) { | |
| 12 | + val pluginService = getContinuePluginService(e.project) ?: return | |
| 13 | + pluginService.coreMessengerManager?.restart() | |
| 14 | + } | |
| 15 | +} | |
| 10 | 16 | |
| 11 | 17 | class AcceptDiffAction : AnAction() { |
| 12 | 18 | override fun actionPerformed(e: AnActionEvent) { |
modified extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessengerManager.kt +22 −26
| @@ -4,48 +4,44 @@ | ||
| 4 | 4 | import com.github.continuedev.continueintellijextension.utils.castNestedOrNull |
| 5 | 5 | import com.github.continuedev.continueintellijextension.utils.getMachineUniqueID |
| 6 | 6 | import com.intellij.openapi.components.service |
| 7 | +import com.intellij.openapi.diagnostic.Logger | |
| 7 | 8 | import com.intellij.openapi.project.Project |
| 8 | 9 | import kotlinx.coroutines.CoroutineScope |
| 9 | -import kotlinx.coroutines.launch | |
| 10 | 10 | |
| 11 | 11 | class CoreMessengerManager( |
| 12 | 12 | private val project: Project, |
| 13 | 13 | private val ideProtocolClient: IdeProtocolClient, |
| 14 | 14 | private val coroutineScope: CoroutineScope |
| 15 | 15 | ) { |
| 16 | - | |
| 17 | - var coreMessenger: CoreMessenger? = null | |
| 16 | + var coreMessenger: CoreMessenger = createCoreMessenger() | |
| 18 | 17 | private var lastBackoffInterval = 0.5 |
| 18 | + private val log = Logger.getInstance(CoreMessengerManager::class.java) | |
| 19 | 19 | |
| 20 | 20 | init { |
| 21 | - coroutineScope.launch { | |
| 22 | - setupCoreMessenger() | |
| 23 | - } | |
| 21 | + setupAnonymousTelemetry() | |
| 24 | 22 | } |
| 25 | 23 | |
| 26 | - private fun setupCoreMessenger() { | |
| 24 | + fun restart() { | |
| 27 | 25 | try { |
| 28 | - coreMessenger = CoreMessenger(project, ideProtocolClient, coroutineScope, onExit = { | |
| 29 | - lastBackoffInterval *= 2 | |
| 30 | - println("CoreMessenger exited, retrying in $lastBackoffInterval seconds") | |
| 31 | - Thread.sleep((lastBackoffInterval * 1000).toLong()) | |
| 32 | - setupCoreMessenger() | |
| 33 | - }) | |
| 34 | - | |
| 35 | - coreMessenger?.request("config/getSerializedProfileInfo", null, null) { response -> | |
| 36 | - val allowAnonymousTelemetry = | |
| 37 | - response.castNestedOrNull<Boolean>("content", "result", "config", "allowAnonymousTelemetry") | |
| 26 | + coreMessenger.killSubProcess() | |
| 27 | + lastBackoffInterval *= 2 | |
| 28 | + log.warn("Continue process exited, retrying in $lastBackoffInterval seconds") | |
| 29 | + Thread.sleep((lastBackoffInterval * 1000).toLong()) | |
| 30 | + coreMessenger = createCoreMessenger() | |
| 31 | + } catch (e: Exception) { | |
| 32 | + service<TelemetryService>().capture("jetbrains_core_start_error", mapOf("error" to e)) | |
| 33 | + } | |
| 34 | + } | |
| 38 | 35 | |
| 39 | - val telemetryService = service<TelemetryService>() | |
| 40 | - if (allowAnonymousTelemetry == true || allowAnonymousTelemetry == null) { | |
| 41 | - telemetryService.setup(getMachineUniqueID()) | |
| 42 | - } | |
| 43 | - } | |
| 44 | - } catch (err: Throwable) { | |
| 45 | - val telemetryService = service<TelemetryService>() | |
| 46 | - telemetryService.capture("jetbrains_core_start_error", mapOf("error" to err)) | |
| 36 | + private fun createCoreMessenger() = | |
| 37 | + CoreMessenger(project, ideProtocolClient, coroutineScope, ::restart) | |
| 47 | 38 | |
| 48 | - err.printStackTrace() | |
| 39 | + private fun setupAnonymousTelemetry() { | |
| 40 | + coreMessenger.request("config/getSerializedProfileInfo", null, null) { response -> | |
| 41 | + val allowAnonymousTelemetry = | |
| 42 | + response.castNestedOrNull<Boolean>("content", "result", "config", "allowAnonymousTelemetry") | |
| 43 | + if (allowAnonymousTelemetry == true || allowAnonymousTelemetry == null) | |
| 44 | + service<TelemetryService>().setup(getMachineUniqueID()) | |
| 49 | 45 | } |
| 50 | 46 | } |
| 51 | 47 | } |
modified extensions/intellij/src/main/resources/META-INF/plugin.xml +7 −0
| @@ -70,6 +70,13 @@ | ||
| 70 | 70 | <override-text place="GoToAction" text="Continue: Accept Diff"/> |
| 71 | 71 | </action> |
| 72 | 72 | |
| 73 | + <action id="continue.restartProcess" | |
| 74 | + class="com.github.continuedev.continueintellijextension.actions.RestartContinueProcess" | |
| 75 | + text="Restart Process" | |
| 76 | + description="Restart Process"> | |
| 77 | + <override-text place="GoToAction" text="Continue: Restart Process"/> | |
| 78 | + </action> | |
| 79 | + | |
| 73 | 80 | <action id="continue.rejectDiff" |
| 74 | 81 | class="com.github.continuedev.continueintellijextension.actions.RejectDiffAction" |
| 75 | 82 | text="Reject Diff" description="Reject Diff"> |