From 5ce16f3f24b0c3d794d62ce04a35de0d01a4b38f Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Wed, 23 Sep 2026 13:22:25 +0200 Subject: [PATCH] Rename message tables to message files --- .../Chat/ContentBlockComponent.razor | 6 ++-- .../Chat/ContentBlockComponent.razor.cs | 32 +++++++++---------- .../Tools/{MessageTable.cs => MessageFile.cs} | 4 +-- .../Tools/PlainFileExport.cs | 4 +-- app/Tests/Chat/IContentExtensionsTests.cs | 2 +- 5 files changed, 24 insertions(+), 24 deletions(-) rename app/MindWork AI Studio/Tools/{MessageTable.cs => MessageFile.cs} (74%) diff --git a/app/MindWork AI Studio/Chat/ContentBlockComponent.razor b/app/MindWork AI Studio/Chat/ContentBlockComponent.razor index 71d5729d..e1dc635f 100644 --- a/app/MindWork AI Studio/Chat/ContentBlockComponent.razor +++ b/app/MindWork AI Studio/Chat/ContentBlockComponent.razor @@ -91,12 +91,12 @@ { } - @if (this.MessageTables.Count > 0) + @if (this.MessageFiles.Count > 0) { - @foreach (var messageTable in this.MessageTables) + @foreach (var messageFile in this.MessageFiles) { - + } } diff --git a/app/MindWork AI Studio/Chat/ContentBlockComponent.razor.cs b/app/MindWork AI Studio/Chat/ContentBlockComponent.razor.cs index 4dc68e92..9d912c06 100644 --- a/app/MindWork AI Studio/Chat/ContentBlockComponent.razor.cs +++ b/app/MindWork AI Studio/Chat/ContentBlockComponent.razor.cs @@ -125,8 +125,8 @@ public partial class ContentBlockComponent : MSGComponentBase private int lastRenderHash; private string cachedMarkdownRenderPlanInput = string.Empty; private MarkdownRenderPlan cachedMarkdownRenderPlan = MarkdownRenderPlan.EMPTY; - private string cachedMessageTablesInput = string.Empty; - private IReadOnlyList cachedMessageTables = []; + private string cachedMessageFilesInput = string.Empty; + private IReadOnlyList cachedMessageFiles = []; private char csvSeparator = ','; private ElementReference mathContentContainer; private SourcesList? sourcesList; @@ -154,19 +154,19 @@ public partial class ContentBlockComponent : MSGComponentBase /// message, and a block re-renders for reasons which have nothing to do with its text, such as /// switching the theme, which would parse every message of a long chat again. /// - private IReadOnlyList MessageTables + private IReadOnlyList MessageFiles { get { if (!this.Content.TryGetMarkdownText(out var markdown)) return []; - if (ReferenceEquals(this.cachedMessageTablesInput, markdown) || string.Equals(this.cachedMessageTablesInput, markdown, StringComparison.Ordinal)) - return this.cachedMessageTables; + if (ReferenceEquals(this.cachedMessageFilesInput, markdown) || string.Equals(this.cachedMessageFilesInput, markdown, StringComparison.Ordinal)) + return this.cachedMessageFiles; - this.cachedMessageTablesInput = markdown; - this.cachedMessageTables = PlainFileExport.ExtractTables(markdown, this.csvSeparator); - return this.cachedMessageTables; + this.cachedMessageFilesInput = markdown; + this.cachedMessageFiles = PlainFileExport.ExtractFiles(markdown, this.csvSeparator); + return this.cachedMessageFiles; } } @@ -178,9 +178,9 @@ public partial class ContentBlockComponent : MSGComponentBase /// one, the user has to be able to tell them apart: the heading above a table does that, unless /// it is missing or two tables share one, and then we count them. /// - private string ExportLabel(MessageTable table) + private string ExportLabel(MessageFile table) { - var tables = this.MessageTables; + var tables = this.MessageFiles; if (tables.Count < 2) return table.Format.ToName(); @@ -221,8 +221,8 @@ public partial class ContentBlockComponent : MSGComponentBase return; this.csvSeparator = separator; - this.cachedMessageTablesInput = string.Empty; - this.cachedMessageTables = []; + this.cachedMessageFilesInput = string.Empty; + this.cachedMessageFiles = []; await this.InvokeAsync(this.StateHasChanged); } @@ -749,17 +749,17 @@ public partial class ContentBlockComponent : MSGComponentBase } /// - /// Exports one table out of the message, exactly as the menu offered it. + /// Exports one file out of the message, exactly as the menu offered it. /// - private async Task ExportTable(MessageTable table) + private async Task ExportFile(MessageFile file) { try { - await PlainFileExport.ToFile(this.RustService, this.EffectiveExportTitle, table.Format, table.Content, table.Caption); + await PlainFileExport.ToFile(this.RustService, this.EffectiveExportTitle, file.Format, file.Content, file.Caption); } catch (ArgumentOutOfRangeException e) { - await this.ReportUnknownExportFormat(e, table.Format); + await this.ReportUnknownExportFormat(e, file.Format); } } diff --git a/app/MindWork AI Studio/Tools/MessageTable.cs b/app/MindWork AI Studio/Tools/MessageFile.cs similarity index 74% rename from app/MindWork AI Studio/Tools/MessageTable.cs rename to app/MindWork AI Studio/Tools/MessageFile.cs index 7ea9a7be..15668106 100644 --- a/app/MindWork AI Studio/Tools/MessageTable.cs +++ b/app/MindWork AI Studio/Tools/MessageFile.cs @@ -1,7 +1,7 @@ namespace AIStudio.Tools; /// -/// A table found in a message, ready to be written to a file. +/// A file found in a message, ready to be written: a table the model wrote. /// /// Which table of the message this is, counting from one. The same table /// appears once per format we offer for it, so this is what tells two tables apart even when they @@ -9,4 +9,4 @@ namespace AIStudio.Tools; /// What the table is about, taken from its first column heading. /// The format this content is written as. /// The finished file content. -public sealed record MessageTable(int Ordinal, string Caption, FileExportFormat Format, string Content); \ No newline at end of file +public sealed record MessageFile(int Ordinal, string Caption, FileExportFormat Format, string Content); \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/PlainFileExport.cs b/app/MindWork AI Studio/Tools/PlainFileExport.cs index a3ccf1fa..657cd576 100644 --- a/app/MindWork AI Studio/Tools/PlainFileExport.cs +++ b/app/MindWork AI Studio/Tools/PlainFileExport.cs @@ -27,7 +27,7 @@ public static class PlainFileExport /// The Markdown text of the message. /// The separator to write a Markdown table with, see CsvWriter.SeparatorFor. /// The tables, or an empty list when the message holds none. - public static IReadOnlyList ExtractTables(string markdown, char separator) + public static IReadOnlyList ExtractFiles(string markdown, char separator) { if (string.IsNullOrWhiteSpace(markdown)) return []; @@ -59,7 +59,7 @@ public static class PlainFileExport return tables.Concat(codeBlocks) .Where(entry => entry.Content is not null) .OrderBy(entry => entry.Line) - .Select((entry, index) => new MessageTable( + .Select((entry, index) => new MessageFile( index + 1, Caption: HeadingAbove(entry.Line) is { Length: > 0 } heading ? heading : entry.Content!.Value.Fallback, entry.Content!.Value.Format, diff --git a/app/Tests/Chat/IContentExtensionsTests.cs b/app/Tests/Chat/IContentExtensionsTests.cs index 873ecf53..3e3fb371 100644 --- a/app/Tests/Chat/IContentExtensionsTests.cs +++ b/app/Tests/Chat/IContentExtensionsTests.cs @@ -163,7 +163,7 @@ public sealed class IContentExtensionsTests "| Q1 | 100 |"), TOOL_SOURCE); content.TryGetMarkdownText(out var markdown); - var tables = PlainFileExport.ExtractTables(markdown, ','); + var tables = PlainFileExport.ExtractFiles(markdown, ','); Assert.Multiple(() => {