RynthChat pins: source-scan the always-written pin array
ChatFilterTests now scans ChatData.cs for the pin save and load lines so a refactor back to NullIfEmpty cannot silently turn "nothing pinned" into "All pinned". Also fixes the save comment that still said pins are left out while empty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ef61144592
commit
4d4788ac7a
2 changed files with 19 additions and 1 deletions
|
|
@ -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)),
|
||||
|
|
|
|||
|
|
@ -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<float>(), 500, 22, 2) == (0, false), "nothing to draw, no overflow button");
|
||||
Check(ChatPins.Layout(Array.Empty<float>(), -50, 22, 2) == (0, false), "also in no room");
|
||||
|
|
|
|||
Loading…
Reference in a new issue