mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-13 11:41:36 +00:00
Add layer-based drop area handling and prioritization
This commit is contained in:
parent
087d74e967
commit
6d7dd69b0e
@ -103,7 +103,7 @@ else
|
|||||||
@T("Documents for the analysis")
|
@T("Documents for the analysis")
|
||||||
</MudText>
|
</MudText>
|
||||||
|
|
||||||
<AttachDocuments Name="Document Analysis Files" @bind-DocumentPaths="@this.loadedDocumentPaths" CatchAllDocuments="true" UseSmallForm="false" Provider="@this.providerSettings"/>
|
<AttachDocuments Name="Document Analysis Files" Layer="@DropLayers.ASSISTANTS" @bind-DocumentPaths="@this.loadedDocumentPaths" CatchAllDocuments="true" UseSmallForm="false" Provider="@this.providerSettings"/>
|
||||||
|
|
||||||
</ExpansionPanel>
|
</ExpansionPanel>
|
||||||
</MudExpansionPanels>
|
</MudExpansionPanels>
|
||||||
|
|||||||
@ -17,6 +17,18 @@ public partial class AttachDocuments : MSGComponentBase
|
|||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// On which layer to register the drop area. Higher layers have priority over lower layers.
|
||||||
|
/// </summary>
|
||||||
|
[Parameter]
|
||||||
|
public int Layer { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When true, pause catching dropped files. Default is false.
|
||||||
|
/// </summary>
|
||||||
|
[Parameter]
|
||||||
|
public bool PauseCatchingDrops { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public HashSet<FileAttachment> DocumentPaths { get; set; } = [];
|
public HashSet<FileAttachment> DocumentPaths { get; set; } = [];
|
||||||
@ -63,6 +75,7 @@ public partial class AttachDocuments : MSGComponentBase
|
|||||||
private const Placement TOOLBAR_TOOLTIP_PLACEMENT = Placement.Top;
|
private const Placement TOOLBAR_TOOLTIP_PLACEMENT = Placement.Top;
|
||||||
private static readonly string DROP_FILES_HERE_TEXT = TB("Drop files here to attach them.");
|
private static readonly string DROP_FILES_HERE_TEXT = TB("Drop files here to attach them.");
|
||||||
|
|
||||||
|
private uint numDropAreasAboveThis;
|
||||||
private bool isComponentHovered;
|
private bool isComponentHovered;
|
||||||
private bool isDraggingOver;
|
private bool isDraggingOver;
|
||||||
|
|
||||||
@ -70,7 +83,10 @@ public partial class AttachDocuments : MSGComponentBase
|
|||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
this.ApplyFilters([], [ Event.TAURI_EVENT_RECEIVED ]);
|
this.ApplyFilters([], [ Event.TAURI_EVENT_RECEIVED, Event.REGISTER_FILE_DROP_AREA, Event.UNREGISTER_FILE_DROP_AREA ]);
|
||||||
|
|
||||||
|
// Register this drop area:
|
||||||
|
await this.MessageBus.SendMessage(this, Event.REGISTER_FILE_DROP_AREA, this.Layer);
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +94,35 @@ public partial class AttachDocuments : MSGComponentBase
|
|||||||
{
|
{
|
||||||
switch (triggeredEvent)
|
switch (triggeredEvent)
|
||||||
{
|
{
|
||||||
|
case Event.REGISTER_FILE_DROP_AREA when sendingComponent != this:
|
||||||
|
{
|
||||||
|
if(data is int layer && layer > this.Layer)
|
||||||
|
{
|
||||||
|
this.numDropAreasAboveThis++;
|
||||||
|
this.PauseCatchingDrops = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Event.UNREGISTER_FILE_DROP_AREA when sendingComponent != this:
|
||||||
|
{
|
||||||
|
if(data is int layer && layer > this.Layer)
|
||||||
|
{
|
||||||
|
if(this.numDropAreasAboveThis > 0)
|
||||||
|
this.numDropAreasAboveThis--;
|
||||||
|
|
||||||
|
if(this.numDropAreasAboveThis is 0)
|
||||||
|
this.PauseCatchingDrops = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case Event.TAURI_EVENT_RECEIVED when data is TauriEvent { EventType: TauriEventType.FILE_DROP_HOVERED }:
|
case Event.TAURI_EVENT_RECEIVED when data is TauriEvent { EventType: TauriEventType.FILE_DROP_HOVERED }:
|
||||||
|
if(this.PauseCatchingDrops)
|
||||||
|
return;
|
||||||
|
|
||||||
if(!this.isComponentHovered && !this.CatchAllDocuments)
|
if(!this.isComponentHovered && !this.CatchAllDocuments)
|
||||||
{
|
{
|
||||||
this.Logger.LogDebug("Attach documents component '{Name}' is not hovered, ignoring file drop hovered event.", this.Name);
|
this.Logger.LogDebug("Attach documents component '{Name}' is not hovered, ignoring file drop hovered event.", this.Name);
|
||||||
@ -91,11 +135,17 @@ public partial class AttachDocuments : MSGComponentBase
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Event.TAURI_EVENT_RECEIVED when data is TauriEvent { EventType: TauriEventType.FILE_DROP_CANCELED }:
|
case Event.TAURI_EVENT_RECEIVED when data is TauriEvent { EventType: TauriEventType.FILE_DROP_CANCELED }:
|
||||||
|
if(this.PauseCatchingDrops)
|
||||||
|
return;
|
||||||
|
|
||||||
this.isDraggingOver = false;
|
this.isDraggingOver = false;
|
||||||
this.StateHasChanged();
|
this.StateHasChanged();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Event.TAURI_EVENT_RECEIVED when data is TauriEvent { EventType: TauriEventType.WINDOW_NOT_FOCUSED }:
|
case Event.TAURI_EVENT_RECEIVED when data is TauriEvent { EventType: TauriEventType.WINDOW_NOT_FOCUSED }:
|
||||||
|
if(this.PauseCatchingDrops)
|
||||||
|
return;
|
||||||
|
|
||||||
this.isDraggingOver = false;
|
this.isDraggingOver = false;
|
||||||
this.isComponentHovered = false;
|
this.isComponentHovered = false;
|
||||||
this.ClearDragClass();
|
this.ClearDragClass();
|
||||||
@ -103,6 +153,9 @@ public partial class AttachDocuments : MSGComponentBase
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Event.TAURI_EVENT_RECEIVED when data is TauriEvent { EventType: TauriEventType.FILE_DROP_DROPPED, Payload: var paths }:
|
case Event.TAURI_EVENT_RECEIVED when data is TauriEvent { EventType: TauriEventType.FILE_DROP_DROPPED, Payload: var paths }:
|
||||||
|
if(this.PauseCatchingDrops)
|
||||||
|
return;
|
||||||
|
|
||||||
if(!this.isComponentHovered && !this.CatchAllDocuments)
|
if(!this.isComponentHovered && !this.CatchAllDocuments)
|
||||||
{
|
{
|
||||||
this.Logger.LogDebug("Attach documents component '{Name}' is not hovered, ignoring file drop dropped event.", this.Name);
|
this.Logger.LogDebug("Attach documents component '{Name}' is not hovered, ignoring file drop dropped event.", this.Name);
|
||||||
@ -198,6 +251,9 @@ public partial class AttachDocuments : MSGComponentBase
|
|||||||
|
|
||||||
private void OnMouseEnter(EventArgs _)
|
private void OnMouseEnter(EventArgs _)
|
||||||
{
|
{
|
||||||
|
if(this.PauseCatchingDrops)
|
||||||
|
return;
|
||||||
|
|
||||||
this.Logger.LogDebug("Attach documents component '{Name}' is hovered.", this.Name);
|
this.Logger.LogDebug("Attach documents component '{Name}' is hovered.", this.Name);
|
||||||
this.isComponentHovered = true;
|
this.isComponentHovered = true;
|
||||||
this.SetDragClass();
|
this.SetDragClass();
|
||||||
@ -206,6 +262,9 @@ public partial class AttachDocuments : MSGComponentBase
|
|||||||
|
|
||||||
private void OnMouseLeave(EventArgs _)
|
private void OnMouseLeave(EventArgs _)
|
||||||
{
|
{
|
||||||
|
if(this.PauseCatchingDrops)
|
||||||
|
return;
|
||||||
|
|
||||||
this.Logger.LogDebug("Attach documents component '{Name}' is no longer hovered.", this.Name);
|
this.Logger.LogDebug("Attach documents component '{Name}' is no longer hovered.", this.Name);
|
||||||
this.isComponentHovered = false;
|
this.isComponentHovered = false;
|
||||||
this.ClearDragClass();
|
this.ClearDragClass();
|
||||||
|
|||||||
@ -82,7 +82,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<ChatTemplateSelection CanChatThreadBeUsedForTemplate="@this.CanThreadBeSaved" CurrentChatThread="@this.ChatThread" CurrentChatTemplate="@this.currentChatTemplate" CurrentChatTemplateChanged="@this.ChatTemplateWasChanged"/>
|
<ChatTemplateSelection CanChatThreadBeUsedForTemplate="@this.CanThreadBeSaved" CurrentChatThread="@this.ChatThread" CurrentChatTemplate="@this.currentChatTemplate" CurrentChatTemplateChanged="@this.ChatTemplateWasChanged"/>
|
||||||
<AttachDocuments Name="File Attachments" @bind-DocumentPaths="@this.chatDocumentPaths" CatchAllDocuments="true" UseSmallForm="true" Provider="@this.Provider"/>
|
<AttachDocuments Name="File Attachments" Layer="@DropLayers.PAGES" @bind-DocumentPaths="@this.chatDocumentPaths" CatchAllDocuments="true" UseSmallForm="true" Provider="@this.Provider"/>
|
||||||
|
|
||||||
@if (this.SettingsManager.ConfigurationData.Workspace.StorageBehavior is WorkspaceStorageBehavior.STORE_CHATS_AUTOMATICALLY)
|
@if (this.SettingsManager.ConfigurationData.Workspace.StorageBehavior is WorkspaceStorageBehavior.STORE_CHATS_AUTOMATICALLY)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -86,9 +86,10 @@
|
|||||||
</MudJustifiedText>
|
</MudJustifiedText>
|
||||||
<AttachDocuments
|
<AttachDocuments
|
||||||
Name="ChatTemplateFileAttachments"
|
Name="ChatTemplateFileAttachments"
|
||||||
|
Layer="@DropLayers.DIALOGS"
|
||||||
@bind-DocumentPaths="@this.fileAttachments"
|
@bind-DocumentPaths="@this.fileAttachments"
|
||||||
UseSmallForm="false"
|
UseSmallForm="false"
|
||||||
CatchAllDocuments="false"
|
CatchAllDocuments="true"
|
||||||
ValidateMediaFileTypes="false"
|
ValidateMediaFileTypes="false"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
11
app/MindWork AI Studio/Tools/DropLayers.cs
Normal file
11
app/MindWork AI Studio/Tools/DropLayers.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace AIStudio.Tools;
|
||||||
|
|
||||||
|
public static class DropLayers
|
||||||
|
{
|
||||||
|
public const int ROOT = 0;
|
||||||
|
|
||||||
|
public const int PAGES = 10;
|
||||||
|
public const int ASSISTANTS = 20;
|
||||||
|
|
||||||
|
public const int DIALOGS = 100;
|
||||||
|
}
|
||||||
@ -34,6 +34,10 @@ public enum Event
|
|||||||
// RAG events:
|
// RAG events:
|
||||||
RAG_AUTO_DATA_SOURCES_SELECTED,
|
RAG_AUTO_DATA_SOURCES_SELECTED,
|
||||||
|
|
||||||
|
// File attachment events:
|
||||||
|
REGISTER_FILE_DROP_AREA,
|
||||||
|
UNREGISTER_FILE_DROP_AREA,
|
||||||
|
|
||||||
// Send events:
|
// Send events:
|
||||||
SEND_TO_GRAMMAR_SPELLING_ASSISTANT,
|
SEND_TO_GRAMMAR_SPELLING_ASSISTANT,
|
||||||
SEND_TO_ICON_FINDER_ASSISTANT,
|
SEND_TO_ICON_FINDER_ASSISTANT,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user