Fix push notifications: focus suppression, empty body, error visibility
- sw.js: suppress notification when the target chat tab is already focused (clients.matchAll visibility check before showNotification) - generation_task.py: provide meaningful body for tool-only responses (lists tool names instead of sending an empty string that browsers discard); promote scheduling failure from debug to warning - push.py: promote send errors from warning to error with exc_info; log successful sends at INFO so they're visible in normal operation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+15
-5
@@ -2,12 +2,22 @@
|
||||
self.addEventListener('push', event => {
|
||||
if (!event.data) return;
|
||||
const data = event.data.json();
|
||||
const notifUrl = data.url || '/';
|
||||
|
||||
event.waitUntil(
|
||||
self.registration.showNotification(data.title || 'Fabled Assistant', {
|
||||
body: data.body || '',
|
||||
icon: '/favicon.ico',
|
||||
badge: '/favicon.ico',
|
||||
data: { url: data.url || '/' },
|
||||
clients.matchAll({ type: 'window', includeUncontrolled: true }).then(clientList => {
|
||||
// Suppress notification if the user already has the relevant page focused
|
||||
for (const client of clientList) {
|
||||
if (client.visibilityState === 'visible' && client.url.includes(notifUrl)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
return self.registration.showNotification(data.title || 'Fabled Assistant', {
|
||||
body: data.body || '',
|
||||
icon: '/favicon.ico',
|
||||
badge: '/favicon.ico',
|
||||
data: { url: notifUrl },
|
||||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user