Skip to content

MC-46: show unread notifications in the browser tab (favicon bell badge and title count) - #9

Merged
mmhy2003 merged 6 commits into
developfrom
megoo/MC-46-notification-favicon
Nov 18, 2026
Merged

mmhy2003 merged 6 commits into
developfrom
megoo/MC-46-notification-favicon

Conversation

@mmhy2003

Copy link
Copy Markdown
Owner

MC-46: unread notifications in the browser tab

What changed

  • Favicon badge: frontend/src/lib/favicon.ts draws a small red bell badge over the real favicon on a canvas. It switches every link[rel~="icon"] between the normal icon and the badged one. If drawing fails, the icon is left as it is.
  • Count in the title: frontend/src/lib/title.ts puts (N) in front of the title (99+ above 99), for example (3) Projects · MegooColab.
  • TabBadge: a component that renders nothing, mounted in the signed-in layout. It reads useUnreadCount() and drives both. When it unmounts (sign-out), the normal favicon and title come back.
  • Other tabs and devices: POST /api/notifications/{id}/read and POST /api/notifications/read-all now publish the live event notification.read. A second tab or device then clears its bell, badge and title count without a reload.
  • Docs: README and docs/install.md. Design and plan are in docs/superpowers/.

Why

When someone works in another tab, they can see at a glance that MegooColab has unread notifications waiting for them. The look follows the approved mockup v2.

How it was tested

  • Frontend: npx tsc --noEmit and eslint on the changed files are clean. npm test (Vitest): 1254/1254 passed, including the new favicon, title and TabBadge tests.
  • Backend: uv run pytest -n 8: 2040 passed, 1 failed. The failure is the wall-clock benchmark tests/dashboard/test_speed.py at 306 ms against its 300 ms limit. Run alone, it fails at random on this branch and also on the unchanged base commit, while the machine is under load. This branch doesn't touch the dashboard. New tests check that both read endpoints publish notification.read.
  • The plan adds a Playwright check in frontend/e2e/notifications.spec.ts (tab badge and title count, also across tabs). It was not re-run in this finishing step.

🤖 Generated with Claude Code

mmhy2003 and others added 6 commits November 18, 2026 23:40
…abs and devices

Before, marking a notification read (or "Mark all read") sent no live event,
so a second MegooColab tab or device kept its bell count until a reload.
Both endpoints now publish notification.read when something actually became
read, mirroring service.read_by_acting. MC-46's tab badge needs it so the
favicon bell and "(3)" title clear everywhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TabBadge reads the shared unread count and marks the tab: a bell on the
favicon and the count before the title. It re-applies on every page change,
since the head's icon links and title may be re-rendered, and clears both
when the signed-in layout goes away.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The notifications end-to-end test now checks that while Bea has unread notifications her tab title starts with the
count and every favicon link points at the badged drawing, also after a client-side page change and in a second tab.
Marking everything read in one tab clears the title and icon in the other through the server's notification.read
event. The README describes the new section, and docs/install.md tells people what the tab shows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@mmhy2003 mmhy2003 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Verdict: approved

The change matches the approved design and plan (mockup v2). The favicon bell badge is drawn on a canvas over the real icon and only rel~="icon" links change, so the Apple touch icon and manifest icons stay as they are. The title gets a (N) prefix, written 99+ above 99 like the bell. TabBadge is mounted only when signed in. It marks the tab again on every page change and takes the marks away on unmount. On the backend, both mark-as-read endpoints now publish notification.read, and only when something actually became read, so other tabs and devices clear their marks.

Unit tests cover the drawing and its failure cases (load error, no 2D canvas, late load after turning off, drawn once), the title prefix and TabBadge. The backend test covers someone else's notification, an already-read one and an empty read-all. Section 7 of the e2e test covers the badge after a page change and in a second tab. All CI checks pass.

Minor, not blocking: the PR description says the Playwright spec was not re-run in the finishing step. That spec is the only check that the title prefix and the badged icon survive a client-side page change in a real browser.

@mmhy2003
mmhy2003 merged commit 4e08a07 into develop Nov 18, 2026
12 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.

1 participant