feat: Add diff preview for ACP providers
ACP Diff Preview Feature
Overview
Adds visual diff preview functionality for ACP (Agent Client Protocol) providers, allowing users to see proposed changes directly in their buffers before applying them.
Core Feature
- ACP Diff Preview: Visual diff display in buffers before applying ACP tool call changes
- Configurable via
acp_show_diff_in_buffersetting (defaults totrue)
Architecture & Refactoring
- Extracted diff display logic: New
diff_display.luautility module for reusable diff rendering - Separated ACP diff handling: New
acp_diff_handler.luamodule for ACP-specific diff extraction and processing - Added diff preview UI: New
acp_diff_preview.luamodule for buffer preview management - Removed duplicate code: Eliminated redundant diff rendering logic from
llm.lua
Configuration Changes
- Replaced config option: Changed
acp_follow_agent_locations?acp_show_diff_in_buffer(focuses on diff preview vs. auto-navigation)
Type System Improvements
- Enhanced ACP types: Improved type definitions for
ToolCallUpdateRequestPermissionACPRawInput
Code Quality
- Comprehensive test suite: Added 490+ lines of unit tests for ACP diff handler with fixtures and sample data
- Cleanup: Removed deprecated helper functions and streamlined
replace_in_file.lua
UI Enhancements
- Syntax highlighting: Added highlight groups for diff display elements
- History rendering: Updated message rendering to support new ACP tool name
Oops, some code conflicts
solved!
This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 10 days.
This PR was closed because it has been stalled for 10 days with no activity.
Sorry, the bot closed it. I will merge this PR as soon as possible.
@carlos-algms Excuse me. I test this PR on my service with claude-code + avante.nvim. I did not see the diff preview as expected. Can you help me to check my steps :
My configurations :
{
provider = "claude-code",
acp_providers = {
["claude-code"] = {
command = "npx",
args = { "@zed-industries/claude-code-acp" },
env = {
NODE_NO_WARNINGS = "1",
ANTHROPIC_API_KEY = os.getenv("ANTHROPIC_API_KEY"),
},
},
},
}
- export ANTHROPIC_AUTH_TOKEN=xxx
- export ANTHROPIC_BASE_URL=xxx # because I am not using the official service.
claude will modify the file in the background but no diff view appears. Do I need to enable certain settings?
@Waitzz have you checked this branch locally?
You should not be required to do anything else.
Maybe Claude changed the diff message since the last commit in this branch.
It looks correct.
Waitzz@G3:~/.local/share/nvim/lazy/avante.nvim$ git log --oneline -10
2bfaf2c (HEAD -> pr2816) feat(config): enable ACP diff inline
05e49a2 Merge remote-tracking branch 'origin/main' into cgomes/display-ACP-diff
47daac1 remove diff config as it's default for api providers
44b5948 fix(history): improve parameter display in get_tool_display_name function (#2822)
496670e fix import path
05199e7 relocate files to acp subfolder
f8f8a73 fix context length in ACP diff display in sidebar
4cd57f1 pass the right object and reduce ternary checks
a064c85 fixed tests
db3d337 [pre-commit.ci lite] apply automatic fixes
@Waitzz have you checked this branch locally?
You should not be required to do anything else.
Maybe Claude changed the diff message since the last commit in this branch.
My Claude's version is :
Waitzz@G3:~$ claude --version
2.0.43 (Claude Code)
Could you tell me your Claude version?