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): bind settings callbacks by name (#1177)

Call White1734b4dd9387
diff --git a/core/handlers/settings_handler.py b/core/handlers/settings_handler.py
index 78d8a93a2..1d0519a3f 100644
--- a/core/handlers/settings_handler.py
+++ b/core/handlers/settings_handler.py
@@ -674,6 +674,7 @@ class SettingsHandler(BaseHandler):
self,
user_id: str,
show_message_types: list,
+ *,
channel_id: Optional[str] = None,
thread_id: Optional[str] = None,
require_mention: Optional[bool] = None,
@@ -752,6 +753,7 @@ class SettingsHandler(BaseHandler):
view_id: str,
view_hash: str,
selection: RoutingModalSelection,
+ *,
thread_id: Optional[str] = None,
is_dm: bool = False,
platform: Optional[str] = None,
@@ -819,6 +821,7 @@ class SettingsHandler(BaseHandler):
backend: str,
opencode_agent: Optional[str],
opencode_model: Optional[str],
+ *,
thread_id: Optional[str] = None,
opencode_reasoning_effort: Optional[str] = None,
claude_agent: Optional[str] = None,
diff --git a/modules/im/discord.py b/modules/im/discord.py
index 179a432ec..6dfc59329 100644
--- a/modules/im/discord.py
+++ b/modules/im/discord.py
@@ -1307,11 +1307,11 @@ class DiscordBot(BaseIMClient):
await save_interaction.response.defer()
if hasattr(self, "_on_settings_update"):
await self._on_settings_update(
- str(save_interaction.user.id),
- show_types,
- channel_id or str(save_interaction.channel_id or ""),
- require_mention,
- language,
+ user_id=str(save_interaction.user.id),
+ show_message_types=show_types,
+ channel_id=channel_id or str(save_interaction.channel_id or ""),
+ require_mention=require_mention,
+ language=language,
notify_user=True,
is_dm=save_interaction.guild is None,
)
@@ -2035,18 +2035,18 @@ class DiscordBot(BaseIMClient):
if hasattr(self.outer, "_on_routing_update"):
await self.outer._on_routing_update(
- str(interaction.user.id),
- channel_id,
- self.selected_backend,
- _normalize(self.oc_agent),
- _normalize(self.oc_model),
- _normalize(self.oc_reasoning),
- _normalize(self.claude_agent),
- _normalize(self.claude_model),
- _normalize(self.claude_reasoning),
- _normalize(self.codex_agent),
- _normalize(self.codex_model),
- _normalize(self.codex_reasoning),
+ user_id=str(interaction.user.id),
+ channel_id=channel_id,
+ backend=self.selected_backend,
+ opencode_agent=_normalize(self.oc_agent),
+ opencode_model=_normalize(self.oc_model),
+ opencode_reasoning_effort=_normalize(self.oc_reasoning),
+ claude_agent=_normalize(self.claude_agent),
+ claude_model=_normalize(self.claude_model),
+ claude_reasoning_effort=_normalize(self.claude_reasoning),
+ codex_agent=_normalize(self.codex_agent),
+ codex_model=_normalize(self.codex_model),
+ codex_reasoning_effort=_normalize(self.codex_reasoning),
notify_user=True,
is_dm=interaction.guild is None,
)
diff --git a/modules/im/feishu.py b/modules/im/feishu.py
index 206d4982c..edd2f4434 100644
--- a/modules/im/feishu.py
+++ b/modules/im/feishu.py
@@ -1968,11 +1968,11 @@ class FeishuBot(BaseIMClient):
if self._on_settings_update:
await self._on_settings_update(
- context.user_id,
- show_message_types,
- context.channel_id,
- require_mention,
- language,
+ user_id=context.user_id,
+ show_message_types=show_message_types,
+ channel_id=context.channel_id,
+ require_mention=require_mention,
+ language=language,
is_dm=context.platform_specific.get("is_dm", False),
)
@@ -2154,18 +2154,18 @@ class FeishuBot(BaseIMClient):
if self._on_routing_update:
await self._on_routing_update(
- context.user_id,
- context.channel_id,
- backend,
- opencode_agent,
- opencode_model,
- opencode_reasoning,
- claude_agent,
- claude_model,
- claude_reasoning,
- codex_agent,
- codex_model,
- codex_reasoning,
+ user_id=context.user_id,
+ channel_id=context.channel_id,
+ backend=backend,
+ opencode_agent=opencode_agent,
+ opencode_model=opencode_model,
+ opencode_reasoning_effort=opencode_reasoning,
+ claude_agent=claude_agent,
+ claude_model=claude_model,
+ claude_reasoning_effort=claude_reasoning,
+ codex_agent=codex_agent,
+ codex_model=codex_model,
+ codex_reasoning_effort=codex_reasoning,
is_dm=context.platform_specific.get("is_dm", False),
)
diff --git a/modules/im/slack.py b/modules/im/slack.py
index aa3d22982..e5aaf88c0 100644
--- a/modules/im/slack.py
+++ b/modules/im/slack.py
@@ -2313,11 +2313,11 @@ class SlackBot(BaseIMClient):
fallback_selected_backend="",
)
await self._on_routing_modal_update(
- user.get("id"),
- effective_channel,
- view.get("id"),
- view.get("hash"),
- selection,
+ user_id=user.get("id"),
+ channel_id=effective_channel,
+ view_id=view.get("id"),
+ view_hash=view.get("hash"),
+ selection=selection,
is_dm=isinstance(effective_channel, str) and effective_channel.startswith("D"),
)
elif action_type == "plain_text_input":
@@ -2374,11 +2374,11 @@ class SlackBot(BaseIMClient):
# Update settings - need access to settings manager
if hasattr(self, "_on_settings_update"):
await self._on_settings_update(
- user_id,
- show_types,
- channel_id,
- require_mention,
- language,
+ user_id=user_id,
+ show_message_types=show_types,
+ channel_id=channel_id,
+ require_mention=require_mention,
+ language=language,
is_dm=isinstance(channel_id, str) and channel_id.startswith("D"),
)
@@ -2605,18 +2605,18 @@ class SlackBot(BaseIMClient):
# Update routing via callback
if hasattr(self, "_on_routing_update"):
await self._on_routing_update(
- user_id,
- channel_id,
- backend,
- oc_agent,
- oc_model,
- oc_reasoning,
- claude_agent,
- claude_model,
- claude_reasoning,
- codex_agent,
- codex_model,
- codex_reasoning,
+ user_id=user_id,
+ channel_id=channel_id,
+ backend=backend,
+ opencode_agent=oc_agent,
+ opencode_model=oc_model,
+ opencode_reasoning_effort=oc_reasoning,
+ claude_agent=claude_agent,
+ claude_model=claude_model,
+ claude_reasoning_effort=claude_reasoning,
+ codex_agent=codex_agent,
+ codex_model=codex_model,
+ codex_reasoning_effort=codex_reasoning,
is_dm=isinstance(channel_id, str) and channel_id.startswith("D"),
)
diff --git a/tests/test_feishu_routing_card.py b/tests/test_feishu_routing_card.py
index 4c7cd431a..08b2f7136 100644
--- a/tests/test_feishu_routing_card.py
+++ b/tests/test_feishu_routing_card.py
@@ -246,16 +246,60 @@ class FeishuRoutingCardTests(unittest.IsolatedAsyncioTestCase):
)
bot._on_routing_update.assert_awaited_once()
- args = bot._on_routing_update.await_args.args
- self.assertEqual(args[3], None)
- self.assertEqual(args[4], None)
- self.assertEqual(args[5], None)
- self.assertEqual(args[6], None)
- self.assertEqual(args[7], None)
- self.assertEqual(args[8], None)
- self.assertEqual(args[9], "reviewer")
- self.assertEqual(args[10], "gpt-5.4")
- self.assertEqual(args[11], "high")
+ call = bot._on_routing_update.await_args
+ self.assertEqual(call.args, ())
+ self.assertEqual(
+ call.kwargs,
+ {
+ "user_id": "user",
+ "channel_id": "chat",
+ "backend": "codex",
+ "opencode_agent": None,
+ "opencode_model": None,
+ "opencode_reasoning_effort": None,
+ "claude_agent": None,
+ "claude_model": None,
+ "claude_reasoning_effort": None,
+ "codex_agent": "reviewer",
+ "codex_model": "gpt-5.4",
+ "codex_reasoning_effort": "high",
+ "is_dm": False,
+ },
+ )
+
+ async def test_settings_submit_binds_optional_fields_by_name(self):
+ bot = self._make_bot()
+ bot._on_settings_update = AsyncMock()
+ context = MessageContext(
+ user_id="user",
+ channel_id="chat",
+ platform="lark",
+ platform_specific={"is_dm": False},
+ )
+
+ await bot._handle_settings_form_submit(
+ context,
+ {
+ "show_message_types": ["assistant"],
+ "require_mention": "false",
+ "language": "zh",
+ },
+ )
+
+ bot._on_settings_update.assert_awaited_once()
+ call = bot._on_settings_update.await_args
+ self.assertEqual(call.args, ())
+ self.assertEqual(
+ call.kwargs,
+ {
+ "user_id": "user",
+ "show_message_types": ["assistant"],
+ "channel_id": "chat",
+ "require_mention": False,
+ "language": "zh",
+ "is_dm": False,
+ },
+ )
async def test_routing_draft_populates_selected_backend_from_current_selection(self):
bot = self._make_bot()