fix: unify mention gating across providers

This commit is contained in:
Peter Steinberger
2026-01-06 01:32:17 +01:00
parent 48d52d13f1
commit 811ec8b78b
10 changed files with 253 additions and 51 deletions

View File

@@ -123,6 +123,51 @@ describe("monitorSlackProvider tool results", () => {
expect(sendMock.mock.calls[1][1]).toBe("PFX final reply");
});
it("accepts channel messages when mentionPatterns match", async () => {
config = {
messages: { responsePrefix: "PFX" },
slack: {
dm: { enabled: true },
groupDm: { enabled: false },
channels: { C1: { allow: true, requireMention: true } },
},
routing: {
allowFrom: [],
groupChat: { mentionPatterns: ["\\bclawd\\b"] },
},
};
replyMock.mockResolvedValue({ text: "hi" });
const controller = new AbortController();
const run = monitorSlackProvider({
botToken: "bot-token",
appToken: "app-token",
abortSignal: controller.signal,
});
await waitForEvent("message");
const handler = getSlackHandlers()?.get("message");
if (!handler) throw new Error("Slack message handler not registered");
await handler({
event: {
type: "message",
user: "U1",
text: "clawd: hello",
ts: "123",
channel: "C1",
channel_type: "channel",
},
});
await flush();
controller.abort();
await run;
expect(replyMock).toHaveBeenCalledTimes(1);
expect(replyMock.mock.calls[0][0].WasMentioned).toBe(true);
});
it("threads replies when incoming message is in a thread", async () => {
replyMock.mockResolvedValue({ text: "thread reply" });