Fixed the workspace list not following a moved chat (#1048)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-10-11 13:42:15 +02:00
1 parent 5ee4dfa2b5
commit 1c13300988
9 files changed
+362 -41

No files matched your search

@@ -1028,7 +1028,7 @@ public partial class ChatComponent : MSGComponentBase
this.RefreshCurrentProfileAndChatTemplate();
var promptName = this.ExtractThreadName(this.ComposerState.UserInput);
var threadName = string.IsNullOrWhiteSpace(this.ComposerState.UserInput)
? $"Transkription: {Path.GetFileName(firstMediaPath)}"
? string.Format(T("Transcription: {0}"), Path.GetFileName(firstMediaPath))
: promptName;
this.ChatThread = this.NewChatThread(threadName) with
@@ -1036,7 +1036,16 @@ public partial class ChatComponent : MSGComponentBase
DataSourceOptions = this.earlyDataSourceOptions,
};
await WorkspaceBehaviour.StoreChatAsync(this.ChatThread);
//
// Like saving, this goes through the workspace component whenever there is one, so its tree
// lists the new chat right away, together with the progress of the transcription, instead
// of only after the first message was sent:
//
if (this.Workspaces is not null)
await this.Workspaces.StoreChatAsync(this.ChatThread);
else
await WorkspaceBehaviour.StoreChatAsync(this.ChatThread);
this.MarkCurrentChatAsLoadedParameter();
await this.ChatThreadChanged.InvokeAsync(this.ChatThread);
await this.SyncForegroundChatAsync();
@@ -1391,8 +1400,16 @@ public partial class ChatComponent : MSGComponentBase
if (workspaceId == Guid.Empty)
return;
//
// Like saving and copying, the move goes through the workspace component whenever there is
// one, so its tree shows the chat in the new place right away:
//
var previousWorkspaceId = this.ChatThread!.WorkspaceId;
await WorkspaceBehaviour.MoveChatAsync(this.ChatThread!, workspaceId);
if (this.Workspaces is not null)
await this.Workspaces.MoveChatAsync(this.ChatThread!, workspaceId);
else
await WorkspaceBehaviour.MoveChatAsync(this.ChatThread!, workspaceId);
await this.FollowMovedChatAsync(previousWorkspaceId);
}
@@ -78,7 +78,7 @@ else
<div style="justify-self: end;">
<MudTooltip Text="@T("Move to workspace")" Placement="@WORKSPACE_ITEM_TOOLTIP_PLACEMENT">
<MudIconButton Icon="@Icons.Material.Filled.MoveToInbox" Size="Size.Medium" Color="Color.Inherit" Disabled="@this.IsChatTreeItemBusy(treeItem)" OnClick="@(() => this.MoveChatAsync(treeItem.Path))"/>
<MudIconButton Icon="@Icons.Material.Filled.MoveToInbox" Size="Size.Medium" Color="Color.Inherit" Disabled="@this.IsChatTreeItemBusy(treeItem)" OnClick="@(() => this.MoveChatFromTreeAsync(treeItem.Path))"/>
</MudTooltip>
<MudTooltip Text="@T("Copy chat")" Placement="@WORKSPACE_ITEM_TOOLTIP_PLACEMENT">
@@ -938,7 +938,24 @@ public partial class Workspaces : MSGComponentBase
await this.LoadTreeItemsAsync(startPrefetch: false);
}
private async Task MoveChatAsync(string? chatPath)
/// <summary>
/// Moves the given chat into another workspace and shows it there in the tree.
/// </summary>
/// <param name="chat">The chat to move. It gets the new workspace and the new paths of its attachments.</param>
/// <param name="targetWorkspaceId">The workspace to move the chat into.</param>
/// <remarks>
/// Neither asks for the target workspace nor follows the chat in the chat view: both depend on
/// where the move was asked for. Whoever moves a chat while this component exists goes through
/// here, though, since the tree draws what it has built before and would otherwise keep showing
/// the chat in its old place.
/// </remarks>
public async Task MoveChatAsync(ChatThread chat, Guid targetWorkspaceId)
{
await WorkspaceBehaviour.MoveChatAsync(chat, targetWorkspaceId);
await this.LoadTreeItemsAsync(startPrefetch: false);
}
private async Task MoveChatFromTreeAsync(string? chatPath)
{
var storedChat = await this.LoadChatAsync(chatPath, false);
if (storedChat is null)
@@ -969,11 +986,9 @@ public partial class Workspaces : MSGComponentBase
if (workspaceId == Guid.Empty)
return;
await WorkspaceBehaviour.MoveChatAsync(chat, workspaceId);
await this.MoveChatAsync(chat, workspaceId);
if (ReferenceEquals(chat, this.CurrentChatThread))
await this.CurrentChatThreadChanged.InvokeAsync(this.CurrentChatThread);
await this.LoadTreeItemsAsync(startPrefetch: false);
}
private async Task AddChatAsync(string workspacePath)