Skip to content

Commit 8ba447a

Browse files
Michel BelleauMichel Belleau
authored andcommitted
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.
1 parent f0055ab commit 8ba447a

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Using `@latest` ensures you always get the newest version automatically when Ope
2121

2222
Restart OpenCode. The plugin will automatically start optimizing your sessions.
2323

24+
> **Important:** DCP is designed for the TUI (terminal) version of OpenCode. It auto-disables on Desktop/Web clients (see [Known Issues](#known-issues)).
25+
2426
## How Pruning Works
2527

2628
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
147149

148150
### Protected Tools
149151

152+
## Known Issues
153+
154+
### Desktop / Web App Incompatibility
155+
156+
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).
157+
158+
**Symptoms on Desktop/Web:**
159+
160+
- `/dcp` commands fail with `TypeError: {} is not iterable`
161+
- `discard` and `extract` tools fail with the same error
162+
- Pruning notifications don't display correctly
163+
164+
**Solution:**
165+
166+
- DCP automatically detects when running on Desktop (Electron-based clients) and **auto-disables itself** with a console message
167+
- Use the TUI version of OpenCode for full DCP functionality
168+
169+
**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.
170+
150171
By default, these tools are always protected from pruning across all strategies:
151172
`task`, `todowrite`, `todoread`, `discard`, `extract`, `batch`, `write`, `edit`
152173

index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,24 @@ import {
99
createSystemPromptHandler,
1010
} from "./lib/hooks"
1111

12+
function isDesktop(): boolean {
13+
return process.env.ELECTRON_RUN_AS_NODE !== undefined
14+
}
15+
1216
const plugin: Plugin = (async (ctx) => {
1317
const config = getConfig(ctx)
1418

1519
if (!config.enabled) {
1620
return {}
1721
}
1822

23+
if (isDesktop()) {
24+
console.log(
25+
"DCP: Auto-disabled on Desktop – use the TUI version for full DCP functionality",
26+
)
27+
return {}
28+
}
29+
1930
const logger = new Logger(config.debug)
2031
const state = createSessionState()
2132

0 commit comments

Comments
 (0)