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(push): send nothing for a Session the owner's Inbox hides (#3136)
Call White3d3541289bfd
diff --git a/core/web_push_notifications.py b/core/web_push_notifications.pyindex f8ee37227..045c66620 100644--- a/core/web_push_notifications.py+++ b/core/web_push_notifications.py@@ -43,6 +43,7 @@ WEB_PUSH_DISPOSITION_NO_SUBSCRIPTION = "no_subscription"WEB_PUSH_DISPOSITION_PROVIDER_FAILURE = "provider_failure"WEB_PUSH_DISPOSITION_SUPPRESSED_READ = "suppressed_read"WEB_PUSH_DISPOSITION_MUTED = "muted"+WEB_PUSH_DISPOSITION_HIDDEN = "hidden"WEB_PUSH_DISPOSITION_CONFIG_UNAVAILABLE = "config_unavailable"@@ -945,6 +946,37 @@ def _filter_project_authorized_user_keys(return authorized+def _owners_hidden_from_session(+ conn: Any,+ *,+ session_id: str | None,+ user_keys: list[str],+ contexts: dict[str, AuthorizationContext],+) -> list[str]:+ """Owners whose Inbox leaves this Session out, so a push would open a conversation they cannot see.++ ``hidden_bot_session_ids`` owns that set, as it does for ``GET /api/inbox`` and the+ event stream: a removed Bot's Session for the Owner, every Bot's for anyone else+ (``docs/plans/bots.md`` D1). Only ids in the Bots' namespace pay for the read. A+ remote owner without a current context is treated as unable to see it.+ """++ from storage.agent_session_rows import is_bot_session_id++ if not session_id or not is_bot_session_id(session_id):+ return []+ from core.bots import hidden_bot_session_ids++ hidden: list[str] = []+ for user_key in user_keys:+ context = None if user_key == "local" else contexts.get(user_key)+ if user_key != "local" and context is None:+ hidden.append(user_key)+ elif session_id in hidden_bot_session_ids(conn, context):+ hidden.append(user_key)+ return hidden++def _badge_count_for_user_key(conn: Any,*,@@ -1109,6 +1141,25 @@ def _send_to_enabled_subscriptions(payload: dict[str, Any]) -> None:"reason": "local fallback with remote access disabled",}+ # A Session hidden from an owner is not a muted category for them: it is not+ # in their Inbox at all, so nothing about it may reach their devices.+ hidden_keys = _owners_hidden_from_session(+ conn,+ session_id=session_id,+ user_keys=authorized_keys,+ contexts=contexts,+ )+ for user_key in hidden_keys:+ attempt["owners"][user_key] = {+ "policy": attempt["owners"].get(user_key, {}).get("policy") or (+ "local" if user_key == "local" else "unknown"+ ),+ "disposition": WEB_PUSH_DISPOSITION_HIDDEN,+ "reason": "the Session is hidden from this owner's Inbox",+ }+ logger.info("web push: skipping owner %s: the Session is hidden from them", user_key)+ authorized_keys = [user_key for user_key in authorized_keys if user_key not in hidden_keys]+from core.notification_categories import category_for_session_id, current_bot_session_idsfrom core.notification_preferences import category_is_loud, get_notification_preferencesdiff --git a/docs/plans/workbench-refinements.md b/docs/plans/workbench-refinements.mdindex 53c5b9b73..415e122f0 100644--- a/docs/plans/workbench-refinements.md+++ b/docs/plans/workbench-refinements.md@@ -188,7 +188,10 @@ it is still delivered, listed, and unread.- Web Push: `_send_to_enabled_subscriptions` drops, after authorization and theProject policy, the owners for whom the message is quiet, recording a new`muted` disposition in the diagnostics ring; `_badge_count_for_user_key`- returns `badge_total`.+ returns `badge_total`. Before that, it drops the owners whose Inbox hides the+ Session (`hidden_bot_session_ids`: a removed Bot's for the Owner, every Bot's+ for anyone else), recording `hidden`: a push must not open a conversation the+ owner cannot see.- Service worker: the badge refresh reads `badge_total`, falling back to`unread_total` for an older server.- Desktop runtime-host: the Dock badge reads `badge_total` (falling back todiff --git a/tests/test_notification_categories.py b/tests/test_notification_categories.pyindex 4dbf105dd..0328e4850 100644--- a/tests/test_notification_categories.py+++ b/tests/test_notification_categories.py@@ -306,6 +306,51 @@ def test_push_gating_records_muted_and_badge_total_excludes_quiet_category(engine.dispose()+def test_push_skips_a_removed_bots_session_and_records_hidden(monkeypatch, isolated_state):+ """A push for a Session the owner's Inbox hides would open a conversation they cannot see (D1)."""+ from core.bots import BotService+ from core import web_push_notifications+ from storage import web_push_service+ from storage.db import create_sqlite_engine++ with BotService() as service:+ service.ensure_main_bot()+ bot = service.create_bot(display_name="Researcher")+ engine = create_sqlite_engine()+ with engine.begin() as conn:+ before = _seed_result(conn, scope_id=None, session_id=bot.session_id, text="Before removal")+ web_push_service.upsert_subscription(+ conn,+ user_key="local",+ payload={+ "endpoint": "https://push.example.test/hidden-bot",+ "keys": {"p256dh": "p256dh", "auth": "auth"},+ },+ )+ sent: list[dict] = []+ monkeypatch.setattr(web_push_notifications.time, "sleep", lambda _seconds: None)+ monkeypatch.setattr("core.web_push.send_web_push", lambda *, subscription, payload: sent.append(payload))++ def push(message: dict) -> dict:+ web_push_notifications._send_to_enabled_subscriptions(+ {"title": "Researcher", "body": message["text"], "session_id": bot.session_id, "message_id": message["id"]}+ )+ return web_push_notifications.recent_delivery_dispositions(user_key="local")[0]["owners"]["local"]++ # Every switch is on: while it is a Bot, its reply is pushed.+ assert push(before)["disposition"] == web_push_notifications.WEB_PUSH_DISPOSITION_SENT+ assert len(sent) == 1++ with BotService() as service:+ service.remove_bot(bot.handle)+ with engine.begin() as conn:+ # An explicit run can still land a reply in the kept Session.+ after = _seed_result(conn, scope_id=None, session_id=bot.session_id, text="After removal")+ assert push(after)["disposition"] == web_push_notifications.WEB_PUSH_DISPOSITION_HIDDEN+ assert len(sent) == 1+ engine.dispose()++def test_service_worker_badge_prefers_badge_total_and_falls_back_to_unread_total():worker = (Path(__file__).resolve().parents[1] / "ui" / "public" / "push-sw.js").read_text()assert "payload?.badge_total ?? payload?.unread_total" in worker