Skip to content

fix(acp): emit writeTextFile for file edits when client advertises fs.writeTextFile#28734

Open
bcdady wants to merge 2 commits into
anomalyco:devfrom
bcdady:fix/acp-write-text-file-capability
Open

fix(acp): emit writeTextFile for file edits when client advertises fs.writeTextFile#28734
bcdady wants to merge 2 commits into
anomalyco:devfrom
bcdady:fix/acp-write-text-file-capability

Conversation

@bcdady
Copy link
Copy Markdown

@bcdady bcdady commented May 21, 2026

Issue for this PR

Closes #4240

Type of change

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

What does this PR do?

When running OpenCode in ACP mode (e.g. inside Zed), file edits are applied silently — Zed's native "Review changes" button never appears. This is because the ACP agent wasn't calling writeTextFile back to the client after edits.

Three things were missing:

  1. clientCapabilities from the ACP initialize handshake was never persisted, so the agent couldn't check whether the client supports fs.writeTextFile
  2. The file.edited bus event had no sessionID field, so the ACP agent couldn't look up the right session to notify
  3. There was no file.edited case in the ACP agent event handler

This PR adds all three. On each file edit, if the client advertised fs.writeTextFile, the agent now reads the file from disk and sends its contents to the client via connection.writeTextFile, which triggers Zed's diff-review UI.

The SDK generated types (EventFileEdited) in both v1 and v2 are updated to include the new sessionID field.

This is a rebase of PR #22674 onto current dev HEAD. That PR addressed the same issue but went stale.

How did you verify your code works?

Tested locally in Zed with opencode acp. After the fix, the "Review changes" button appears after each file edit, matching the behavior described in the issue.

Screenshots / recordings

N/A — behaviour matches the Gemini CLI screenshots already in issue #4240.

Checklist

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

….writeTextFile

Fixes anomalyco#4240

Store clientCapabilities from the ACP initialize handshake on ACPConfig.
Add sessionID to the file.edited bus event so the ACP agent can look up
the right session. On each file.edited event, if the client advertised
fs.writeTextFile, push the updated file contents to the ACP client via
connection.writeTextFile, enabling Zed's native diff-review UI.

Update SDK generated types (EventFileEdited) in both v1 and v2 to include
the new sessionID field.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found a related PR:

Related PR:

Why it's related: According to your PR description, PR #22674 is the original submission of this exact fix. You mention: "This is a re-submission of the same fix from PR #22674, which addressed the same issue but went stale. The diff is functionally identical; it has been rebased onto the current dev HEAD."

Since PR #22674 went stale and you're resubmitting the rebased fix as PR #28734, ensure PR #22674 is closed/marked as superseded before merging this one.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

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

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.

acp, zed: does not support native changes review

1 participant