WIP: RynthChat: pin channels to the top bar #16

Draft
AwfulWaffle wants to merge 12 commits from AwfulWaffle/RynthCore:chat/pins into main
2 changed files with 51 additions and 0 deletions
Showing only changes of commit 626cc9dfc3 - Show all commits

RynthChat settings: server tab, owner, pinned fields

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Daniel Wallace 2026-11-15 08:23:24 -08:00

View file

@ -41,6 +41,13 @@ internal sealed class RynthChatFilterDto
// 2026-10-05:
/// <summary>"contains" | "startswith" | "endswith"; absent: a regex (ChatRuleMatching).</summary>
[JsonPropertyName("mode")] public string? Mode { get; set; }
// 2026-11-15 (server default tabs, ChatServerTabs); each is absent on a player's own rule:
/// <summary>The server id whose plugin tab this rule belongs to; absent = every server.</summary>
[JsonPropertyName("server")] public string? Server { get; set; }
/// <summary>"&lt;server&gt;/&lt;entry id&gt;" of the plugin entry that owns this rule; absent = the player's rule.</summary>
[JsonPropertyName("owner")] public string? Owner { get; set; }
/// <summary>True on the rule whose pattern follows the room discovered from chat; absent = false.</summary>
[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.
/// <summary>Owner keys ("server/id") of the plugin tabs already seeded, so a deleted tab is not re-created.</summary>
[JsonPropertyName("seededTabs")] public string[]? SeededTabs { get; set; }
/// <summary>Tab name -> the server id whose plugin declared it; the tab shows only while that server is active.</summary>
[JsonPropertyName("tabServers")] public Dictionary<string, string>? TabServers { get; set; }
/// <summary>Server id -> the Global room (General, Trade, LFG, Roleplay) last discovered from chat.</summary>
[JsonPropertyName("globalRooms")] public Dictionary<string, string>? GlobalRooms { get; set; }
/// <summary>Tabs pinned to the main chat window's top bar, in pin order.</summary>
[JsonPropertyName("pinnedTabs")] public string[]? PinnedTabs { get; set; }
[JsonPropertyName("filters")] public RynthChatFilterDto[]? Filters { get; set; }
/// <summary>Standard filters' user state (RynthChatPresets); absent while none was changed.</summary>
[JsonPropertyName("presets")] public RynthChatPresetDto[]? Presets { get; set; }

View file

@ -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<string, string> { ["Network"] = "dreamweave" },
GlobalRooms = new Dictionary<string, string> { ["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");