diff --git a/src/RynthCore.Engine/UI/Data/ChatData.cs b/src/RynthCore.Engine/UI/Data/ChatData.cs index 10247de..52576a4 100644 --- a/src/RynthCore.Engine/UI/Data/ChatData.cs +++ b/src/RynthCore.Engine/UI/Data/ChatData.cs @@ -1887,7 +1887,7 @@ internal static class ChatModel LineColors = ChatLineColors.ToJson(), // null (left out) until a colour is set RetailColors = ChatLineColors.RetailColors ? null : false, // left out while on (the default) CustomTabs = Volatile.Read(ref _customTabs), - // Left out while empty (2026-11-15), so a file without server tabs or pins is as before. + // Left out while empty: seeded tabs, tab servers, global rooms. Pins are always written (see below). SeededTabs = NullIfEmpty(Volatile.Read(ref _seededTabs)), TabServers = NullIfEmpty(Volatile.Read(ref _tabServers)), GlobalRooms = NullIfEmpty(Volatile.Read(ref _globalRooms)), diff --git a/tools/ChatFilterTests/Program.cs b/tools/ChatFilterTests/Program.cs index 06a1b06..179af1b 100644 --- a/tools/ChatFilterTests/Program.cs +++ b/tools/ChatFilterTests/Program.cs @@ -1664,6 +1664,24 @@ internal static class Program Check(!nullJson.Contains("pinnedTabs", StringComparison.Ordinal), "WhenWritingNull still drops only null"); string[] kept = ChatPins.FromSettings(new[] { "Chat", " ", "chat", "Network" }); Check(kept.SequenceEqual(new[] { "Chat", "Network" }), "a saved list is cleaned, order kept"); + // Source scan (the model is not compiled into this tool): the pin save and load lines are + // what make [] persist, and a refactor back to NullIfEmpty would silently turn "nothing + // pinned" into "All pinned" on the next load. + Case("PinsDefault_SourceScan"); + string? chatData = null; + for (string? dir = AppContext.BaseDirectory; dir != null && chatData == null; dir = Path.GetDirectoryName(dir)) + { + string candidate = Path.Combine(dir, "src", "RynthCore.Engine", "UI", "Data", "ChatData.cs"); + if (File.Exists(candidate)) chatData = candidate; + } + Check(chatData != null, "found src/RynthCore.Engine/UI/Data/ChatData.cs by walking up from " + AppContext.BaseDirectory); + if (chatData != null) + { + string src = File.ReadAllText(chatData); + Check(src.Contains("PinnedTabs = Volatile.Read(ref _pinnedTabs)", StringComparison.Ordinal), "save writes the pin array as is"); + Check(src.Contains("ChatPins.FromSettings(dto.PinnedTabs)", StringComparison.Ordinal), "load goes through FromSettings (absent = All)"); + Check(!src.Contains("NullIfEmpty(Volatile.Read(ref _pinnedTabs))", StringComparison.Ordinal), "save does not drop an empty pin array"); + } Case("Layout_ZeroPins"); Check(ChatPins.Layout(Array.Empty(), 500, 22, 2) == (0, false), "nothing to draw, no overflow button"); Check(ChatPins.Layout(Array.Empty(), -50, 22, 2) == (0, false), "also in no room");