mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-11 22:33:47 +00:00
Fixed invisible file attachments in assistant plugins & allow file attachment component (#877)
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (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
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (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
Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
1 parent
f13c35d814
commit
7595def8f3
20 files changed
+312
-29
No files matched your search
@@ -15,17 +15,9 @@ public partial class ReadFileContent : MSGComponentBase
|
||||
[CascadingParameter]
|
||||
private MediaImportOwner? ImportOwner { get; set; }
|
||||
|
||||
private MediaImportOwner EffectiveImportOwner => this.ImportOwner ?? this.fallbackMediaImportOwner;
|
||||
|
||||
[Parameter]
|
||||
public string MediaImportTargetId { get; set; } = string.Empty;
|
||||
|
||||
private string EffectiveMediaImportTargetId => string.IsNullOrWhiteSpace(this.MediaImportTargetId)
|
||||
? string.IsNullOrWhiteSpace(this.Text) ? "primary" : this.Text
|
||||
: this.MediaImportTargetId;
|
||||
|
||||
private MediaImportTarget EffectiveMediaImportTarget => new(this.EffectiveImportOwner, this.EffectiveMediaImportTargetId);
|
||||
|
||||
[Parameter]
|
||||
public string Text { get; set; } = string.Empty;
|
||||
|
||||
@@ -35,6 +27,12 @@ public partial class ReadFileContent : MSGComponentBase
|
||||
[Parameter]
|
||||
public EventCallback<string> FileContentChanged { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true, the component will display the state of the attached document (if any).
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public bool ShowAttachedDocumentState { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool Disabled { get; set; }
|
||||
|
||||
@@ -75,12 +73,35 @@ 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);
|
||||
|
||||
private MediaImportOwner EffectiveImportOwner => this.ImportOwner ?? this.fallbackMediaImportOwner;
|
||||
|
||||
private string EffectiveMediaImportTargetId => string.IsNullOrWhiteSpace(this.MediaImportTargetId)
|
||||
? string.IsNullOrWhiteSpace(this.Text) ? "primary" : this.Text
|
||||
: this.MediaImportTargetId;
|
||||
|
||||
private MediaImportTarget EffectiveMediaImportTarget => new(this.EffectiveImportOwner, this.EffectiveMediaImportTargetId);
|
||||
|
||||
#region Overrides of MSGComponentBase
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(this.FileContent))
|
||||
{
|
||||
this.hasLoadedFileContent = false;
|
||||
this.loadedFileName = string.Empty;
|
||||
}
|
||||
|
||||
base.OnParametersSet();
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
this.MediaTranscriptionService.StateChanged += this.OnMediaImportStateChanged;
|
||||
@@ -145,7 +166,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 +319,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 +331,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<bool> LoadMediaTranscriptAsync(string filePath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(this.SettingsManager.ConfigurationData.App.UseTranscriptionProvider))
|
||||
@@ -342,6 +374,17 @@ public partial class ReadFileContent : MSGComponentBase
|
||||
this.EffectiveMediaImportTarget);
|
||||
}
|
||||
|
||||
private string FileLoadedTooltip()
|
||||
{
|
||||
if (!this.hasLoadedFileContent)
|
||||
return string.Empty;
|
||||
|
||||
if (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";
|
||||
|
||||
Reference in new issue
Block a user