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:
@@ -358,9 +358,18 @@ async def run_generation(
|
||||
try:
|
||||
from fabledassistant.services.push import send_push_notification, vapid_enabled
|
||||
if vapid_enabled():
|
||||
preview = buf.content_so_far[:120].rstrip()
|
||||
if len(buf.content_so_far) > 120:
|
||||
preview += "…"
|
||||
text = buf.content_so_far.strip()
|
||||
if text:
|
||||
preview = text[:120].rstrip()
|
||||
if len(text) > 120:
|
||||
preview += "…"
|
||||
else:
|
||||
# Tool-only response — summarise what was done
|
||||
tool_names = [tc.get("function") for tc in all_tool_calls if tc.get("function")]
|
||||
if tool_names:
|
||||
preview = f"Completed: {', '.join(tool_names[:3])}"
|
||||
else:
|
||||
preview = "Action completed"
|
||||
asyncio.create_task(send_push_notification(
|
||||
user_id,
|
||||
title="Response ready",
|
||||
@@ -368,7 +377,7 @@ async def run_generation(
|
||||
url=f"/chat/{conv_id}",
|
||||
))
|
||||
except Exception:
|
||||
logger.debug("Failed to schedule push notification", exc_info=True)
|
||||
logger.warning("Failed to schedule push notification", exc_info=True)
|
||||
|
||||
# Title generation is non-critical — fire-and-forget so done fires immediately
|
||||
non_system = [m for m in messages if m["role"] != "system"]
|
||||
|
||||
Reference in New Issue
Block a user