feat(acp): stage edits for native review in ACP clients#31392
Open
PacoDw wants to merge 3 commits into
Open
Conversation
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
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>
b1ee2f4 to
7cbf988
Compare
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.
Issue for this PR
Related to #4240
Related to #30913
Type of change
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:writeTextFile, so they appear in the native review UI.writeTextFile, opencode writes to disk like before (safe fallback).How it works
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.writeTextFilecapability (Zed and Devin do).bun install./path/to/opencodewith your local path, and make surebunis on yourPATH(or use the full path to thebunbinary).apply_patchdeletes 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-aarch64for Apple Silicon).Screenshots / recordings
Checklist