Skip to content

fix(opencode): support v2 plugins under the plain executable name - #22078

Merged
nwparker merged 2 commits into
mainfrom
fix/opencode-version-detection
Sep 21, 2026
Merged

nwparker merged 2 commits into
mainfrom
fix/opencode-version-detection

Conversation

@nwparker

@nwparker nwparker commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

OpenCode 2 installed as opencode receives a plugin it cannot load. The plugin now supports both OpenCode versions, so its filename no longer determines which loader can use it.

What Changed

The plain OpenCode plugin now includes the existing v2 setup() adapter and event normalization alongside its v1 server() and named factory exports. It keeps the /hook/opencode endpoint and pane-variant guard. An inactive variant returns from setup before registering subscriptions or prompt hooks.

Why

The CLI name does not identify the installed major version. Supporting both loader contracts avoids subprocess version probes, cached-version mistakes, and gaps for commands typed into existing shell panes. The existing opencode2 plugin retains its endpoint. Quick-command prompts for both opencode and opencode2 use the ready-state submission path so a v2 install under either executable name behaves consistently. This also removes the incompatible module content that previously failed again when rewritten on another pane spawn; this PR does not change file-write frequency.

Linked Issue

Fixes #21974

Visual Proof

N/A — generated plugin contract change; no Orca UI layout changes. Live installed-binary verification was attempted but is incomplete: local v2.0.9 stalled during private-server startup and produced no hook callbacks before timeout. This is not claimed as an end-to-end pass.

Testing

  • I manually tested these changes locally end to end
  • Automated tests added/updated
  • 191 OpenCode plugin tests passed, including legacy factory behavior and both generated variants running v2 setup/lifecycle, permission, form, text, disposal, and isolation contracts.
  • 43 relay/WSL overlay and hook integration tests passed.
  • Node typecheck, targeted oxlint, formatting, and diff whitespace checks passed.
  • Real macOS opencode v2.0.9 run attempted with isolated generated plugin and HTTP callback capture; startup timed out without callbacks. No real Windows/Linux/SSH agent run claimed.

AI Disclosure

Review

The shared generated plugin reaches local and relay installs without adding a wire field or a new process probe. Tests check that callbacks retain the selected agent endpoint. MiMo generation is unchanged.

Agent skill upstream boundary

  • Not applicable; no upstream skill source copied.

Notes

This fixes loader compatibility, not picker version labels, shared-server pane ownership, or macOS privacy permissions. Existing shared OpenCode services may require restarting to load updated plugins.

Checklist

  • Small and focused
  • Before/after behavior and approach explained
  • Validation limitations documented
  • Self-reviewed for correctness, security, and performance
  • Cross-platform and SSH impact considered
  • Full CI passes (pending)

@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 3c9a8385-658e-4cd7-ae4b-ab5a18adf9b3

📥 Commits

Reviewing files that changed from the base of the PR and between 467b709 and b70c010.

📒 Files selected for processing (2)
  • src/renderer/src/lib/run-quick-command-in-new-tab.test.ts
  • src/renderer/src/lib/run-quick-command-in-new-tab.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The plugin source generator now passes explicit agent configuration and supports next-event emission. OpenCode 2 setup skips hook registration when event hooks are unavailable. Contract tests now run against both opencode and opencode2, verify agent filtering and hook endpoints, and update the generated-source digest. OpenCode quick commands now use submit-after-ready delivery for both agents.

Priority: ➖ Normal

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #21974 requires the plain opencode plugin to load with OpenCode 2 while preserving OpenCode 1 behavior. getOpenCodePluginSource() now enables the v2 event normalization and setup path, sets …
Out of Scope Changes check ✅ Passed The changes support the dual-loader behavior for the plain opencode agent. The setup no-op guard and the quick-command promptDelivery update keep plain opencode behavior aligned with the v2 path…
Title check ✅ Passed The title clearly identifies the main change: support for v2 plugins when using the plain opencode executable name.
Description check ✅ Passed The description covers the required sections, linked issue, user impact, implementation, testing, limitations, and checklist status. It accurately records that end-to-end validation and full CI remain…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Dual-loader plain plugin — getOpenCodePluginSource() now emits the v2 setup() adapter and session.next.* / permission.v2.* normalization alongside the v1 server(), so an OpenCode 2 install named opencode can load it. The v2 setup path is neutralized for the wrong pane variant before it registers a prompt hook or event subscription.
  • Explicit expectedAgent — getStatusPluginFactorySource accepts an expectedAgent override, and the plain plugin pins 'opencode'. This is load-bearing: the previous derivation was emitNextEvents ? 'opencode2' : 'opencode', so flipping emitNextEvents on without the override would have made the plain plugin inert under its own agent.
  • Regression tests — the v2 setup suite is parametrized over both agents, adds a wrong-variant test asserting no hook/subscription registration, and scrubs ORCA_OPENCODE_AGENT; the plain-plugin byte-stability digest is updated (opencode2/mimo digests unchanged).

Verified locally: the three touched opencode suites (53 tests) and the full src/main/opencode src/main/mimo src/relay scope (1948 tests) pass. The new wrong-variant test genuinely fails without the if (!hooks.event) return async () => {} guard, so it is not theatre. Endpoint routing is unaffected — a plain v2 pane posts to /hook/opencode and server-side normalization is identical for both sources — and the mimo family source is byte-identical to before.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 1a3f4e8 into main Sep 21, 2026
29 checks passed
@nwparker
nwparker deleted the fix/opencode-version-detection branch September 21, 2026 21:29
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.

Plain opencode 2.x gets the OpenCode 1 status plugin — detection is binary-name only

1 participant