User-gate round 3 findings (a)-(c):
(a) SpewBox: TopOffset moves from the round-1 60px placeholder to 0 (flush
to the viewport top). SpewBoxController never wired DatFont/Font at all
before this round, so it silently rendered through the 15px debug
BitmapFont fallback; it now resolves retail dat Font 0x40000025
(MaxCharHeight=11px) through a new RetailUiRuntime.Assets accessor —
the smallest font id confirmed in use by any currently-imported retail
LayoutDesc fixture, cross-referenced against every
tests/AcDream.App.Tests/UI/Layout/fixtures/*.json dump and confirmed
against the installed DAT via AcDream.Cli dump-font-atlas. It is also the
chat window's own smallest font (the 0x2100006F floating-window 1/2/3/4
indicator badges), so both selection criteria the brief offered agree.
Both remain best-available approximations, not resolved retail values —
register row AP-178 updated accordingly.
(b)/(c) /help and /help death: round 2 extracted the individual retail
strings byte-exact but never traced ClientCommunicationSystem::DoHelp's
complete print sequence. Byte-swept DoHelp's own range plus the five
Summary-branch functions it calls into (HelpEmote/HelpSquelch/
HelpStatusGroup/HelpTextGroup/HelpAllGroup) against the PDB-paired
acclient.exe. Retail's real shape: bare /help prints exactly TWO scroll
entries (HelpPrefixNote, then the 13-item AvailableHelpListing built from
DoHelp's own literals and each group's Summary_HelpType branch, in exact
source order) — not the acdream-invented cheat sheet BuildHelpText()
built before. Any resolved /help <verb> gets the SAME two-entry shape:
HelpPrefixNote, then ForMoreInformationPrefix concatenated directly onto
the verb's own Detail text (retail's own unsubstituted "<command>"
literal, ported verbatim). ChatCommandRouter.EmitVerbHelp applies this
uniformly to every resolved verb, not just death. An unresolved verb now
shows retail's real "Unknown command" fallback text; that fallback types
0x1A (ClientLocal), which retail routes to the SpewBox exclusively — a
gap ChatVM's UI.Abstractions layer can't yet reach, filed as ISSUES #367
/ register AP-186 rather than left silently unregistered.
Jump-in-air (round 2's open item 1) was root-caused and fixed separately
at a5a7eb4f between rounds — recorded in the campaign ledger.
Debug suite (all projects): 12,329 passed / 4 skipped / 1 failed — the
one failure is issue #351, a pre-existing Debug-only streaming flake
confirmed reproducing identically on the pristine pre-round-3 commit via
git stash, not a regression. Release verification covers every project
reachable without rebuilding AcDream.App: a live client process (PID
15064) held its own Release binaries locked for the session and was not
killed per project policy — AcDream.UI.Abstractions.Tests (867/867, the
layer both /help fixes live in) plus every other non-App-dependent
project, all 0 failed. AcDream.App/AcDream.App.Tests/AcDream.Core.Tests
(the SpewBox fix's layer) are green in Debug only this session.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
302 lines
12 KiB
C#
302 lines
12 KiB
C#
using AcDream.Core.Chat;
|
|
using AcDream.UI.Abstractions;
|
|
using AcDream.UI.Abstractions.Panels.Chat;
|
|
using Xunit;
|
|
|
|
namespace AcDream.UI.Abstractions.Tests.Panels.Chat;
|
|
|
|
public class ChatCommandRouterTests
|
|
{
|
|
private sealed class CaptureBus : ICommandBus
|
|
{
|
|
public List<object> Published { get; } = new();
|
|
|
|
public void Publish<T>(T command) where T : notnull
|
|
=> Published.Add(command);
|
|
}
|
|
|
|
private static (ChatVM vm, ChatLog log, CaptureBus bus) Fixture()
|
|
{
|
|
var log = new ChatLog();
|
|
var vm = new ChatVM(log, displayLimit: 50);
|
|
return (vm, log, new CaptureBus());
|
|
}
|
|
|
|
[Fact]
|
|
public void PlainText_PublishesOnDefaultChannel()
|
|
{
|
|
var (vm, _, bus) = Fixture();
|
|
var outcome = ChatCommandRouter.Submit("hello there", vm, bus, ChatChannelKind.Say);
|
|
|
|
Assert.Equal(SubmitOutcome.Sent, outcome);
|
|
var command = Assert.IsType<SendChatCmd>(Assert.Single(bus.Published));
|
|
Assert.Equal(ChatChannelKind.Say, command.Channel);
|
|
Assert.Equal("hello there", command.Text);
|
|
}
|
|
|
|
[Fact]
|
|
public void DefaultChannel_IsHonored()
|
|
{
|
|
var (vm, _, bus) = Fixture();
|
|
ChatCommandRouter.Submit("hi", vm, bus, ChatChannelKind.Fellowship);
|
|
|
|
var command = Assert.IsType<SendChatCmd>(Assert.Single(bus.Published));
|
|
Assert.Equal(ChatChannelKind.Fellowship, command.Channel);
|
|
}
|
|
|
|
[Fact]
|
|
public void ClearCommand_PublishesTypedRetailCommand()
|
|
{
|
|
var (vm, log, bus) = Fixture();
|
|
log.OnSystemMessage("x", chatType: 0);
|
|
|
|
var outcome = ChatCommandRouter.Submit("/clear", vm, bus, ChatChannelKind.Say);
|
|
|
|
Assert.Equal(SubmitOutcome.ClientHandled, outcome);
|
|
var command = Assert.IsType<ExecuteClientCommandCmd>(Assert.Single(bus.Published));
|
|
Assert.Equal(ClientCommandId.ClearChat, command.Command);
|
|
Assert.Equal("", command.Arguments);
|
|
Assert.Single(log.Snapshot());
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("/lifestone")]
|
|
[InlineData("/lif")]
|
|
[InlineData("/ls")]
|
|
[InlineData("@LS")]
|
|
public void LifestoneAliases_PublishTypedClientCommand(string input)
|
|
{
|
|
var (vm, _, bus) = Fixture();
|
|
|
|
var outcome = ChatCommandRouter.Submit(input, vm, bus, ChatChannelKind.Fellowship);
|
|
|
|
Assert.Equal(SubmitOutcome.ClientHandled, outcome);
|
|
var command = Assert.IsType<ExecuteClientCommandCmd>(Assert.Single(bus.Published));
|
|
Assert.Equal(ClientCommandId.LifestoneRecall, command.Command);
|
|
}
|
|
|
|
[Fact]
|
|
public void LifestoneWithArguments_ShowsUsageAndPublishesNothing()
|
|
{
|
|
var (vm, log, bus) = Fixture();
|
|
|
|
var outcome = ChatCommandRouter.Submit("/ls now", vm, bus, ChatChannelKind.Say);
|
|
|
|
Assert.Equal(SubmitOutcome.ClientHandled, outcome);
|
|
Assert.Empty(bus.Published);
|
|
Assert.Contains(log.Snapshot(), entry => entry.Text == "Usage: /lifestone");
|
|
}
|
|
|
|
[Fact]
|
|
public void PkLiteAlias_ResolvesAsClientHandled_NotTheServerTextPath()
|
|
{
|
|
var (vm, _, bus) = Fixture();
|
|
|
|
var outcome = ChatCommandRouter.Submit("@pklite", vm, bus, ChatChannelKind.Say);
|
|
|
|
Assert.Equal(SubmitOutcome.ClientHandled, outcome);
|
|
var command = Assert.IsType<ExecuteClientCommandCmd>(Assert.Single(bus.Published));
|
|
Assert.Equal(ClientCommandId.EnterPkLite, command.Command);
|
|
}
|
|
|
|
[Fact]
|
|
public void UnknownSlashVerb_RoutesThroughExplicitServerCommand()
|
|
{
|
|
var (vm, log, bus) = Fixture();
|
|
|
|
var outcome = ChatCommandRouter.Submit(
|
|
"/notacommand", vm, bus, ChatChannelKind.Say);
|
|
|
|
Assert.Equal(SubmitOutcome.Sent, outcome);
|
|
var command = Assert.IsType<SendServerCommandCmd>(Assert.Single(bus.Published));
|
|
Assert.Equal("@notacommand", command.Text);
|
|
Assert.DoesNotContain(log.Snapshot(), entry => entry.Text.Contains("Unknown command"));
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("/ci 629 5")]
|
|
[InlineData("@ci 629 5")]
|
|
public void ServerCommandWithArgs_PublishesCanonicalAtForm_EvenOnChannelDefault(
|
|
string input)
|
|
{
|
|
var (vm, _, bus) = Fixture();
|
|
|
|
var outcome = ChatCommandRouter.Submit(
|
|
input, vm, bus, ChatChannelKind.Fellowship);
|
|
|
|
Assert.Equal(SubmitOutcome.Sent, outcome);
|
|
var command = Assert.IsType<SendServerCommandCmd>(Assert.Single(bus.Published));
|
|
Assert.Equal("@ci 629 5", command.Text);
|
|
}
|
|
|
|
[Fact]
|
|
public void EmptyInput_DoesNothing()
|
|
{
|
|
var (vm, _, bus) = Fixture();
|
|
|
|
var outcome = ChatCommandRouter.Submit(" ", vm, bus, ChatChannelKind.Say);
|
|
|
|
Assert.Equal(SubmitOutcome.Empty, outcome);
|
|
Assert.Empty(bus.Published);
|
|
}
|
|
|
|
// ── Campaign CH slice CH4 (2026-08-09) ──────────────────────────────
|
|
|
|
[Theory]
|
|
[InlineData(":waves")]
|
|
[InlineData(";waves")]
|
|
public void EmotePrefix_RewritesToAtEmote(string raw)
|
|
{
|
|
var (vm, _, bus) = Fixture();
|
|
|
|
var outcome = ChatCommandRouter.Submit(raw, vm, bus, ChatChannelKind.Say);
|
|
|
|
Assert.Equal(SubmitOutcome.ClientHandled, outcome);
|
|
var command = Assert.IsType<ExecuteClientCommandCmd>(Assert.Single(bus.Published));
|
|
Assert.Equal(ClientCommandId.Emote, command.Command);
|
|
Assert.Equal("waves", command.Arguments);
|
|
}
|
|
|
|
[Fact]
|
|
public void UnregisteredChannelTag_PublishesRawChannelBroadcast()
|
|
{
|
|
var (vm, _, bus) = Fixture();
|
|
|
|
var outcome = ChatCommandRouter.Submit("/admin server is misbehaving", vm, bus, ChatChannelKind.Say);
|
|
|
|
Assert.Equal(SubmitOutcome.Sent, outcome);
|
|
var command = Assert.IsType<SendRawChannelCmd>(Assert.Single(bus.Published));
|
|
Assert.Equal(0x00000002u, command.ChannelId);
|
|
Assert.Equal("server is misbehaving", command.Text);
|
|
}
|
|
|
|
[Fact]
|
|
public void UnregisteredChannelTag_WithNoText_PassesThroughToServer()
|
|
{
|
|
// CH4 REJECT-review SHOULD-FIX 3 (2026-08-09): retail's
|
|
// DoChannelCommand @0x005774A7 returns 0 SILENTLY on argc<=0 for an
|
|
// UNREGISTERED tag; DoCommand's own final fallback then sends the
|
|
// raw @-line to the server via Event_Talk. "You must specify the
|
|
// text you wish to say!" belongs to DoStupidChannelHack
|
|
// @0x0057B144, which only runs for REGISTERED channel verbs — it
|
|
// must never appear for one of the 22 unregistered fallback tags.
|
|
var (vm, log, bus) = Fixture();
|
|
|
|
var outcome = ChatCommandRouter.Submit("/sentinel", vm, bus, ChatChannelKind.Say);
|
|
|
|
Assert.Equal(SubmitOutcome.Sent, outcome);
|
|
var command = Assert.IsType<SendServerCommandCmd>(Assert.Single(bus.Published));
|
|
Assert.Equal("@sentinel", command.Text);
|
|
Assert.DoesNotContain(log.Snapshot(), entry => entry.Text.Contains("You must specify the text"));
|
|
}
|
|
|
|
// ── CH4 REJECT-review Blocker 1 (2026-08-09) ────────────────────────
|
|
// "@allegiance <sub>" must never broadcast to the Allegiance channel
|
|
// or reach the server for an unrecognized subcommand — retail's own
|
|
// DoAllegiance claims the entire verb unconditionally and shows its
|
|
// own client-local refusal.
|
|
|
|
[Theory]
|
|
[InlineData("/allegiance boot Bob")]
|
|
[InlineData("/all boot Bob")]
|
|
public void AllegianceUnrecognizedSubcommand_ShowsRetailRefusal_NeverBroadcastsOrSends(string input)
|
|
{
|
|
var (vm, log, bus) = Fixture();
|
|
|
|
var outcome = ChatCommandRouter.Submit(input, vm, bus, ChatChannelKind.Say);
|
|
|
|
Assert.Equal(SubmitOutcome.ClientHandled, outcome);
|
|
Assert.Empty(bus.Published); // no SendRawChannelCmd, no SendServerCommandCmd
|
|
Assert.Contains(log.Snapshot(), entry =>
|
|
entry.Text == "Please see @help Allegiance for more information on how to use this command.");
|
|
}
|
|
|
|
[Fact]
|
|
public void RegisteredChannelVerb_NeverReachesTheRawFallback()
|
|
{
|
|
// "/f" is a KNOWN ChatInputParser verb (Fellowship) — it must ride
|
|
// the normal SendChatCmd/self-echo path, not the raw fallback.
|
|
var (vm, _, bus) = Fixture();
|
|
|
|
var outcome = ChatCommandRouter.Submit("/f hi gang", vm, bus, ChatChannelKind.Say);
|
|
|
|
Assert.Equal(SubmitOutcome.Sent, outcome);
|
|
var command = Assert.IsType<SendChatCmd>(Assert.Single(bus.Published));
|
|
Assert.Equal(ChatChannelKind.Fellowship, command.Channel);
|
|
}
|
|
|
|
[Fact]
|
|
public void HelpVerb_ShowsCatalogHelpText()
|
|
{
|
|
var (vm, log, bus) = Fixture();
|
|
|
|
var outcome = ChatCommandRouter.Submit("/help lifestone", vm, bus, ChatChannelKind.Say);
|
|
|
|
Assert.Equal(SubmitOutcome.ClientHandled, outcome);
|
|
Assert.Empty(bus.Published);
|
|
Assert.Contains(log.Snapshot(), entry => entry.Text.Contains("Returns you to the last lifestone"));
|
|
}
|
|
|
|
// Campaign CH user-gate round 3 (2026-08-10), finding (c): a resolved
|
|
// verb prints retail's DoHelp SHAPE, not just its content — the SAME
|
|
// HelpPrefixNote entry every /help path prints, then a SECOND entry
|
|
// that is ForMoreInformationPrefix concatenated directly onto the
|
|
// verb's own detail text (no blank line, no separate third entry).
|
|
[Theory]
|
|
[InlineData("/help mr", "@mr <text> - Sends the text to the last person who used @m to send you a message. This only works for monarchs.")]
|
|
[InlineData("/help pr", "@pr <text> - Sends the text to the last vassal who used @p to send you a message.")]
|
|
public void HelpVerb_MrPr_ShowsVerbatimRetailText(string input, string expected)
|
|
{
|
|
// CH4 REJECT-review SHOULD-FIX 7 (2026-08-09): these were
|
|
// previously fabricated acdream summaries; now the verbatim retail
|
|
// strings from data_7daa08/data_7daa80 (the double space before
|
|
// "you" is confirmed byte-level, not a typo).
|
|
var (vm, log, bus) = Fixture();
|
|
|
|
var outcome = ChatCommandRouter.Submit(input, vm, bus, ChatChannelKind.Say);
|
|
|
|
Assert.Equal(SubmitOutcome.ClientHandled, outcome);
|
|
var entries = log.Snapshot();
|
|
Assert.Equal(2, entries.Length);
|
|
Assert.Equal(RetailCommandHelpTable.HelpPrefixNote, entries[0].Text);
|
|
Assert.Equal(RetailCommandHelpTable.ForMoreInformationPrefix + expected, entries[1].Text);
|
|
}
|
|
|
|
[Fact]
|
|
public void HelpVerb_UnknownVerb_ShowsRetailUnknownCommandText()
|
|
{
|
|
// Campaign CH user-gate round 3 (2026-08-10): retail's own DoHelp
|
|
// fallback text is "Unknown command" (swept verbatim), not an
|
|
// acdream-invented "No help available" message. Retail types this
|
|
// 0x1A (ClientLocal / SpewBox-only); ChatVM has no SpewBox routing
|
|
// capability yet (ISSUES.md #367), so it still lands in the chat
|
|
// scroll here as ONE entry (no HelpPrefixNote wrapper — DoHelp's
|
|
// fallback bypasses the two-entry shape entirely).
|
|
var (vm, log, bus) = Fixture();
|
|
|
|
var outcome = ChatCommandRouter.Submit("/help nonsenseverb", vm, bus, ChatChannelKind.Say);
|
|
|
|
Assert.Equal(SubmitOutcome.ClientHandled, outcome);
|
|
Assert.Empty(bus.Published);
|
|
var entry = Assert.Single(log.Snapshot());
|
|
Assert.Equal(RetailCommandHelpTable.UnknownCommand, entry.Text);
|
|
}
|
|
|
|
[Fact]
|
|
public void HelpBare_ShowsRetailTwoEntryShape()
|
|
{
|
|
// Campaign CH user-gate round 3 (2026-08-10), finding (b): bare
|
|
// /help must emit retail's real two-entry sequence (Note, then the
|
|
// 13-item "Available help:" listing) — not the previous
|
|
// acdream-invented single-blob cheat sheet.
|
|
var (vm, log, bus) = Fixture();
|
|
|
|
var outcome = ChatCommandRouter.Submit("/help", vm, bus, ChatChannelKind.Say);
|
|
|
|
Assert.Equal(SubmitOutcome.ClientHandled, outcome);
|
|
var entries = log.Snapshot();
|
|
Assert.Equal(2, entries.Length);
|
|
Assert.Equal(RetailCommandHelpTable.HelpPrefixNote, entries[0].Text);
|
|
Assert.Equal(RetailCommandHelpTable.AvailableHelpListing, entries[1].Text);
|
|
}
|
|
}
|