Skip to content

Conversation

@carlos-algms
Copy link
Contributor

@carlos-algms carlos-algms commented Nov 2, 2025

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

local Utils = require("avante.utils")

---@class avante.HistoryMessage
---@class avante.history.Message
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Missing fields were causing lua_ls to type them as unknown
  • Rename as it was conflicting with the sidebar HistoryMessage

diff_display:scroll_to_first_diff()
diff_display:register_cursor_move_events()
diff_display:register_navigation_keybindings()
diff_display:register_accept_reject_keybindings(on_accept_diff_block, on_reject_diff_block)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid we would need to remove the hunk accept/reject until it's tied to the tool call confirmation.

There's a bug: if the user accepts all the hunks, the confirmation pop-up won't be dismissed.
Or if the user rejects 1 hunk, and then goes to the sidebar and "approve" it'll override and accept all.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't quite understand this bug. What caused it?

@carlos-algms carlos-algms marked this pull request as ready for review November 5, 2025 11:41
@yetone
Copy link
Owner

yetone commented Nov 5, 2025

Oops, some code conflicts

@carlos-algms
Copy link
Contributor Author

solved!

@github-actions
Copy link

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 github-actions bot added the Stale label Nov 21, 2025
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

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

@github-actions github-actions bot closed this Dec 1, 2025
@yetone yetone reopened this Dec 1, 2025
@yetone
Copy link
Owner

yetone commented Dec 1, 2025

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

@yetone yetone removed the Stale label Dec 1, 2025
@Waitzz
Copy link
Collaborator

Waitzz commented Dec 15, 2025

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

@carlos-algms
Copy link
Contributor Author

carlos-algms commented Dec 15, 2025

@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
Copy link
Collaborator

Waitzz commented Dec 15, 2025

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
Copy link
Collaborator

Waitzz commented Dec 15, 2025

My Claude's version is :

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

Could you tell me your Claude version?

@naowalrahman
Copy link

naowalrahman commented Dec 26, 2025

I just tried the changes from this PR as well, and I don't see any diff appearing on Gemini CLI; it just edits the file in the background.

I'm on version 0.22.2 of Gemini CLI and am on the latest push to this branch.

> git log --oneline -10
2bfaf2c (HEAD -> cgomes/display-ACP-diff) 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

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.

4 participants