Skip to content

fix(opencode2): only treat the question tool's form as a pane blocker - #22399

Merged
nwparker merged 2 commits into
mainfrom
nwparker/opencode2-form-question-22371
Sep 23, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/opencode2-form-question-22371

Conversation

@nwparker

@nwparker nwparker commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​118 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​114
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​170 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​169

ELI5

When an agent asks you a question, Orca marks the pane "needs your answer" and won't clear it until you answer. OpenCode 2 uses the same internal "form" for several unrelated things — a web-search provider picker, and prompts raised by MCP servers. Orca treated all of them as questions from your agent. One of them can jam a pane in "needs input" with nothing you can do to clear it.

What Changed

src/main/opencode2/status-plugin-setup-source.ts mapped every form.created to question.asked — Orca's un-evictable "the pane owner must answer this" blocker. It now admits only the agent's question tool, keyed on form.metadata.kind === "question".

Every Form.ask call site in the shipped opencode v2.0.12 bundle, cross-checked against live captures:

metadata.kind Form title sessionID Agent-initiated question?
question Questions the session yes — the question tool
websearch.provider Choose a web search provider the session no — a provider picker
mcp-elicitation <server> is requesting input "global" no — an MCP server prompt

mcp-elicitation is the damaging one. "global" is not a session id, so the blocker it minted could never be retired by that session going idle — the pane stays "needs input" until an exactly-matching form.replied/form.cancelled arrives, or the plugin is disposed.

The guard is symmetric. Admitted form ids are remembered (bounded at 64, oldest evicted first) and a form.replied/form.cancelled for a form Orca never admitted is dropped. Without that, an ignored form's resolution shares the attention-key shape and would retire an unrelated live blocker.

Why

Reported in #22371.

This PR does not close that issue, and I want to be explicit about why. The report attributes the stray "question" indicator to OpenCode 2's subagent menu. I set out to confirm that and disproved it: I drove the real TUI in a PTY against a real opencode serve, opened the exact Subagents / Shell / Terminals dock from the reporter's screenshot, and paged and dismissed it while reading the server's /api/event stream. It carried nothing but server.connected and heartbeats. Same for the shift+tab agent picker and the ctrl+p command palette. Those pickers are local Solid components in the TUI; they never call Form.ask and emit no server event at all, so they were never the form.created source.

What the investigation did surface is that the blanket mapping is wrong regardless — two of the three real form producers are not questions. That is worth fixing on its own, so it ships here, tagged Refs rather than Fixes.

Alternatives considered:

  • Filter on sessionID === "global". Catches mcp-elicitation only; websearch.provider carries a real session id and would still mint a blocker. An allow-list on the producer's own stamp is both narrower and more honest about intent.
  • Deny-list the two known non-question kinds. Fails open on the next producer upstream adds — and this bug exists precisely because a new producer appeared under an existing event.
  • Match the form title. User-facing English, and not a contract.

Also found while reading the retirement paths, not changed here: OpenCode 2 never emits message.part.updated, and its question form carries metadata.tool = { messageID, id } rather than the { messageID, callID } that Orca's clearQuestionForToolPart matches. That tool-completion retirement path is therefore dead code for OpenCode 2, leaving form.replied/form.cancelled and session idle as its only ways out. Worth a follow-up; out of scope here.

Linked Issue

Refs #22371

Visual Proof

N/A — and the reason matters more than usual here.

This changes which OpenCode 2 events become a pane blocker. A before/after screenshot would require making the app paint the blocker on demand, which needs a live MCP elicitation or a web-search provider prompt driven through a real agent turn — I could raise those forms on the server, but not through the genuine producers. Rather than stage a screenshot from a synthetic form and present it as the real path, the proof here is the captured event stream plus an end-to-end run of the real plugin.

Committed under docs/bug-reproductions/opencode2-form-created-kinds/: the discriminator table, the live form.created / form.replied captures for the question kind, and the rendered PTY screen of the subagent dock that produced no events. (docs/** is gitignored behind an allow-list, so .gitignore gains !docs/bug-reproductions/** — AGENTS.md already points the has_repro label at that directory, which did not yet exist.)

End-to-end against the fixed plugin and a live server:

  • a kind: "websearch.provider" form produced no hook post
  • a kind: "question" form produced AskUserQuestion
  • replying to it produced the retiring status post

Testing

Platforms: macOS, against the shipped opencode v2.0.12 binary.

  • pnpm test src/main/opencode/ src/main/opencode2/ — 11 files, 168 tests pass
  • pnpm test src/shared/agent-hook-listener src/main/agent-hooks — 1261 pass
  • pnpm tc clean; oxlint clean; pnpm run check:code-quality:changed — 0 new findings

The new picker tests were checked for vacuousness: stubbing out the guard fails 4 of them. The plugin byte-digest test in hook-service.test.ts was re-pinned, which is expected for any change to the emitted plugin source.

Reviewer steps: docs/bug-reproductions/opencode2-form-created-kinds/README.md has the exact opencode serve + SSE commands to re-capture all three form shapes.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Backwards compatibility: OpenCode 1 is untouched — this file only feeds the OpenCode 2 setup() bridge. For OpenCode 2, the only behavior change is that two form kinds stop minting a blocker.
  • Failure mode if the discriminator is wrong: a genuine question that somehow lacks kind: "question" would stop blocking the pane — the agent's own prompt is still visible in the terminal, so the user sees it; they just don't get the sidebar indicator. The previous failure mode was a pane jammed in "needs input" with no way to clear it. The new one is strictly less harmful.
  • Bounded memory: the admitted-id set is capped at 64 with FIFO eviction, so a long session cannot grow it without limit.
  • Cross-platform: pure event-shape logic, no paths or platform branches.
  • Security, SSH/remote, mobile, performance: unaffected.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test pass locally

OpenCode 2 has one form primitive and several producers, and Orca's setup
bridge mapped every `form.created` to `question.asked` — the un-evictable
"the pane owner must answer this" blocker. Against opencode v2.0.12 only
`metadata.kind === "question"` is the agent's question tool; `websearch.provider`
is a provider picker and `mcp-elicitation` is an MCP server prompt raised on
sessionID "global", which is not a session and so can never be retired by that
session going idle.

Admit only the question kind, remember the admitted form ids, and drop
`form.replied`/`form.cancelled` for forms that were never admitted so an
ignored form's resolution cannot retire a live blocker.

Evidence (live v2.0.12 capture, real TUI in a PTY against `opencode serve`)
in docs/bug-reproductions/opencode2-form-created-kinds. That capture also
shows the reported Subagents/Shell/Terminals dock and the agent picker emit
no server event at all, so they were never the `form.created` source.

Refs #22371
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 9 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 9edba94e-da13-4085-8114-605f4ffd8813

📥 Commits

Reviewing files that changed from the base of the PR and between 98a6a53 and 6cf7934.

📒 Files selected for processing (9)
  • .gitignore
  • docs/bug-reproductions/opencode2-form-created-kinds/README.md
  • docs/bug-reproductions/opencode2-form-created-kinds/form-created-question.json
  • docs/bug-reproductions/opencode2-form-created-kinds/form-replied-question.json
  • docs/bug-reproductions/opencode2-form-created-kinds/subagent-panel-screen.txt
  • src/main/opencode/hook-plugin-opencode2-setup.test.ts
  • src/main/opencode/hook-service.test.ts
  • src/main/opencode/opencode-client-sweep.test.ts
  • src/main/opencode2/status-plugin-setup-source.ts

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 critical issues — one minor suggestion inline.

Reviewed changes

  • Only the question tool's form blocks the pane. form.created now requires form.metadata.kind === "question" before mapping to question.asked, so the websearch.provider picker and mcp-elicitation prompts stop minting Orca's un-evictable "needs input" blocker. The mcp-elicitation case is the damaging one (sessionID: "global" can never be retired by session idle).
  • Symmetric resolution guard. admittedQuestionFormIDs (module-scoped, cap 64, FIFO) remembers admitted form ids and drops form.replied/form.cancelled for forms Orca never admitted.
  • Tests + docs. Two new picker tests, one question/retire test, one "live blocker survives an ignored form" test; byte-digest re-pin in hook-service.test.ts; captured form shapes under docs/bug-reproductions/opencode2-form-created-kinds/ (gated by a new .gitignore allow-list).

The form.created kind guard is correct and load-bearing — stubbing it fails 4 tests. I have one minor note on the resolution guard inline: it isn't exercised by any test and the collision its Why comment describes isn't reachable, given the attention key is an exact tuple that already includes the form id.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Review was right that the admitted-form-id set defended against nothing.
`clearAttentionForResolution` builds the exact key
[factoryID, "AskUserQuestion", form.id, sourceSessionID] and returns null on a
miss, with no session-wide fallback, and form ids are unique — so a resolution
for a form Orca ignored already matches no live blocker. The guard's comment
claimed a collision the key structure rules out, which is worse than no comment.

Removes the set, its FIFO eviction helper, and the claim; the kind check on
form.created is the whole fix. The end-to-end test stays: it pins the behavior
that an MCP form raised and cancelled leaves a live question blocker standing,
which is the property worth holding regardless of how it is achieved.
@nwparker

Copy link
Copy Markdown
Contributor Author

Good catch — you're right, and I verified it rather than taking it on faith. Dropped the guard in 6cf7934.

clearAttentionForResolution (src/main/opencode/status-plugin-ownership-source.ts:53) builds the exact key [factoryID, "AskUserQuestion", requestID, sessionID] where requestID is the form id, and returns null when it misses — there's no session-wide fallback that a stray resolution could ride in on. Form ids are unique, so a resolution for a form Orca ignored already matches nothing. The guard was defending a door that was never open.

Since it was also unpinnable by any behavioral test — exactly as you found — keeping it would have meant carrying a module-scoped mutable Set plus a FIFO eviction helper for zero observable effect, with a comment asserting an invariant that isn't true. Removed all of it. The form.created kind check is the whole fix; I left a one-line note at the resolution branch saying why an ignored form's resolution is inert, rather than implying it's dangerous.

I kept the "keeps a live question blocker while an ignored form is raised and resolved" test. You're right that it passes either way, but that's the point — it pins the behavior (an MCP form raised and cancelled leaves a live question blocker standing), which is the property worth holding regardless of how the code achieves it.

Re-pinned the plugin byte digest again. pnpm test src/main/opencode/ src/main/opencode2/ → 11 files, 168 pass; pnpm tc clean; changed-code quality gate clean.

@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

  • Dropped the unreachable resolution guard. 6cf7934 removes admittedQuestionFormIDs, the FIFO admitQuestionForm helper, and the form.replied/form.cancelled drop, addressing the prior review. clearAttentionForResolution builds the exact key [factoryID, "AskUserQuestion", form.id, sessionID] and returns null on a miss with no session-wide fallback, so an ignored form's resolution already matches nothing; the rewritten comment now says so.
  • Kind check is the whole fix. form.created still admits only metadata.kind === "question", and the end-to-end test that an ignored MCP form raised and cancelled leaves a live question blocker standing is retained (still passes).
  • Digest re-pin. The hook-service.test.ts byte digest was updated for the emitted plugin source; expected, since both getOpenCodePluginSource() and getOpenCode2PluginSource() embed getOpenCode2SetupSource().
  • Unrelated reformat. psRunner in opencode-client-sweep.test.ts is a Prettier-only reflow; no behavior change.

Verified locally: pnpm test src/main/opencode/hook-plugin-opencode2-setup.test.ts src/main/opencode/hook-service.test.ts — 52 pass.

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

@nwparker
nwparker merged commit 0afc66e into main Sep 23, 2026
56 of 58 checks passed
@nwparker
nwparker deleted the nwparker/opencode2-form-question-22371 branch September 23, 2026 05:08
nwparker added a commit that referenced this pull request Sep 23, 2026
#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.
flosrn pushed a commit to flosrn/orca that referenced this pull request Sep 25, 2026
…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)
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.

1 participant