From 8ba447abcf3a2aa8dbb9ca3cb2ee5915ee131e08 Mon Sep 17 00:00:00 2001 From: Michel Belleau Date: Tue, 27 Jan 2026 22:14:29 -0500 Subject: [PATCH] feat: auto-disable DCP on Desktop clients DCP is incompatible with Desktop/Web clients due to breaking changes in @opencode-ai/plugin. Add automatic detection of Electron/Desktop environment and disable plugin with console message. Update README to document this known issue. --- README.md | 21 +++++++++++++++++++++ index.ts | 11 +++++++++++ 2 files changed, 32 insertions(+) diff --git a/README.md b/README.md index 4d39d2cd..3ada2d44 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ Using `@latest` ensures you always get the newest version automatically when Ope Restart OpenCode. The plugin will automatically start optimizing your sessions. +> **Important:** DCP is designed for the TUI (terminal) version of OpenCode. It auto-disables on Desktop/Web clients (see [Known Issues](#known-issues)). + ## How Pruning Works DCP uses multiple tools and strategies to reduce context size: @@ -147,6 +149,25 @@ When enabled, turn protection prevents tool outputs from being pruned for a conf ### Protected Tools +## Known Issues + +### Desktop / Web App Incompatibility + +DCP is currently incompatible with OpenCode's desktop and web clients. This is a known issue tracked in [Issue #304](https://github.com/Opencode-DCP/opencode-dynamic-context-pruning/issues/304). + +**Symptoms on Desktop/Web:** + +- `/dcp` commands fail with `TypeError: {} is not iterable` +- `discard` and `extract` tools fail with the same error +- Pruning notifications don't display correctly + +**Solution:** + +- DCP automatically detects when running on Desktop (Electron-based clients) and **auto-disables itself** with a console message +- Use the TUI version of OpenCode for full DCP functionality + +**Status:** The plugin is designed for TUI usage only. Desktop/Web clients have breaking changes in their `@opencode-ai/plugin` implementation that haven't been addressed yet. + By default, these tools are always protected from pruning across all strategies: `task`, `todowrite`, `todoread`, `discard`, `extract`, `batch`, `write`, `edit` diff --git a/index.ts b/index.ts index 0c7ae2a7..f599456a 100644 --- a/index.ts +++ b/index.ts @@ -9,6 +9,10 @@ import { createSystemPromptHandler, } from "./lib/hooks" +function isDesktop(): boolean { + return process.env.ELECTRON_RUN_AS_NODE !== undefined +} + const plugin: Plugin = (async (ctx) => { const config = getConfig(ctx) @@ -16,6 +20,13 @@ const plugin: Plugin = (async (ctx) => { return {} } + if (isDesktop()) { + console.log( + "DCP: Auto-disabled on Desktop – use the TUI version for full DCP functionality", + ) + return {} + } + const logger = new Logger(config.debug) const state = createSessionState()