Repository navigation
Conversation
The v2 server loader rejects the legacy { id, server } default with
Missing key at ["default"]["effect"] / ["default"]["setup"], which
disables all Orca status updates (failed to load plugin). Emit both
server and setup keys pointing at the same factory so pre-v2 and v2
loaders each resolve; setup() bridges ctx.event.subscribe to the v1
event handler and returns dispose as cleanup, and is a side-effect-free
no-op when no event stream exists.
There was a problem hiding this comment.
🟡 Changes recommended
Existing hash expectations fail the test suite, and abort handling can leave requests running past their deadline.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Updates the generated OpenCode status plugin with OpenCode v2 setup() support while preserving the v1 server() path.
Changes:
- Adds a v2 event-subscription adapter and session-client shim.
- Exposes
setupalongsideserver. - Adds contract and lifecycle tests.
File summaries
| File | Summary | Review findings |
|---|---|---|
src/main/opencode/status-plugin-v2-setup-source.ts |
Generates the v2 setup adapter. | Moderate: Preserve abort errors before retrying list() to avoid uncancellable requests. (2 votes) |
src/main/opencode/status-plugin-factory-source.ts |
Adds setup to the default export. |
No findings. |
src/main/opencode/hook-service.ts |
Includes the new source in generated plugins. | Critical: Refresh the stale SHA-256 expectations in hook-service.test.ts; the current suite will fail. (3 votes) |
src/main/opencode/hook-plugin-module-contract.test.ts |
Tests v1/v2 module contracts and setup behavior. | No findings. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe OpenCode plugin now exports both Priority: ⬇️ Low Merge Risk: 🟡 Moderate · up to On OpenCode v2 session-domain contexts, status updates can be skipped because root sessions are not recognized. Correct the session lookup argument before merging. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the problem, implementation, compatibility behavior, and validation, but it does not follow the required template. It omits the required linked issue, template headings, visual-proof statement, checklist items, and complete testing details. Resolution Rewrite the description using the repository template. Add a real issue reference under Linked Issue, complete ELI5, What Changed, Why, Testing, Review, Notes, and Checklist sections, and add Visual Proof with exactly N/A plus a reason if no visual or interaction change exists. 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: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 205bc3b0-55d6-45a9-b217-f445ed3b3e28
📒 Files selected for processing (4)
src/main/opencode/hook-plugin-module-contract.test.tssrc/main/opencode/hook-service.tssrc/main/opencode/status-plugin-factory-source.tssrc/main/opencode/status-plugin-v2-setup-source.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
- list() shim rethrows when the lookup signal aborted instead of retrying without the signal as an uncancellable request. - hook-service.test.ts stability digests regenerated for the new generated bytes, plus containment pins for the setup adapter.
|
Both review findings addressed in 66060c5:
Re-ran the standalone generated-module harness after the change: shape |
There was a problem hiding this comment.
Caution
The setup() adapter forwards the wrong event shape. On opencode 2.0.7 the plugin event stream yields { type, data } events under v2 names, while the reused v1 factory reads event.properties.* and v1 names — so v2 still reports no status. A pinned generated-source digest test also fails. The loader-shape fix itself is correct.
Reviewed changes
- Dual-key default export —
{ id, server, setup }so the pre-v2 (server) and v2 (setup) loaders both resolve. This part checks out; I verified both loader schemas ignore the extra key, and this is opencode's documented V1+V2 migration shape. - New
setup()adapter (status-plugin-v2-setup-source.ts) — reuses the v1 factory behind aclient.sessionshim, subscribes toctx.event.subscribe({ signal }), and returns an abort/dispose cleanup. - Contract tests — pin
setuppresence, a no-op setup without an event stream, and aSessionBusypost driven through a fabricated v2 context.
⚠️ Generated-source digest test is stale and fails
src/main/opencode/hook-service.test.ts:77-82 pins the sha256 of the assembled plugin source, and this PR changes that source without updating the pins. I ran the file: expected 'd14859a36c88aefe3a45cd232789503296e0a…' to be 'd14859…' — received fa4700f1a99f06f7e97ef578e270027cf9bda19fb76157236c9d514709875159. The second pin (the /hook/mimo-code family source) also changes because it shares the added part. This is a CI failure, not a runtime one, but it blocks the merge; regenerate both digests after the event-bridge fix below lands so the bytes are pinned once.
Technical details
# Stale generated-source digest pins
## Affected sites
- `src/main/opencode/hook-service.test.ts:74-83` — `keeps generated plugin bytes stable across the module split` asserts exact digests of `getOpenCodePluginSource()` and `getOpenCodeFamilyPluginSource('/hook/mimo-code', { emitSessionStart: false })`.
- `src/main/opencode/hook-service.ts:65` — adding `...getStatusPluginV2SetupSource()` changes both assembled strings.
## Required outcome
- Both pinned digests match the assembled source once the final adapter shape is settled.
## Suggested approach (optional)
- Update the pins from the failure output (or recompute via the test's own `digest()` helper). Do this after the event-bridge fix, since that fix will change the bytes again.ℹ️ Nitpicks
src/main/opencode/status-plugin-factory-source.ts:218-219says both keys point at "the same implementation", butserverisOrcaOpenCodeStatusPluginandsetupis the separateOrcaOpenCodeStatusSetupadapter. Consider "both keys resolve to the shared factory" to avoid implying one function.buildV1ClientShimalways returns asession.list, but opencode 2.0.7'sSessionDomainexposes nolist(onlyget,create,prompt, …). It is only a fallback becausegetexists, and failures are caught upstream as fail-open, but advertising a method the host does not have is misleading.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ Delta is clean — the digest pins are refreshed and the
listshim now preserves abort. The v2 event-shape blocker from the prior review is still open.
Reviewed changes (since the prior review at 58a3f51)
- Refreshed generated-source digest pins —
hook-service.test.tsnow pins the post-change hashes and asserts the v2 setup symbols are present.pnpm test src/main/opencode/passes 116/116. - Abort preserved in the
listshim —status-plugin-v2-setup-source.ts:46-52rethrows when the deadline signal is aborted rather than retrying without it, so a cancelled lookup stays cancelled.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
- toV1LifecycleEvent maps encoded OpenCodeEvent {type, data} to the
v1 {type, properties} shape for session.status/idle/created and
permission.asked/replied only; v2 text/preview vocabulary is dropped
rather than mislabeled, and session.created's flat id is nested under
info as the factory expects.
- Adapter disposes the factory in a finally when the subscribe stream
terminates so a dead stream cannot pin a busy owner.
- Simplify list shim to the single-input v2 form; errors propagate to
the lookup timeout/fail-open path.
- Contract tests use real v2 envelopes throughout; created->Start,
delta-drop, busy->idle-on-stream-end, and permission attention covered.
Stability digests regenerated.
|
Update in f6b683e — both new findings addressed, and pullfrog's envelope catch was correct and important: V2 envelope translation (pullfrog). Verified against the published 2.0.7 packages: Dispose on stream end (coderabbit). The subscription task now disposes the factory in a Validation (standalone harness executing the assembled generated module): v2 busy -> |
There was a problem hiding this comment.
Important
The v2 event bridge only fires for session.status/session.idle. The session.created and permission.* branches target v1 event names/payloads that opencode 2.x's server stream does not carry, so SessionStart and PermissionRequest never post on 2.x.
Reviewed changes (since the prior review at 66060c5)
- Event-shape bridge —
toV1LifecycleEventmaps the v2{ type, data }envelope to the v1 factory's{ type, properties }shape for a lifecycle whitelist and drops everything else. - Client shim narrowed —
buildV1ClientShimexposesget/listonly when the v2 session domain has them and drops the signal/arg-shape probing. - Stream-end dispose —
setup()disposes the factory in afinallywhen the event stream ends. - Tests + digest pins — added a v2
session.statuscase and asession.created/text-drop case; refreshed the generated-source hashes (pnpm test src/main/opencode/passes 117/117).
ℹ️ Pane previews and session start stay unmapped on v2
The default: return null branch drops every session.next.* event, which is where v2 carries prompt/reply text (session.next.prompted, session.next.text.ended) and session lifecycle. The test documents this as a deliberate choice, but it means this fix restores busy/idle while pane previews and SessionStart remain blank on 2.x. Worth deciding explicitly whether those are follow-ups or out of scope.
Technical details
# v2 preview/session-start scope
## Affected sites
- `src/main/opencode/status-plugin-v2-setup-source.ts:31-32` — `default: return null`.
- `src/main/opencode/hook-plugin-module-contract.test.ts:241-244` — asserts the delta is dropped.
## Open questions for the human (optional)
- Is v2 preview/session-start parity a follow-up, or intentionally out of scope for this fix?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Checked both new findings against the published 2.0.7 packages ( 1. 2. Consistent with this, |
Live 2.0.7 turns emit no session.status/session.idle; liveness is session.execution.started -> ...succeeded|failed|interrupted. Map those to v1 busy/idle and synthesize SessionStart on first sight of a lookup-confirmed root (skipped for children and on lookup failure). Real creation events mark first sight to avoid double Start. Contract tests rewritten around observed v2 flows; digests regenerated.
|
Live probing changed the picture — pushed 4f38212. I ran an instrumented copy of the adapter against a real 2.0.7 turn and found a full successful turn emits no What changed:
|
There was a problem hiding this comment.
Important
The new busy/idle derivation is correct against opencode 2.0.7, but the session.created signal it builds on is misread: v2 sends { sessionID, parentID, … }, not { id, … }, so the real creation event is still dropped and SessionStart depends entirely on the execution.started lookup path.
Reviewed changes (since the prior review at f6b683e)
- Derived v2 busy/idle from execution events —
toV1LifecycleEventmapssession.execution.startedto a v1 busysession.statusand…succeeded|failed|interruptedtosession.idle, so a normal turn now flips the pane. - Synthesized
session.createdfor confirmed roots — on the firstexecution.startedthe adapter looks up the session and, when it has noparentID, forwards a v1-shapedsession.createdso the factory postsSessionStartbefore the busy transition. - Bounded seen-session set —
seenV2SessionIDs(128, FIFO) prevents a repeated start;session.createdis also meant to mark first sight. - Tests and digest pins refreshed — the execution-event test asserts the exact
SessionStart/SessionBusy/SessionIdleorder and both generated-source hashes are re-pinned.
ℹ️ The prior permission.asked / permission.replied finding was based on the wrong file
The open thread at status-plugin-v2-setup-source.ts:25-29 is a false positive: opencode 2.0.7's packages/schema/src/permission.ts defines permission.asked / permission.replied (carrying id and sessionID) and event-manifest.ts includes Permission.Event.Definitions in ServerDefinitions. permission-v1.ts is the legacy re-export. No change is needed on those cases.
Technical details
# v2 permission events keep their v1 names
## Evidence (opencode v2.0.7)
- `packages/schema/src/permission.ts` — `Asked = ephemeral({ type: "permission.asked", schema: Request.fields })`, `Replied = ephemeral({ type: "permission.replied", … })`.
- `packages/schema/src/event-manifest.ts` — `Permission.Event.Definitions` is part of `featureDefinitions`, hence `ServerDefinitions`.
- `packages/schema/src/permission-v1.ts` — `export * from "./v1/permission.js"` (legacy, not in the server manifest).DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
- session.created carries data.sessionID per packages/schema source, not data.id; mapping and first-sight marking corrected, tests now use the genuine envelope. - ensureV2SessionStart reuses resolveRootSessionID instead of a bare session.get, inheriting its deadline and cache so a hung lookup can never stall the event loop; unknown lineage skips the synthetic. - Digests regenerated.
|
Pushed e1c6220 addressing the two new findings — one of them caught a genuine bug in my revision:
Start-synthesis timeout. Adopted the suggested approach wholesale: Validated against the assembled bytes: created( |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟠 Major · Pass the scalar session ID to the v2 session domain. · status-plugin-v2-setup-source.ts:84-106
src/main/opencode/status-plugin-v2-setup-source.ts:84-106
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winPass the scalar session ID to the v2 session domain. OpenCode 2.0.7 defines
context.data.session.get(sessionID). The shim passes{ sessionID }to that domain without another wrapper. The root lookup can therefore fail, andensureV2SessionStartskips the syntheticSessionStartevent.session.list({})uses the valid v2 list shape. FixbuildV1ClientShim; the nativectx.client.sessionpath is unaffected.Proposed fix
- const raw = await sessionDomain.get({ sessionID }); + const raw = await sessionDomain.get(sessionID);
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: dfedef9f-4421-49fc-9ffe-dd6ff926e6b0
📒 Files selected for processing (3)
src/main/opencode/hook-plugin-module-contract.test.tssrc/main/opencode/hook-service.test.tssrc/main/opencode/status-plugin-v2-setup-source.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
There was a problem hiding this comment.
ℹ️ No critical issues — the prior review's findings are addressed; one test-coverage suggestion inline.
Reviewed changes (since the prior review at 4f38212)
- Corrected the
session.createdshape —toV1LifecycleEventand the loop's mark-seen check now readdata.sessionID/data.parentID(the real v2 payload) instead ofdata.id, so a root creation event postsSessionStartat creation rather than only via theexecution.startedsynthesis. - Timeout-safe start synthesis —
ensureV2SessionStartnow resolves lineage throughresolveRootSessionID, inheriting itsSESSION_LOOKUP_TIMEOUT_MSdeadline and lookup cache, so a hungctx.session.getcannot stall the event loop. - Updated the v2 creation test — the fake context now feeds the real
{ sessionID }shape. - Refreshed digest pins — both generated-source hashes re-pinned;
pnpm test src/main/opencode/passes.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…er shim - Skip forwarding real session.created when Start was already posted (either order), closing the reverse-order double post. - Release the first-sight mark when lineage resolves non-root/unknown so transient failures retry instead of suppressing Start forever. - Trim client shim to observed shapes (native v1 passthrough, single ctx.session domain, documented v1 call forms); document why the abort signal has no v2 channel and why raw results need no unwrap. - Contract tests share fetch-capture/context helpers; created-mapping test drops the session domain so only the mapping can post Start; new reverse-order test pins single Start. - Cite verified 2.0.7 shapes in-code; digests regenerated.
|
Batch pushed in af99bb8 covering the latest review round plus my own review pass: Bot finding fixed: the created-mapping test now drops the session domain, so the mapping is the only route to Start and the test genuinely pins it. New reverse-order test (execution-then-late-creation) pins single Start. From my review pass:
Deliberately left alone: the silent per-event catch (matches the file's fail-open design — changing that philosophy deserves its own discussion), and the bridge (no such events exist in 2.0.7 — verified, not assumed). Validated against the assembled bytes: execution -> |
There was a problem hiding this comment.
ℹ️ No new issues — the delta is clean and the prior test-coverage finding is addressed. This is not an approval only because an earlier verified-false-positive thread (the
permission.asked/permission.repliedcallout) remains open; no action is needed on it.
Reviewed changes (since the prior review at e1c6220)
- Refactored the contract tests — shared
captureHookPosts/hookNames/makeV2Ctx/rootSessionGethelpers replace four copies of the fetch mock and the inline v2 contexts. - Pinned the
session.createdmapping — the creation test now runs without a session domain, so the synthesis path cannot mask a regression; confirmed it fails if the read reverts todata.id. - Added a double-post guard test —
execution.startedfollowed by a latesession.createdposts exactly oneSessionStart; confirmed it fails (['SessionStart','SessionStart']) when the mark-seen guard is removed. - Retryable start synthesis —
ensureV2SessionStartreleases its seen-mark when the lineage lookup does not confirm a root, so a transient failure retries on the next execution instead of suppressing Start forever. - Slimmed the client shim —
buildV1ClientShimadapts onlyctx.session.get, dropping the unusedlistshim and thectx.data.session/first.idfallbacks. Verified against opencode v2.0.7 thatctx.session.get({ sessionID })is the real signature and the result is unwrappedSessionInfo. - Refreshed digest pins —
pnpm test src/main/opencode/passes 41/41 locally.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Validated the branch independently in an ARM container (node 24, pnpm 12, frozen lockfile): 142/142 unit tests pass across src/main/opencode. Two nits, both in hook-plugin-module-contract.test.ts: oxfmt flags the file, and the quality gate reports eslint(curly) at line 126, a braceless for-of in the shared fake-context generator: for (const event of events) yield eventSuggested: for (const event of events) {
yield event
}Full-project typecheck exceeded the container, leaving that lane to repo CI. Separately, one scope observation from comparing against the v1 factory and the Claude/Codex surfaces: neither this PR nor #20410 bridges session.tool.*, so the in-flight-tool readout both siblings enjoy has no opencode path. Happy to help test a revision, including an effect() formulation if you go that way. |
|
Closing as superseded — the work here already shipped through a parallel implementation.
None of the six commits here are on
Rebasing would mean re-resolving three review rounds against a redesigned file location ( |

Problem
On OpenCode 2.x the status plugin fails to load and all Orca status updates stop:
The generated
orca-opencode-status.jsdefault-exports the legacy v1 shape{ id, server }, which the v2 loader rejects (verified against opencode 2.0.7 server logs: everyloading pluginis followed byfailed to load plugin).Fix (4 files, +190/-12)
status-plugin-v2-setup-source.ts: emits asetup()adapter that reuses the tested v1 factory — v1eventmaps toctx.event.subscribe(), v1disposemaps to the cleanup returned bysetup. Includes a client shim adapting v2ctx.session.get/listto theclient.sessionshape the factory expects (fail-open when neither exists).setup()without an event stream returns a no-op cleanup without instantiating the factory, so a pre-v2 loader invoking it cannot spawn a ghost owner.server+setup) pointing at the same implementation, so each loader resolves (a{ id, server, setup }module loads on 1.18.x becauseserveris present).setupalongsideserver; no-subscribe setup is side-effect-free (zero hook POSTs);setup()with a v2-style ctx postsSessionBusy.Validation
{ id, server, setup }+ named factory OK; no-op setup produced 0 posts;setup()produced exactly 1SessionBusyPOST with the rightpaneKey;server()path unchanged.failed to load pluginWARN (previously every load warned).vitestsuite not run locally (monorepo toolchain); relies on CI.