@using AIStudio.Tools.ChatArchive
@inherits SettingsPanelBase
@T("Save your chats as an archive file, for example as a backup or to move them to another computer. You can read such archives back into AI Studio at any time.")
@if (this.isLoadingWorkspaces)
{
}
else
{
@if (!string.IsNullOrWhiteSpace(this.workspaceLoadError))
{
@this.workspaceLoadError
}
else if (!this.HasWorkspacesToExport)
{
@T("There are no chats to export yet.")
}
else
{
@T("Choose the workspaces you want to export.")
}
@* The refresh button stays available even when nothing could be read,
so that a failed attempt can be repeated: *@
@if (this.HasWorkspacesToExport)
{
@T("Select all")
@T("Select none")
}
@T("Refresh")
@if (this.HasWorkspacesToExport)
{
@foreach (var selection in this.workspaceSelections)
{
}
@if (this.temporaryChatCount > 0)
{
}
@* Stated permanently, because it holds for every export and decides whether
an archive is of any use on the other computer: *@
@T("Documents you attached, such as PDF or Word files, are not written into the archive. The chats keep the location where each document is stored, so those documents stay usable as long as the other computer can reach that location.")
@if (this.isProcessing)
{
@this.ProgressWithCancel
}
else
{
}
}
@if (this.exportResult is { } result)
{
@if (!result.Success)
{
@result.Issue
}
else if (result.Cancelled)
{
@T("The export was stopped. No archive was created.")
}
else
{
@* A chat missing from a backup must not pass as a success: *@
@string.Format(T("Exported {0} chats from {1} workspaces to: {2}"), result.ExportedChats, result.ExportedWorkspaces, result.ArchivePath)
@if (result.IncludedFiles > 0)
{
@string.Format(T("{0} files created by AI Studio, such as transcripts, were included."), result.IncludedFiles)
}
@if (result.UnreadableChats > 0)
{
@string.Format(T("{0} chats could not be read and are missing from the archive. Please try the export again later."), result.UnreadableChats)
}
}
}
}
@T("Choose an archive to see what it contains before anything is imported.")
@if (!string.IsNullOrWhiteSpace(this.selectedArchivePath))
{
@this.selectedArchivePath
}
@if (this.importPreview is { } preview)
{
@if (!preview.Success)
{
@preview.Issue
}
else
{
@string.Format(T("Created on {0} with AI Studio {1}"), preview.Manifest.ExportedAt.ToLocalTime().ToString("g"), preview.Manifest.AppVersion)
@foreach (var workspace in preview.Manifest.Workspaces)
{
@($"{workspace.Name} ({string.Format(T("{0} chats"), workspace.Chats.Count)})")
}
@if (preview.Manifest.TemporaryChats.Count > 0)
{
@($"{T("Temporary chats")} ({string.Format(T("{0} chats"), preview.Manifest.TemporaryChats.Count)})")
}
@T("Keep the existing chat")
@T("Import it as an additional chat")
@if (this.isProcessing)
{
@this.ProgressWithCancel
}
else
{
@string.Format(T("Import {0} chats"), preview.Manifest.TotalChatCount)
}
}
}
@if (this.importResult is { } importOutcome)
{
@if (importOutcome.Success)
{
@string.Format(T("Imported {0} chats into {1} workspaces."), importOutcome.ImportedChats, importOutcome.ImportedWorkspaces)
@if (importOutcome.Cancelled)
{
@T("The import was stopped. The chats imported until then were kept.")
}
@if (importOutcome.SkippedChats > 0)
{
@string.Format(T("{0} chats already existed and were kept as they are."), importOutcome.SkippedChats)
}
@if (importOutcome.FailedChats > 0)
{
@string.Format(T("{0} chats could not be imported."), importOutcome.FailedChats)
}
}
else
{
@importOutcome.Issue
}
}
@code {
///
/// The progress of the running export or import. Both tabs show the same thing.
///
private RenderFragment ProgressWithCancel => @
@string.Format(T("Chat {0} of {1}"), this.progress.ProcessedChats + 1, this.progress.TotalChats)
@T("Cancel")
@T("Please stay on this page until this is done. Leaving the settings stops the run.")
;
}