fix(channels): use Chat SDK ChatMessage.text, not .content

The engage-mode gating added in #1869 read `message.content` from the
Chat SDK's ChatMessage in all three inbound handlers (onSubscribedMessage,
onNewMention, onDirectMessage). ChatMessage exposes the user-visible
string as `.text` — `.content` exists on the underlying nested structure
but isn't the plain-text field. Result: `shouldEngage` always saw an
empty string, pattern gating never matched, non-wildcard regex wirings
silently dropped every inbound.

Fix: use `message.text` in all three gates.

Discovered during live smoke-test on v2 post-merge.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gavrielc
2026-04-20 10:07:50 +03:00
parent a1079da877
commit 9882c94530

View File

@@ -237,7 +237,7 @@ export function createChatSdkBridge(config: ChatSdkBridgeConfig): ChannelAdapter
// plain 'mention' wiring doesn't keep firing after a one-off mention.
chat.onSubscribedMessage(async (thread, message) => {
const channelId = adapter.channelIdFromThreadId(thread.id);
const text = typeof message.content === 'string' ? message.content : '';
const text = typeof message.text === 'string' ? message.text : '';
const decision = shouldEngage(channelId, 'subscribed', text);
if (!decision.engage) return;
await setupConfig.onInbound(channelId, thread.id, await messageToInbound(message));
@@ -247,7 +247,7 @@ export function createChatSdkBridge(config: ChatSdkBridgeConfig): ChannelAdapter
// if the wiring is 'mention-sticky'.
chat.onNewMention(async (thread, message) => {
const channelId = adapter.channelIdFromThreadId(thread.id);
const text = typeof message.content === 'string' ? message.content : '';
const text = typeof message.text === 'string' ? message.text : '';
const decision = shouldEngage(channelId, 'mention', text);
if (!decision.engage) return;
await setupConfig.onInbound(channelId, thread.id, await messageToInbound(message));
@@ -266,7 +266,7 @@ export function createChatSdkBridge(config: ChatSdkBridgeConfig): ChannelAdapter
// escalation).
chat.onDirectMessage(async (thread, message) => {
const channelId = adapter.channelIdFromThreadId(thread.id);
const text = typeof message.content === 'string' ? message.content : '';
const text = typeof message.text === 'string' ? message.text : '';
const decision = shouldEngage(channelId, 'dm', text);
log.info('Inbound DM received', {
adapter: adapter.name,