feat(project): blinking popup for new mentions and task assignments

Project pages poll GET /api/notifications/alerts every 20s (and when the
tab becomes visible). New unread mention/assigned notifications show in a
large blinking popup at the bottom center until closed; closing in one tab
closes it in the others. A new browser starts from the latest id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-07 17:30:15 +09:00
parent 4bdab1de3d
commit 21fc78adb9
5 changed files with 206 additions and 0 deletions
+20
View File
@@ -2292,6 +2292,26 @@ def api_notifications(request: Request) -> JSONResponse:
return JSONResponse({"notifications": items, "unread": _notification_unread(st, user)})
@router.get("/api/notifications/alerts")
def api_notification_alerts(request: Request, after: int = -1) -> JSONResponse:
"""화면 가운데 아래 큰 팝업용(2026-10-07) — 나를 태그(mention)하거나 작업을 배정(assigned)한, 읽지 않은 알림 중
id 가 after 보다 큰 것(오래된 것부터 최대 10, 지금 볼 수 있는 작업만). after 없이 부르면 기준점(latest_id)만 —
처음 쓰는 브라우저가 쌓인 옛 알림을 한꺼번에 띄우지 않게."""
user = _require_user(request)
st = _db_or_503(request)
newest = st.list_notifications(recipient_email=user["email"], limit=1)
latest = int(newest[0]["id"]) if newest else 0
out: dict[str, Any] = {"me": store.norm_str(user["email"], lower=True), "latest_id": latest, "alerts": []}
if after < 0:
return JSONResponse(out)
rows = [n for n in st.list_notifications(recipient_email=user["email"], unread_only=True, limit=50)
if n.get("type") in ("mention", "assigned") and int(n["id"]) > after]
rows = sorted(_visible_notifications(st, user, rows), key=lambda n: int(n["id"]))[:10]
out["alerts"] = [{k: n.get(k) for k in ("id", "type", "title", "body", "task_id", "project_id", "actor_email", "created_at")}
for n in rows]
return JSONResponse(out)
@router.get("/api/notifications/unread-count")
def api_notif_count(request: Request) -> JSONResponse:
user = _require_user(request)