diff --git a/app/MindWork AI Studio/Components/ReadFileContent.razor b/app/MindWork AI Studio/Components/ReadFileContent.razor index c06fd5b5..48195b7f 100644 --- a/app/MindWork AI Studio/Components/ReadFileContent.razor +++ b/app/MindWork AI Studio/Components/ReadFileContent.razor @@ -4,7 +4,7 @@ {
- + @this.ButtonText @@ -18,6 +18,15 @@ @T("Drop one file here to load its content.") } + + @if (this.hasLoadedFileContent) + { + + + + + + }
@@ -29,5 +38,13 @@ else @this.ButtonText + @if (this.hasLoadedFileContent) + { + + + + + + } -} \ No newline at end of file +} diff --git a/app/MindWork AI Studio/Components/ReadFileContent.razor.cs b/app/MindWork AI Studio/Components/ReadFileContent.razor.cs index dd2887b0..4de1fb19 100644 --- a/app/MindWork AI Studio/Components/ReadFileContent.razor.cs +++ b/app/MindWork AI Studio/Components/ReadFileContent.razor.cs @@ -75,6 +75,8 @@ public partial class ReadFileContent : MSGComponentBase private uint numDropAreasAboveThis; private bool isComponentHovered; private bool isFileDialogOpen; + private bool hasLoadedFileContent; + private string loadedFileName = string.Empty; private bool IsCurrentTargetBusy => this.MediaTranscriptionService.GetSnapshot(this.EffectiveImportOwner) is { IsBusy: true } snapshot && snapshot.Target == this.EffectiveMediaImportTarget; private bool IsUnavailable => this.Disabled || this.isFileDialogOpen || this.MediaTranscriptionService.IsBusy(this.EffectiveImportOwner); @@ -145,7 +147,11 @@ public partial class ReadFileContent : MSGComponentBase if (delivery is null || delivery.Text is not { } text) return; - await this.FileContentChanged.InvokeAsync(text); + var fileName = this.MediaTranscriptionService.GetSnapshot(this.EffectiveImportOwner) is { Target: var target } snapshot + && target == this.EffectiveMediaImportTarget + ? snapshot.CurrentFileName + : string.Empty; + await this.ApplyFileContentAsync(text, fileName); this.MediaTranscriptionService.AcknowledgeDelivery(delivery); } @@ -294,7 +300,7 @@ public partial class ReadFileContent : MSGComponentBase try { var fileContent = await UserFile.LoadFileData(filePath, this.RustService, this.DialogService); - await this.FileContentChanged.InvokeAsync(fileContent); + await this.ApplyFileContentAsync(fileContent, filePath); this.Logger.LogInformation("Successfully loaded file content: {FilePath}", filePath); return true; } @@ -306,6 +312,13 @@ public partial class ReadFileContent : MSGComponentBase } } + private async Task ApplyFileContentAsync(string fileContent, string filePath) + { + await this.FileContentChanged.InvokeAsync(fileContent); + this.loadedFileName = Path.GetFileName(filePath); + this.hasLoadedFileContent = true; + } + private async Task LoadMediaTranscriptAsync(string filePath) { if (string.IsNullOrWhiteSpace(this.SettingsManager.ConfigurationData.App.UseTranscriptionProvider)) @@ -342,6 +355,14 @@ public partial class ReadFileContent : MSGComponentBase this.EffectiveMediaImportTarget); } + private string FileLoadedTooltip() + { + if (!this.hasLoadedFileContent || string.IsNullOrWhiteSpace(this.loadedFileName)) + return this.T("File content loaded"); + + return string.Format(this.T("Attached file '{0}'."), this.loadedFileName); + } + private bool CanCatchDroppedFile() => this.numDropAreasAboveThis is 0 && (this.isComponentHovered || this.CatchAllDocuments); private void SetDragClass() => this.dragClass = $"{DEFAULT_DRAG_CLASS} mud-border-primary border-2"; @@ -369,4 +390,4 @@ public partial class ReadFileContent : MSGComponentBase this.ClearDragClass(); this.StateHasChanged(); } -} \ No newline at end of file +}