From 626cc9dfc33215f83608b394b292a5baf55daf61 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Sun, 15 Nov 2026 08:23:24 -0800 Subject: [PATCH] RynthChat settings: server tab, owner, pinned fields Co-Authored-By: Claude Opus 5.5 --- .../UI/Data/ChatSettingsDto.cs | 16 +++++++++ tools/ChatFilterTests/Program.cs | 35 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/src/RynthCore.Engine/UI/Data/ChatSettingsDto.cs b/src/RynthCore.Engine/UI/Data/ChatSettingsDto.cs index d3dfbf9..49d42d8 100644 --- a/src/RynthCore.Engine/UI/Data/ChatSettingsDto.cs +++ b/src/RynthCore.Engine/UI/Data/ChatSettingsDto.cs @@ -41,6 +41,13 @@ internal sealed class RynthChatFilterDto // 2026-10-05: /// "contains" | "startswith" | "endswith"; absent: a regex (ChatRuleMatching). [JsonPropertyName("mode")] public string? Mode { get; set; } + // 2026-11-15 (server default tabs, ChatServerTabs); each is absent on a player's own rule: + /// The server id whose plugin tab this rule belongs to; absent = every server. + [JsonPropertyName("server")] public string? Server { get; set; } + /// "<server>/<entry id>" of the plugin entry that owns this rule; absent = the player's rule. + [JsonPropertyName("owner")] public string? Owner { get; set; } + /// True on the rule whose pattern follows the room discovered from chat; absent = false. + [JsonPropertyName("globalRoom")] public bool? GlobalRoom { get; set; } } internal sealed class RynthChatSettingsDto @@ -71,6 +78,15 @@ internal sealed class RynthChatSettingsDto // 2026-10-20: the tabs in a row across the top instead of the channels drawer; absent while off. [JsonPropertyName("tabsAcross")] public bool? TabsAcross { get; set; } [JsonPropertyName("customTabs")] public string[]? CustomTabs { get; set; } + // 2026-11-15: server default tabs (ChatServerTabs) and pinned channels (ChatPins); each absent while unused. + /// Owner keys ("server/id") of the plugin tabs already seeded, so a deleted tab is not re-created. + [JsonPropertyName("seededTabs")] public string[]? SeededTabs { get; set; } + /// Tab name -> the server id whose plugin declared it; the tab shows only while that server is active. + [JsonPropertyName("tabServers")] public Dictionary? TabServers { get; set; } + /// Server id -> the Global room (General, Trade, LFG, Roleplay) last discovered from chat. + [JsonPropertyName("globalRooms")] public Dictionary? GlobalRooms { get; set; } + /// Tabs pinned to the main chat window's top bar, in pin order. + [JsonPropertyName("pinnedTabs")] public string[]? PinnedTabs { get; set; } [JsonPropertyName("filters")] public RynthChatFilterDto[]? Filters { get; set; } /// Standard filters' user state (RynthChatPresets); absent while none was changed. [JsonPropertyName("presets")] public RynthChatPresetDto[]? Presets { get; set; } diff --git a/tools/ChatFilterTests/Program.cs b/tools/ChatFilterTests/Program.cs index 20cb2dd..12407ea 100644 --- a/tools/ChatFilterTests/Program.cs +++ b/tools/ChatFilterTests/Program.cs @@ -53,6 +53,7 @@ internal static class Program RetailRules(); RetailSetting(); TabsAcrossSetting(); + ServerTabSettingsRoundTrip(); SharedFileReload(); LineColorTags(); LineColorKinds(); @@ -1108,6 +1109,40 @@ internal static class Program Check(JsonSerializer.Deserialize(off, opts)!.Filters!.Length == 3, "the other fields are untouched"); } + private static void ServerTabSettingsRoundTrip() + { + Case("server tab settings: server, owner, globalRoom, seededTabs, tabServers, globalRooms, pinnedTabs (2026-11-15)"); + var opts = RynthChatJsonContext.Default.RynthChatSettingsDto; + var full = new RynthChatSettingsDto + { + SeededTabs = new[] { "dreamweave/dereth-network" }, + TabServers = new Dictionary { ["Network"] = "dreamweave" }, + GlobalRooms = new Dictionary { ["dreamweave"] = "Trade" }, + PinnedTabs = new[] { "Chat", "Network" }, + Filters = new[] + { + new RynthChatFilterDto { Pattern = "x", Tab = "Network", Server = "dreamweave", Owner = "dreamweave/dereth-network", GlobalRoom = true }, + }, + }; + RynthChatSettingsDto back = JsonSerializer.Deserialize(JsonSerializer.Serialize(full, opts), opts)!; + Check(back.SeededTabs != null && back.SeededTabs.Length == 1 && back.SeededTabs[0] == "dreamweave/dereth-network", "seededTabs round-trips"); + Check(back.TabServers != null && back.TabServers["Network"] == "dreamweave", "tabServers round-trips"); + Check(back.GlobalRooms != null && back.GlobalRooms["dreamweave"] == "Trade", "globalRooms round-trips"); + Check(back.PinnedTabs != null && back.PinnedTabs.SequenceEqual(new[] { "Chat", "Network" }), "pinnedTabs round-trips in order"); + RynthChatFilterDto r = back.Filters![0]; + Check(r.Server == "dreamweave" && r.Owner == "dreamweave/dereth-network" && r.GlobalRoom == true, "rule server, owner and globalRoom round-trip"); + + string plain = JsonSerializer.Serialize(new RynthChatSettingsDto { Filters = new[] { new RynthChatFilterDto { Pattern = "x", Tab = "Chat" } } }, opts); + Check(!plain.Contains("seededTabs", StringComparison.Ordinal) && !plain.Contains("pinnedTabs", StringComparison.Ordinal) + && !plain.Contains("\"owner\"", StringComparison.Ordinal), "a default DTO writes none of the new keys: " + plain); + Check(!plain.Contains("tabServers", StringComparison.Ordinal) && !plain.Contains("globalRooms", StringComparison.Ordinal) + && !plain.Contains("\"server\"", StringComparison.Ordinal) && !plain.Contains("globalRoom", StringComparison.Ordinal), "nor the rest"); + + RynthChatSettingsDto old = JsonSerializer.Deserialize(OldFile, opts)!; + Check(old.SeededTabs == null && old.TabServers == null && old.GlobalRooms == null && old.PinnedTabs == null, "an old file has none of the settings fields"); + Check(old.Filters!.All(f => f.Server == null && f.Owner == null && f.GlobalRoom == null), "an old file's rules have none of the rule fields"); + } + private static void TabsAcrossSetting() { Case("tabs across the top: off (the drawer) unless a file says true");