Skip to content

fix(notifications): true pending count for NavBar badge — not page-capped (#1143)#1145

Merged
vybe merged 2 commits into
devfrom
feature/1143-notification-badge-count
Jun 12, 2026
Merged

fix(notifications): true pending count for NavBar badge — not page-capped (#1143)#1145
vybe merged 2 commits into
devfrom
feature/1143-notification-badge-count

Conversation

@dolho

@dolho dolho commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary

stores/notifications.js:fetchPendingCount() read the count field off GET /api/notifications?status=pending&limit=1, but that count is len(returned page) — capped by limit. The polled NavBar badge therefore clamped back to 1 on every 60s poll, no matter how many pending notifications existed. (WS addNotification could push it higher between polls, then the next poll reset it.)

Fix

  • New endpoint GET /api/notifications/count?status=pending — returns the true total scoped to the caller's accessible agents, mirroring the per-agent /api/agents/{name}/notifications/count. Registered before the /{notification_id} catch-all (Invariant fix: add missing logging_config.py to backend Dockerfile #4).
  • db.count_pending_notifications gains an agent_names list filter for the fleet count over accessible agents. Empty list → 0 (not "all"), guarding against invalid IN () SQL.
  • fetchPendingCount() now hits the new endpoint.

Currently only status=pending is countable at the DB layer (the only badge case); other statuses 400 explicitly rather than silently miscounting.

Verification (live instance)

Check Result
GET /notifications/count?status=pending 32 (true total)
Old ?status=pending&limit=1 count 1 (the bug)
GET /notifications/{unknown-id} 404 — /count does not shadow the param route
status=acknowledged / status=bogus 400
no token 401

Scope

Bug fix — no architecture.md/requirements change (notifications endpoints aren't documented there). Touches 4 files: db method, facade passthrough, router, store.

Closes #1143

🤖 Generated with Claude Code

…ped (#1143)

`stores/notifications.js:fetchPendingCount()` read `count` off
`GET /api/notifications?status=pending&limit=1`, where `count` is
`len(returned page)` — so the polled NavBar badge clamped to 1 every
60s regardless of how many pending notifications existed.

- Add `GET /api/notifications/count?status=pending` — returns the true
  total scoped to the caller's accessible agents (mirrors the per-agent
  `/api/agents/{name}/notifications/count`). Registered before the
  `/{notification_id}` catch-all (Invariant #4).
- `db.count_pending_notifications` gains an `agent_names` list filter
  (fleet count over accessible agents); empty list → 0, not "all"
  (avoids invalid `IN ()`).
- Point `fetchPendingCount()` at the new endpoint.

Verified live: a fleet with 32 pending now reports 32 (old limit=1
query still returns 1); `/{id}` route unshadowed (404 on unknown id);
invalid/unsupported status → 400; unauth → 401.

Related to #1143

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dolho
dolho requested a review from vybe June 11, 2026 09:14
@github-actions

Copy link
Copy Markdown

⚠️ Nightly unit-suite check skipped — merge conflict against dev.

Resolve by running git merge dev locally and pushing the result. The next nightly run will re-test once the conflict is gone.

# Conflicts:
#	src/backend/routers/notifications.py

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validated via /validate-pr: root cause correct (list endpoint count is page-capped), new /count endpoint mirrors list-endpoint access scoping, route ordering (Invariant #4) and parameterized IN clause verified, empty-accessible-set fails closed. CI fully green across all 6 pytest seeds + regression diff. Live verification documented in PR body.

@vybe
vybe merged commit 7ec36ae into dev Jun 12, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants