bug: automatically applies suggestions
Describe the bug
Describe the bug
Avante.nvim automatically applies and saves changes directly to the file instead of showing a side-by-side diff preview where I can review suggestions before accepting them. The changes are applied immediately without giving me the opportunity to see what's being changed or to accept/reject individual suggestions.
Expected behavior: I should see the original code on one side and the suggested changes on the other side, with the ability to review and selectively accept or reject changes before they are applied to my file.
Actual behavior: Changes are automatically implemented and the file is saved without showing any diff preview.
To reproduce
- Open a file in Neovim with Avante.nvim configured
- Trigger Avante with
:Avanteor<leader>ap - Ask for a code modification (e.g., "refactor this function")
- Instead of showing a side-by-side diff, changes are immediately applied and saved to the file
Attempted solutions
I've tried multiple configuration changes without success:
Attempt 1: Disabled fast apply
behaviour = {
enable_fastapply = false,
},
Attempt 2: Configured edit settings
edit = {
auto_apply = false, -- prevent automatic application of edits
diff_preview = true, -- show diff preview instead of direct application
},
Attempt 3: Tried older version
- Downgraded to version
0.0.25 - Issue persisted across versions
Attempt 4: Consulted AI assistants
I've also tried using the latest models from OpenAI, Claude, and DeepSeek to help me configure this properly, but none of the suggested configurations resolved the issue. 🤓
Note: I enabled Avante as a single plugin to isolate the issue and ensure no conflicts with other plugins.
Installation method
Using lazy.nvim
Environment
- OS: Ubuntu 24.04
- Neovim version: 0.11.3
- Avante.nvim version: Latest from main branch (commit: [insert commit hash here])
- Plugin manager: lazy.nvim
System details
$ uname -a
Linux laptop 6.14.0-27-generic #27~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 17:38:49 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
$ nvim --version
NVIM v0.11.3
Build type: Release
LuaJIT 2.1.1741730670
Configuration
Click to expand my Avante.nvim configuration
return {
{
"yetone/avante.nvim",
-- build with `make` (recommended by the plugin). If you prefer prebuilt,
-- set BUILD_FROM_SOURCE env or change config per README.
build = vim.fn.has("win32") ~= 0 and
"powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false"
or "make",
event = "VeryLazy",
version = false, -- the plugin author warns about pinning "*"
dependencies = {
-- required
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
-- optional but recommended for nicer UX
"MeanderingProgrammer/render-markdown.nvim", -- render Avante outputs
"hrsh7th/nvim-cmp", -- completion for mentions/commands
"nvim-tree/nvim-web-devicons", -- icons
"HakonHarnes/img-clip.nvim", -- image paste support
"zbirenbaum/copilot.lua", -- copilot provider (optional)
"stevearc/dressing.nvim", -- nicer input UI
"folke/snacks.nvim", -- modern input UI
},
opts = {
-- Default mode & provider
provider = "openai", -- use OpenAI (ChatGPT / API key)
mode = "agentic", -- "agentic" or "legacy" ; agentic uses tools
-- Provider-specific configuration
providers = {
openai = {
-- OpenAI REST endpoint (default)
endpoint = "https://api.openai.com/v1",
-- The name of the environment variable holding your key:
-- Avante will read os.getenv("OPENAI_API_KEY") internally when needed.
-- Set that env var (example above).
api_key = "OPENAI_API_KEY",
-- A model that works for edits + reasoning. Change if you have access.
model = "gpt-4o",
timeout = 60000, -- ms
-- extra_request_body will be merged to the API request body if used
extra_request_body = {
temperature = 0,
max_tokens = 8192,
},
},
morph = {
endpoint = "https://api.morphllm.com/v1",
api_key = "MORPH_API_KEY",
model = "morph-v3-fast",
},
},
-- Input UI: "native" | "dressing" | "snacks"
input = {
provider = "snacks",
provider_opts = {
title = "Avante: prompt",
placeholder = "Ask the AI about the current file / selection...",
},
},
-- Behavior toggles
behaviour = {
enable_fastapply = true, -- set true only if you set up Morph apply service (see README)
},
-- RAG service off by default; enable only if you want local RAG container
rag_service = {
enabled = false,
-- if enabling, set llm/embed provider/api_key fields appropriately
},
-- optional: file selector provider; can be "telescope" or "fzf_lua" or "mini_pick"
selector = {
provider = "telescope",
},
-- UI tweaks (feel free to change)
ui = {
sidebar_width = 48,
float = {
max_width = 160,
max_height = 40,
},
},
-- custom prompts directory (optional):
-- override_prompt_dir = vim.fn.expand("~/.config/nvim/avante_prompts"),
},
config = function(_, opts)
-- ensure auxiliary plugins are configured first (if present)
local has = vim.fn.has
-- If render-markdown is installed, register Avante filetype
pcall(function()
require("render-markdown").setup({ file_types = { "markdown", "Avante" } })
end)
-- call setup
require("avante").setup(opts)
-- Keymaps: adjust to taste
local map = vim.keymap.set
-- Toggle sidebar
map("n", "<leader>aa", "<cmd>AvanteToggle<CR>", { desc = "Avante: Toggle" })
-- Open inline prompt
map("n", "<leader>ap", "<cmd>Avante<CR>", { desc = "Avante: Open prompt" })
-- Switch provider (useful if you added multiple providers)
map("n", "<leader>as", "<cmd>AvanteSwitchProvider<CR>", { desc = "Avante: Switch Provider" })
-- History
map("n", "<leader>ah", "<cmd>AvanteHistory<CR>", { desc = "Avante: History" })
-- Stop current request
map("n", "<leader>aS", "<cmd>AvanteStop<CR>", { desc = "Avante: Stop request" })
end,
},
}
Additional context
I'm quite desperate to get this working as the automatic application of changes makes it difficult to review and understand what's being modified. The side-by-side diff view is a core feature that I expected based on the plugin's documentation and comparison to Cursor IDE.
Any guidance on the correct configuration to enable the diff preview mode would be greatly appreciated.
Checklist
- [x] I have searched existing issues to ensure this hasn't been reported before
- [x] I have read the documentation
- [x] I have tested with minimal configuration
- [x] I have included my full configuration
- [x] I have included steps to reproduce
- [x] I have included environment details
I have very much the same issue. I resolved to telling the AI explicitly to only offer me the changes without applying them.
I have the same question.
same. related #2689 -- not solved
I ran into this same issue just now and solved it by adding the following to my lazyvim avante plugin config:
behaviour = {
auto_approve_tool_permissions = false,
},
^ inside of opts.
I am using copilot as my provider. Yes it is the British spelling.
it works for me without opts ... i'm sharing my config:
require('avante').setup({
---@alias Provider "copilot"
---@type Provider
provider = "copilot",
---@alias Mode "agentic" | "legacy"
---@type Mode
mode = "legacy",
auto_suggestions_provider = "copilot",
providers = {
copilot = {
endpoint = "https://mycorp.ghe.com",
model = "gpt-4o-2024-11-20",
extra_request_body = {
temperature = 0.75,
max_tokens = 4096,
},
},
},
behaviour = {
auto_approve_tool_permissions = false,
auto_focus_sidebar = true,
auto_suggestions = false, -- Experimental stage
auto_suggestions_respect_ignore = true,
auto_set_highlight_group = true,
auto_set_keymaps = true,
auto_apply_diff_after_generation = true,
jump_result_buffer_on_finish = false,
support_paste_from_clipboard = false,
minimize_diff = true,
enable_token_counting = true,
use_cwd_as_project_root = false,
auto_focus_on_diff_view = false,
},
prompt_logger = {
enabled = true,
log_dir = vim.fn.stdpath("cache") .. "/avante_prompts",
fortune_cookie_on_success = false,
next_prompt = {
normal = "<C-n>",
insert = "<C-n>",
},
prev_prompt = {
normal = "<C-p>",
insert = "<C-p>",
},
},
mappings = {
diff = {
ours = "co",
theirs = "ct",
all_theirs = "ca",
both = "cb",
cursor = "cc",
next = "]x",
prev = "[x",
},
suggestion = {
accept = "<M-l>",
next = "<M-]>",
prev = "<M-[>",
dismiss = "<C-]>",
},
jump = {
next = "]]",
prev = "[[",
},
submit = {
normal = "<CR>",
insert = "<C-s>",
},
cancel = {
normal = { "<C-c>", "<Esc>", "q" },
insert = { "<C-c>" },
},
sidebar = {
apply_all = "A",
apply_cursor = "a",
retry_user_request = "r",
edit_user_request = "e",
switch_windows = "<Tab>",
reverse_switch_windows = "<S-Tab>",
remove_file = "d",
add_file = "@",
close = { "<Esc>", "q" },
close_from_input = nil,
},
},
selection = {
enabled = true,
hint_display = "delayed",
},
windows = {
position = "right",
wrap = true,
width = 30,
sidebar_header = {
enabled = true,
align = "center",
rounded = true,
},
spinner = {
editing = { "⡀", "⠄", "⠂", "⠁", "⠈", "⠐", "⠠", "⢀", "⣀", "⢄", "⢂", "⢁", "⢈", "⢐", "⢠", "⣠", "⢤", "⢢", "⢡", "⢨", "⢰", "⣰", "⢴", "⢲", "⢱", "⢸", "⣸", "⢼", "⢺", "⢹", "⣹", "⢽", "⢻", "⣻", "⢿", "⣿" },
generating = { "·", "✢", "✳", "∗", "✻", "✽" },
thinking = { "🤯", "🙄" },
},
input = {
prefix = "> ",
height = 8,
},
edit = {
border = "rounded",
start_insert = true,
},
ask = {
floating = false,
start_insert = true,
border = "rounded",
focus_on_apply = "ours",
},
},
highlights = {
diff = {
current = "DiffText",
incoming = "DiffAdd",
},
},
diff = {
autojump = true,
list_opener = "copen",
override_timeoutlen = 500,
},
suggestion = {
debounce = 600,
throttle = 600,
},
})
Im also getting this bug. I tried every solution in this thread. Giving up for now.
This is a matter of config. I do not know why auto approve tool call is set to enable by default.
If you want to preview code changes (a tool call in this plugin) in this plugin auto_approve_tool_permissions must be set to false.
This is my config for lazy nvim
return {
"yetone/avante.nvim",
opts = { -- <-- for lazy nvim your config should me set in opts table
-- mode = "agentic",
selection = {
enable = true,
hint_display = "delayed",
},
windows = {
width = 40,
},
behaviour = {
auto_approve_tool_permissions = false, -- <-- this one
-- auto_apply_diff_after_generation = false,
},
},
}
This is a matter of config. I do not know why auto approve tool call is set to enable by default. If you want to preview code changes (a tool call in this plugin) in this plugin
auto_approve_tool_permissionsmust be set to false.This is my config for lazy nvim
return { "yetone/avante.nvim", opts = { -- <-- for lazy nvim your config should me set in opts table -- mode = "agentic", selection = { enable = true, hint_display = "delayed", }, windows = { width = 40, }, behaviour = { auto_approve_tool_permissions = false, -- <-- this one -- auto_apply_diff_after_generation = false, }, }, }
This solution prompts edit confirmation in the sidebar, but does not show edits in the buffer itself like the example videos shown in the project readme.
this simply does not happen...
@runitmisra Why do you want the prompt window is at the buffer? Aren't the agent changing code for you? Then why at the moment you accept code your cursor is at the buffer window? For me this is just a config choice and I am happy go around the window using control+w + vim movement key.
@celestialdr4g0n I agree it's a matter of preference, I was pointing out that the current config does not allow for the features that are showed on the project README to work out of the box. Diff in the buffer allows for easy comparison, less cognitive load and is the behavior of cursor-like IDEs which avante is aiming feature parity with. Reading and verifying changes in the sidebar is cumbersome as the sidebar is narrow (which I know I can change, but that's not the point), Diff is hard to compare and avante does not jump to the buffer it is supposed to make changes in. I'll keep looking around for solutions to this, just giving my 2 cents.
There seems to be different behavior happening for different folks; like @matdombrock I've tried all config changes and just yesterday I was watching changes automatically be applied as the Allow/Allow All/Reject buttons were still visible. Perhaps there's something happening with a downstream dependency.
I'm also not sure why this was closed prematurely, it's the same issue.
Unfortunately, the problem is disruptive enough that I've switched to VSCode to orchestrate copilot.
Yep, it's a deal breaker for me as well. Guess I'll stick to Cursor for now.
This is a matter of config. I do not know why auto approve tool call is set to enable by default. If you want to preview code changes (a tool call in this plugin) in this plugin
auto_approve_tool_permissionsmust be set to false. This is my config for lazy nvim return { "yetone/avante.nvim", opts = { -- <-- for lazy nvim your config should me set in opts table -- mode = "agentic", selection = { enable = true, hint_display = "delayed", }, windows = { width = 40, }, behaviour = { auto_approve_tool_permissions = false, -- <-- this one -- auto_apply_diff_after_generation = false, }, }, }This solution prompts edit confirmation in the sidebar, but does not show edits in the buffer itself like the example videos shown in the project readme.
this simply does not happen...
this is because your AI directly use tool calls, if you want to make like the vedios, you need to ask AI not to use it.Maybe you should orgnize your system prompt like this(just an example):
2. Code Modification Format
When modifying code, use the following plain text format:
<FILEPATH>Relative path of the file</FILEPATH> <SEARCH> Original code to be searched and replaced (must exactly match the original file content) </SEARCH> <REPLACE> New code for replacement </REPLACE>
3. Formatting Rules
- Each tag must be on a separate line.
- The content of SEARCH must exactly match the original file content (including spaces and indentation).
- Do not enclose the SEARCH/REPLACE blocks within three backticks.
- Use multiple independent SEARCH/REPLACE blocks when modifying multiple locations.
Even like this,AI may also sometimes not follow the rules, that depends on the AI,but it can really make efferts
it seems that the markdown does not render correctly,below is the image
this simply does not happen...