Added support for parallel AI job processing (#774)
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-05-24 13:50:42 +02:00
1 parent 8853ea0cfe
commit a0753488b3
19 files changed
+883 -69

No files matched your search

@@ -4,6 +4,7 @@ using System.Text.Json;
using AIStudio.Chat;
using AIStudio.Dialogs;
using AIStudio.Settings;
using AIStudio.Tools.AIJobs;
using Microsoft.AspNetCore.Components;
@@ -18,6 +19,9 @@ public partial class Workspaces : MSGComponentBase
[Inject]
private ILogger<Workspaces> Logger { get; init; } = null!;
[Inject]
private AIJobService AIJobService { get; init; } = null!;
[Parameter]
public ChatThread? CurrentChatThread { get; set; }
@@ -42,6 +46,7 @@ public partial class Workspaces : MSGComponentBase
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
this.ApplyFilters([], [ Event.AI_JOB_CHANGED, Event.AI_JOB_FINISHED, Event.CHAT_GENERATION_CHANGED ]);
_ = this.LoadTreeItemsAsync(startPrefetch: true);
}
@@ -111,7 +116,7 @@ public partial class Workspaces : MSGComponentBase
var temporaryChatsChildren = new List<TreeItemData<ITreeItem>>();
foreach (var temporaryChat in snapshot.TemporaryChats.OrderByDescending(x => x.LastEditTime))
temporaryChatsChildren.Add(CreateChatTreeItem(temporaryChat, WorkspaceBranch.TEMPORARY_CHATS, depth: 1, icon: Icons.Material.Filled.Timer));
temporaryChatsChildren.Add(this.CreateChatTreeItem(temporaryChat, WorkspaceBranch.TEMPORARY_CHATS, depth: 1, icon: Icons.Material.Filled.Timer));
this.treeItems.Add(new TreeItemData<ITreeItem>
{
@@ -136,7 +141,7 @@ public partial class Workspaces : MSGComponentBase
if (workspace.ChatsLoaded)
{
foreach (var workspaceChat in workspace.Chats.OrderByDescending(x => x.LastEditTime))
children.Add(CreateChatTreeItem(workspaceChat, WorkspaceBranch.WORKSPACES, depth: 2, icon: Icons.Material.Filled.Chat));
children.Add(this.CreateChatTreeItem(workspaceChat, WorkspaceBranch.WORKSPACES, depth: 2, icon: Icons.Material.Filled.Chat));
}
else if (this.loadingWorkspaceChatLists.Contains(workspace.WorkspaceId))
children.AddRange(this.CreateLoadingRows(workspace.WorkspacePath));
@@ -192,7 +197,7 @@ public partial class Workspaces : MSGComponentBase
};
}
private static TreeItemData<ITreeItem> CreateChatTreeItem(WorkspaceTreeChat chat, WorkspaceBranch branch, int depth, string icon)
private TreeItemData<ITreeItem> CreateChatTreeItem(WorkspaceTreeChat chat, WorkspaceBranch branch, int depth, string icon)
{
return new TreeItemData<ITreeItem>
{
@@ -204,13 +209,43 @@ public partial class Workspaces : MSGComponentBase
Branch = branch,
Text = chat.Name,
Icon = icon,
DefaultIcon = icon,
Expandable = false,
Path = chat.ChatPath,
ChatId = chat.ChatId,
WorkspaceId = chat.WorkspaceId,
LastEditTime = chat.LastEditTime,
},
};
}
private string GetTreeItemIcon(TreeItemData treeItem)
{
if (treeItem.Type is not TreeItemType.CHAT)
return treeItem.Icon;
var defaultIcon = string.IsNullOrWhiteSpace(treeItem.DefaultIcon) ? treeItem.Icon : treeItem.DefaultIcon;
return this.GetChatTreeIcon(treeItem.ChatId, defaultIcon);
}
private bool IsChatTreeItemBusy(TreeItemData treeItem)
{
return treeItem.Type is TreeItemType.CHAT && this.AIJobService.IsChatGenerationActive(treeItem.ChatId);
}
private string GetChatTreeIcon(Guid chatId, string defaultIcon)
{
var snapshot = this.AIJobService.TryGetChatSnapshot(chatId);
return snapshot?.Status switch
{
AIJobStatus.WAITING_FOR_REMOTE => Icons.Material.Filled.HourglassTop,
AIJobStatus.RUNNING => Icons.Material.Filled.ChangeCircle,
AIJobStatus.CANCELED => Icons.Material.Filled.Cancel,
AIJobStatus.FAILED => Icons.Material.Filled.Error,
_ => defaultIcon,
};
}
private async Task SafeStateHasChanged()
{
if (this.isDisposed)
@@ -348,6 +383,9 @@ public partial class Workspaces : MSGComponentBase
{
var chatData = await File.ReadAllTextAsync(Path.Join(chatPath, "thread.json"), Encoding.UTF8);
var chat = JsonSerializer.Deserialize<ChatThread>(chatData, WorkspaceBehaviour.JSON_OPTIONS);
if (chat is not null)
chat = this.AIJobService.TryGetLiveChatThread(chat.ChatId) ?? chat;
if (switchToChat)
{
this.CurrentChatThread = chat;
@@ -371,6 +409,9 @@ public partial class Workspaces : MSGComponentBase
if (chat is null)
return;
if (this.AIJobService.IsChatGenerationActive(chat.ChatId))
return;
if (askForConfirmation)
{
var workspaceName = await WorkspaceBehaviour.LoadWorkspaceNameAsync(chat.WorkspaceId);
@@ -407,6 +448,9 @@ public partial class Workspaces : MSGComponentBase
var chat = await this.LoadChatAsync(chatPath, false);
if (chat is null)
return;
if (this.AIJobService.IsChatGenerationActive(chat.ChatId))
return;
var dialogParameters = new DialogParameters<SingleInputDialog>
{
@@ -525,6 +569,9 @@ public partial class Workspaces : MSGComponentBase
var chat = await this.LoadChatAsync(chatPath, false);
if (chat is null)
return;
if (this.AIJobService.IsChatGenerationActive(chat.ChatId))
return;
var dialogParameters = new DialogParameters<WorkspaceSelectionDialog>
{
@@ -597,6 +644,12 @@ public partial class Workspaces : MSGComponentBase
case Event.PLUGINS_RELOADED:
await this.ForceRefreshFromDiskAsync();
break;
case Event.AI_JOB_CHANGED:
case Event.AI_JOB_FINISHED:
case Event.CHAT_GENERATION_CHANGED:
await this.SafeStateHasChanged();
break;
}
}