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:
Dmitry Torokhov
2025-08-06 22:06:30 -07:00
parent b08dc79088
commit d0f0580d64
4 changed files with 36 additions and 25 deletions

View File

@@ -503,9 +503,9 @@ vim.g.avante_login = vim.g.avante_login
---@class avante.ChatHistory
---@field title string
---@field timestamp string
---@field messages avante.HistoryMessage[] | nil
---@field entries avante.ChatHistoryEntry[] | nil
---@field todos avante.TODO[] | nil
---@field messages avante.HistoryMessage[]
---@field entries avante.ChatHistoryEntry[]
---@field todos avante.TODO[]
---@field memory avante.ChatMemory | nil
---@field filename string
---@field system_prompt string | nil