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(im): delegate question modals through multi client

cyh334b70042f45
diff --git a/modules/im/multi.py b/modules/im/multi.py
index f74d4db71..e7d06629f 100644
--- a/modules/im/multi.py
+++ b/modules/im/multi.py
@@ -383,6 +383,20 @@ class MultiIMClient(BaseIMClient):
async def dismiss_form_message(self, context: MessageContext) -> None:
await self.get_client_for_context(context).dismiss_form_message(context)
+ async def open_question_modal(
+ self,
+ trigger_id: Any,
+ context: MessageContext,
+ pending: Any,
+ callback_prefix: str = "claude_question",
+ ):
+ return await self.get_client_for_context(context).open_question_modal(
+ trigger_id=trigger_id,
+ context=context,
+ pending=pending,
+ callback_prefix=callback_prefix,
+ )
+
async def answer_callback(self, callback_id: str, text: Optional[str] = None, show_alert: bool = False) -> bool:
return await self.clients[self.primary_platform].answer_callback(callback_id, text=text, show_alert=show_alert)
diff --git a/tests/test_multi_platform_runtime.py b/tests/test_multi_platform_runtime.py
index d97edd0f9..71ee901a2 100644
--- a/tests/test_multi_platform_runtime.py
+++ b/tests/test_multi_platform_runtime.py
@@ -36,6 +36,7 @@ class _StubClient(BaseIMClient):
self.sent = []
self.removed = []
self.dismissed = []
+ self.question_modals = []
self.stopped = False
async def send_message(self, context, text, parse_mode=None, reply_to=None):
@@ -58,6 +59,10 @@ class _StubClient(BaseIMClient):
async def dismiss_form_message(self, context):
self.dismissed.append((context.platform, context.message_id))
+ async def open_question_modal(self, trigger_id, context, pending, callback_prefix="claude_question"):
+ self.question_modals.append((trigger_id, context.platform, pending, callback_prefix))
+ return self.name
+
async def answer_callback(self, callback_id, text=None, show_alert=False):
return True
@@ -154,6 +159,28 @@ def test_multi_im_client_routes_send_by_context_platform():
assert wechat.sent == [("wechat", "c", "hello")]
+def test_multi_im_client_delegates_question_modal_by_context_platform():
+ slack = _StubClient("slack")
+ discord = _StubClient("discord")
+ client = MultiIMClient({"slack": slack, "discord": discord}, primary_platform="slack")
+ context = MessageContext(user_id="u", channel_id="c", platform="discord")
+ pending = {"questions": [{"header": "H", "question": "Q", "options": ["A"]}]}
+
+ assert hasattr(client, "open_question_modal")
+ result = asyncio.run(
+ client.open_question_modal(
+ trigger_id="trigger-1",
+ context=context,
+ pending=pending,
+ callback_prefix="test_question",
+ )
+ )
+
+ assert result == "discord"
+ assert slack.question_modals == []
+ assert discord.question_modals == [("trigger-1", "discord", pending, "test_question")]
+
+
def test_multi_im_client_add_client_registers_callbacks_before_start():
client = MultiIMClient({}, primary_platform="avibe")
added = _StubClient("slack")