The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(slack): strip mention labels before emphasis parsing in rich_text
Teknium67bce8c25dfd
diff --git a/plugins/platforms/slack/block_kit.py b/plugins/platforms/slack/block_kit.pyindex 83bcce8169a..25a3d04e37f 100644--- a/plugins/platforms/slack/block_kit.py+++ b/plugins/platforms/slack/block_kit.py@@ -151,6 +151,9 @@ def _inline_elements(text: str) -> list[dict[str, Any]]:def _walk_slack_links(s: str, style: dict[str, bool]) -> None:# rich_text does not interpret mrkdwn. Agents often emit <url|label># (works in section/mrkdwn; was literal in lists/quotes/table cells).+ # Mention labels are dropped from the element anyway; strip them first+ # so a label like |dev_ops_alerts is not split by the italic regex.+ s = _SLACK_MENTION_RE.sub(lambda m: f"<{m.group(1)}>", s)pos = 0for m in _SLACK_LINK_RE.finditer(s):_walk_emphasis(s[pos : m.start()], style)diff --git a/tests/gateway/test_slack_block_kit.py b/tests/gateway/test_slack_block_kit.pyindex c87412a94de..93ca99b93b0 100644--- a/tests/gateway/test_slack_block_kit.py+++ b/tests/gateway/test_slack_block_kit.py@@ -128,6 +128,15 @@ class TestSlackMentions:assert {"type": "usergroup", "usergroup_id": "S987XYZ"} in elsassert not any("marketing" in (e.get("text") or "") for e in els)+ def test_mention_label_with_underscores_is_not_split_by_italic(self):+ blocks = render_blocks("- see <#C1|dev_ops_alerts> and <!subteam^S1|@eng_team_x>")+ assert blocks is not None+ els = self._item_elements(blocks)+ assert {"type": "channel", "channel_id": "C1"} in els+ assert {"type": "usergroup", "usergroup_id": "S1"} in els+ assert not any(e.get("style") for e in els)+ assert not any("<" in (e.get("text") or "") for e in els)+def test_mention_in_quote_becomes_mention_element(self):blocks = render_blocks("> ping <@U123> now")assert blocks is not None