Merge pull request #4666 from lkk214/fix/uncaught-typeError

This commit is contained in:
Nate Sesti 2025-03-16 22:51:34 -07:00 • committed by GitHub
commit 8a688cd85e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 8 deletions

View file

@ -14,6 +14,7 @@ import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer
import com.intellij.ui.jcef.*
import com.intellij.ui.jcef.JBCefClient.Properties
import org.cef.CefApp
import org.cef.browser.CefBrowser
import org.cef.handler.CefLoadHandlerAdapter
@ -32,10 +33,16 @@ class ContinueBrowser(val project: Project, url: String) {
init {
val isOSREnabled = ServiceManager.getService(ContinueExtensionSettings::class.java).continueState.enableOSR
this.browser = JBCefBrowser.createBuilder().setOffScreenRendering(isOSREnabled).build()
this.browser = JBCefBrowser.createBuilder().setOffScreenRendering(isOSREnabled).build().apply {
// To avoid using System.setProperty to affect other plugins,
// we should configure JS_QUERY_POOL_SIZE after JBCefClient is instantiated,
// and eliminate the 'Uncaught TypeError: window.cefQuery_xxx is not a function' error
// in the JS debug console, which is caused by ContinueBrowser lazy loading.
jbCefClient.setProperty(Properties.JS_QUERY_POOL_SIZE, JS_QUERY_POOL_SIZE)
}
registerAppSchemeHandler()
browser.loadURL(url);
browser.loadURL(url)
Disposer.register(ContinuePluginDisposable.getInstance(project), browser)
// Listen for events sent from browser

View file

@ -11,7 +11,7 @@ import com.intellij.openapi.wm.ToolWindowFactory
import com.intellij.ui.content.ContentFactory
import javax.swing.*
const val JS_QUERY_POOL_SIZE = "200"
const val JS_QUERY_POOL_SIZE = 200
class ContinuePluginToolWindowFactory : ToolWindowFactory, DumbAware {
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
@ -43,11 +43,6 @@ class ContinuePluginToolWindowFactory : ToolWindowFactory, DumbAware {
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")
}
val browser: ContinueBrowser by lazy {
val url = System.getenv("GUI_URL")?.toString() ?: defaultGUIUrl