Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/windows-chat-focus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ jobs:
runs-on: ubuntu-24.04
timeout-minutes: 90
env:
# Match the extension used in the existing focus investigation.
ZOO_EXTENSION_VERSION: "3.84.0"
# Reproduce the release under investigation with the current Kotlin changes.
ZOO_EXTENSION_VERSION: "3.96.0"
# This job packages the plugin; headful tests use the IDE's bundled JCEF.
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"
steps:
Expand Down
4 changes: 4 additions & 0 deletions docs/KNOWN_ISSUES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

This document records the known issues, limitations, and solutions for the Zoo Code JetBrains project.

The 3.96.0 Marketplace API warnings and JCEF compatibility work are tracked in
[issue #16](https://github.com/Zoo-Code-Org/Zoo-Code-Jetbrains/issues/16).
Release verification and the internal/experimental editor API migration remain open.

## 1. JCEF Related Issues

The current plugin implementation heavily relies on JCEF capabilities. In environments where JCEF cannot function properly, the plugin may fail to load normally.
Expand Down
2 changes: 1 addition & 1 deletion jetbrains_plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Plugin basic information
pluginGroup=org.zoocode.jetbrains
pluginVersion=3.78.0
pluginVersion=3.96.0

# Platform basic information
platformVersion=2023.3
Expand Down
46 changes: 42 additions & 4 deletions jetbrains_plugin/scripts/ui-harness/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,46 @@
The source and runner in this directory work without the ignored investigation
fixture. Prerequisites: a JCEF-enabled IntelliJ installation with JBR `javac`
(tested with IU-253.28294.334), `jar`, `unzip`, Xvfb, xdotool, and Openbox.
Build the ZooCode plugin distribution first. Its Kotlin plugin version is
3.78.0; the embedded Zoo Code extension version is 3.84.0.
Supply a complete ZooCode release distribution ZIP. The tested plugin and
embedded extension versions come from that archive, not the harness source.

## Testing Zoo Code 3.96.0

To test the published release, download its JetBrains plugin ZIP and pass it
directly to `PLUGIN_ZIP` on Linux or `-PluginZip` on Windows. This exercises the
released binary, including its bundled extension and runtime. Renaming an older
ZIP or overriding only `pluginVersion` does not produce a 3.96.0 release test.

On a new checkout, run `./scripts/setup.sh` first. To test the current Kotlin
changes with extension 3.96.0, build from the repository root:

```sh
ZOO_EXTENSION_VERSION=3.96.0 ./scripts/build.sh --mode release --clean --verbose
```

The build downloads that extension version and packages this checkout as 3.96.0.
This is a candidate build, distinct from the published release. The build updates
`gradle.properties` and replaces generated build outputs. Run it in a separate
checkout when retaining another build for comparison.

Use the resulting ZIP with the Linux instructions below or the Windows command:

```powershell
./run-windows.ps1 -IdeDir C:/tools/idea -PluginZip C:/build/ZooCode-3.96.0.zip `
-EvidenceDir C:/temp/focus-3.96.0
```

The credential-free fixture exercises real chat streaming, typing, and editor
opens. Live Solheim testing additionally covers model-driven terminal and diff
operations and needs the provider setup documented below. Gradle tests alone do
not exercise the bundled extension in a running IDE.

The Windows CI workflow pins extension 3.96.0 and builds the checkout;
it has no input for an existing release ZIP. Its IDEA matrix is 2025.3 and
2026.2.1, so those jobs do not establish compatibility with IDEA 2023.3.8.
Record the exact ZIP, IDE version, and evidence directory when comparing builds.

## Linux live setup

Store the Solheim key in a private file outside the repository (mode 0600).
Generate a random per-run local token. Run the `export` line in both shells, with the same value:
Expand All @@ -25,7 +63,7 @@ In a second shell, export the same `SOLHEIM_RELAY_TOKEN` value. Then run from th

```sh
IDE_DIR=/path/to/intellij \
PLUGIN_ZIP=/path/to/ZooCode-3.78.0.zip \
PLUGIN_ZIP=/path/to/ZooCode-3.96.0.zip \
HARNESS_WM_BIN=/usr/bin/openbox \
HARNESS_HEAP_MB=768 HARNESS_CPU_COUNT=4 DEADLINE_SECONDS=650 \
bash run-solheim.sh
Expand Down Expand Up @@ -104,7 +142,7 @@ nothing.
## Windows GitHub Actions regression test (issue #5)

`.github/workflows/windows-chat-focus.yml` builds the plugin from the tested
checkout with Zoo Code extension **3.84.0**, then runs the same Java driver on
checkout with Zoo Code extension **3.96.0**, then runs the same Java driver on
`windows-2022` with IntelliJ **2025.3** and **2026.2.1**. It runs for pull requests
that change the harness or relevant implementation, and supports manual dispatch
once the workflow exists on the default branch. It does not publish a plugin.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

package org.zoocode.jetbrains.events

import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile

/**
Expand Down Expand Up @@ -60,21 +59,3 @@ object WorkspaceDirectoriesChangeEvent: EventType<WorkspaceFilesChangeData>
data class WorkspaceFilesChangeData(
val changes: List<WorkspaceFileChangeData>
)


/**
* Workspace root change data class
* @param project The changed project
* @param oldPath Original workspace root path
* @param newPath New workspace root path
*/
data class WorkspaceRootChangeData(
val project: Project,
val oldPath: String?,
val newPath: String
)

/**
* Workspace root change event
*/
object WorkspaceRootChangeEvent : EventType<WorkspaceRootChangeData>
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,45 @@
package org.zoocode.jetbrains.ipc.proxy

import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.DisposableHandle
import kotlinx.coroutines.ExperimentalCoroutinesApi

/**
* Lazy Promise implementation
* Corresponds to LazyPromise in VSCode
*/
open class LazyPromise : CompletableDeferred<Any?> by CompletableDeferred() {
open class LazyPromise {
// Delegating the entire CompletableDeferred interface generates overrides
// for obsolete Job APIs (plus, ChildJob and ChildHandle) in our bytecode.
// Keep the coroutine implementation private and expose only RPC operations.
private val deferred = CompletableDeferred<Any?>()

val isCompleted: Boolean get() = deferred.isCompleted

suspend fun await(): Any? = deferred.await()

fun cancel() = deferred.cancel()

fun invokeOnCompletion(handler: (Throwable?) -> Unit): DisposableHandle =
deferred.invokeOnCompletion(handler)

@OptIn(ExperimentalCoroutinesApi::class)
fun getCompleted(): Any? = deferred.getCompleted()

/**
* Resolve Promise successfully
* @param value Result value
*/
fun resolveOk(value: Any?) {
complete(value)
deferred.complete(value)
}

/**
* Reject Promise
* @param err Error object
*/
fun resolveErr(err: Throwable) {
completeExceptionally(err)
deferred.completeExceptionally(err)
}
}

Expand All @@ -35,11 +54,11 @@ open class LazyPromise : CompletableDeferred<Any?> by CompletableDeferred() {
class CanceledLazyPromise : LazyPromise() {
init {
// Immediately complete with cancellation exception
completeExceptionally(CanceledException())
resolveErr(CanceledException())
}
}

/**
* Cancellation exception
*/
class CanceledException : Exception("Operation cancelled")
class CanceledException : Exception("Operation cancelled")
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ class TerminalInstance(
return@invokeLater
}
hideTerminalToolWindow()
shellWidget?.hide()
shellWidget?.isVisible = false
logger.info("✅ Terminal hidden: $extHostTerminalId")
} catch (e: Exception) {
logger.error("❌ Failed to hide terminal: $extHostTerminalId", e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer
import com.intellij.ui.jcef.JBCefBrowser
import com.intellij.ui.jcef.JBCefBrowserBase
import com.intellij.ui.jcef.JBCefJSQuery
import org.zoocode.jetbrains.core.PluginContext
import org.zoocode.jetbrains.core.ServiceProxyRegistry
Expand Down Expand Up @@ -946,8 +947,8 @@ class WebViewInstance(
}

private fun setupJSBridge() {
// Create JS query object to handle messages from webview
jsQuery = JBCefJSQuery.create(browser)
// The cast selects the non-deprecated JBCefBrowserBase overload.
jsQuery = JBCefJSQuery.create(browser as JBCefBrowserBase)

// Set callback for receiving messages from webview
jsQuery?.addHandler { message ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,17 @@
package org.zoocode.jetbrains.workspace

import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.Service
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.project.ProjectManagerListener
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.vfs.*
import com.intellij.openapi.vfs.newvfs.BulkFileListener
import com.intellij.openapi.vfs.newvfs.events.*
import com.intellij.util.messages.MessageBusConnection
import org.zoocode.jetbrains.core.PluginContext
import org.zoocode.jetbrains.core.ServiceProxyRegistry
import org.zoocode.jetbrains.core.WorkspaceManager
import org.zoocode.jetbrains.events.*
import org.zoocode.jetbrains.ipc.proxy.interfaces.FileSystemEvents
import java.util.concurrent.ConcurrentHashMap


/**
Expand All @@ -32,92 +26,23 @@ import java.util.concurrent.ConcurrentHashMap
class WorkspaceFileChangeManager(val project: Project) : Disposable {
private val logger = Logger.getInstance(WorkspaceFileChangeManager::class.java)

// Record registered file listener connections
private val vfsConnections = ConcurrentHashMap<Project, MessageBusConnection>()
private var vfsConnection: MessageBusConnection? = null

// Record project workspace directory paths
private val projectWorkspacePaths = ConcurrentHashMap<Project, String>()

// Project connection
private var projectConnection: MessageBusConnection? = null

// Project listener
private val projectListener = object : ProjectManagerListener {
override fun projectOpened(project: Project) {
registerFileListener(project)
// Record initial project workspace directory
project.basePath?.let { projectWorkspacePaths[project] = it }
// Trigger workspace root change event
triggerWorkspaceRootChangeEvent(project, null, project.basePath ?: "")
}

override fun projectClosed(project: Project) {
unregisterFileListener(project)
// Remove project workspace directory record
projectWorkspacePaths.remove(project)
}
}

init {
// The extension host initializes this project's file watcher on startup.
logger.info("Initialize workspace file change manager")

// Listen for project open/close events
projectConnection = ApplicationManager.getApplication().messageBus.connect(this)
projectConnection?.subscribe(ProjectManager.TOPIC, projectListener)

// Register file listeners for already opened projects
val openProjects = ProjectManager.getInstance().openProjects
for (project in openProjects) {
registerFileListener(project)
// Record workspace directory for opened projects
project.basePath?.let { projectWorkspacePaths[project] = it }
}
}

/**
* Trigger workspace root change event
* @param project Project
* @param oldPath Old workspace directory path
* @param newPath New workspace directory path
*/
private fun triggerWorkspaceRootChangeEvent(project: Project, oldPath: String?, newPath: String) {
logger.debug("Trigger workspace root change event: ${project.name}, old path: $oldPath, new path: $newPath")

// Create workspace root change data
val workspaceChangeData = WorkspaceRootChangeData(project, oldPath, newPath)

// Send workspace root change event via EventBus
project.getService(ProjectEventBus::class.java).emitInApplication(WorkspaceRootChangeEvent, workspaceChangeData)

// Get ExtHostWorkspace proxy
val extHostWorkspace = PluginContext.getInstance(project).getRPCProtocol()?.getProxy(ServiceProxyRegistry.ExtHostContext.ExtHostWorkspace)

// Get current workspace data
val workspaceData = project.getService(WorkspaceManager::class.java).getProjectWorkspaceData(project)

extHostWorkspace?.let {
if(workspaceData != null) {
logger.debug("Send workspace root change to extension process: ${workspaceData.name}, folders: ${workspaceData.folders.size}")
it.acceptWorkspaceData(workspaceData)
}
}
registerFileListener()
}

/**
* Register file listener
* @param project Project to listen to
*/
private fun registerFileListener(project: Project) {
if (vfsConnections.containsKey(project)) {
logger.info("File listener for project ${project.name} already exists, skip registration")
return
}

private fun registerFileListener() {
logger.info("Register file listener for project ${project.name}")

try {
// Create connection and subscribe to VFS change events
val connection = project.messageBus.connect()
val connection = project.messageBus.connect(this)

// Add virtual file system listener
connection.subscribe(VirtualFileManager.VFS_CHANGES, object : BulkFileListener {
Expand All @@ -127,30 +52,13 @@ class WorkspaceFileChangeManager(val project: Project) : Disposable {
})

// Save connection for later cleanup
vfsConnections[project] = connection
vfsConnection = connection

} catch (e: Exception) {
logger.error("Failed to register file listener for project ${project.name}", e)
}
}

/**
* Unregister file listener
* @param project Project to unregister listener from
*/
private fun unregisterFileListener(project: Project) {
val connection = vfsConnections.remove(project)
if (connection != null) {
logger.info("Unregister file listener for project ${project.name}")

try {
connection.disconnect()
} catch (e: Exception) {
logger.error("Failed to unregister file listener for project ${project.name}", e)
}
}
}

/**
* Process bulk file events
* @param events List of file events
Expand Down Expand Up @@ -357,21 +265,9 @@ class WorkspaceFileChangeManager(val project: Project) : Disposable {
logger.info("Release workspace file change manager resources")

try {
// Disconnect project listener connection
projectConnection?.disconnect()
projectConnection = null

// Release all file listener connections
vfsConnections.forEach { (project, connection) ->
try {
logger.info("Unregister file listener for project ${project.name}")
connection.disconnect()
} catch (e: Exception) {
logger.error("Failed to unregister file listener for project ${project.name}", e)
}
}

vfsConnections.clear()
// Also support the explicit extension-host shutdown path.
vfsConnection?.disconnect()
vfsConnection = null

} catch (e: Exception) {
logger.error("Failed to release workspace file change manager resources", e)
Expand Down
Loading
Loading