Repository navigation
fix(opencode): add V2 setup() to generated status plugin - #20458
donniesilalahi wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Caution
src/main/opencode/status-plugin-factory-source.ts no longer parses: the new trailing array element was appended without a comma, so every test that imports hook-service.ts errors during transform before it can run. The V2 setup() approach itself looks sound once that is fixed.
Reviewed changes
- V2
setup()entrypoint — the generated default export now carries{ id, setup, server };setup(ctx)instantiates the existing V1 factory behind a client facade and pumpsctx.event.subscribe()into the unchangedeventhandler. form.*bridge —normalizeV2Eventmaps V2form.created/replied/cancelledonto thequestion.asked/replied/rejectedshapes the attention path already consumes.- Contract tests — new cases assert
setup()is callable, drivesSessionBusy, and postsAskUserQuestionforform.created.
⚠️ The pinned generated-source digest in hook-service.test.ts was not updated
Even after the missing comma is added, the keeps generated plugin bytes stable across the module split test fails: the generated source changed, so the pinned SHA-256 no longer matches. The author needs to recompute both pins.
Technical details
# Update the generated-source digest pins
## Affected sites
- `src/main/opencode/hook-service.test.ts:77` — pins `getOpenCodePluginSource()` to `d14859a36c88…`.
- `src/main/opencode/hook-service.test.ts:80-82` — pins `getOpenCodeFamilyPluginSource('/hook/mimo-code', { emitSessionStart: false })`; the factory source is shared, so this digest almost certainly changes too (the test never reached it because the first assertion aborts).
## Required outcome
- Recompute both `sha256` pins against the corrected generated source.
- Verified value for the primary source, after temporarily adding the missing comma: `51eb33931d60a4d74b83cf1153a159fd252fa445cef313ca1050bfc59f5297dc`.
## Suggested approach (optional)
`pnpm test src/main/opencode/hook-service.test.ts` prints the received digest on failure; copy both received values into the assertions.
## Open questions for the human
- Is the double trailing `''` element intentional (two tagged-template newlines) or was a single trailing newline intended? Either is fine, but confirm the generated file's trailing whitespace is what the loader should see.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| '' | ||
| '' |
There was a problem hiding this comment.
The pre-existing '' on line 323 was the last array element, so it had no trailing comma. Appending a second '' without adding that comma leaves two adjacent string literals, and the module stops parsing — oxlint reports Expected ',' or ']' but found 'string' at line 324, and pnpm test src/main/opencode/hook-service.test.ts fails at transform. Add the comma.
| '' | |
| '' | |
| '', | |
| '' |
📝 WalkthroughWalkthroughThe plugin contract now includes an optional V2 Priority: ⬇️ Low Merge Risk: 🔴 Critical · up to The updated OpenCode status plugin source contains a small syntax mistake that prevents the file from compiling, so the application build and the new plugin support cannot run at all until the stray empty string is removed. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description clearly explains the problem, implementation, compatibility behavior, event bridge, and tests. It does not follow the required template and omits the mandatory Linked Issue, Visual Proof or an N/A explanation, checklist items, and other required sections. Resolution Use the repository template headings. Add a linked issue after “Fixes #”. Add “Visual Proof” with N/A and a reason if there is no UI change. Complete the Testing, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections, including platform coverage and command results.
Warning Some tools did not complete. Review the errors below. 🔧 Biome (2.5.10)src/main/opencode/status-plugin-factory-source.tsFile contains syntax errors that prevent linting: Line 324: expected 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: d966829e-1900-4d8a-81fe-742e123b0c21
📒 Files selected for processing (2)
src/main/opencode/hook-plugin-module-contract.test.tssrc/main/opencode/status-plugin-factory-source.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| ' server: OrcaOpenCodeStatusPlugin,', | ||
| '};', | ||
| '' | ||
| '' |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
Remove the duplicate empty string element.
Line 323 is already the final array element. Line 324 adds an adjacent string literal without a comma. TypeScript cannot parse this file.
Proposed fix
'};',
''
- ''
]📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| '' |
🧰 Tools
🪛 Biome (2.5.10)
[error] 324-324: expected , but instead found ''
(parse)
Source: Linters/SAST tools
|
This approach matches what 2.0.3 GA actually requires. I verified the loader schema firsthand today: a default export with One data point from the consumer side: I ran a minimal equivalent (setup plus subscribe pump, no facade) against 2.0.3 and it loads with zero errors across service restarts, including hot-reload on file change. The facade direction in this PR is strictly better since it keeps the full v1 feature set instead of reimplementing a subset. Happy to test a preview build with the generated output on 2.0.3 if that helps move it along. |
|
Superseded by the generated V2 plugin and Form bridge now on main, including merged #24662. Credit to @donniesilalahi for the original setup/event-stream and question-attention work. Verified with installed OpenCode 2.0.16: the pre-fix generated module fails the real loader; the current module loads. A genuine question tool creates a Form, the plugin sends busy and question details, and OpenCode consumes the actual reply before reporting idle and a successful session. Cancelling a second genuine Form returns HTTP 204 and produces the mapped idle hook before process cleanup. The cancellation suite exited unsuccessfully because its extra check expected terminal session fields that never appeared. Cancellation’s durable session outcome remains unproved; the observed Form bridge is sufficient for this PR’s scope. Broader permission and child-session behavior remains tracked in #20410. Closing this older implementation because its loader and question-attention fixes are covered by merged code. |

Problem
After migrating OpenCode V1 → V2, the generated
orca-opencode-status.jsno longer loads. The V2 plugin loader requires the default export to carryidplussetup()(oreffect()); our file only exports{ id, server }, so every OpenCode V2 session logs:Result: Orca receives no session busy/idle/message status from any OpenCode V2 agent (
opencode plugin listshows the plugin as-instead oforca-opencode-status).Fix
src/main/opencode/status-plugin-factory-source.ts— the generated module's default export is now{ id, setup, server }:setup(ctx)(V2 entrypoint) instantiates the existing V1 factory with a thin client facade (ctx.session.getadapted to the V1{ data }shape; emptylistfallback so ancestry walks fail open), pumpsctx.event.subscribe()into the unchanged V1eventhandler in order, and returns an abort +dispose()cleanup.server()is untouched, so V1 keeps working from the same file.question.asked/replied/rejectedno longer exist (nowform.created/replied/cancelled, confirmed against the V2 binary's event strings).setup()normalizesform.*to thequestion.*shapes the attention path expects; without this the dashboard never learns a question tool is waiting. All other consumed events (session.idle/status/created/error,message.*,permission.*) still exist in V2 and are forwarded as-is.Tests
src/main/opencode/hook-plugin-module-contract.test.ts— existing V1 contract tests unchanged (they still pass:serveris kept), plus:setup()alongsideserver(),setup()over a mock V2 event stream postsSessionBusythrough the hook endpoint,form.createdbridges to anAskUserQuestionpost.Verified locally against the assembled plugin: one stream produced
SessionStart → SessionBusy → AskUserQuestion → SessionIdle(trailing idle is disposal publishing its final state), andopencode plugin listreports the pluginactive.Notes
require("fs")for the endpoint-file read; that still resolves under V2 (Bun providesrequirein ESM plugin scope) — no change needed there.