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(ui): address web push review follow-ups

cyh5c20e2646ea0
diff --git a/core/web_push.py b/core/web_push.py
index a26f5c212..bfa9ba11b 100644
--- a/core/web_push.py
+++ b/core/web_push.py
@@ -18,6 +18,7 @@ logger = logging.getLogger(__name__)
_VAPID_FILE = "web_push_vapid.json"
DEFAULT_WEB_PUSH_TIMEOUT_SECONDS = 10.0
+DEFAULT_WEB_PUSH_TTL_SECONDS = 12 * 60 * 60
@dataclass(frozen=True)
@@ -84,6 +85,7 @@ def send_web_push(
vapid_keys: VapidKeys | None = None,
subject: str = "mailto:[email protected]",
timeout: float = DEFAULT_WEB_PUSH_TIMEOUT_SECONDS,
+ ttl: int = DEFAULT_WEB_PUSH_TTL_SECONDS,
) -> None:
"""Send one Web Push payload.
@@ -109,4 +111,5 @@ def send_web_push(
vapid_private_key=vapid_signer,
vapid_claims={"sub": subject},
timeout=timeout,
+ ttl=ttl,
)
diff --git a/tests/test_web_push_service.py b/tests/test_web_push_service.py
index aa9d64ef1..edced0f77 100644
--- a/tests/test_web_push_service.py
+++ b/tests/test_web_push_service.py
@@ -4,7 +4,12 @@ import json
import pytest
-from core.web_push import DEFAULT_WEB_PUSH_TIMEOUT_SECONDS, load_or_create_vapid_keys, send_web_push
+from core.web_push import (
+ DEFAULT_WEB_PUSH_TIMEOUT_SECONDS,
+ DEFAULT_WEB_PUSH_TTL_SECONDS,
+ load_or_create_vapid_keys,
+ send_web_push,
+)
from storage import web_push_service
from storage.db import create_sqlite_engine
from storage.migrations import run_migrations
@@ -95,5 +100,6 @@ def test_send_web_push_passes_vapid_signer_and_timeout(monkeypatch, tmp_path):
assert len(calls) == 1
assert calls[0]["timeout"] == DEFAULT_WEB_PUSH_TIMEOUT_SECONDS
+ assert calls[0]["ttl"] == DEFAULT_WEB_PUSH_TTL_SECONDS
assert not isinstance(calls[0]["vapid_private_key"], str)
assert calls[0]["subscription_info"]["endpoint"] == "https://push.example.test/sub/1"
diff --git a/ui/src/components/workbench/WebPushControl.tsx b/ui/src/components/workbench/WebPushControl.tsx
index c7b298ebe..9d046b9fe 100644
--- a/ui/src/components/workbench/WebPushControl.tsx
+++ b/ui/src/components/workbench/WebPushControl.tsx
@@ -30,8 +30,11 @@ export const WebPushControl: React.FC = () => {
setStatus(nextSupport.reason === 'ios_requires_standalone' ? 'needs_install' : 'unsupported');
return;
}
- const existing = await getExistingWebPushSubscription();
- setStatus(existing ? 'enabled' : 'disabled');
+ const [existing, serverStatus] = await Promise.all([
+ getExistingWebPushSubscription(),
+ api.getWebPushStatus().catch(() => null),
+ ]);
+ setStatus(existing && serverStatus && serverStatus.subscription_count > 0 ? 'enabled' : 'disabled');
};
useEffect(() => {
@@ -43,7 +46,7 @@ export const WebPushControl: React.FC = () => {
setBusy(true);
try {
await enableWebPush(api);
- setStatus('enabled');
+ await refresh();
} catch {
await refresh();
} finally {