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:
2026-03-09 22:12:20 -04:00
parent 059a2e06d5
commit 690270519f
3 changed files with 35 additions and 13 deletions
+7 -4
View File
@@ -190,7 +190,7 @@ async def send_push_notification(
)
return response.status_code, sub.endpoint
except Exception as e:
logger.warning("Push send failed for sub %d: %s", sub.id, e)
logger.error("Push send failed for sub %d: %s", sub.id, e, exc_info=True)
return 0, sub.endpoint
loop = asyncio.get_event_loop()
@@ -199,9 +199,12 @@ async def send_push_notification(
for sub, result in zip(subscriptions, results):
if isinstance(result, Exception):
logger.error("Push gather exception for user %d: %s", user_id, result, exc_info=result)
continue
status_code, endpoint = result
if status_code == 410:
if status_code in (200, 201):
logger.info("Push notification sent to sub %d (status %d)", sub.id, status_code)
elif status_code == 410:
asyncio.create_task(_remove_expired_subscription(user_id, endpoint))
elif status_code and status_code not in (200, 201):
logger.warning("Push returned status %d for user %d", status_code, user_id)
elif status_code:
logger.error("Push returned unexpected status %d for user %d sub %d", status_code, user_id, sub.id)