diff --git a/CHANGELOG.md b/CHANGELOG.md index 19a4dd8..18c74b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ versions follow [Semantic Versioning](https://semver.org/). ## [Unreleased] - `ChatRunner.SupersedesEarlierContext` sends earlier prompts' context by its label alone: the latest prompt that carries a `PromptContext` the function accepts, and every prompt after it, send their context in full, and each earlier context goes to the model as its label with a note that it is not repeated. An application that sends the same document with each prompt no longer sends a copy of it for every earlier prompt. `SaveHistory` and the views keep every context's text; nothing changes for an application that does not set it. +- A table wider than a reply shows a button at its top right corner that opens the whole table over the window (Avalonia) or the page (Blazor), where it scrolls both ways. `ChatStrings.ExpandTable` labels the button, in every language the package ships. +- **Change:** both views take `Polhem.Markdown.Avalonia` and `Polhem.Markdown.Blazor` 0.8.0, and with them `Polhem.Markdown` 0.8.0 and the viewer fixes since 0.6.1: the Avalonia viewer no longer reads a `file` image that names a Windows network share, and an unchecked task box stands out from the background. Both viewers pin `Polhem.Markdown` to exactly 0.8.0, so an application that references it itself uses 0.8.0, and one that references a viewer package itself uses 0.8.0 or later. In the Blazor view, a reply's table cells now keep their text on one line, so a wide table scrolls sideways instead of breaking its words. ## [0.6.0] - 2026-11-30 diff --git a/CHANGELOG.zh-TW.md b/CHANGELOG.zh-TW.md index 92833a0..762a315 100644 --- a/CHANGELOG.zh-TW.md +++ b/CHANGELOG.zh-TW.md @@ -9,6 +9,8 @@ Polhem.Chat 各套件的重要變更,每個版本只列幾項重點。每個 ## [Unreleased] - `ChatRunner.SupersedesEarlierContext` 讓較早提問的 context 只送標籤:最近一則帶有此函式接受之 `PromptContext` 的提問,以及之後的每則提問,照常送出完整 context;更早的每份 context 只以標籤加一句「不再重送」的說明交給模型。每則提問都附上同一份文件的應用程式,不再為每則較早的提問各送一份。`SaveHistory` 與兩個 view 仍保留每份 context 的全文;沒設定的應用程式行為不變。 +- 比回覆寬的表格,右上角會出現一個按鈕,把整張表格蓋在視窗(Avalonia)或頁面(Blazor)上展開,可上下左右捲動。按鈕文字是 `ChatStrings.ExpandTable`,套件附帶的每種語言都有翻譯。 +- **變更:** 兩個 view 改用 `Polhem.Markdown.Avalonia` 與 `Polhem.Markdown.Blazor` 0.8.0,連帶使用 `Polhem.Markdown` 0.8.0,並帶入 0.6.1 之後的 viewer 修正:Avalonia viewer 不再讀取指向 Windows 網路共用資料夾的 `file` 圖片,未勾選的工作項目方框也與背景有足夠對比。兩個 viewer 都把 `Polhem.Markdown` 鎖定在 0.8.0,所以自行引用 `Polhem.Markdown` 的應用程式要用 0.8.0,自行引用 viewer 套件的要用 0.8.0 以上。Blazor view 裡回覆的表格儲存格改為不換行,寬表格會橫向捲動,不再把字拆開擠進畫面。 ## [0.6.0] - 2026-11-30 diff --git a/src/Polhem.Chat.Avalonia/DefaultEntryTemplates.axaml b/src/Polhem.Chat.Avalonia/DefaultEntryTemplates.axaml index 3ade96c..c705bc2 100644 --- a/src/Polhem.Chat.Avalonia/DefaultEntryTemplates.axaml +++ b/src/Polhem.Chat.Avalonia/DefaultEntryTemplates.axaml @@ -112,6 +112,7 @@ IsStreaming="{Binding IsStreaming}" CjkFontFamily="{Binding $parent[local:ChatView].CjkFontFamily}" CopyCodeLabel="{Binding $parent[local:ChatView].Strings.CopyCode}" + ExpandTableLabel="{Binding $parent[local:ChatView].Strings.ExpandTable}" IsVisible="{Binding Text, Converter={x:Static StringConverters.IsNotNullOrEmpty}}" /> - + diff --git a/src/Polhem.Chat.Blazor/ChatView.razor b/src/Polhem.Chat.Blazor/ChatView.razor index 779ddb2..06535f7 100644 --- a/src/Polhem.Chat.Blazor/ChatView.razor +++ b/src/Polhem.Chat.Blazor/ChatView.razor @@ -245,7 +245,8 @@ } @if (reply.Text.Length > 0) { - + }
@if (reply.IsStopped) diff --git a/src/Polhem.Chat.Blazor/Polhem.Chat.Blazor.csproj b/src/Polhem.Chat.Blazor/Polhem.Chat.Blazor.csproj index eb0c7ae..90a085e 100644 --- a/src/Polhem.Chat.Blazor/Polhem.Chat.Blazor.csproj +++ b/src/Polhem.Chat.Blazor/Polhem.Chat.Blazor.csproj @@ -14,10 +14,10 @@ - + diff --git a/src/Polhem.Chat/ChatStrings.cs b/src/Polhem.Chat/ChatStrings.cs index 154ee98..aa3e63f 100644 --- a/src/Polhem.Chat/ChatStrings.cs +++ b/src/Polhem.Chat/ChatStrings.cs @@ -34,6 +34,7 @@ private ChatStrings(CultureInfo culture) Reasoning = Load(nameof(Reasoning), culture); Copy = Load(nameof(Copy), culture); CopyCode = Load(nameof(CopyCode), culture); + ExpandTable = Load(nameof(ExpandTable), culture); JumpToLatest = Load(nameof(JumpToLatest), culture); EmptyTitle = Load(nameof(EmptyTitle), culture); ToolRunning = Load(nameof(ToolRunning), culture); @@ -103,6 +104,11 @@ private ChatStrings(CultureInfo culture) /// Gets or sets the label of the button that copies a code block inside a reply. public string CopyCode { get; set; } + /// + /// Gets or sets the label of the button that opens a table too wide for a reply over the window or the page. + /// + public string ExpandTable { get; set; } + /// Gets or sets the label of the button that scrolls back to the newest entry. public string JumpToLatest { get; set; } diff --git a/src/Polhem.Chat/PublicAPI.Unshipped.txt b/src/Polhem.Chat/PublicAPI.Unshipped.txt index 54d330c..3d07a16 100644 --- a/src/Polhem.Chat/PublicAPI.Unshipped.txt +++ b/src/Polhem.Chat/PublicAPI.Unshipped.txt @@ -1,3 +1,5 @@ #nullable enable Polhem.Chat.ChatRunner.SupersedesEarlierContext.get -> System.Func? Polhem.Chat.ChatRunner.SupersedesEarlierContext.set -> void +Polhem.Chat.ChatStrings.ExpandTable.get -> string! +Polhem.Chat.ChatStrings.ExpandTable.set -> void diff --git a/src/Polhem.Chat/Resources/ChatStrings.ja.resx b/src/Polhem.Chat/Resources/ChatStrings.ja.resx index 8ac6f43..6f4c68d 100644 --- a/src/Polhem.Chat/Resources/ChatStrings.ja.resx +++ b/src/Polhem.Chat/Resources/ChatStrings.ja.resx @@ -36,6 +36,9 @@ コピー + + 表を拡大表示 + 最新へ移動 diff --git a/src/Polhem.Chat/Resources/ChatStrings.resx b/src/Polhem.Chat/Resources/ChatStrings.resx index 75022ed..298ad2e 100644 --- a/src/Polhem.Chat/Resources/ChatStrings.resx +++ b/src/Polhem.Chat/Resources/ChatStrings.resx @@ -36,6 +36,9 @@ Copy + + Expand table + Jump to latest diff --git a/src/Polhem.Chat/Resources/ChatStrings.zh-Hans.resx b/src/Polhem.Chat/Resources/ChatStrings.zh-Hans.resx index cda74fb..e502869 100644 --- a/src/Polhem.Chat/Resources/ChatStrings.zh-Hans.resx +++ b/src/Polhem.Chat/Resources/ChatStrings.zh-Hans.resx @@ -36,6 +36,9 @@ 复制 + + 展开表格 + 回到最新 diff --git a/src/Polhem.Chat/Resources/ChatStrings.zh-Hant.resx b/src/Polhem.Chat/Resources/ChatStrings.zh-Hant.resx index ebefd34..cd9c92b 100644 --- a/src/Polhem.Chat/Resources/ChatStrings.zh-Hant.resx +++ b/src/Polhem.Chat/Resources/ChatStrings.zh-Hant.resx @@ -36,6 +36,9 @@ 複製 + + 展開表格 + 回到最新 diff --git a/tests/Polhem.Chat.Avalonia.UnitTests/ReplyMarkdownTests.cs b/tests/Polhem.Chat.Avalonia.UnitTests/ReplyMarkdownTests.cs index bba6ddc..50676de 100644 --- a/tests/Polhem.Chat.Avalonia.UnitTests/ReplyMarkdownTests.cs +++ b/tests/Polhem.Chat.Avalonia.UnitTests/ReplyMarkdownTests.cs @@ -188,6 +188,19 @@ public Task CjkFontFamily_Set_ReachesViewer() => session.RunAsync(() => Assert.Equal(family, viewer.CjkFontFamily); }); + [Fact(DisplayName = "The reply's viewer labels its code and table buttons with the view's texts")] + public Task ButtonLabels_FollowTheViewsStrings() => session.RunAsync(() => + { + var conversation = new ChatConversation(); + conversation.Entries.Add(new AssistantReplyEntry("| a | b |\n| - | - |\n| 1 | 2 |")); + var view = new ChatView { Conversation = conversation, Strings = ChatStrings.ForCulture(CultureInfo.GetCultureInfo("zh-TW")) }; + Show(view); + var viewer = Assert.Single(Descendants(EntryView(view, 0))); + + Assert.Equal("複製", viewer.CopyCodeLabel); + Assert.Equal("展開表格", viewer.ExpandTableLabel); + }); + [Fact(DisplayName = "A bidirectional override in a reply shows as an escape in text, inline code and code blocks, and Hebrew shows as it is")] public Task BidiOverride_Reply_ShowsAsEscape() => session.RunAsync(() => { diff --git a/tests/Polhem.Chat.Blazor.UnitTests/ChatViewTests.cs b/tests/Polhem.Chat.Blazor.UnitTests/ChatViewTests.cs index f6da2c6..7ae2e39 100644 --- a/tests/Polhem.Chat.Blazor.UnitTests/ChatViewTests.cs +++ b/tests/Polhem.Chat.Blazor.UnitTests/ChatViewTests.cs @@ -190,6 +190,24 @@ public void Reply_Images_HostList_ShowsListedHostsOnly() Assert.Contains("html theirs", view.Find(".pch-reply").TextContent, StringComparison.Ordinal); } + [Fact(DisplayName = "A reply labels its code and table buttons with the view's texts")] + public void Reply_ButtonLabels_FollowTheViewsStrings() + { + var conversation = new ChatConversation(); + conversation.AddUserPrompt("Hi"); + var turn = conversation.BeginTurn(); + turn.Apply(Update(new TextContent("```\ncode\n```\n\n| a | b |\n| - | - |\n| 1 | 2 |"))); + turn.Complete(); + + var view = HostDriven(conversation); + view.Render(parameters => parameters.Add(v => v.Strings, ChatStrings.ForCulture(CultureInfo.GetCultureInfo("zh-TW")))); + + Assert.Equal("複製", view.Find(".pch-reply .pmd-copy").GetAttribute("aria-label")); + var expand = view.Find(".pch-reply .pmd-table-expand"); + Assert.Equal("展開表格", expand.GetAttribute("aria-label")); + Assert.Equal("展開表格", expand.GetAttribute("title")); + } + [Fact(DisplayName = "A bidirectional override in a reply shows as an escape in text, inline code and code blocks, and Hebrew shows as it is")] public void Reply_BidiOverride_ShowsAsEscape() {