From e81c005d15e99414135a8c332f9dc0c9a8deeaa3 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sun, 2 Aug 2026 14:42:59 +0200 Subject: [PATCH] Fixed visual briefing edits being lost when switching between briefings --- .../VisualBriefingAssistant.razor.Projects.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/app/MindWork AI Studio/Assistants/VisualBriefing/VisualBriefingAssistant.razor.Projects.cs b/app/MindWork AI Studio/Assistants/VisualBriefing/VisualBriefingAssistant.razor.Projects.cs index f5c93d89..376ae643 100644 --- a/app/MindWork AI Studio/Assistants/VisualBriefing/VisualBriefingAssistant.razor.Projects.cs +++ b/app/MindWork AI Studio/Assistants/VisualBriefing/VisualBriefingAssistant.razor.Projects.cs @@ -199,6 +199,38 @@ public partial class VisualBriefingAssistant if (reload) await this.ReloadListAsync(this.selectedBriefing.BriefingId); + else + await this.RefreshSavedBriefingAsync(this.selectedBriefing.BriefingId); + } + + /// + /// Refreshes the in-memory manifest copies of one briefing after it was written to disk. + /// + /// + /// The store re-reads and rewrites the manifest file, so the copies this component holds are + /// stale after every save. They must be refreshed, because selecting a briefing restores the + /// editor from the stored manifest: a stale copy would first show the values from before the + /// save and would then be written back over the saved ones on the next save. + /// The list order is deliberately left untouched. Auto-saving happens while the user is typing, + /// and re-sorting by modification date would make the edited briefing jump within the list on + /// every change. Explicit actions re-sort through ReloadListAsync instead. + /// + /// The briefing that was just saved. + /// A task that completes once the in-memory copies match the stored manifest. + private async Task RefreshSavedBriefingAsync(Guid briefingId) + { + var saved = await this.Store.LoadAsync(briefingId); + if (saved is null) + return; + + if (this.selectedBriefing?.BriefingId == briefingId) + this.selectedBriefing = saved; + + var refreshed = VisualBriefingProjectEntry.FromManifest(saved); + this.projects = [.. this.projects.Select(project => project.BriefingId == briefingId ? refreshed : project)]; + + if (this.selectedProject?.BriefingId == briefingId) + this.selectedProject = refreshed; } ///