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.
Change the constructor to accept role and a single content item instead
of raw AvanteLLMMessage instance. This will help when we will start
changing message.content from being a string or a list of tables to just
a string or a single table.
This adds History.Helpers.get_text_data() helper to fetch contents of a
"text" message. This removes the need to know internals of message
structure outside of history module.
Maintaining secondary table of window IDs is cumbersome and is prone to
getting out of sync with the true state of the sidebar. In preparation
for removal of winids table move all containers (sub-windows of the
sidebar) into "containers" table.
The change is mostly mechanical rename with following exceptions:
- Sidebar:reifresh_winids() and other places where the code scanned
entire Sidebar object looking for tables with specific fields, such
as "winid", or "mount" needed to be adjusted for the new structure
- Sidebar:new() and Sidebar:reset() have been adjusted to make better
use of the new sub-table.
Tool results are not useful without their "use" messages, so delete them
when deleting "use" ones.
Makes use of the new get_tool_use_data() and get_tool_result_data()
helpers.
The utils module has grown too big and contains unrelated functionality.
Start moving code related to managing history messages comprising chat
history into lua/avante/history module to keep the code more manageable.