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(core): parse markdown link quick replies

cyh05a1fac9ca21
diff --git a/core/reply_enhancer.py b/core/reply_enhancer.py
index 49ab28ffd..a6ad560ea 100644
--- a/core/reply_enhancer.py
+++ b/core/reply_enhancer.py
@@ -9,7 +9,7 @@ Extracts special syntaxes from agent reply text:
e.g. ``[screenshot](file:///tmp/shot.png)``
3. **Quick-reply buttons** – A ``---`` separator followed by
- ``[button text]`` or Slack-style ``<url|button text>`` tokens separated by ``|``
+ ``[button text]`` or link-formatted ``[button text](<url>)`` tokens separated by ``|``
e.g. ``---\\n[👌好的] | [✅提交PR] | [先review一下]``
"""
@@ -66,15 +66,15 @@ _FILE_LINK_RE = re.compile(r"(!?)\[([^\]]*)\]\((file://(?:[^()]+|\([^)]*\))+)\)"
# Matches the quick-reply button block at the end of the text.
# A horizontal rule (``---``) on its own line, followed by bracket buttons or
-# Slack-style link buttons separated by ``|`` or full-width ``|``.
+# link-formatted buttons separated by ``|`` or full-width ``|``.
_BUTTON_BLOCK_RE = re.compile(
r"\n-{3,}\s*\n" # --- separator line
- r"((?:\s*(?:\[[^\]]+\]|<[^|>\n]+\|[^>\n]+>)\s*(?:[||]\s*)?)+)" # button tokens
+ r"((?:\s*(?:\[[^\]]+\](?:\(<[^)>\n]+>\)|\([^)>\n]+\))?|<[^|>\n]+\|[^>\n]+>)\s*(?:[||]\s*)?)+)" # button tokens
r"\s*$", # trailing whitespace / end of string
)
-# Individual button tokens: [button text] or Slack-style <url|button text>.
-_BUTTON_TOKEN_RE = re.compile(r"\[([^\]]+)\]|<[^|>\n]+\|([^>\n]+)>")
+# Individual button tokens: [button text], [button text](<url>), or Slack-style <url|button text>.
+_BUTTON_TOKEN_RE = re.compile(r"\[([^\]]+)\](?:\(<[^)>\n]+>\)|\([^)>\n]+\))?|<[^|>\n]+\|([^>\n]+)>")
# Silent output blocks are intentionally simple and model-facing. They are
# stripped before any reply enhancement parsing so hidden text cannot create
diff --git a/tests/test_reply_enhancer_platform.py b/tests/test_reply_enhancer_platform.py
index d6bca698b..61dd23cf5 100644
--- a/tests/test_reply_enhancer_platform.py
+++ b/tests/test_reply_enhancer_platform.py
@@ -126,7 +126,20 @@ class ReplyEnhancerPlatformTests(unittest.IsolatedAsyncioTestCase):
self.assertEqual([file.path for file in reply.files], ["/tmp/report.txt"])
self.assertEqual(reply.buttons, [])
- def test_process_reply_accepts_slack_link_style_quick_reply_button(self):
+ def test_process_reply_accepts_markdown_link_style_quick_reply_button(self):
+ reply = process_reply(
+ "Done.\n\n---\n"
+ "[:eyes: 看 PR](<https://github.com/cyhhao/vibe-remote/pull/298>) | "
+ "[:rocket: 等评审完合并] | [:test_tube: 先回归测一遍]"
+ )
+
+ self.assertEqual(reply.text, "Done.")
+ self.assertEqual(
+ [button.text for button in reply.buttons],
+ [":eyes: 看 PR", ":rocket: 等评审完合并", ":test_tube: 先回归测一遍"],
+ )
+
+ def test_process_reply_accepts_slack_angle_link_style_quick_reply_button(self):
reply = process_reply(
"Done.\n\n---\n"
"<https://github.com/cyhhao/vibe-remote/pull/298|:eyes: 看 PR> | "
@@ -284,7 +297,7 @@ class ReplyEnhancerPlatformTests(unittest.IsolatedAsyncioTestCase):
keyboard = controller.im_client.sent_button_messages[0][3]
self.assertEqual([[button.text for button in row] for row in keyboard.buttons], [["继续"], ["提交PR"]])
- async def test_slack_link_style_quick_reply_dispatches_label_callbacks(self):
+ async def test_markdown_link_style_quick_reply_dispatches_label_callbacks(self):
controller = _StubController("slack")
dispatcher = ConsolidatedMessageDispatcher(controller)
context = MessageContext(user_id="U1", channel_id="C1", platform="slack")
@@ -293,7 +306,7 @@ class ReplyEnhancerPlatformTests(unittest.IsolatedAsyncioTestCase):
context,
"result",
"Done.\n---\n"
- "<https://github.com/cyhhao/vibe-remote/pull/298|:eyes: 看 PR> | "
+ "[:eyes: 看 PR](<https://github.com/cyhhao/vibe-remote/pull/298>) | "
"[:rocket: 等评审完合并]",
)