diff --git a/app/MindWork AI Studio/Components/AttachDocuments.razor.cs b/app/MindWork AI Studio/Components/AttachDocuments.razor.cs index 511adfe5..5d650a43 100644 --- a/app/MindWork AI Studio/Components/AttachDocuments.razor.cs +++ b/app/MindWork AI Studio/Components/AttachDocuments.razor.cs @@ -76,10 +76,19 @@ public partial class AttachDocuments : MSGComponentBase } // Ensure that Pandoc is installed and ready: - await this.PandocAvailabilityService.EnsureAvailabilityAsync( + var pandocState = await this.PandocAvailabilityService.EnsureAvailabilityAsync( showSuccessMessage: false, showDialog: true); + // If Pandoc is not available (user cancelled installation), abort file drop: + if (!pandocState.IsAvailable) + { + this.Logger.LogInformation("The user cancelled the Pandoc installation or Pandoc is not available. Aborting file drop."); + this.ClearDragClass(); + this.StateHasChanged(); + return; + } + foreach (var path in paths) { if(!await this.IsFileExtensionValid(path)) @@ -106,10 +115,17 @@ public partial class AttachDocuments : MSGComponentBase private async Task AddFilesManually() { // Ensure that Pandoc is installed and ready: - await this.PandocAvailabilityService.EnsureAvailabilityAsync( + var pandocState = await this.PandocAvailabilityService.EnsureAvailabilityAsync( showSuccessMessage: false, showDialog: true); + // If Pandoc is not available (user cancelled installation), abort file selection: + if (!pandocState.IsAvailable) + { + this.Logger.LogInformation("The user cancelled the Pandoc installation or Pandoc is not available. Aborting file selection."); + return; + } + var selectedFile = await this.RustService.SelectFile(T("Select a file to attach")); if (selectedFile.UserCancelled) return;