avante.nvim icon indicating copy to clipboard operation
avante.nvim copied to clipboard

feat: Add diff preview for ACP providers

Open carlos-algms opened this issue 1 month ago • 5 comments

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_buffer setting (defaults to true)

Architecture & Refactoring

  • Extracted diff display logic: New diff_display.lua utility module for reusable diff rendering
  • Separated ACP diff handling: New acp_diff_handler.lua module for ACP-specific diff extraction and processing
  • Added diff preview UI: New acp_diff_preview.lua module 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
    • ToolCallUpdate
    • RequestPermission
    • ACPRawInput

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

carlos-algms avatar Nov 02 '25 14:11 carlos-algms

Oops, some code conflicts

yetone avatar Nov 05 '25 21:11 yetone

solved!

carlos-algms avatar Nov 06 '25 07:11 carlos-algms

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.

github-actions[bot] avatar Nov 21 '25 02:11 github-actions[bot]

This PR was closed because it has been stalled for 10 days with no activity.

github-actions[bot] avatar Dec 01 '25 02:12 github-actions[bot]

Sorry, the bot closed it. I will merge this PR as soon as possible.

yetone avatar Dec 01 '25 03:12 yetone

@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 avatar Dec 15 '25 11:12 Waitzz

@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.

carlos-algms avatar Dec 15 '25 13:12 carlos-algms

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.

Waitzz avatar Dec 15 '25 13:12 Waitzz

My Claude's version is :

Waitzz@G3:~$ claude --version
2.0.43 (Claude Code)

Could you tell me your Claude version?

Waitzz avatar Dec 15 '25 13:12 Waitzz