Skip to content

fix(acp): include diff content block in edit permission requests#31783

Closed
ReeSilva wants to merge 6 commits into
anomalyco:devfrom
ReeSilva:feat/emit-diff-content
Closed

fix(acp): include diff content block in edit permission requests#31783
ReeSilva wants to merge 6 commits into
anomalyco:devfrom
ReeSilva:feat/emit-diff-content

Conversation

@ReeSilva

@ReeSilva ReeSilva commented Jun 10, 2026

Copy link
Copy Markdown

Issue for this PR

Fixes #31781

Type of change

  • Bug fix

What does this PR do?

When OpenCode calls requestPermission for edit operations, the toolCall payload was missing the content: [{ type: "diff" }] block. ACP clients use this block to show a diff view alongside the approval prompt. Without it, clients receive the permission request but have no diff to display.
Screenshot of the issue showing a CodeCompanion edit permission request without diff info

Root cause

permission.ts builds the toolCall for requestPermission manually, but never populates the content field. On top of that, the metadata forwarded by edit.ts and write.ts via ctx.ask only carried filepath and diff (a unified patch string) — not the oldString/newString values needed to build an ACP diff content block.

Changes

File Change
tool/edit.ts Added oldString and newString to ctx.ask metadata (both call sites)
tool/write.ts Same as above
acp/permission.ts Added editDiffContent() helper and wired its output into toolCall.content

The editDiffContent helper returns [{ type: "diff", path, oldText, newText }] for edit permissions, and undefined otherwise — consistent with the shape already used by completedToolContent in acp/tool.ts.

How did you verify your code works?

Tested via CodeCompanion's ACP integration against opencode acp. With permissions.edit: "ask" set, edit operations now trigger the client's diff view before approval, matching the behaviour of claude-agent-acp.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@ReeSilva

Copy link
Copy Markdown
Author

Added a commit to fix issue with formatting of the message when overwriting a file and having opts.verbose_output = true

@ReeSilva

Copy link
Copy Markdown
Author

@jlongster Please, can you take a look when you have some time? Tks :D

@ReeSilva

Copy link
Copy Markdown
Author

Closing this in favor of #34079 that covers broader scope. Great job @nexxeln

@ReeSilva ReeSilva closed this Jun 26, 2026
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.

fix(acp): edit/write permission requests don't include diff content block

1 participant