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.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(wechat): retry pending bind hint after send failure
cyh2a5035fe2849
diff --git a/modules/im/wechat.py b/modules/im/wechat.pyindex 4ac1f4c93..845b3de84 100644--- a/modules/im/wechat.py+++ b/modules/im/wechat.py@@ -1214,35 +1214,50 @@ class WeChatBot(BaseIMClient):except Exception:logger.exception("WeChat message callback task failed")- def _consume_pending_bind_menu_hint(self, user_id: str) -> bool:+ def _get_pending_bind_menu_hint_user(self, user_id: str) -> Any:manager = self.settings_managerif manager is None:- return False+ return Nonestore_getter = getattr(manager, "get_store", None)if not callable(store_getter):- return False+ return Nonetry:store = store_getter()user = store.get_user(user_id, platform="wechat")if user is None or not user.pending_bind_menu_hint:- return False+ return None+ return user+ except Exception as exc:+ logger.warning("Failed to read WeChat bind menu hint for %s: %s", user_id, exc)+ return None++ def _clear_pending_bind_menu_hint(self, user_id: str, user: Any) -> None:+ manager = self.settings_manager+ if manager is None:+ return+ store_getter = getattr(manager, "get_store", None)+ if not callable(store_getter):+ return+ try:+ store = store_getter()user.pending_bind_menu_hint = Falsestore.update_user(user_id, user, platform="wechat")manager_reload = getattr(manager, "_reload_if_changed", None)if callable(manager_reload):manager_reload()- return Trueexcept Exception as exc:- logger.warning("Failed to consume WeChat bind menu hint for %s: %s", user_id, exc)- return False+ logger.warning("Failed to clear WeChat bind menu hint for %s: %s", user_id, exc)async def _send_bind_menu_hint_if_pending(self, context: MessageContext) -> None:- if not self._consume_pending_bind_menu_hint(context.user_id):+ user = self._get_pending_bind_menu_hint_user(context.user_id)+ if user is None:returntry:await self.send_message(context, self._t("bind.menuHintStart", context.channel_id))except Exception as exc:logger.warning("Failed to send WeChat bind menu hint to %s: %s", context.user_id, exc)+ return+ self._clear_pending_bind_menu_hint(context.user_id, user)async def _process_inbound_message(self, msg: dict) -> None:"""Convert an iLink message to MessageContext and dispatch."""diff --git a/tests/test_wechat_bot.py b/tests/test_wechat_bot.pyindex ab2414b31..b62f1664a 100644--- a/tests/test_wechat_bot.py+++ b/tests/test_wechat_bot.py@@ -358,6 +358,46 @@ class WeChatBotTests(unittest.IsolatedAsyncioTestCase):bot.dispatch_text_command.assert_awaited_once()bot.on_message_callback.assert_not_called()+ async def test_process_inbound_message_keeps_pending_bind_menu_hint_after_send_failure(self):+ SettingsStore.reset_instance()+ store = SettingsStore.get_instance()+ store.set_users_for_platform(+ "wechat",+ {+ "user-1": UserSettings(+ display_name="WeChat User",+ enabled=True,+ pending_bind_menu_hint=True,+ )+ },+ )+ store.save()++ bot = self._make_bot()+ bot.set_settings_manager(SettingsManager(platform="wechat"))+ bot.check_authorization = lambda **kwargs: AuthResult(allowed=True, is_dm=True)+ bot.dispatch_text_command = AsyncMock(return_value=False)+ bot._process_media_items = AsyncMock(return_value=None)+ bot.on_message_callback = AsyncMock()+ bot.send_message = AsyncMock(side_effect=RuntimeError("temporary send failure"))++ msg = {+ "message_id": "mid-hint-fail",+ "from_user_id": "user-1",+ "context_token": "ctx-1",+ "item_list": [{"type": 1, "text_item": {"text": "hi"}}],+ }++ await bot._process_inbound_message(msg)+ await asyncio.gather(*tuple(bot._message_callback_tasks))++ bot.send_message.assert_awaited_once()+ bot.on_message_callback.assert_awaited_once()+ self.assertEqual(bot.on_message_callback.await_args.args[1], "hi") # type: ignore[union-attr]+ user = SettingsStore.get_instance().get_user("user-1", platform="wechat")+ self.assertIsNotNone(user)+ self.assertTrue(user.pending_bind_menu_hint) # type: ignore[union-attr]+async def test_process_inbound_message_persists_context_token(self):with tempfile.TemporaryDirectory() as tmpdir:with patch.dict("os.environ", {"VIBE_REMOTE_HOME": tmpdir}):