Added option to delete current & start new chat

This commit is contained in:
Thorsten Sommer 2024-07-12 22:03:46 +02:00
parent 4f8a6533c3
commit 152eed6542
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
2 changed files with 26 additions and 4 deletions

View File

@ -63,6 +63,13 @@
</MudTooltip> </MudTooltip>
} }
@if (this.SettingsManager.ConfigurationData.WorkspaceStorageBehavior is WorkspaceStorageBehavior.STORE_CHATS_AUTOMATICALLY)
{
<MudTooltip Text="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)"/>
</MudTooltip>
}
@if (this.SettingsManager.ConfigurationData.WorkspaceStorageBehavior is not WorkspaceStorageBehavior.DISABLE_WORKSPACES) @if (this.SettingsManager.ConfigurationData.WorkspaceStorageBehavior is not WorkspaceStorageBehavior.DISABLE_WORKSPACES)
{ {
<MudTooltip Text="Move chat to (another) workspace" Placement="@TOOLBAR_TOOLTIP_PLACEMENT"> <MudTooltip Text="Move chat to (another) workspace" Placement="@TOOLBAR_TOOLTIP_PLACEMENT">

View File

@ -224,9 +224,9 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable
return threadName; return threadName;
} }
private async Task StartNewChat(bool useSameWorkspace = false) private async Task StartNewChat(bool useSameWorkspace = false, bool deletePreviousChat = false)
{ {
if (this.hasUnsavedChanges) if (this.SettingsManager.ConfigurationData.WorkspaceStorageBehavior is WorkspaceStorageBehavior.STORE_CHATS_MANUALLY && this.hasUnsavedChanges)
{ {
var dialogParameters = new DialogParameters var dialogParameters = new DialogParameters
{ {
@ -239,6 +239,21 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable
return; return;
} }
if (this.chatThread is not null && this.workspaces is not null && deletePreviousChat)
{
string chatPath;
if (this.chatThread.WorkspaceId == Guid.Empty)
{
chatPath = Path.Join(SettingsManager.DataDirectory, "tempChats", this.chatThread.ChatId.ToString());
}
else
{
chatPath = Path.Join(SettingsManager.DataDirectory, "workspaces", this.chatThread.WorkspaceId.ToString(), this.chatThread.ChatId.ToString());
}
await this.workspaces.DeleteChat(chatPath, askForConfirmation: false, unloadChat: true);
}
this.isStreaming = false; this.isStreaming = false;
this.hasUnsavedChanges = false; this.hasUnsavedChanges = false;
this.userInput = string.Empty; this.userInput = string.Empty;
@ -273,7 +288,7 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable
if(this.workspaces is null) if(this.workspaces is null)
return; return;
if (this.hasUnsavedChanges) if (this.SettingsManager.ConfigurationData.WorkspaceStorageBehavior is WorkspaceStorageBehavior.STORE_CHATS_MANUALLY && this.hasUnsavedChanges)
{ {
var confirmationDialogParameters = new DialogParameters var confirmationDialogParameters = new DialogParameters
{ {