From 621e1dbf6bdd16183ed4e80e37fb49c15bc7f369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20B=C5=82ach?= Date: Fri, 25 Jul 2025 20:29:20 +0200 Subject: [PATCH] fix: Add JCEF not supported warning (#6762) * fix: Add JCEF not supported warning Related to: #5107, #4598, #649, #596 * fix: provide guidance on how to install the correct JDK --- .../ContinuePluginToolWindowFactory.kt | 87 ++++++++++--------- .../src/main/resources/jcef_error.html | 22 +++++ 2 files changed, 69 insertions(+), 40 deletions(-) create mode 100644 extensions/intellij/src/main/resources/jcef_error.html 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/resources/jcef_error.html b/extensions/intellij/src/main/resources/jcef_error.html new file mode 100644 index 000000000..1e3b683bf --- /dev/null +++ b/extensions/intellij/src/main/resources/jcef_error.html @@ -0,0 +1,22 @@ + + +

+
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:

+
    +
  1. In the main menu, go to Help | Find Action or press + Ctrl + Shift + A. +
  2. +
  3. Find and select the Choose Boot Java Runtime for the IDE action.
  4. +
  5. Select the runtime that comes with JCEF support and click OK.
  6. +
  7. Restart with the new runtime.
  8. +
+

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