SillyTavern / SillyTavern

LLM Frontend for Power Users.
https://sillytavern.app
GNU Affero General Public License v3.0
13.83k stars 3.15k forks source link

Add integrity check when saving solo chat files #3698

Closed Cohee1207 closed 1 month ago

Cohee1207 commented 1 month ago

Some users experience their chats being nuked on load. This is most likely a concurrency issue when an emptied chat is being saved before it could be loaded from a server. The solution is plain and dumb: generate an integrity token, save it to the metadata, and check the token with the already saved file. If tokens mismatch, we cancel the save but give an option to overwrite.

I'm not too happy with putting a config toggle to backups section, but there isn't just a generic "Chat settings" section there, since it's all UI.

Out of scope: groups.

Copilot summary

This pull request includes several changes to improve the chat backup functionality and enhance the integrity check process. The most important changes include adding an integrity check for chat backups, updating the saveChat function to support additional options, and ensuring that the integrity metadata is included during chat loading and saving.

Improvements to chat backup functionality:

Enhancements to chat saving process:

Refactoring for consistency:

Checklist: