Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(slack): preserve existing angle link tokens

cyh3637e51496b2
diff --git a/modules/im/slack.py b/modules/im/slack.py
index 8e4ea086d..78b2ea987 100644
--- a/modules/im/slack.py
+++ b/modules/im/slack.py
@@ -44,7 +44,6 @@ _UNSET = object()
_SLACK_SECTION_TEXT_LIMIT = 3000
_BARE_HTTP_URL_RE = re.compile(r"https?://[^\s<>\|]+")
_TRAILING_URL_PUNCTUATION = ".,!?;:"
-_SLACK_TOKEN_PREFIXES = ("http://", "https://", "@", "#", "!", "!date^")
class SlackBot(BaseIMClient):
@@ -549,13 +548,16 @@ class SlackBot(BaseIMClient):
return text
def _linkify_segment(segment: str) -> str:
+ token_ranges = [
+ (match.start(), match.end())
+ for match in re.finditer(r"<[^<>\s][^<>]*>", segment)
+ ]
+
def _replace(match: re.Match) -> str:
url = match.group(0)
start = match.start()
end = match.end()
- last_lt = segment.rfind("<", 0, start)
- last_gt = segment.rfind(">", 0, start)
- if last_lt > last_gt and segment[last_lt + 1 :].startswith(_SLACK_TOKEN_PREFIXES):
+ if any(token_start < start < token_end for token_start, token_end in token_ranges):
return url
trailing = ""
diff --git a/tests/test_slack_dm_mentions.py b/tests/test_slack_dm_mentions.py
index cfff7c080..d2c25de08 100644
--- a/tests/test_slack_dm_mentions.py
+++ b/tests/test_slack_dm_mentions.py
@@ -242,6 +242,7 @@ class SlackDmMentionTests(unittest.IsolatedAsyncioTestCase):
text = (
"Open https://example.com/path?a=1&b=2.\n"
"Existing <https://example.org|Example>.\n"
+ "Mail <mailto:[email protected]|Visit https://status.example.com now>.\n"
"Date <!date^1392734382^{date_short}^https://date.example/|Feb 18>.\n"
"Comparison 1 < 2 https://compare.example.\n"
"Inline `https://code.example`.\n"
@@ -253,6 +254,7 @@ class SlackDmMentionTests(unittest.IsolatedAsyncioTestCase):
block_text = sent_payloads[0]["blocks"][0]["text"]["text"]
self.assertIn("<https://example.com/path?a=1&b=2>.", block_text)
self.assertIn("<https://example.org|Example>", block_text)
+ self.assertIn("<mailto:[email protected]|Visit https://status.example.com now>", block_text)
self.assertIn("<!date^1392734382^{date_short}^https://date.example/|Feb 18>", block_text)
self.assertIn("Comparison 1 < 2 <https://compare.example>.", block_text)
self.assertIn("`https://code.example`", block_text)