From dc71c2ba0bf65d999e9dd2ec854b573ecb9a6006 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sun, 2 Aug 2026 16:08:23 +0200 Subject: [PATCH] Added a warning when files are removed from the source material --- .../Assistants/I18N/allTexts.lua | 3 ++ .../VisualBriefingAssistant.razor | 4 +-- .../VisualBriefingAssistant.razor.Sources.cs | 34 ++++++++++++------- ...isualBriefingAssistant.razor.Validation.cs | 6 ++++ .../plugin.lua | 3 ++ .../plugin.lua | 3 ++ 6 files changed, 39 insertions(+), 14 deletions(-) diff --git a/app/MindWork AI Studio/Assistants/I18N/allTexts.lua b/app/MindWork AI Studio/Assistants/I18N/allTexts.lua index 64313c27..c5e9e5c3 100644 --- a/app/MindWork AI Studio/Assistants/I18N/allTexts.lua +++ b/app/MindWork AI Studio/Assistants/I18N/allTexts.lua @@ -2356,6 +2356,9 @@ UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT:: -- Documents, spreadsheets, images, audio, and video are considered as source context. UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2228157968"] = "Documents, spreadsheets, images, audio, and video are considered as source context." +-- These files are already attached as visual assets and were removed from the source material: {0} +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2271225937"] = "These files are already attached as visual assets and were removed from the source material: {0}" + -- Target language UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T237828418"] = "Target language" diff --git a/app/MindWork AI Studio/Assistants/VisualBriefing/VisualBriefingAssistant.razor b/app/MindWork AI Studio/Assistants/VisualBriefing/VisualBriefingAssistant.razor index 0181934b..f9d8ef01 100644 --- a/app/MindWork AI Studio/Assistants/VisualBriefing/VisualBriefingAssistant.razor +++ b/app/MindWork AI Studio/Assistants/VisualBriefing/VisualBriefingAssistant.razor @@ -122,7 +122,7 @@ - /// Defines SourceMaterialChangedAsync for the visual briefing feature. + /// Keeps source material and visual assets mutually exclusive after either list changed. /// - private async Task SourceMaterialChangedAsync(HashSet _) + /// + /// A file is either source material or a visual asset, never both: visual assets have to appear in + /// the briefing, while source material only feeds the analysis. Visual assets win, so the overlap is + /// always resolved on the source-material side. Both attachment controls route here because either + /// one can create the overlap — the source-material control catches all document kinds, including + /// the image types the visual-asset control is limited to. The warning matters because the file + /// would otherwise vanish from the source-material list without any explanation, possibly leaving + /// the briefing without the source material it requires. + /// + /// The changed attachment set. It is ignored because both lists are inspected anyway. + private async Task EnforceSourceExclusivityAsync(HashSet _) { var visualPaths = this.editor.VisualAssets.Select(attachment => attachment.FilePath).ToHashSet(PathComparer()); - this.editor.SourceMaterial.RemoveWhere(attachment => visualPaths.Contains(attachment.FilePath)); - await this.SaveCurrentAsync(reload: true); - } + var displaced = this.editor.SourceMaterial.Where(attachment => visualPaths.Contains(attachment.FilePath)).ToArray(); + if (displaced.Length > 0) + { + this.editor.SourceMaterial.ExceptWith(displaced); + await this.MessageBus.SendWarning(new( + Icons.Material.Filled.Warning, + string.Format( + T("These files are already attached as visual assets and were removed from the source material: {0}"), + string.Join(", ", displaced.Select(attachment => Path.GetFileName(attachment.FilePath)))))); + } - /// - /// Defines VisualAssetsChangedAsync for the visual briefing feature. - /// - private async Task VisualAssetsChangedAsync(HashSet _) - { - var visualPaths = this.editor.VisualAssets.Select(attachment => attachment.FilePath).ToHashSet(PathComparer()); - this.editor.SourceMaterial.RemoveWhere(attachment => visualPaths.Contains(attachment.FilePath)); await this.SaveCurrentAsync(reload: true); } diff --git a/app/MindWork AI Studio/Assistants/VisualBriefing/VisualBriefingAssistant.razor.Validation.cs b/app/MindWork AI Studio/Assistants/VisualBriefing/VisualBriefingAssistant.razor.Validation.cs index a40cd3e9..195fc22c 100644 --- a/app/MindWork AI Studio/Assistants/VisualBriefing/VisualBriefingAssistant.razor.Validation.cs +++ b/app/MindWork AI Studio/Assistants/VisualBriefing/VisualBriefingAssistant.razor.Validation.cs @@ -7,6 +7,12 @@ namespace AIStudio.Assistants.VisualBriefing; public partial class VisualBriefingAssistant { /// Gets whether the briefing contains at least one actual source-material file. + /// + /// This deliberately reads the stored manifest instead of the editor state: a build always runs + /// against what the store accepted, and the store drops attachments whose file disappeared before + /// the save. Every path that changes sources therefore has to save with a reload, otherwise this + /// check keeps reporting the state from before the change. + /// private bool HasSourceMaterial => this.selectedBriefing?.Sources.Any(source => source.Kind is VisualBriefingSourceKind.SOURCE_MATERIAL) == true; /// Gets all current field, source, and revision issues shown below the actions. diff --git a/app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua b/app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua index f46ff72c..87536244 100644 --- a/app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua +++ b/app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua @@ -2358,6 +2358,9 @@ UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT:: -- Documents, spreadsheets, images, audio, and video are considered as source context. UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2228157968"] = "Dokumente, Tabellenkalkulationen, Bilder, Audio- und Videodateien werden als Ausgangsmaterial berücksichtigt." +-- These files are already attached as visual assets and were removed from the source material: {0} +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2271225937"] = "Diese Dateien sind bereits als visuelle Elemente angehängt und wurden aus dem Ausgangsmaterial entfernt: {0}" + -- Target language UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T237828418"] = "Zielsprache" diff --git a/app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua b/app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua index 0579dfb8..ebd90710 100644 --- a/app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua +++ b/app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua @@ -2358,6 +2358,9 @@ UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT:: -- Documents, spreadsheets, images, audio, and video are considered as source context. UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2228157968"] = "Documents, spreadsheets, images, audio, and video are considered as source context." +-- These files are already attached as visual assets and were removed from the source material: {0} +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2271225937"] = "These files are already attached as visual assets and were removed from the source material: {0}" + -- Target language UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T237828418"] = "Target language"