From f1e1728755e6a14e7541731a4e3998555f30d659 Mon Sep 17 00:00:00 2001 From: annguyenNous Date: Thu, 25 Jun 2026 14:48:27 +0700 Subject: [PATCH] fix(slack): check Block Kit blocks for @mentions, not just flat text Mention detection only checked the flat field for @mentions. Block Kit messages that have the @mention only in (e.g. rich_text sections with user elements) were silently dropped. Extract text from blocks and include it in the mention check so @mentions in Block Kit blocks are properly detected. Fixes #52387 --- plugins/platforms/slack/adapter.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/platforms/slack/adapter.py b/plugins/platforms/slack/adapter.py index 5ef300b086f3c..7e4316ef8595a 100644 --- a/plugins/platforms/slack/adapter.py +++ b/plugins/platforms/slack/adapter.py @@ -2578,10 +2578,15 @@ async def _handle_slack_message(self, event: dict) -> None: # 3. The message is in a thread where the bot was previously @mentioned, OR # 4. There's an existing session for this thread (survives restarts) bot_uid = self._team_bot_user_ids.get(team_id, self._bot_user_id) - routing_text = original_text or "" + # Check both flat text and blocks text for mentions — Block Kit + # messages may have the @mention only in blocks, not in the flat + # text field (#52387). + blocks = event.get("blocks") + blocks_text = _extract_text_from_slack_blocks(blocks) if blocks else "" + mention_text = (original_text or "") + ("\n" + blocks_text if blocks_text else "") is_mentioned = bool( - (bot_uid and f"<@{bot_uid}>" in routing_text) - or self._slack_message_matches_mention_patterns(routing_text) + (bot_uid and f"<@{bot_uid}>" in mention_text) + or self._slack_message_matches_mention_patterns(mention_text) ) event_thread_ts = event.get("thread_ts") is_thread_reply = bool(event_thread_ts and event_thread_ts != ts)