Skip to content

feat(acp): stage edits for native review in ACP clients#31392

Open
PacoDw wants to merge 3 commits into
anomalyco:devfrom
PacoDw:feat/acp-review-at-end
Open

feat(acp): stage edits for native review in ACP clients#31392
PacoDw wants to merge 3 commits into
anomalyco:devfrom
PacoDw:feat/acp-review-at-end

Conversation

@PacoDw
Copy link
Copy Markdown

@PacoDw PacoDw commented Jun 8, 2026

Issue for this PR

Related to #4240
Related to #30913

Type of change

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

What does this PR do?

This makes opencode work with the native file review in ACP clients like Zed and Devin.

Before, opencode wrote files directly to disk during the turn. Because of this, the client could not show its native review UI (the "Keep / Reject" diff).

Now, when the client supports fs.writeTextFile:

  • File creates and edits (add / update) are kept in memory during the turn. opencode sends them to the client with writeTextFile, so they appear in the native review UI.
  • Deletes and moves still go to disk, because ACP has no delete/rename method. They are shown as a diff in the tool call, and the tool output says they are not part of the staged review.
  • If the client does not support writeTextFile, opencode writes to disk like before (safe fallback).
  • The staged changes are cleared at the end of every turn (success, error, or cancel), so nothing leaks into the next turn.

How it works

agent turn
  │
  ├─ add / update ──► ReviewOverlay (memory) ──writeTextFile──► client review UI (Keep / Reject)
  │
  ├─ delete / move ──► disk  +  diff shown in tool_call
  │
  └─ no writeTextFile support ──► disk (fallback)

end of turn ──► overlay cleared

How did you verify your code works?

Added and updated unit tests: review-mode capability gating, staging via the tool registry, the apply_patch disk note, and clearing the overlay when a prompt fails. All tests pass and typecheck is clean.

Tested manually in Zed and Devin (see screenshots below).

How to try it

You need an ACP client that supports the fs.writeTextFile capability (Zed and Devin do).

  1. Clone this fork and check out the branch.
  2. Install dependencies: bun install.
  3. Add an ACP agent in your client that runs this repo (examples below). Replace /path/to/opencode with your local path, and make sure bun is on your PATH (or use the full path to the bun binary).
  4. Open the client, start a session with that agent, and ask it to create or edit a file.
  5. Expected: the change shows up in the native review UI ("Keep / Reject") instead of being written to disk right away. For apply_patch deletes and moves, you see a diff in the tool call.

Zed

Add this to your Zed settings.json:

{
  "agent_servers": {
    "OpenCode (Review UI)": {
      "type": "custom",
      "command": "bun",
      "args": [
        "run",
        "--conditions=browser",
        "/path/to/opencode/packages/opencode/src/index.ts",
        "acp"
      ]
    }
  }
}

Windsurf / Devin

Add this entry to your ACP registry.json:

{
  "id": "opencode-review-ui",
  "name": "OpenCode (Review UI)",
  "version": "1.0.0",
  "description": "OpenCode ACP review-at-end",
  "distribution": {
    "binary": {
      "darwin-aarch64": {
        "archive": "",
        "cmd": "bun",
        "args": [
          "run",
          "--conditions=browser",
          "/path/to/opencode/packages/opencode/src/index.ts",
          "acp"
        ]
      }
    }
  }
}

Use the platform key that matches your OS (for example darwin-aarch64 for Apple Silicon).

Screenshots / recordings

  • Zed:
zed_gif
  • Devin:
devin_gif

Checklist

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

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jun 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 8, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

PacoDw and others added 3 commits June 8, 2026 11:48
In-memory overlay that holds staged file content during an ACP turn so
add/update writes can be sent to the client for native review instead of
hitting disk immediately.

Co-authored-by: Cursor <cursoragent@cursor.com>
Gate review staging on the client writeTextFile capability, flush staged
edits through ACP, and wrap FSUtil so tool writes land in the overlay
instead of disk while review mode is active.

Co-authored-by: Cursor <cursoragent@cursor.com>
Wire review mode into ACP session lifecycle, tool registry, and edit/write/
apply_patch tools so add/update changes reach the client review UI via
writeTextFile. Delete/move still hit disk and show as tool_call diffs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PacoDw PacoDw force-pushed the feat/acp-review-at-end branch from b1ee2f4 to 7cbf988 Compare June 8, 2026 17:48
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