Skip to content

feat(notifications): ability to customize notification sound, duration, and toggle - #220

Merged
ravindra-cloudflare merged 4 commits into
stagingfrom
feat/notifications-customisation
Nov 27, 2026
Merged

ravindra-cloudflare merged 4 commits into
stagingfrom
feat/notifications-customisation

Conversation

@ravindra-cloudflare

@ravindra-cloudflare ravindra-cloudflare commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Notifications were never documented. Because of that, there was no standard way to configure them, and customers changed them in ways that we do not officially support. Customers must fix their non official integration code to support this structure.

Only subtractive change is the removal of umbrella notifications keys such as chat, webinar to allow more customization.

What customers can do now

  1. Turn each notification on or off. Every notification has its own key, for example
    chat_new_message, chat_message_edited and chat_message_deleted. Before, one
    chat key covered new messages only, and many notifications had no key at all.
  2. Turn the sound of each notification on or off, separately from the notification.
  3. Choose the audio file for each notification with notification_sound_urls.
  4. Play a custom sound for their own notifications sent with sendNotification().
  5. Set how long each notification stays on screen. A duration of 0 keeps it until
    the user dismisses it.
  6. Limit how many notifications are on screen at one time with
    visible_notifications_limit. The default is 5, as before.

Corrected Defaults

  1. createDefaultConfig() intentionally sets participant_joined_sound_notification_limit as 3 similar to how earlier config generation would set it in packages/core/src/utils/config.ts to streamline defaults.
  2. A customer must use the official ways of passing config. Read "How to configure" section of this PR description. Every valid config generation method ensures that defaults are properly set. If in case config is not passed, default config will be picked.

New notifications

  • Chat message edited and chat message deleted. Both are off by default.
  • A participant asked to join the stage, and a participant joined the stage. Both are off
    by default. The code for these existed but was never connected.

Notifications that can now be configured

These were always shown and could not be changed before:

  • Speaker, camera and microphone switched.
  • Network messages: reconnecting, delayed, could not reconnect, failed, restored.
  • Recording, livestream and screen share errors.
  • Stage request accepted, rejected, new request received, and invite sent.
  • Notifications sent with sendNotification()

How to configure

There are two official ways to get a UI config. Both return every notification key with
its default value:

  1. Call createDefaultConfig(), Change the keys in the object. Pass the altered config to rtk-ui-provider or rtk-meeting as config.
  2. Use the config that registerAddons() returns. Pass the altered config to rtk-ui-provider or rtk-meeting as config.

Using createDefaultConfig

import { createDefaultConfig } from '@cloudflare/realtimekit-ui';

const uiConfig = createDefaultConfig();

// hide the notification
uiConfig.config.notifications.participant_joined = false;

// stop its sound too
uiConfig.config.notification_sounds.participant_joined = false;

// configure duration
uiConfig.config.notification_duration.participant_joined = 5000;

// the audio file that the notification plays
uiConfig.config.notification_sound_urls.participant_joined = 'https://example.com/sounds/join.mp3';

// Pass it to the UI Kit
// <RtkNotifications meeting={meeting} config={uiConfig} />

Using registerAddons()

import { registerAddons } from '@cloudflare/realtimekit-ui';

const uiConfig = registerAddons([], meeting); // replace [] with addons

// hide the notification
uiConfig.config.notifications.participant_joined = false;

// stop its sound too
uiConfig.config.notification_sounds.participant_joined = false;

// configure duration
uiConfig.config.notification_duration.participant_joined = 5000;

// the audio file that the notification plays
uiConfig.config.notification_sound_urls.participant_joined = 'https://example.com/sounds/join.mp3';

// Pass it to the UI Kit
// <RtkNotifications meeting={meeting} config={uiConfig} />

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Superseded by the review of e8624854.

This review, of 003907e5

⚠️ Minor issues — One WARNING with production impact: the component no longer merges config.config with the defaults. A partial or older config now throws in meeting event handlers or hides notifications without any error. There are also three INFO notes.

Findings: 1 warning · 3 info (4 are inline comments on the diff)

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.

🔧 Fix with your agent

Paste the following into your coding agent to investigate and fix these issues.

Fix the following code review issues found in pull request #220.

Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
  for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order

## WARNING (1)

### [Code Quality] `notificationConfig` returns `config.config` without merging it with `DEFAULT_NOTIFICATION_CONFIG`. A partial or older `config.config` makes the notification listeners throw a TypeError, or hides every notification key it does not list.
- **File:** packages/core/src/components/rtk-notifications/rtk-notifications.tsx:509

## INFO (3)

### [Code Quality] `createDefaultConfig()` now inherits `participant_joined_sound_notification_limit: 3` instead of 10. This is a behaviour change the description does not mention.
- **File:** packages/core/src/lib/default-ui-config.ts:332

### [Code Quality] The stage-request notification shows an Accept button that calls `stage.grantAccess` without checking `permissions.acceptStageRequests`. The waitlist and new-stage-request notifications do check their permissions.
- **File:** packages/core/src/components/rtk-notifications/rtk-notifications.tsx:399

### [Documentation] The invalid-URL fallback sentence does not hold for `custom`, which has no built-in default sound. The same sentence is in `html-example.md:146` and `react-example.md:145`.
- **File:** packages/core/src/components/rtk-notifications/usage/angular-example.md:154

📋 Code Quality: ⚠️ 1 warning · 2 info

Notification settings are read from config.config without a merge against the defaults. Two smaller points: a changed default sound limit and an Accept button with no permission check.

Recommendation: 📝 Minor Comments

  • [WARNING] notificationConfig returns config.config without merging it with DEFAULT_NOTIFICATION_CONFIG. A partial or older config.config makes the notification listeners throw a TypeError, or hides every notification key it does not list. (packages/core/src/components/rtk-notifications/rtk-notifications.tsx:509)
  • [INFO] createDefaultConfig() now inherits participant_joined_sound_notification_limit: 3 instead of 10. This is a behaviour change the description does not mention. (packages/core/src/lib/default-ui-config.ts:332)
  • [INFO] The stage-request notification shows an Accept button that calls stage.grantAccess without checking permissions.acceptStageRequests. The waitlist and new-stage-request notifications do check their permissions. (packages/core/src/components/rtk-notifications/rtk-notifications.tsx:399)
View full review

1. Notification config is no longer merged with the defaults (rtk-notifications.tsx:508-509)

  • Before this change, parseConfig merged notifications, notification_sounds and notification_duration from config.config over DEFAULT_NOTIFICATION_CONFIG.
  • The new getter falls back to the defaults only when config.config is missing entirely.
  • Some configs have a config.config without one of these sub-objects, for example { videoFit: 'cover' }, or a config built from the old default shape with no notification_sound_urls. For those configs, isShown, isSoundOn, the duration lookup and the sound URL lookup dereference undefined inside meeting event listeners. The listener throws and no notification appears.
  • A partial map such as notifications: { participant_joined: false } now hides every other notification, including ones that default to on.
  • Fix: merge each map with its defaults in the getter.

2. Default sound limit changed (default-ui-config.ts:332)

  • createDefaultConfig() now inherits participant_joined_sound_notification_limit: 3 (it was 10).
  • Join, leave and waitlist sounds now stop at much smaller meeting sizes. The description does not mention this.

3. Stage-request Accept button has no permission check (rtk-notifications.tsx:399)

  • The newly connected peerStageStatusListener shows an Accept button that calls stage.grantAccess, but it does not check permissions.acceptStageRequests.
  • The waitlist and newStageRequests notifications both have this check.

📝 Documentation: 💬 1 info

The usage examples describe the invalid-URL fallback inaccurately for custom.

Recommendation: 💬 Optional Nits

  • [INFO] The invalid-URL fallback sentence does not hold for custom, which has no built-in default sound. The same sentence is in html-example.md:146 and react-example.md:145. (packages/core/src/components/rtk-notifications/usage/angular-example.md:154)
View full review

All three usage examples say that an invalid URL plays the notification's default sound. custom has no built-in default: playCustomSoundIfEnabled plays the sender's sound if sendNotification() provided one, and otherwise plays nothing. The same sentence appears in html-example.md:146 and react-example.md:145.


✅ All other checks passed

🔒 Security: ✅ LGTM

No security issues found. A custom sound URL is used only when isAudioFileUrl accepts it: an http or https URL whose path ends in an audio extension. The URL is only ever assigned to audio.src. The message rendering path is unchanged.


📖 AGENTS.md: ✅ LGTM

No issues found.


⚡ Performance: ✅ LGTM

No performance issues found.


Reviewed commit: 003907e5

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Superseded by the review of a63efd97.

This review, of e8624854

💬 Approved with comments — The earlier config-merge problem and the permission gap are fixed. What remains is one WARNING about a stale contributor-doc example and one INFO about the sound URL rules in the usage docs; neither affects production.

Findings: 1 warning · 1 info (1 is an inline comment on the diff)

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.

🔧 Fix with your agent

Paste the following into your coding agent to investigate and fix these issues.

Fix the following code review issues found in pull request #220.

Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
  for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order

## WARNING (1)

### [AGENTS.md] packages/core/src/utils/AGENTS.md:85-94 still passes `true` as `playSound`; the new signature takes `Sound | string`. Change the example to pass a supported value such as `'message'`. This is contributor documentation and has no effect on production.

## INFO (1)

### [Documentation] The docs say a sound URL must start with http(s), but relative audio paths are also accepted.
- **File:** packages/core/src/components/rtk-notifications/usage/angular-example.md:151

📖 AGENTS.md: ⚠️ 1 warning

The sendNotification example in utils/AGENTS.md is out of date.

Recommendation: 📝 Minor Comments

  • [WARNING] packages/core/src/utils/AGENTS.md:85-94 still passes true as playSound; the new signature takes Sound | string. Change the example to pass a supported value such as 'message'. This is contributor documentation and has no effect on production.
View full review

The example at packages/core/src/utils/AGENTS.md:85-94 still calls sendNotification(..., true). The new signature (packages/core/src/utils/notification.ts:16-19) takes a built-in sound name (joined, left, message) or an audio URL. Change the example to pass, for example, 'message'.


📝 Documentation: 💬 1 info

The documented sound URL rules are narrower than the code.

Recommendation: 💬 Optional Nits

  • [INFO] The docs say a sound URL must start with http(s), but relative audio paths are also accepted. (packages/core/src/components/rtk-notifications/usage/angular-example.md:151)
View full review

The usage docs say a sound URL must start with https: or http:. isAudioFileUrl resolves relative paths against document.baseURI, so a relative path such as /sounds/join.mp3 is also accepted. The same text is in html-example.md and react-example.md.


✅ All other checks passed

🔒 Security: ✅ LGTM

Sound URLs from the config and from events both go through isAudioFileUrl, which accepts only http and https URLs whose path ends in an audio extension. They are only ever assigned to audio.src. The stage-request and waitlist actions are now gated by permission checks.


📋 Code Quality: ✅ LGTM

The notification config is now deep-merged with the defaults (rtk-notifications.tsx:538), and the Accept button on stage requests now checks canAcceptStageRequests(). The new clearTimeout in rtk-notification.tsx stops a notification that replaces another one from closing on the old timer. The meetingId filter on sendNotification events matches the code that consumes it.


⚡ Performance: ✅ LGTM

No performance issues found.


Reviewed commit: e8624854

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Approved — Both earlier findings are fixed: sound URLs must now be absolute, as the docs say, and the AGENTS.md example matches the new signature. No new issues were found.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

isAudioFileUrl (lib/notification.ts:28-43) parses the URL without a base, so relative paths are rejected. It accepts only http: and https: URLs whose path ends in an audio extension. The URL is only ever assigned to audio.src. Stage-request and waitlist actions are gated by permission checks.


📖 AGENTS.md: ✅ LGTM

The sendNotification example in packages/core/src/utils/AGENTS.md now passes 'message', which matches the new signature.


📋 Code Quality: ✅ LGTM

The notification config is still deep-merged with the defaults, and the stage-request Accept button checks its permission. In utils/notification.ts, playSound now takes Sound | string, and the event detail type matches. Events carry an optional meetingId, and a listener ignores events whose meetingId belongs to another meeting. Existing callers are unaffected.


⚡ Performance: ✅ LGTM

No performance issues found. Every new listener is removed in clearListeners.


📝 Documentation: ✅ LGTM

The usage docs now say that a relative sound path is rejected, which matches isAudioFileUrl.


Reviewed commit: a63efd97

@ravindra-cloudflare
ravindra-cloudflare merged commit 5869c2d into staging Nov 27, 2026
6 checks passed
@ravindra-cloudflare
ravindra-cloudflare deleted the feat/notifications-customisation branch November 27, 2026 19:49
github-actions Bot pushed a commit that referenced this pull request Nov 27, 2026
# [2.2.0-staging.5](https://github.com/cloudflare/realtimekit-ui/compare/@cloudflare/realtimekit-ui-v2.2.0-staging.4...@cloudflare/realtimekit-ui-v2.2.0-staging.5) (2026-11-27)

### Features

* **notifications:** ability to customize notification sound, duration, and toggle ([#220](#220)) ([5869c2d](5869c2d))

skip-checks: true
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.2.0-staging.5 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants