fix: sanitize loaded chat history
Ensure that chat history loaded from a file has resemblance of correct data. Namely title and timestamp are present and are strings, and entires, messages, and todos are lists. In case of inconsistencies replace with empty/default data. This should help with #2584. More changes are needed to sanitize individual entries.
This commit is contained in:
@@ -48,7 +48,7 @@ function M.func(input, opts)
|
||||
local sidebar = require("avante").get()
|
||||
if not sidebar then return false, "Avante sidebar not found" end
|
||||
local todos = sidebar.chat_history.todos
|
||||
if not todos or #todos == 0 then return false, "No todos found" end
|
||||
if #todos == 0 then return false, "No todos found" end
|
||||
for _, todo in ipairs(todos) do
|
||||
if tostring(todo.id) == tostring(input.id) then
|
||||
todo.status = input.status
|
||||
|
||||
Reference in New Issue
Block a user