diff --git a/app/MindWork AI Studio/Chat/FileAttachment.cs b/app/MindWork AI Studio/Chat/FileAttachment.cs
index 4d49b225..eaf9d399 100644
--- a/app/MindWork AI Studio/Chat/FileAttachment.cs
+++ b/app/MindWork AI Studio/Chat/FileAttachment.cs
@@ -35,6 +35,11 @@ public record FileAttachment(FileAttachmentType Type, string FileName, string Fi
///
public bool IsImage { get; } = Type == FileAttachmentType.IMAGE;
+ ///
+ /// Gets the file path formatted as a file URL (file:///).
+ ///
+ public string FilePathAsUrl { get; } = $"file:///{FilePath.Replace('\\', '/')}";
+
///
/// Gets a value indicating whether the file still exists on the file system.
///
diff --git a/app/MindWork AI Studio/Components/AttachDocuments.razor.cs b/app/MindWork AI Studio/Components/AttachDocuments.razor.cs
index bddcbe43..9bc48747 100644
--- a/app/MindWork AI Studio/Components/AttachDocuments.razor.cs
+++ b/app/MindWork AI Studio/Components/AttachDocuments.razor.cs
@@ -219,7 +219,7 @@ public partial class AttachDocuments : MSGComponentBase
{
var dialogParameters = new DialogParameters
{
- { x => x.FilePath, fileAttachment.FilePath },
+ { x => x.Document, fileAttachment },
};
await this.DialogService.ShowAsync(T("Document Preview"), dialogParameters, DialogOptions.FULLSCREEN);
diff --git a/app/MindWork AI Studio/Dialogs/DocumentCheckDialog.razor b/app/MindWork AI Studio/Dialogs/DocumentCheckDialog.razor
index 88e5353f..2d1f9b09 100644
--- a/app/MindWork AI Studio/Dialogs/DocumentCheckDialog.razor
+++ b/app/MindWork AI Studio/Dialogs/DocumentCheckDialog.razor
@@ -6,7 +6,7 @@
@T("See how we load your file. Review the content before we process it further.")
- @if (string.IsNullOrWhiteSpace(this.FilePath))
+ @if (this.Document is null)
{
}
@@ -14,7 +14,7 @@
{
-
-
-
-
-
-
-
-
-
-
+ @if (this.Document?.IsImage ?? false)
+ {
+
+
+
+ }
+ else
+ {
+
+
+
+
+
+
+
+
+
+
+ }
diff --git a/app/MindWork AI Studio/Dialogs/DocumentCheckDialog.razor.cs b/app/MindWork AI Studio/Dialogs/DocumentCheckDialog.razor.cs
index 241e0393..799db7d1 100644
--- a/app/MindWork AI Studio/Dialogs/DocumentCheckDialog.razor.cs
+++ b/app/MindWork AI Studio/Dialogs/DocumentCheckDialog.razor.cs
@@ -1,4 +1,5 @@
-using AIStudio.Components;
+using AIStudio.Chat;
+using AIStudio.Components;
using AIStudio.Tools.Services;
using Microsoft.AspNetCore.Components;
@@ -13,7 +14,7 @@ public partial class DocumentCheckDialog : MSGComponentBase
private IMudDialogInstance MudDialog { get; set; } = null!;
[Parameter]
- public string FilePath { get; set; } = string.Empty;
+ public FileAttachment? Document { get; set; }
private void Close() => this.MudDialog.Cancel();
@@ -31,23 +32,26 @@ public partial class DocumentCheckDialog : MSGComponentBase
protected override async Task OnAfterRenderAsync(bool firstRender)
{
- if (firstRender && !string.IsNullOrWhiteSpace(this.FilePath))
+ if (firstRender && this.Document is not null)
{
try
{
- var fileContent = await UserFile.LoadFileData(this.FilePath, this.RustService, this.DialogService);
- this.FileContent = fileContent;
- this.StateHasChanged();
+ if (!this.Document.IsImage)
+ {
+ var fileContent = await UserFile.LoadFileData(this.Document.FilePath, this.RustService, this.DialogService);
+ this.FileContent = fileContent;
+ this.StateHasChanged();
+ }
}
catch (Exception ex)
{
- this.Logger.LogError(ex, "Failed to load file content from '{FilePath}'", this.FilePath);
+ this.Logger.LogError(ex, "Failed to load file content from '{FilePath}'", this.Document);
this.FileContent = string.Empty;
this.StateHasChanged();
}
}
else if (firstRender)
- this.Logger.LogWarning("Document check dialog opened without a valid file path");
+ this.Logger.LogWarning("Document check dialog opened without a valid file path.");
}
private CodeBlockTheme CodeColorPalette => this.SettingsManager.IsDarkMode ? CodeBlockTheme.Dark : CodeBlockTheme.Default;