-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workspaces & persistent chats (#23)
- Loading branch information
1 parent
2926366
commit 59d0321
Showing
43 changed files
with
1,392 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace AIStudio.Components.Blocks; | ||
|
||
public interface ITreeItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace AIStudio.Components.Blocks; | ||
|
||
public readonly record struct TreeButton(WorkspaceBranch Branch, int Depth, string Text, string Icon, Func<Task> Action) : ITreeItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace AIStudio.Components.Blocks; | ||
|
||
public readonly record struct TreeDivider : ITreeItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace AIStudio.Components.Blocks; | ||
|
||
public class TreeItemData : ITreeItem | ||
{ | ||
public WorkspaceBranch Branch { get; init; } = WorkspaceBranch.NONE; | ||
|
||
public int Depth { get; init; } | ||
|
||
public string Text { get; init; } = string.Empty; | ||
|
||
public string ShortenedText => Text.Length > 30 ? this.Text[..30] + "..." : this.Text; | ||
|
||
public string Icon { get; init; } = string.Empty; | ||
|
||
public TreeItemType Type { get; init; } | ||
|
||
public string Path { get; init; } = string.Empty; | ||
|
||
public bool Expandable { get; init; } = true; | ||
|
||
public HashSet<ITreeItem> Children { get; init; } = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace AIStudio.Components.Blocks; | ||
|
||
public enum TreeItemType | ||
{ | ||
NONE, | ||
|
||
CHAT, | ||
WORKSPACE, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace AIStudio.Components.Blocks; | ||
|
||
public enum WorkspaceBranch | ||
{ | ||
NONE, | ||
|
||
WORKSPACES, | ||
TEMPORARY_CHATS, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<MudTreeView T="ITreeItem" Items="@this.treeItems" MultiSelection="@false" Hover="@true" ExpandOnClick="@true"> | ||
<ItemTemplate Context="item"> | ||
@switch (item) | ||
{ | ||
case TreeDivider: | ||
<li style="min-height: 1em;"> | ||
<MudDivider Style="margin-top: 1em; width: 90%; border-width: 3pt;"/> | ||
</li> | ||
break; | ||
|
||
case TreeItemData treeItem: | ||
@if (treeItem.Type is TreeItemType.CHAT) | ||
{ | ||
<MudTreeViewItem T="ITreeItem" Icon="@treeItem.Icon" Value="@item" CanExpand="@treeItem.Expandable" Items="@treeItem.Children" OnClick="() => this.LoadChat(treeItem.Path, true)"> | ||
<BodyContent> | ||
<div style="display: grid; grid-template-columns: 1fr auto; align-items: center; width: 100%"> | ||
<MudText Style="justify-self: start;"> | ||
@if (string.IsNullOrWhiteSpace(treeItem.Text)) | ||
{ | ||
@("Empty chat") | ||
} | ||
else | ||
{ | ||
@treeItem.ShortenedText | ||
} | ||
</MudText> | ||
<div style="justify-self: end;"> | ||
|
||
<MudTooltip Text="Move to workspace" Placement="@WORKSPACE_ITEM_TOOLTIP_PLACEMENT"> | ||
<MudIconButton Icon="@Icons.Material.Filled.MoveToInbox" Size="Size.Medium" Color="Color.Inherit" OnClick="() => this.MoveChat(treeItem.Path)"/> | ||
</MudTooltip> | ||
|
||
<MudTooltip Text="Rename" Placement="@WORKSPACE_ITEM_TOOLTIP_PLACEMENT"> | ||
<MudIconButton Icon="@Icons.Material.Filled.Edit" Size="Size.Medium" Color="Color.Inherit" OnClick="() => this.RenameChat(treeItem.Path)"/> | ||
</MudTooltip> | ||
|
||
<MudTooltip Text="Delete" Placement="@WORKSPACE_ITEM_TOOLTIP_PLACEMENT"> | ||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Medium" Color="Color.Inherit" OnClick="() => this.DeleteChat(treeItem.Path)"/> | ||
</MudTooltip> | ||
</div> | ||
</div> | ||
</BodyContent> | ||
</MudTreeViewItem> | ||
} | ||
else if (treeItem.Type is TreeItemType.WORKSPACE) | ||
{ | ||
<MudTreeViewItem T="ITreeItem" Icon="@treeItem.Icon" Value="@item" CanExpand="@treeItem.Expandable" Items="@treeItem.Children"> | ||
<BodyContent> | ||
<div style="display: grid; grid-template-columns: 1fr auto; align-items: center; width: 100%"> | ||
<MudText Style="justify-self: start;">@treeItem.Text</MudText> | ||
<div style="justify-self: end;"> | ||
<MudTooltip Text="Rename" Placement="@WORKSPACE_ITEM_TOOLTIP_PLACEMENT"> | ||
<MudIconButton Icon="@Icons.Material.Filled.Edit" Size="Size.Medium" Color="Color.Inherit" OnClick="() => this.RenameWorkspace(treeItem.Path)"/> | ||
</MudTooltip> | ||
|
||
<MudTooltip Text="Delete" Placement="@WORKSPACE_ITEM_TOOLTIP_PLACEMENT"> | ||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Medium" Color="Color.Inherit" OnClick="() => this.DeleteWorkspace(treeItem.Path)"/> | ||
</MudTooltip> | ||
</div> | ||
</div> | ||
</BodyContent> | ||
</MudTreeViewItem> | ||
} | ||
else | ||
{ | ||
<MudTreeViewItem T="ITreeItem" Icon="@treeItem.Icon" Value="@item" CanExpand="@treeItem.Expandable" Items="@treeItem.Children"> | ||
<BodyContent> | ||
<div style="display: grid; grid-template-columns: 1fr auto; align-items: center; width: 100%"> | ||
<MudText Style="justify-self: start;">@treeItem.Text</MudText> | ||
</div> | ||
</BodyContent> | ||
</MudTreeViewItem> | ||
} | ||
break; | ||
|
||
case TreeButton treeButton: | ||
<li> | ||
<div class="mud-treeview-item-content" style="background-color: unset;"> | ||
<div class="mud-treeview-item-arrow"></div> | ||
<MudButton StartIcon="@treeButton.Icon" Variant="Variant.Filled" OnClick="treeButton.Action"> | ||
@treeButton.Text | ||
</MudButton> | ||
</div> | ||
</li> | ||
break; | ||
} | ||
</ItemTemplate> | ||
</MudTreeView> |
Oops, something went wrong.