Settings > Notifications "Test notification" button never shows a notification #48

Closed
opened 2026-10-09 22:18:03 +00:00 by dwofford · 2 comments

Steps to reproduce

  1. Settings > Notifications, allow notifications (permission "granted").
  2. Press "Test notification".

Expected
A sample new-mail notification appears.

Actual
Nothing appears. The sound plays, so it looks like the browser or OS is blocking notifications when it isn't.

Cause (from reading the source)
NotificationsSettings.tsx:84 calls showNotification(), and web/src/lib/notify/notify.ts:96 returns early when document.visibilityState === "visible" && document.hasFocus(). That guard is right for new mail, but when you press the button, the tab is always visible and focused, so the test can never show.

Suggested fix
Give showNotification() a force option (or have the Test button call the service worker's showNotification directly) so the test skips the focus check.

Environment
ihasmail 2026.10.5+g20c32ed (same code on main 2649c00), Docker, Stalwart 0.16.23, macOS desktop browser. It's client-only, so it should reproduce against the mock.

**Steps to reproduce** 1. Settings > Notifications, allow notifications (permission "granted"). 2. Press "Test notification". **Expected** A sample new-mail notification appears. **Actual** Nothing appears. The sound plays, so it looks like the browser or OS is blocking notifications when it isn't. **Cause (from reading the source)** NotificationsSettings.tsx:84 calls showNotification(), and web/src/lib/notify/notify.ts:96 returns early when document.visibilityState === "visible" && document.hasFocus(). That guard is right for new mail, but when you press the button, the tab is always visible and focused, so the test can never show. **Suggested fix** Give showNotification() a force option (or have the Test button call the service worker's showNotification directly) so the test skips the focus check. **Environment** ihasmail 2026.10.5+g20c32ed (same code on main 2649c00), Docker, Stalwart 0.16.23, macOS desktop browser. It's client-only, so it should reproduce against the mock.
jcoffey-dev added the bug
priority
p3
labels 2026-10-09 22:22:49 +00:00
jcoffey-dev self-assigned this 2026-10-09 22:22:49 +00:00
jcoffey-dev added the due date 2026-10-12 2026-10-09 22:28:44 +00:00
Owner

Fixed in #51, thanks @dwofford. The test button shows a real notification now, and it'll be in Monday's release.

Fixed in #51, thanks @dwofford. The test button shows a real notification now, and it'll be in Monday's release.
Owner

Live on ihasmail.com now, and in Monday's release for self-hosted.

Live on ihasmail.com now, and in Monday's release for self-hosted.
Sign in to join this conversation.
2 Participants
Notifications
Due Date
2026-10-12
Dependencies

No dependencies set.

Reference: coffey-labs/ihasmail#48