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): keep shared content and own app guard

cyh660e8f1bdbdb
diff --git a/core/handlers/message_handler.py b/core/handlers/message_handler.py
index 577c00e92..1d0d43384 100644
--- a/core/handlers/message_handler.py
+++ b/core/handlers/message_handler.py
@@ -135,7 +135,7 @@ class MessageHandler(BaseHandler):
# If message is empty AND no files attached (e.g., user just @mentioned bot without text),
# trigger the /start command instead of sending empty message to agent
has_files = bool(context.files)
- if (not control_message or not control_message.strip()) and not has_files:
+ if (not message or not message.strip()) and not has_files:
if is_human:
await self.controller.command_handler.handle_start(context, "")
return None
diff --git a/modules/im/slack.py b/modules/im/slack.py
index 13122d933..c70f8dcd5 100644
--- a/modules/im/slack.py
+++ b/modules/im/slack.py
@@ -358,6 +358,8 @@ class SlackBot(BaseIMClient):
if bot_user_id and bot_profile.get("user_id") == bot_user_id:
return True
config_app_id = getattr(self.config, "app_id", None)
+ if config_app_id and event.get("app_id") == config_app_id:
+ return True
return bool(config_app_id and bot_profile.get("app_id") == config_app_id)
@staticmethod
diff --git a/tests/test_message_handler_typing.py b/tests/test_message_handler_typing.py
index 85516a128..d8e9ef4f4 100644
--- a/tests/test_message_handler_typing.py
+++ b/tests/test_message_handler_typing.py
@@ -342,6 +342,25 @@ class MessageHandlerTypingTests(unittest.IsolatedAsyncioTestCase):
self.assertEqual(len(controller.agent_service.stop_requests), 1)
self.assertEqual(controller.agent_service.requests, [])
+ async def test_empty_fallback_uses_agent_message_not_control_text(self):
+ controller = _StubController(platform="slack", ack_mode="reaction", typing_result=True)
+ controller.command_handler.handle_start = AsyncMock()
+ handler = MessageHandler(controller)
+ handler.set_session_handler(_StubSessionHandler())
+ context = MessageContext(
+ user_id="U1",
+ channel_id="C1",
+ message_id="m1",
+ platform="slack",
+ platform_specific={"bot_mention": "<@U_BOT>", "control_text": ""},
+ )
+
+ await handler.handle_user_message(context, "<@U_BOT>\n\nshared content")
+
+ controller.command_handler.handle_start.assert_not_awaited()
+ _, request = controller.agent_service.requests[0]
+ self.assertIn("shared content", request.message)
+
async def test_control_text_routes_mentioned_subagent_prefix(self):
controller = _StubController(platform="slack", ack_mode="reaction", typing_result=True)
handler = MessageHandler(controller)
diff --git a/tests/test_slack_dm_mentions.py b/tests/test_slack_dm_mentions.py
index b16aa812f..b107982b5 100644
--- a/tests/test_slack_dm_mentions.py
+++ b/tests/test_slack_dm_mentions.py
@@ -922,6 +922,33 @@ class SlackDmMentionTests(unittest.IsolatedAsyncioTestCase):
self.assertFalse(received["called"])
+ async def test_own_bot_message_with_top_level_app_id_is_ignored(self):
+ slack = SlackBot(SlackConfig(bot_token="xoxb-test", app_id="A_SELF"))
+ received = {"called": False}
+
+ async def _on_message(_context, _text):
+ received["called"] = True
+
+ slack.register_callbacks(on_message=_on_message)
+
+ payload = {
+ "event_id": "evt-own-bot-top-level-app",
+ "team_id": "T1",
+ "authorizations": [{"user_id": "U_BOT"}],
+ "event": {
+ "type": "message",
+ "channel": "C_CONNECT",
+ "bot_id": "B_SELF",
+ "app_id": "A_SELF",
+ "text": "<@U_BOT> loop",
+ "ts": "1710000000.000358",
+ },
+ }
+
+ await slack._handle_event(payload)
+
+ self.assertFalse(received["called"])
+
async def test_slack_connect_channel_mention_marks_thread_active(self):
slack = SlackBot(SlackConfig(bot_token="xoxb-test", require_mention=True))
marked = []