From dbba8304178d33b204e0255426c3bb6996e111ea Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Wed, 22 Apr 2026 12:34:27 -0700 Subject: [PATCH] fix(hooks): track thread ownership mentions case-insensitively --- extensions/thread-ownership/index.test.ts | 19 +++++++++++++++++++ extensions/thread-ownership/index.ts | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/extensions/thread-ownership/index.test.ts b/extensions/thread-ownership/index.test.ts index c29e7072042..6fcea2897a6 100644 --- a/extensions/thread-ownership/index.test.ts +++ b/extensions/thread-ownership/index.test.ts @@ -306,5 +306,24 @@ describe("thread-ownership plugin", () => { expect(result).toBeUndefined(); expect(globalThis.fetch).not.toHaveBeenCalled(); }); + + it("tracks agent-name mentions case-insensitively", async () => { + await hooks.message_received( + { + content: "hey @testbot help", + threadId: "8888.0002", + metadata: { channelId: "C789" }, + }, + { channelId: "slack", conversationId: "C789" }, + ); + + const result = await hooks.message_sending( + { content: "On it!", replyToId: "8888.0002", metadata: { channelId: "C789" }, to: "C789" }, + { channelId: "slack", conversationId: "C789" }, + ); + + expect(result).toBeUndefined(); + expect(globalThis.fetch).not.toHaveBeenCalled(); + }); }); }); diff --git a/extensions/thread-ownership/index.ts b/extensions/thread-ownership/index.ts index 5b9d9bd71d8..79df6baea13 100644 --- a/extensions/thread-ownership/index.ts +++ b/extensions/thread-ownership/index.ts @@ -91,6 +91,7 @@ export default definePluginEntry({ } const text = event.content ?? ""; + const normalizedText = text.toLowerCase(); const threadTs = resolveThreadToken(event.threadId) || resolveThreadToken(event.metadata?.threadId) || @@ -104,7 +105,7 @@ export default definePluginEntry({ } const mentioned = - (agentName && text.includes(`@${agentName}`)) || + (agentName && normalizedText.includes(`@${agentName.toLowerCase()}`)) || (botUserId && text.includes(`<@${botUserId}>`)); if (mentioned) { cleanExpiredMentions();