Skip to content

fix(opencode): ACP Attach structured diff content for edit permissions#15517

Open
MaxDillon wants to merge 3 commits intoanomalyco:devfrom
MaxDillon:dev
Open

fix(opencode): ACP Attach structured diff content for edit permissions#15517
MaxDillon wants to merge 3 commits intoanomalyco:devfrom
MaxDillon:dev

Conversation

@MaxDillon
Copy link

Issue for this PR

Closes #11653

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This addresses an issue where ACP edit permissions do not include structured diff content, preventing ACP compliant editors to show diff before asking for final edit approval.

Previously, edit permissions only sent metadata (filepath, diff) to requestPermission, and the file was written immediately after approval. No ToolCallContent of type "diff" was attached, so the client could not render a diff preview.

This PR:

  • Precomputes oldText and newText for edit permissions
  • Attaches a { type: "diff", path, oldText, newText } object to requestPermission
  • Writes the file only after approval using the same newText

This allows ACP clients (e.g. CodeCompanion) to render a proper diff preview.

Non-edit permissions are unchanged.

How did you verify your code works?

  • I tested locally with opencode acp integration with CodeCompanion.nvim
  • In the image section is the relevant configuration for hooking up local instance to codecompanion

Screenshots / recordings

Screenshot 2026-02-28 at 5 49 29 PM

Dev environment configuration


Screenshot 2026-02-28 at 5 51 06 PM

Make change request


Screenshot 2026-02-28 at 5 51 41 PM

Diff visualization in CodeCompanion.nvim


Screenshot 2026-02-28 at 5 51 50 PM

Updated file after change approval

Checklist

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

@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

Hey! Your PR title ACP: Attach structured diff content for edit permissions doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@MaxDillon MaxDillon changed the title ACP: Attach structured diff content for edit permissions fix(acp): Attach structured diff content for edit permissions Mar 1, 2026
@MaxDillon MaxDillon changed the title fix(acp): Attach structured diff content for edit permissions fix(opencode): ACP Attach structured diff content for edit permissions Mar 2, 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.

Diff is not shown on CodeCompanion integration with OpenCode

1 participant