Skip to content

fix(hook): support OpenCode Desktop (Node.js) in plugin - #2153

Open
synnks wants to merge 1 commit into
rtk-ai:developfrom
synnks:fix/opencode-desktop-plugin
Open

synnks wants to merge 1 commit into
rtk-ai:developfrom
synnks:fix/opencode-desktop-plugin

Conversation

@synnks

@synnks synnks commented May 29, 2026

Copy link
Copy Markdown

Summary

  • Fix OpenCode plugin failing silently in the Desktop app (Electron/Node.js)
  • Add node:child_process fallback when Bun.$ is unavailable

Fixes #2039

Root Cause

OpenCode Desktop runs its server in an Electron utility process (Node.js), not Bun.
OpenCode passes $: undefined to plugins when typeof Bun === "undefined".
The plugin calls await $which rtk.quiet() — since $ is undefined, this throws a TypeError, caught by the catch block with the misleading message "rtk binary not found in PATH".

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test
  • node --experimental-strip-types --test hooks/opencode/tests/rtk.test.ts
  • Manual testing: verified in OpenCode TUI (Bun path) and Desktop (child_process path)

@CLAassistant

CLAassistant commented May 29, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@alexandre-leites

Copy link
Copy Markdown

Any workaround while this is not merged?

@aurelienpolletadeo

Copy link
Copy Markdown

I am using this version of the rtk.ts for opencode desktop and it's working fine.
Waiting for merge.
Thanks for the PR!

@smzh369

smzh369 commented Jul 19, 2026

Copy link
Copy Markdown

which may failed to get the path on Windows, better to make a platform judgement(line 29-33):

    const check = process.platform === "win32" ? "where" : "which"
    if ($) {
      await $`${check} rtk`.quiet()
    } else {
      execFileSync(check, ["rtk"], { encoding: "utf8", timeout: 5000 })
    }

@amnesiaof

Copy link
Copy Markdown
Contributor

Same root causes reproduce on Windows CLI (not only Desktop Electron): no $ in plugin context + Unix-only which. Also note rtk rewrite exit-code-3 semantics — stdout must be captured from the exception. #3330's cross-platform process API fixes the CLI case too; verified with a working workaround.

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.

OpenCode Desktop does not detect rtk when launched from macOS GUI

6 participants