Fixed chats being deleted without asking

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
j-erlerandClaude Opus 5 committed 2026-09-20 23:09:06 +02:00
1 parent c95cc5bacc
commit 45211658e9
6 files changed
+51 -1

No files matched your search

@@ -92,7 +92,7 @@
@if (this.SettingsManager.ConfigurationData.Workspace.StorageBehavior is WorkspaceStorageBehavior.STORE_CHATS_AUTOMATICALLY)
{
<MudTooltip Text="@T("Delete this chat & start a new one.")" Placement="@TOOLBAR_TOOLTIP_PLACEMENT">
<MudIconButton Icon="@Icons.Material.Filled.Refresh" OnClick="@(() => this.StartNewChat(useSameWorkspace: true, deletePreviousChat: true))" Disabled="@(!this.CanThreadBeSaved || this.IsCurrentChatStreaming)"/>
<MudIconButton Icon="@Icons.Material.Filled.DeleteSweep" Color="Color.Error" OnClick="@(() => this.StartNewChat(useSameWorkspace: true, deletePreviousChat: true))" Disabled="@(!this.CanThreadBeSaved || this.IsCurrentChatStreaming)"/>
</MudTooltip>
}
@@ -1167,6 +1167,28 @@ public partial class ChatComponent : MSGComponentBase
//
if (this.ChatThread is not null && deletePreviousChat)
{
//
// A deleted chat cannot be restored. The check above never covers this case, because
// this path exists only while chats are stored automatically. So we ask here, with the
// same question the chat list asks:
//
var workspaceName = await WorkspaceBehaviour.LoadWorkspaceNameAsync(this.ChatThread.WorkspaceId);
var deleteDialogParameters = new DialogParameters<ConfirmDialog>
{
{
x => x.Message, (this.ChatThread.WorkspaceId == Guid.Empty) switch
{
true => string.Format(this.T("Are you sure you want to delete the temporary chat '{0}'?"), this.ChatThread.Name),
false => string.Format(this.T("Are you sure you want to delete the chat '{0}' in the workspace '{1}'?"), this.ChatThread.Name, workspaceName),
}
},
};
var deleteDialogReference = await this.DialogService.ShowAsync<ConfirmDialog>(this.T("Delete Chat"), deleteDialogParameters, DialogOptions.FULLSCREEN);
var deleteDialogResult = await deleteDialogReference.Result;
if (deleteDialogResult is null || deleteDialogResult.Canceled)
return;
string chatPath;
if (this.ChatThread.WorkspaceId == Guid.Empty)
chatPath = Path.Join(SettingsManager.DataDirectory, "tempChats", this.ChatThread.ChatId.ToString());