-
Notifications
You must be signed in to change notification settings - Fork 53
fix(notifications): routing, in-app banners, and background audio #872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5ce5529
fix(notifications): correct room routing and preserve event context o…
Just-Insane 05d64a8
docs: document notification and service worker issues
Just-Insane 0f2e9b5
merge: fix/notification-click-routing - correct room routing on notif…
Just-Insane 94d5579
fix(notifications): play audio when tab hidden; show banner for loud …
Just-Insane d43e271
fix(notifications): remove pre-init roomInitialSync/getLatestTimeline…
Just-Insane 0cd0d80
fix(notifications): show in-app banners for rooms set to All Messages
Just-Insane 4dcd1a6
style: format NOTIFICATIONS_FIXES.md
Just-Insane 7c9e01e
fix(notifications): send background notifications for loud non-DM rooms
Just-Insane cbde522
fix(unread): suppress phantom badges when user sent the latest message
Just-Insane 9dc5607
chore(lint): use proper type imports in ThreadBrowser; remove unused …
Just-Insane 04d08aa
chore: add changeset
Just-Insane 7b3a409
fix(notifications): remove duplicate HTMLReactParserOptions and Linki…
Just-Insane 894f4ce
fix(notifications): address Copilot review feedback
Just-Insane ad731e4
style: fix formatting
Just-Insane File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| default: patch | ||
| --- | ||
|
|
||
| Fix notification routing, in-app banners for All Messages rooms, and background audio for loud non-DM rooms. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| # Notifications & Service Worker Fixes | ||
|
|
||
| This document tracks notification and service worker issues that need to be addressed in `feat/notifications`. | ||
|
|
||
| ## Issue #2: SW connection dropout after idle period | ||
|
|
||
| **Problem**: The service worker doesn't seem to stay connected after a period of time, causing notifications to fail. | ||
|
|
||
| **Root Cause**: | ||
|
|
||
| - Service worker becomes inactive after idle period | ||
| - Push subscription may expire or lose connection | ||
| - Background sync registration not persisting | ||
| - SW messaging channel disconnected after tab becomes inactive | ||
|
|
||
| **Proposed Fix**: | ||
|
|
||
| - Implement periodic SW keepalive ping from active tabs | ||
| - Re-establish push subscription on SW activation | ||
| - Add SW connection health monitoring | ||
| - Implement exponential backoff reconnection logic | ||
| - Persist notification state in IndexedDB for SW access | ||
|
|
||
| **Implementation Notes**: | ||
|
|
||
| - Add `postMessage` keepalive every 30s from active tab | ||
| - Listen for SW `activate` event to restore connections | ||
| - Use `navigator.serviceWorker.ready` to ensure registration | ||
| - Test with Chrome DevTools → Application → Service Workers → "Update on reload" disabled | ||
|
|
||
| ## Issue #5: Media loading failures until hard reset | ||
|
|
||
| **Problem**: Loading media (either media I just sent, or other media), including URL previews, fails until the app is hard reset. | ||
|
|
||
| **Root Cause**: | ||
|
|
||
| - Media authentication tokens not being refreshed/passed correctly | ||
| - CORS issues with media URLs after session changes | ||
| - Service worker caching stale auth headers | ||
| - Blob URL revocation before media loads | ||
|
|
||
| **Proposed Fix**: | ||
|
|
||
| - Implement media auth token refresh mechanism | ||
| - Clear SW media cache on auth token changes | ||
| - Add retry logic with fresh auth for media requests | ||
| - Use stable blob URLs with reference counting | ||
| - Add authentication headers to media fetch requests in SW | ||
|
|
||
| **Implementation Notes**: | ||
|
|
||
| - Store media auth tokens in SW cache with expiry | ||
| - Listen for Matrix client auth token changes | ||
| - Invalidate SW media cache on token refresh | ||
| - Add `Authorization` header to fetch requests in SW | ||
| - Test with private media enabled homeserver | ||
|
|
||
| ## Issue #6: Phantom unread favicon badges/dots | ||
|
|
||
| **Problem**: There are phantom unread favicon badges/dots that don't correspond to actual unread messages. | ||
|
|
||
| **Root Cause**: | ||
|
|
||
| - Unread count calculation includes muted/low-priority rooms | ||
| - Favicon update race condition with sync state | ||
| - Notification count not clearing after room visit | ||
| - Thread notifications counting separately from main timeline | ||
|
|
||
| **Proposed Fix**: | ||
|
|
||
| - Recalculate unread count from room notification state only | ||
| - Exclude muted rooms and low-priority notifications | ||
| - Clear favicon badge immediately on room focus | ||
| - Consolidate thread + main timeline counts correctly | ||
| - Add debouncing to favicon updates during rapid sync | ||
|
|
||
| **Implementation Notes**: | ||
|
|
||
| - Use `room.getUnreadNotificationCount()` with proper filters | ||
| - Check `room.notificationCounts` and respect notification level | ||
| - Update favicon only when total unread count actually changes | ||
| - Test with various notification settings (All, Mentions, Muted) | ||
|
|
||
| **Related Files**: | ||
|
|
||
| - Service worker message handling | ||
| - Push notification registration | ||
| - Favicon update logic | ||
| - Media authentication | ||
| - Notification badge counting |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.