fix: switch back to non-streaming update mode (#106)
This commit is contained in:
parent
2d87dff33b
commit
75ed191f43
@ -700,33 +700,14 @@ function Sidebar:render()
|
|||||||
|
|
||||||
local filetype = api.nvim_get_option_value("filetype", { buf = self.code.buf })
|
local filetype = api.nvim_get_option_value("filetype", { buf = self.code.buf })
|
||||||
|
|
||||||
local is_first_chunk = true
|
|
||||||
|
|
||||||
---@type AvanteChunkParser
|
---@type AvanteChunkParser
|
||||||
local on_chunk = function(chunk)
|
local on_chunk = function(chunk)
|
||||||
local append_chunk = function()
|
signal.is_loading = true
|
||||||
signal.is_loading = true
|
full_response = full_response .. chunk
|
||||||
full_response = full_response .. chunk
|
self:update_content(content_prefix .. full_response, { stream = false, scroll = true })
|
||||||
self:update_content(chunk, { stream = true, scroll = true })
|
vim.schedule(function()
|
||||||
vim.schedule(function()
|
vim.cmd("redraw")
|
||||||
vim.cmd("redraw")
|
end)
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
if is_first_chunk then
|
|
||||||
is_first_chunk = false
|
|
||||||
self:update_content(content_prefix, {
|
|
||||||
scroll = true,
|
|
||||||
callback = function()
|
|
||||||
vim.schedule(function()
|
|
||||||
vim.cmd("redraw")
|
|
||||||
append_chunk()
|
|
||||||
end)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
else
|
|
||||||
append_chunk()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---@type AvanteCompleteParser
|
---@type AvanteCompleteParser
|
||||||
@ -734,18 +715,26 @@ function Sidebar:render()
|
|||||||
signal.is_loading = false
|
signal.is_loading = false
|
||||||
|
|
||||||
if err ~= nil then
|
if err ~= nil then
|
||||||
self:update_content("\n\n🚨 Error: " .. vim.inspect(err), { stream = true, scroll = true })
|
self:update_content(
|
||||||
|
content_prefix .. full_response .. "\n\n🚨 Error: " .. vim.inspect(err),
|
||||||
|
{ stream = false, scroll = true }
|
||||||
|
)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Execute when the stream request is actually completed
|
-- Execute when the stream request is actually completed
|
||||||
self:update_content("\n\n🎉🎉🎉 **Generation complete!** Please review the code suggestions above.\n\n", {
|
self:update_content(
|
||||||
stream = true,
|
content_prefix
|
||||||
scroll = true,
|
.. full_response
|
||||||
callback = function()
|
.. "\n\n🎉🎉🎉 **Generation complete!** Please review the code suggestions above.\n\n",
|
||||||
api.nvim_exec_autocmds("User", { pattern = VIEW_BUFFER_UPDATED_PATTERN })
|
{
|
||||||
end,
|
stream = false,
|
||||||
})
|
scroll = true,
|
||||||
|
callback = function()
|
||||||
|
api.nvim_exec_autocmds("User", { pattern = VIEW_BUFFER_UPDATED_PATTERN })
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
-- Save chat history
|
-- Save chat history
|
||||||
table.insert(chat_history or {}, {
|
table.insert(chat_history or {}, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user