Skip to content

Commit 8a97780

Browse files
HandyS11claude
andcommitted
fix(discord): include select-menu option emote in canonical render
Copilot review: an option-emoji-only change previously canonicalized identically and the gate would skip the edit. Also documents why _publishedStatuses records before bus delivery (observed-state semantics protect the drop sweep against failed deliveries). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 7d60f30 commit 8a97780

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

src/RustPlusBot.Discord/Posting/RenderCanonicalizer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ private static void AppendComponent(StringBuilder sb, IMessageComponent componen
104104
Append(sb, "option.label", option.Label);
105105
Append(sb, "option.value", option.Value);
106106
Append(sb, "option.description", option.Description);
107+
Append(sb, "option.emote", option.Emote?.ToString());
107108
Append(sb, "option.default", option.IsDefault == true ? "1" : "0");
108109
}
109110

src/RustPlusBot.Features.Connections/Supervisor/ConnectionSupervisor.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ internal sealed partial class ConnectionSupervisor(
4747
private readonly ConcurrentDictionary<(ulong Guild, Guid Server), LiveSocket> _liveSockets = new();
4848
private readonly ConnectionOptions _options = options.Value;
4949

50-
/// <summary>Last status published per key IN THIS PROCESS — the store's persisted status survives restarts and would falsely report Connected at boot.</summary>
50+
/// <summary>
51+
/// Last status this process REACHED THE PUBLISH STEP WITH per key — the store's persisted status
52+
/// survives restarts and would falsely report Connected at boot. Recorded before bus delivery on
53+
/// purpose: WasConnected must reflect what the supervisor observed, so a failed/cancelled delivery
54+
/// of a Connected event cannot make the next real drop skip its unreachable sweep.
55+
/// </summary>
5156
private readonly ConcurrentDictionary<(ulong Guild, Guid Server), ConnectionStatus> _publishedStatuses = new();
5257

5358
private readonly CancellationTokenSource _shutdown = new();

tests/RustPlusBot.Discord.Tests/Posting/RenderCanonicalizerTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,20 @@ public void Select_menu_options_are_included()
142142
RenderCanonicalizer.Canonicalize(embed: null, Menu("Beta")));
143143
}
144144

145+
[Fact]
146+
public void Select_menu_option_emote_change_changes_the_canonical_string()
147+
{
148+
static MessageComponent Menu(string emoji) => new ComponentBuilder()
149+
.WithSelectMenu("menu:1", [
150+
new SelectMenuOptionBuilder().WithLabel("A").WithValue("v1").WithEmote(new Emoji(emoji))
151+
])
152+
.Build();
153+
154+
Assert.NotEqual(
155+
RenderCanonicalizer.Canonicalize(embed: null, Menu("🔥")),
156+
RenderCanonicalizer.Canonicalize(embed: null, Menu("💧")));
157+
}
158+
145159
[Fact]
146160
public void Unmodeled_component_kind_differs_from_no_components()
147161
{

0 commit comments

Comments
 (0)