feat: remove history command (#2063)

* feat: remove history command

* Address code review

Co-authored-by: Michael Bøcker-Larsen <247048+mblarsen@users.noreply.github.com>

---------

Co-authored-by: Michael Bøcker-Larsen <247048+mblarsen@users.noreply.github.com>
This commit is contained in:
Jiyeol Lee
2025-06-09 07:59:43 -04:00
committed by GitHub
parent 0cce955816
commit de8fb58bfa
4 changed files with 89 additions and 10 deletions

View File

@@ -31,13 +31,15 @@ function M.open(bufnr, cb)
end
if #selector_items == 0 then
Utils.warn("No models available in config")
Utils.warn("No history items found.")
return
end
local selector = Selector:new({
provider = Config.selector.provider,
title = "Select Avante History",
local current_selector -- To be able to close it from the keymap
current_selector = Selector:new({
provider = Config.selector.provider, -- This should be 'native' for the current setup
title = "Avante History (Select, then choose action)", -- Updated title
items = vim
.iter(selector_items)
:map(
@@ -60,8 +62,21 @@ function M.open(bufnr, cb)
local content = Sidebar.render_history_content(history)
return content, "markdown"
end,
on_delete_item = function(item_id_to_delete)
if not item_id_to_delete then
Utils.warn("No item ID provided for deletion.")
return
end
Path.history.delete(bufnr, item_id_to_delete) -- bufnr from M.open's scope
-- The native provider handles the UI flow; we just need to refresh.
M.open(bufnr, cb) -- Re-open the selector to refresh the list
end,
on_action_cancel = function()
-- If the user cancels the open/delete prompt, re-open the history selector.
M.open(bufnr, cb)
end,
})
selector:open()
current_selector:open()
end
return M