AI-Studio/app/MindWork AI Studio/Tools/ChatArchive/ChatArchiveFormat.cs
j-erler a8e8edc028 Added data backup and restore for chats
The settings gain a data backup panel. It writes the chats of the chosen
workspaces, and optionally the temporary chats, into a single archive file
with the extension .aistudio-chats, and it imports such archives again.
The archive mirrors the chat storage, so restoring needs no conversion.

Documents the user attached are never copied into the archive. The chats
keep the absolute path of each document, which keeps them usable wherever
the documents live and avoids a second copy. Files AI Studio created itself,
such as transcripts, exist nowhere else; when the selection holds any, the
user decides whether they travel with the archive.

On import, chats which already exist, in any workspace, are either kept or
imported as additional chats with a new ID. Workspaces are merged by their
identity. An imported chat gets its own copy of every transcript the archive
did not carry, as a copied chat does, so deleting it never removes the
transcripts of the chat it came from.

An existing archive is only replaced once the new one is complete. Chats
which could not be read are reported instead of missing silently. Both
directions can be stopped at any time and report what was written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 16:25:39 +02:00

50 lines
1.7 KiB
C#

namespace AIStudio.Tools.ChatArchive;
/// <summary>
/// Central definition of the chat archive format. A chat archive is a ZIP file which mirrors
/// the chat storage layout, so that exported chats can be restored without any conversion.
/// </summary>
public static class ChatArchiveFormat
{
/// <summary>
/// The archive format version written by this app version. The importer refuses archives
/// with a higher version, because it cannot know what those archives contain.
/// </summary>
public const int FORMAT_VERSION = 1;
/// <summary>
/// The file extension used for chat archives.
/// </summary>
public const string FILE_EXTENSION = ".aistudio-chats";
/// <summary>
/// The manifest file at the archive root. It describes what the archive contains.
/// </summary>
public const string MANIFEST_FILE_NAME = "manifest.json";
/// <summary>
/// The archive directory containing all exported workspaces.
/// </summary>
public const string WORKSPACES_DIRECTORY = "workspaces";
/// <summary>
/// The archive directory containing all exported temporary chats.
/// </summary>
public const string TEMPORARY_CHATS_DIRECTORY = "tempChats";
/// <summary>
/// The file storing the workspace or chat name.
/// </summary>
public const string NAME_FILE_NAME = "name";
/// <summary>
/// The file storing the serialized chat thread.
/// </summary>
public const string THREAD_FILE_NAME = "thread.json";
/// <summary>
/// The separator used inside ZIP archives. ZIP entries always use forward slashes,
/// regardless of the operating system.
/// </summary>
public const char ENTRY_SEPARATOR = '/';
}