Skip to content

feat: auto-disable DCP on Desktop clients#322

Closed
malaiwah wants to merge 1 commit intoOpencode-DCP:betafrom
malaiwah:master
Closed

feat: auto-disable DCP on Desktop clients#322
malaiwah wants to merge 1 commit intoOpencode-DCP:betafrom
malaiwah:master

Conversation

@malaiwah
Copy link

Summary

DCP is currently incompatible with Desktop/Web OpenCode clients (issue #304). This PR adds automatic detection of Electron/Desktop environments and auto-disables the plugin with a clear console message.

Changes

  • index.ts: Added isDesktop() function that checks for ELECTRON_RUN_AS_NODE environment variable (set by Electron-based clients)
    • Auto-disables DCP when running on Desktop
    • Logs a console message explaining why
  • README.md:
    • Added note about TUI-only support in Installation section
    • Added "Known Issues" section documenting the Desktop incompatibility

Testing

Tested on:

  • ✅ TUI version: DCP works normally
  • ✅ Desktop version: DCP auto-disables and logs message

Context

I've found DCP works significantly better in TUI than Desktop - the Desktop client has breaking changes in @opencode-ai/plugin that weren't handled, leading to errors like TypeError: {} is not iterable for /dcp commands and the discard/extract tools.

This is a temporary workaround/plugin boundary solution while the deeper compatibility issues with newer OpenCode versions get resolved. The auto-disable approach keeps DCP functional for TUI users while preventing confusing errors for Desktop users.

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.
@Tarquinen Tarquinen changed the base branch from master to beta January 28, 2026 03:20
@Tarquinen
Copy link
Collaborator

Are you sure this works? I thought the desktop app is built with Tauri, not electron?

@malaiwah malaiwah closed this Jan 28, 2026
@malaiwah
Copy link
Author

No, it does not work after all. I need to find the Tauri equivalent

@malaiwah
Copy link
Author

Update: Fix is now working! ✅

The original implementation using TAURI_ENV_PLATFORM didn't work, but we've now found the correct approach:

The Problem

The plugin runs on the server side, not the client. Client-side detection methods (checking window.__TAURI__, environment variables, etc.) are unavailable to the plugin.

The Solution

Desktop vs TUI is distinguished by the command in process.argv:

  • Desktop: ["bun","/$bunfs/root/src/index.js","serve",...]
  • TUI: ["bun","/$bunfs/root/src/cli/cmd/tui/worker.js"]

Implementation

function isDesktop(): boolean {
    return process.argv.includes("serve")
}

Testing Results

✅ Desktop mode: Plugin auto-disables, /dcp commands NOT available
✅ TUI mode: Plugin runs normally, /dcp commands work

I've updated the implementation with this fix on my fork and it's working perfectly!

(Since this PR was closed, I'll create a new PR with the working implementation.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants