Repository navigation
fix(opencode2): block on any session-owned form, not just the question tool's - #22548
Conversation
#22399 admitted an OpenCode 2 form.created as a pane blocker only when metadata.kind === "question". On v2.0.15 that is an allow-list on a field with no contract: packages/schema/src/form.ts declares Metadata as an open Schema.Record and metadata itself as optional, and the public POST /api/session/:sessionID/form endpoint lets any client raise a real blocking form on a real session with no metadata. Orca dropped those, so the pane painted no blocker while OpenCode waited forever. Invert the default. Every form whose owner is a real session blocks; only a form owned by the "global" MCP-elicitation sentinel is dropped, because that owner is not a session and never goes idle, so its blocker could not be retired. That also restores websearch.provider as a blocker: it carries the real context.sessionID, session idle retires it, and while it is pending the agent is genuinely stalled on the user. Resolution is unchanged: clearAttentionForResolution keys on the exact form id plus source session, so a resolution for a dropped form matches nothing and cannot retire a live blocker.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughThe OpenCode 2 plugin now classifies Merge Risk: 🔵 Low · up to The MCP reproduction demonstrates the opposite of the documented exclusion. Correct the steps; this does not block the form-handling change. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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: b5a9cd0e-59d6-4214-87cb-d8c929298e51
📒 Files selected for processing (4)
docs/bug-reproductions/opencode2-form-created-kinds/README.mdsrc/main/opencode/hook-plugin-opencode2-setup.test.tssrc/main/opencode/hook-service.test.tssrc/main/opencode2/status-plugin-setup-source.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
| | `websearch.provider` | `Web Search` / `Choose a web search provider` | the session | no — a provider picker | | ||
| | `mcp-elicitation` | `<server> is requesting input` | `"global"` | no — an MCP server prompt | | ||
| | `websearch.provider` | `Web Search` / `Choose a web search provider` | the session | yes — the turn is stalled | | ||
| | `mcp-elicitation` | `<server> is requesting input` | `"global"` | no — see below | |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Correct the MCP reproduction to use the "global" owner.
The Reproduce section at Lines 67–70 tells readers to POST an mcp-elicitation form to /api/session/<sid>/form. OpenCode assigns <sid> to form.sessionID, regardless of metadata.kind. The new guard therefore blocks that form, contrary to this row. Use a real MCP elicitation or a plugin fixture with sessionID: "global" to demonstrate the excluded case. (raw.githubusercontent.com)
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — initial review of the OpenCode 2 form.created pane-blocker guard and its tests.
- Guard re-keyed on the form's owner —
form.creatednow blocks unlessform.sessionIDis the non-session sentinel"global", replacing themetadata.kind === "question"allow-list that silently dropped genuinely blocking forms. Verified against upstreamv2.0.15:Metadatais an optional open record andForm.createpublishesForm.Event.Createdfor every producer, so neitherkindnormetadatacan serve as the discriminator. - Producer table holds — the only in-tree
Form.askcall site with a non-session owner is MCP elicitation (GLOBAL_ELICITATION_SESSION_ID = "global");question.tsand bothwebsearch.tssites passcontext.sessionID. The deny-list drops exactly the un-attributable producer. - Retirement path intact —
form.replied/form.cancelledcarry the sameidandsessionIDas the created form, so each admitted form keys its own(factoryID, AskUserQuestion, form.id, sessionID)attention entry and a resolution for a dropped sentinel matches nothing. form.fieldsdefaulted — theArray.isArrayguard prevents a throw inside thefor awaitfrom killing the entire subscription. The schema enforcesNonEmptyArray(Field), so this is version-skew defense rather than a live path; harmless and cheap.- Tests are meaningful — restoring the old guard in place fails exactly 12 of the 30 setup cases (matching the PR's claim), while the pre-existing 18 pass; with the fix
pnpm test src/main/opencode src/main/opencode2reports 17 files / 221 passed. The digest re-pin matches, and themimo-codebytes are unchanged (that variant omits the setup source).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…22548) stablyai#22399 admitted an OpenCode 2 form.created as a pane blocker only when metadata.kind === "question". On v2.0.15 that is an allow-list on a field with no contract: packages/schema/src/form.ts declares Metadata as an open Schema.Record and metadata itself as optional, and the public POST /api/session/:sessionID/form endpoint lets any client raise a real blocking form on a real session with no metadata. Orca dropped those, so the pane painted no blocker while OpenCode waited forever. Invert the default. Every form whose owner is a real session blocks; only a form owned by the "global" MCP-elicitation sentinel is dropped, because that owner is not a session and never goes idle, so its blocker could not be retired. That also restores websearch.provider as a blocker: it carries the real context.sessionID, session idle retires it, and while it is pending the agent is genuinely stalled on the user. Resolution is unchanged: clearAttentionForResolution keys on the exact form id plus source session, so a resolution for a dropped form matches nothing and cannot retire a live blocker. (cherry picked from commit f1eb191)

ELI5
When an OpenCode agent needs an answer from you, Orca marks the pane "needs input". A recent change of mine narrowed that to one specific kind of prompt — and in doing so, taught Orca to ignore some prompts that genuinely block the agent. The pane then looks busy while the agent sits waiting for you forever. This widens it back, and picks a rule that can't rot.
What Changed
The guard from #22399 was:
It is now:
An allow-list on
kindbecame a one-entry deny-list on the form's owner.metadatano longer appears in the guard at all.Also:
form.fieldsis defaulted to[]. Previously only question-tool forms reachedform.fields.map(…); now arbitrary client-created forms do, and a throw inside thefor awaitloop kills the entire event subscription — it is caught only by the outer.catchthat endsconsume. Widening admission without this would trade a silent blocker for silent total status death.Why
#22399 made two mistakes, both in the dangerous direction. Found by adversarial review, then confirmed from OpenCode source at
v2.0.15.1.
kindis not a contract.packages/schema/src/form.ts:15—Metadata = Schema.Record(Schema.String, Schema.Unknown), an untyped open record in whichkinddoes not appear at all. Line 130 —metadata: Metadata.pipe(optional), sometadataitself is optional onForm.Info, and line 169'sform.createdcarries that sameInfo. This is the same objection #22399 used to reject matching on form title; I applied it to titles and then missed it onkind.The reachable path is a published API:
packages/protocol/src/groups/session.tsregistersPOST /api/session/:sessionID/formwithmetadataoptional;packages/server/src/handlers/session.ts:646callsform.create(…)directly, which publishesForm.Event.Createdomittingmetadataentirely when undefined. A client raising a genuinely blocking form on a real session with no metadata was dropped — pane painted Busy, OpenCode waiting forever.Scoped honestly: this is latent, not live. A sweep for
.form.create(across the whole monorepo atv2.0.15returns zero callers; all 7session.form.createhits are definitional (protocol declaration,openapi.json, both generated client bindings, api wiring, the handler). Nothing intui,desktop,console,cli,sdk, orplugininvokes it. So this is a robustness defect on a versioned, SDK-bound public extension surface with no first-party consumer yet — not an active break on a stock install. It is worth fixing because the surface is published andmetadatais optional by declaration, not because anyone is hitting it today.Enumerating
Form.askstructurally could not find this:form.createdis published insideForm.create(core/src/form.ts:120),ask(:148) is merely a wrapper, and the server handler callscreatedirectly. CountingForm.asksites gives five; the in-tree producer set ofform.createdis six.2.
websearch.providershould never have been dropped. Both websearch call sites pass the realcontext.sessionID, so that blocker retires correctly. The un-retirable argument that justified #22399 applies only to MCP elicitation, which usesGLOBAL_ELICITATION_SESSION_ID = "global"(core/src/mcp/index.ts:82). Dropping websearch left the pane reading Busy while the turn was genuinely parked on a provider picker — a second instance of the exact bug #22399 set out to fix.Re-derived producer table (
git grep -n "\.ask(" v2.0.15 -- packages/core/src, five sites, exhaustive in-tree):core/src/tool/plugin/question.ts:75questioncontext.sessionIDcore/src/tool/plugin/websearch.ts:75websearch.providercontext.sessionIDcore/src/tool/plugin/websearch.ts:108websearch.providercontext.sessionIDcore/src/mcp/index.ts:234mcp-elicitation"global"core/src/mcp/index.ts:262mcp-elicitation"global"Why key on the owner rather than on
kind. The real discriminator is not "is this the question tool" but "can this blocker ever be retired" — and only the"global"sentinel fails that test, because it is not a session and so no session-idle can clear it. Keying there also makes the exclusion self-expiring:packages/schema/src/form.ts:122-129sayssessionIDis a plain string only because "MCP elicitation temporarily needs the"global"sentinel owner… Once elicitations can be attributed to real sessions, revert this to SessionID." When upstream does that, Orca starts blocking on elicitations correctly with no code change. Akind-keyed exclusion would silently keep dropping them.Why unknown shapes now block. A spurious visible blocker is recoverable by the user and is merely the old over-blocking bug. A silently swallowed real question is not recoverable at all. Alternatives considered: an allow-list with extra known kinds — same rot, one release later; matching on title — user-facing English, not a contract.
Consequence worth stating: a hypothetical future non-question kind on a real session will now block the pane. That is intended. It also means the "known non-question kinds" table is no longer encoded in code — it lives in the reproduction doc. Encoding it would recreate the schema-less allow-list this PR removes.
Linked Issue
Refs #22371, and fixes a regression I introduced in #22399.
Visual Proof
N/A— the change decides which OpenCode 2 events become a pane blocker, and the user-visible difference is the presence of an indicator that previously never appeared. Reproducing it on screen needs a client calling the public form-create endpoint, which no first-party caller does today; a screenshot of a hand-posted form would look identical to a real one and prove nothing a test does not. Proof is the source citations above plus the fail-without-fix run below.Testing
Platforms: macOS; source verification against
v2.0.15.Restored the pre-fix guard and re-ran the unchanged new tests — 12 of 12 new instances failed (6 cases × the
opencode/opencode2parametrization), while the 18 pre-existing assertions passed:With the fix: 30 passed. The sentinel-ignore test passes on both sides by design — it pins behaviour this PR deliberately preserves.
Resolution path re-checked:
clearAttentionForResolutionbuildsattentionKey(factoryID, "AskUserQuestion", requestID, sessionID)and returns null on a miss, so a resolution for a dropped sentinel form keys[…, formID, "global"], matches nothing, and publishes nothing. More forms are admitted now, but each still gets its own exact key, so a stray resolution still cannot retire an unrelated live blocker. The admitted-id guard removed in #22399 remains unnecessary.Suites:
pnpm test src/main/opencode src/main/opencode2→ 17 files, 221 passed.pnpm tc→ 0.pnpm run check:code-quality:changed→ 0 new findings.Plugin byte digest re-pinned. The
mimo-codedigest is unchanged, confirming the OpenCode 1-only variant is untouched.AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
docs/bug-reproductions/opencode2-form-created-kinds/README.mdpresentedmetadata.kindas the discriminator. It is rewritten aroundsessionID, with the schema and endpoint citations, so the next reader does not repeat the mistake.setup()bridge.Set.hasper form event.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm testpass locally