fix: don’t execute incomplete streaming commands (#2245)
This commit is contained in:
committed by
GitHub
parent
320bf2cee1
commit
59ad32efcf
@@ -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
|
if not on_complete then return false, "on_complete not provided" end
|
||||||
local sidebar = require("avante").get()
|
local sidebar = require("avante").get()
|
||||||
if not sidebar then return false, "Avante sidebar not found" end
|
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
|
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
|
if opts.command and opts.command ~= vim.NIL and opts.command ~= "" and not vim.startswith(opts.command, "open ") then
|
||||||
session_ctx.always_yes = false
|
session_ctx.always_yes = false
|
||||||
require("avante.llm_tools.bash").func({ command = opts.command }, on_log, on_complete, session_ctx)
|
require("avante.llm_tools.bash").func({ command = opts.command }, on_log, on_complete, session_ctx)
|
||||||
|
|||||||
@@ -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)
|
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)
|
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 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 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 not opts.command then return false, "Command is required" end
|
||||||
if on_log then on_log("command: " .. opts.command) end
|
if on_log then on_log("command: " .. opts.command) end
|
||||||
|
|
||||||
---change cwd to abs_path
|
---change cwd to abs_path
|
||||||
---@param output string
|
---@param output string
|
||||||
---@param exit_code integer
|
---@param exit_code integer
|
||||||
|
|||||||
Reference in New Issue
Block a user