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(update): avoid grace period after failed notifications
cyhf38f6c6c555b
diff --git a/core/update_checker.py b/core/update_checker.pyindex 3e22b72ef..9f2339083 100644--- a/core/update_checker.py+++ b/core/update_checker.py@@ -238,14 +238,19 @@ class UpdateChecker:# Notification flow — failure must not block auto-updateif self.config.notify_admins and self.state.notified_version != latest:+ delivered = Falsetry:- await self._send_update_notification(current, latest)- # Only record delivery time on success — grace period depends on this- self.state.notified_at = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())+ delivered = await self._send_update_notification(current, latest)except Exception as e:logger.error(f"Failed to send update notification: {e}", exc_info=True)- # Always mark version to prevent retry every cycle (even if send failed)- self.state.notified_version = latest+ if delivered:+ self.state.notified_version = latest+ self.state.notified_at = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())+ else:+ logger.warning(+ "Update notification for %s was not delivered; skipping grace period",+ latest,+ )self.state.save()# Auto-update flow — respect a grace period after successful notification@@ -426,25 +431,27 @@ class UpdateChecker:return None- async def _send_update_notification(self, current: str, latest: str) -> None:+ async def _send_update_notification(self, current: str, latest: str) -> bool:"""Send update notification to admin users, with platform-specific fallbacks."""platform = getattr(self.controller.config, "platform", "slack")admin_ids = self._get_admin_user_ids()if admin_ids:# Send DM to each admin via the platform-agnostic send_dm method- await self._send_notification_to_admins(admin_ids, current, latest, platform)+ return await self._send_notification_to_admins(admin_ids, current, latest, platform)else:# Legacy fallback: no admins configuredif platform == "slack":- await self._send_slack_notification_legacy(current, latest)+ return await self._send_slack_notification_legacy(current, latest)elif platform == "discord":- await self._send_discord_notification_fallback(current, latest)+ return await self._send_discord_notification_fallback(current, latest)else:logger.warning("Update notification skipped: no admins and unsupported platform %s", platform)+ return False- async def _send_notification_to_admins(self, admin_ids: list, current: str, latest: str, platform: str) -> None:+ async def _send_notification_to_admins(self, admin_ids: list, current: str, latest: str, platform: str) -> bool:"""Send update notification DM to each admin user."""+ delivered = Falsefor uid in admin_ids:im_client, raw_user_id, user_platform = self._get_im_client_for_user(uid)try:@@ -482,11 +489,13 @@ class UpdateChecker:result = await im_client.send_dm(raw_user_id, text, **kwargs)if result:+ delivered = Truelogger.info(f"Sent update notification to admin {uid}")else:logger.warning(f"Failed to send update notification to admin {uid}: send_dm returned None")except Exception as e:logger.error(f"Failed to send update notification to admin {uid}: {e}")+ return delivereddef _supports_admin_update_button(self, platform: str) -> bool:"""Return whether admin update DMs should include an update button."""@@ -502,18 +511,18 @@ class UpdateChecker:return f"🚀 Vibe Remote Update Available\n\nUpdate from `{current}` → `{latest}`"return f"🚀 Vibe Remote Update Available\n\nUpdate from {current} → {latest}"- async def _send_slack_notification_legacy(self, current: str, latest: str) -> None:+ async def _send_slack_notification_legacy(self, current: str, latest: str) -> bool:"""Legacy Slack notification: send to workspace owner when no admins configured."""owner_id = await self._get_workspace_owner_id()if not owner_id:logger.warning("Cannot send update notification: no admins and no workspace owner found")- return+ return False# Open DM channel first (required for sending messages to users)dm_channel = await self._open_dm_channel(owner_id)if not dm_channel:logger.warning(f"Cannot send update notification: failed to open DM with {owner_id}")- return+ return Falsetry:im_client = self._get_im_client_for_platform("slack")@@ -544,15 +553,17 @@ class UpdateChecker:channel=dm_channel, text=f"Vibe Remote update available: {current} → {latest}", blocks=blocks)logger.info(f"Sent update notification to workspace owner {owner_id}")+ return Trueexcept Exception as e:logger.error(f"Failed to send update notification: {e}")+ return False- async def _send_discord_notification_fallback(self, current: str, latest: str) -> None:+ async def _send_discord_notification_fallback(self, current: str, latest: str) -> bool:"""Fallback Discord notification: send to first enabled channel when no admins configured."""channel_id = self._get_default_notification_channel_id()if not channel_id:logger.warning("Cannot send update notification: no admins and no enabled channel found")- return+ return Falsetry:from modules.im import InlineButton, InlineKeyboard, MessageContext@@ -561,12 +572,14 @@ class UpdateChecker:buttons=[[InlineButton(text="Update Now", callback_data=f"vibe_update_now:{latest}")]])context = MessageContext(user_id="system", channel_id=channel_id, platform="discord")- await self.controller.get_im_client_for_context(context).send_message_with_buttons(+ message_id = await self.controller.get_im_client_for_context(context).send_message_with_buttons(context, text, keyboard, parse_mode="markdown")logger.info("Sent update notification to Discord channel %s", channel_id)+ return bool(message_id)except Exception as e:logger.error(f"Failed to send Discord update notification: {e}")+ return Falsedef _get_default_notification_channel_id(self) -> Optional[str]:if not hasattr(self.controller, "settings_manager"):diff --git a/tests/test_update_checker_platforms.py b/tests/test_update_checker_platforms.pyindex cb36f2d28..744fb2cd2 100644--- a/tests/test_update_checker_platforms.py+++ b/tests/test_update_checker_platforms.py@@ -3,6 +3,7 @@ from __future__ import annotationsimport asyncioimport jsonimport sys+import timefrom pathlib import Pathfrom unittest.mock import patch@@ -72,8 +73,9 @@ def test_update_notification_admin_dms_include_buttons_except_wechat(monkeypatchcontroller.im_client = clients["slack"]checker = UpdateChecker(controller, UpdateConfig())- asyncio.run(checker._send_update_notification("1.0.0", "1.0.1"))+ delivered = asyncio.run(checker._send_update_notification("1.0.0", "1.0.1"))+ assert delivered is Trueslack_kwargs = clients["slack"].dm_calls[0][2]assert slack_kwargs["blocks"][1]["elements"][0]["action_id"] == "vibe_update_now"assert slack_kwargs["blocks"][1]["elements"][0]["value"] == "1.0.1"@@ -87,6 +89,58 @@ def test_update_notification_admin_dms_include_buttons_except_wechat(monkeypatchassert "keyboard" not in clients["wechat"].dm_calls[0][2]+def test_update_notification_returns_false_when_all_admin_dms_fail(monkeypatch, tmp_path):+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))+ SettingsStore.reset_instance()+ store = SettingsStore.get_instance()+ store.set_users_for_platform("discord", {"123456789012345678": UserSettings(display_name="Discord", is_admin=True)})+ store.set_users_for_platform("telegram", {"123456": UserSettings(display_name="Telegram", is_admin=True)})+ store.save()++ controller = _StubController(store)+ controller.im_clients = {+ "discord": _FakeIMClient(message_id=None),+ "telegram": _FakeIMClient(message_id=None),+ }+ checker = UpdateChecker(controller, UpdateConfig())++ delivered = asyncio.run(checker._send_update_notification("1.0.0", "1.0.1"))++ assert delivered is False+++def test_failed_update_notification_does_not_defer_idle_auto_update(monkeypatch, tmp_path):+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))+ SettingsStore.reset_instance()+ store = SettingsStore.get_instance()+ store.set_users_for_platform("discord", {"123456789012345678": UserSettings(display_name="Discord", is_admin=True)})+ store.save()++ controller = _StubController(store)+ controller.im_clients = {"discord": _FakeIMClient(message_id=None)}+ checker = UpdateChecker(controller, UpdateConfig(check_interval_minutes=1, notify_admins=True, auto_update=True))+ checker.state.last_activity_at = time.time() - 3600+ monkeypatch.setattr(+ update_checker,+ "_fetch_pypi_version_sync",+ lambda: {"current": "1.0.0", "latest": "1.0.1", "has_update": True, "error": None},+ )+ monkeypatch.setattr(checker, "_is_idle", lambda: True)+ performed = []++ async def fake_perform_update(target_version, **kwargs):+ performed.append((target_version, kwargs))+ return {"ok": True, "restarting": False, "message": "ok"}++ monkeypatch.setattr(checker, "_perform_update", fake_perform_update)++ asyncio.run(checker._do_check())++ assert checker.state.notified_version is None+ assert checker.state.notified_at is None+ assert performed == [("1.0.1", {})]++def test_update_marker_records_platform_for_non_slack_callbacks(monkeypatch, tmp_path):monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))SettingsStore.reset_instance()