fix(chat): CH1 review fixes — sbb-idiom channel catch-all, command-output typing

Applies the Opus review findings on CH1 (172c6f9a), the exact retail chat
color table. Two blockers plus should-fixes/nits, one commit:

BLOCKER 1 — LegacyChannelChatType.Resolve's channel-bit table was wrong.
Binary Ninja renders retail's `neg esi; sbb esi, esi` idiom (a branchless
select between Channel 0x08 and Channel_Send 0x09) as the trivial pseudo-C
`esi - esi` (always 0), hiding the real values. Corrected by decoding the
raw bytes at the PDB-paired binary: HEAR sbb site VA 0x00570F0A (mask -6 ->
0x08), SEND sbb site VA 0x00570D4F (mask -5 -> 0x09). The generic
admin/audit/sentinel catch-all is Channel/Channel_Send, NOT Abuse (0x0E) —
Abuse is retail's ONLY 0x0E producer (bit 0x0001). The unnamed
FellowBroadcast bit (0x4000000) is hear=Channel(0x08)/send=Fellowship(0x13),
not a flat 0x13. ACE's PDB-sourced Channel enum corroborates. Introduces
`RetailLogTextType`, the 34-value named enum for the wire LogTextType space
(values only, no color — Core stays presentation-free).

BLOCKER 2 — three ChatLog.OnSystemMessage sinks (ChatVM.ShowSystemMessage,
LiveSessionRuntimeFactory's ShowSystemMessage delegate,
HeadlessGameplayOperations.DisplayMessage) were typing ALL
ClientCommandController output 0x1A (bright red), including informational
command output (@version, /loc, friends list, usage lines). Retail types
the great majority of that output 0x00 Default (green) and reserves 0x1A
for genuine refusals/errors. Reverted to 0x00 with a comment noting the
refusal-vs-info split lands with CH2's SpewBox producer rewiring. The five
App composition sites that pass 0x1A for actual refusal text
(InteractionRetainedUiComposition, SessionPlayerComposition) were already
correct and are untouched (aside from converting the literal to the new
enum).

Also: AP-176 divergence-register row for OnWeenieError/OnCombatLine's
single-type approximation of retail's per-code/per-message dispatch; a
carry-forward test for the out-of-range LogTextType color fallback in
ChatWindowController; decomp-confirmed anchors replacing ACE-inferred
citations in CombatChatTranslator and ChatLog.OnPlayerKilled; required
(non-optional) logTextType parameters on OnLocalSpeech/OnTellReceived/
OnCombatLine/OnSelfSent since no production caller relied on a default;
LegacyChannelChatType.Resolve's parameter renamed channelBit -> channelId
with a doc note on multi-bit ids; corrections to the color-table research
doc's §3.3 wire tables; and issue #359 for the pre-existing (not
CH1-introduced) 0x019E PlayerKilled participant-suppression gap retail has
and acdream lacks.

dotnet build clean; full Release suite 11,835 passed / 4 skipped / 0 failed
(11,839 total), up from the CH1 baseline of 11,833/4/0.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-09 16:02:59 +02:00
parent e306c979ae
commit 34d8a3c0e7
31 changed files with 481 additions and 213 deletions

View file

@ -18,8 +18,8 @@ public sealed class ChatVMTests
public void RecentLines_ReturnsAllEntries_WhenBelowLimit()
{
var log = new ChatLog();
log.OnLocalSpeech(sender: "Caith", text: "hello", senderGuid: 0x5000_0001u, isRanged: false);
log.OnLocalSpeech(sender: "Regal", text: "world", senderGuid: 0x5000_0002u, isRanged: false);
log.OnLocalSpeech(sender: "Caith", text: "hello", senderGuid: 0x5000_0001u, isRanged: false, logTextType: 0x02u);
log.OnLocalSpeech(sender: "Regal", text: "world", senderGuid: 0x5000_0002u, isRanged: false, logTextType: 0x02u);
var vm = new ChatVM(log, displayLimit: 20);
var lines = vm.RecentLines();
@ -34,7 +34,7 @@ public sealed class ChatVMTests
{
var log = new ChatLog();
for (int i = 0; i < 30; i++)
log.OnLocalSpeech(sender: "A", text: $"msg{i}", senderGuid: 0x5000_0001u, isRanged: false);
log.OnLocalSpeech(sender: "A", text: $"msg{i}", senderGuid: 0x5000_0001u, isRanged: false, logTextType: 0x02u);
var vm = new ChatVM(log, displayLimit: 5);
var lines = vm.RecentLines();
@ -136,24 +136,27 @@ public sealed class ChatVMTests
Assert.Empty(vm.RecentLines());
log.OnLocalSpeech("Caith", "hello", 0x5000_0001u, false);
log.OnLocalSpeech("Caith", "hello", 0x5000_0001u, false, logTextType: 0x02u);
var after = vm.RecentLines();
Assert.Single(after);
Assert.Equal("Caith says, \"hello\"", after[0]);
}
[Fact]
public void ShowSystemMessage_UsesClientLocalLogTextType()
public void ShowSystemMessage_UsesDefaultLogTextType()
{
// Campaign CH slice CH1: client-local command output (/help, /clear,
// /framerate, /loc, ...) never reaches the wire — retail's own
// client-local text is LogTextType 0x1A (bright red).
// Corrected 2026-08-09, Opus review of 172c6f9a: ShowSystemMessage
// is ClientCommandController's general-purpose informational sink
// (/help, /clear, /framerate, /loc, @version, friends list, ...).
// Retail types the great majority of that command output 0x00
// Default (green); 0x1A (bright red) is reserved for genuine
// refusals, which land separately with CH2's SpewBox routing.
var log = new ChatLog();
var vm = new ChatVM(log);
vm.ShowSystemMessage("Unknown command: foo");
var entry = Assert.Single(log.Snapshot());
Assert.Equal(0x1Au, entry.LogTextType);
Assert.Equal(0x00u, entry.LogTextType);
}
}

View file

@ -280,7 +280,7 @@ public sealed class ChatPanelInputTests
{
var log = new ChatLog();
var vm = new ChatVM(log);
log.OnTellReceived("Bestie", "ping", senderGuid: 0x5000_00AAu);
log.OnTellReceived("Bestie", "ping", senderGuid: 0x5000_00AAu, logTextType: 0x03u);
var panel = new ChatPanel(vm);
var bus = new RecordingBus();

View file

@ -99,7 +99,7 @@ public sealed class ChatPanelLayoutTests
Assert.DoesNotContain(renderer.Calls, c => c.Method == "SetScrollHereY");
// Append a new entry, render again — auto-scroll should fire.
log.OnLocalSpeech("Caith", "hello", senderGuid: 0xAA, isRanged: false);
log.OnLocalSpeech("Caith", "hello", senderGuid: 0xAA, isRanged: false, logTextType: 0x02u);
renderer.Calls.Clear();
panel.Render(ctx, renderer);

View file

@ -34,7 +34,7 @@ public sealed class ChatVMCombatTests
var log = new ChatLog();
var vm = new ChatVM(log);
log.OnCombatLine("Mosswart hit you for 8 fire damage to your chest.",
CombatLineKind.Warning);
logTextType: 0x06u, kind: CombatLineKind.Warning);
var lines = vm.RecentLinesDetailed();
var line = Assert.Single(lines);
@ -48,7 +48,7 @@ public sealed class ChatVMCombatTests
{
var log = new ChatLog();
var vm = new ChatVM(log);
log.OnLocalSpeech("Alice", "hi", senderGuid: 0xAA, isRanged: false);
log.OnLocalSpeech("Alice", "hi", senderGuid: 0xAA, isRanged: false, logTextType: 0x02u);
var line = Assert.Single(vm.RecentLinesDetailed());
Assert.Equal(ChatKind.LocalSpeech, line.Kind);
@ -61,9 +61,9 @@ public sealed class ChatVMCombatTests
{
var log = new ChatLog();
var vm = new ChatVM(log);
log.OnLocalSpeech("Alice", "hi", senderGuid: 0xAA, isRanged: false);
log.OnLocalSpeech("Alice", "hi", senderGuid: 0xAA, isRanged: false, logTextType: 0x02u);
log.OnCombatLine("You hit Mosswart for 5 slashing damage (50.0%).",
CombatLineKind.Info);
logTextType: 0x06u, kind: CombatLineKind.Info);
var panel = new ChatPanel(vm);
var bus = new RecordingChatBus();
@ -74,8 +74,9 @@ public sealed class ChatVMCombatTests
// Plain LocalSpeech entry → Text; combat entry → TextColored, now
// sourced from RetailChatColorTable (Campaign CH slice CH1) keyed
// by LogTextType, not ChatPanel.ColorForCombat's severity bucket.
// OnCombatLine's default logTextType (0x06, generic Combat slot,
// colorDarkRed) applies here since no explicit type was passed.
// The 0x06 generic Combat slot (colorDarkRed) is passed explicitly
// above — a registered approximation of retail's per-message
// dispatch (register row AP-176), not a ChatLog default.
Assert.Contains(renderer.Calls, c =>
c.Method == "Text" && (string?)c.Args[0] == "Alice says, \"hi\"");
var coloredCall = Assert.Single(

View file

@ -17,11 +17,11 @@ public sealed class ChatVMLastTellSenderTests
{
var log = new ChatLog();
var vm = new ChatVM(log);
log.OnTellReceived("Before", "ping", 0x5000_0001u);
log.OnTellReceived("Before", "ping", 0x5000_0001u, logTextType: 0x03u);
vm.Dispose();
vm.Dispose();
log.OnTellReceived("After", "pong", 0x5000_0002u);
log.OnTellReceived("After", "pong", 0x5000_0002u, logTextType: 0x03u);
Assert.Equal("Before", vm.LastIncomingTellSender);
}
@ -41,7 +41,7 @@ public sealed class ChatVMLastTellSenderTests
var log = new ChatLog();
var vm = new ChatVM(log);
log.OnTellReceived(sender: "Bestie", text: "ping", senderGuid: 0x5000_00AAu);
log.OnTellReceived(sender: "Bestie", text: "ping", senderGuid: 0x5000_00AAu, logTextType: 0x03u);
Assert.Equal("Bestie", vm.LastIncomingTellSender);
}
@ -52,8 +52,8 @@ public sealed class ChatVMLastTellSenderTests
var log = new ChatLog();
var vm = new ChatVM(log);
log.OnTellReceived("Bestie", "ping", 0x5000_00AAu);
log.OnTellReceived("Regal", "yo", 0x5000_00BBu);
log.OnTellReceived("Bestie", "ping", 0x5000_00AAu, logTextType: 0x03u);
log.OnTellReceived("Regal", "yo", 0x5000_00BBu, logTextType: 0x03u);
Assert.Equal("Regal", vm.LastIncomingTellSender);
}
@ -66,8 +66,8 @@ public sealed class ChatVMLastTellSenderTests
// /r reply echo: SenderGuid = 0 (no real GUID for ourselves).
// Must NOT clobber the captured sender.
log.OnTellReceived("Bestie", "ping", 0x5000_00AAu);
log.OnSelfSent(ChatKind.Tell, "back at you", targetOrChannel: "Bestie");
log.OnTellReceived("Bestie", "ping", 0x5000_00AAu, logTextType: 0x03u);
log.OnSelfSent(ChatKind.Tell, "back at you", logTextType: 0x04u, targetOrChannel: "Bestie");
Assert.Equal("Bestie", vm.LastIncomingTellSender);
}
@ -78,7 +78,7 @@ public sealed class ChatVMLastTellSenderTests
var log = new ChatLog();
var vm = new ChatVM(log);
log.OnLocalSpeech("Caith", "hello", 0x5000_00CCu, isRanged: false);
log.OnLocalSpeech("Caith", "hello", 0x5000_00CCu, isRanged: false, logTextType: 0x02u);
Assert.Null(vm.LastIncomingTellSender);
}

View file

@ -22,7 +22,7 @@ public sealed class ChatVMRetellAndProvidersTests
using var second = new ChatVM(log, commandTargets: targets);
first.Dispose();
log.OnTellReceived("Bestie", "incoming", 0x50000001u);
log.OnTellReceived("Bestie", "incoming", 0x50000001u, logTextType: 0x03u);
Assert.Equal("Bestie", second.LastIncomingTellSender);
}
@ -32,8 +32,8 @@ public sealed class ChatVMRetellAndProvidersTests
{
var log = new ChatLog();
var vm = new ChatVM(log);
log.OnTellReceived("Bestie", "incoming", 0x50000001u);
log.OnSelfSent(ChatKind.Tell, "outgoing", targetOrChannel: "Caith");
log.OnTellReceived("Bestie", "incoming", 0x50000001u, logTextType: 0x03u);
log.OnSelfSent(ChatKind.Tell, "outgoing", logTextType: 0x04u, targetOrChannel: "Caith");
Assert.NotNull(vm.LastIncomingTellSender);
Assert.NotNull(vm.LastOutgoingTellTarget);
@ -58,7 +58,7 @@ public sealed class ChatVMRetellAndProvidersTests
var log = new ChatLog();
var vm = new ChatVM(log);
log.OnSelfSent(ChatKind.Tell, "hi there", targetOrChannel: "Caith");
log.OnSelfSent(ChatKind.Tell, "hi there", logTextType: 0x04u, targetOrChannel: "Caith");
Assert.Equal("Caith", vm.LastOutgoingTellTarget);
// Inbound-tell tracker must NOT pick up an outgoing echo —
@ -72,7 +72,7 @@ public sealed class ChatVMRetellAndProvidersTests
var log = new ChatLog();
var vm = new ChatVM(log);
log.OnTellReceived("Bestie", "psst", senderGuid: 0x5000_0042);
log.OnTellReceived("Bestie", "psst", senderGuid: 0x5000_0042, logTextType: 0x03u);
Assert.Equal("Bestie", vm.LastIncomingTellSender);
Assert.Null(vm.LastOutgoingTellTarget);
@ -84,8 +84,8 @@ public sealed class ChatVMRetellAndProvidersTests
var log = new ChatLog();
var vm = new ChatVM(log);
log.OnSelfSent(ChatKind.Tell, "hi", targetOrChannel: "Caith");
log.OnTellReceived("Bestie", "psst", senderGuid: 0x5000_0042);
log.OnSelfSent(ChatKind.Tell, "hi", logTextType: 0x04u, targetOrChannel: "Caith");
log.OnTellReceived("Bestie", "psst", senderGuid: 0x5000_0042, logTextType: 0x03u);
Assert.Equal("Caith", vm.LastOutgoingTellTarget);
Assert.Equal("Bestie", vm.LastIncomingTellSender);