fix(permissions): read permission and question subjects from the 1.18.30 payload - #14
Merged
Merged
Conversation
Refs Juliusolsson05/agent-code#878 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… question subjects Real OpenCode 1.18.30 SSE recordings are copied unchanged from opencode-terminal-headless's Stage 0 live probe. They are replayed through the real EventDispatcher and channels. Before the fix, the permission title, the question text and the pending request's subject were all undefined. Refs Juliusolsson05/agent-code#878 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
….30 payload
OpenCode 1.18.30 sends permission.asked as { permission, patterns, tool:
{...} } and nests question text in questions[].question. Both readers
walked keys first-non-null, so the now-object tool field stopped the walk
and blanked the subject. The modal asked for permission without saying
what for.
One shared parser (permissions/subject.ts) now serves the dispatcher and
the pending-request path. It builds 'bash: ls -1' from permission and
patterns, reads questions[].question, and keeps the older keys as
string-only fallbacks, so an object can never shadow a later key again.
Refs Juliusolsson05/agent-code#878
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… subjects Review of #14: the bash subject was built from patterns. Those hold only the command nodes OpenCode collects, skipping cd/pushd and declarations like export, so 'export NODE_OPTIONS=... && git status' still showed as 'bash: git status'. That is the blind approval this fix exists to prevent. bash now shows metadata.command, as OpenCode's own UI does. MCP, todowrite and lsp asks send patterns ['*'], which rendered as 'tool: *' and read like a request for everything; the tool name alone is the subject now. The WHY comment is also corrected: the payload shape predates 1.18.30, and the pending-request builder never matched rather than being stopped by the tool object. Refs Juliusolsson05/agent-code#878 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Juliusolsson05/agent-code#878. The structured runtime's permission modal showed no subject, so users approved
bash: ls -1blind, and the question modal showed no question. OpenCode is bundled in Agent Code now, so this is on the default path and a release blocker.The payload shape (
permission,patterns,metadata.command, an objecttool, andquestions[].question) is present since at least 1.14 and is recorded on 1.18.30. Neither parser matched it:tool;Implemented
src/permissions/subject.tsis one parser, shared by the dispatcher (the modal) and OpencodeHeadless (the pending request).metadata.command, the same as OpenCode's own UI ($ <command>).patternsskipscd/pushd/export, so building the subject from it can hide part of what runs.permission: patterns, for exampleedit: src/a.tsorwebfetch: <url>.["*"](MCP, todowrite, lsp) shows the tool name alone.questions[].question, one line per question.Verification
testing/fixtures/live-1.18.30, provenance in its README) run through the realEventDispatcherand channels. On the unfixed code, the modal title and the question text wereundefined.Cannot find module './subject.js'. The subject failures quoted there came from running the new test against a stub.cd … && npm testcommand, and an MCP["*"]ask. Both failed first.tsc --noEmitandtest:contractare clean.OpencodeHeadless.handleSseMessagecalls the shared function. It is a direct import, but no test drives the SSE handler.Review (independent, round 1) → resolved
Three app-side follow-ups ship in Agent Code's submodule-bump PR:
🤖 Generated with Claude Code