fix: don’t execute incomplete streaming commands (#2245)

This commit is contained in:
Andre-Philippe Paquet
2025-06-16 22:56:58 -04:00
committed by GitHub
parent 320bf2cee1
commit 59ad32efcf
2 changed files with 16 additions and 1 deletions

View File

@@ -74,7 +74,15 @@ function M.func(opts, on_log, on_complete, session_ctx)
if not on_complete then return false, "on_complete not provided" end
local sidebar = require("avante").get()
if not sidebar then return false, "Avante sidebar not found" end
local is_streaming = opts.streaming or false
if is_streaming then
-- wait for stream completion as command may not be complete yet
return
end
session_ctx.attempt_completion_is_called = true
if opts.command and opts.command ~= vim.NIL and opts.command ~= "" and not vim.startswith(opts.command, "open ") then
session_ctx.always_yes = false
require("avante.llm_tools.bash").func({ command = opts.command }, on_log, on_complete, session_ctx)

View File

@@ -214,13 +214,20 @@ M.returns = {
},
}
---@type AvanteLLMToolFunc<{ path: string, command: string }>
---@type AvanteLLMToolFunc<{ path: string, command: string, streaming?: boolean }>
function M.func(opts, on_log, on_complete, session_ctx)
local is_streaming = opts.streaming or false
if is_streaming then
-- wait for stream completion as command may not be complete yet
return
end
local abs_path = Helpers.get_abs_path(opts.path)
if not Helpers.has_permission_to_access(abs_path) then return false, "No permission to access path: " .. abs_path end
if not Path:new(abs_path):exists() then return false, "Path not found: " .. abs_path end
if not opts.command then return false, "Command is required" end
if on_log then on_log("command: " .. opts.command) end
---change cwd to abs_path
---@param output string
---@param exit_code integer