fix: stabilize ACP streaming updates (#2776)

This commit is contained in:
yetone
2025-10-16 21:28:45 +08:00
committed by GitHub
parent 994c049e88
commit 0971d8f421
3 changed files with 8 additions and 2 deletions

View File

@@ -266,6 +266,7 @@ M._defaults = {
command = "codex-acp",
env = {
NODE_NO_WARNINGS = "1",
HOME = os.getenv("HOME"),
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY"),
},
},

View File

@@ -1087,7 +1087,7 @@ function M._stream_acp(opts)
if update.status == "pending" or update.status == "in_progress" then
tool_call_message.is_calling = true
tool_call_message.state = "generating"
else
elseif update.status == "completed" or update.status == "failed" then
tool_call_message.is_calling = false
tool_call_message.state = "generated"
tool_result_message = History.Message:new("assistant", {

View File

@@ -1301,12 +1301,17 @@ function M.update_buffer_lines(ns_id, bufnr, old_lines, new_lines, skip_line_cou
local changed_lines = vim.list_slice(new_lines, diff_start_idx)
local text_lines = vim.tbl_map(function(line) return tostring(line) end, changed_lines)
local cleaned_text_lines = {}
for _, line in ipairs(text_lines) do
local lines_ = vim.split(line, "\n")
cleaned_text_lines = vim.list_extend(cleaned_text_lines, lines_)
end
vim.api.nvim_buf_set_lines(
bufnr,
skip_line_count + diff_start_idx - 1,
skip_line_count + diff_start_idx + #changed_lines,
false,
text_lines
cleaned_text_lines
)
for i, line in ipairs(changed_lines) do
-- Apply highlights