Adds a "Send test notification" button to the notification settings page to allow users to immediately verify their configuration. The button uses the existing notifyAgentCompletion API.
This commit is contained in:
@@ -385,6 +385,31 @@ export const NotificationSettings: React.FC = () => {
|
||||
};
|
||||
};
|
||||
|
||||
const handleTestNotification = async () => {
|
||||
const apis = getRegisteredRuntimeAPIs();
|
||||
if (!apis?.notifications) {
|
||||
toast.error('Notifications API not available');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const success = await apis.notifications.notifyAgentCompletion({
|
||||
title: 'Test Notification',
|
||||
body: 'This is a test notification from OpenChamber.',
|
||||
tag: 'openchamber-test',
|
||||
});
|
||||
|
||||
if (success) {
|
||||
toast.success('Test notification sent successfully');
|
||||
} else {
|
||||
toast.error('Failed to send test notification');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Test notification failed:', error);
|
||||
toast.error('Failed to send test notification');
|
||||
}
|
||||
};
|
||||
|
||||
const handleEnableBackgroundNotifications = async () => {
|
||||
if (!pushSupported) {
|
||||
toast.error('Push notifications not supported');
|
||||
@@ -547,6 +572,7 @@ export const NotificationSettings: React.FC = () => {
|
||||
</div>
|
||||
|
||||
{nativeNotificationsEnabled && canShowNotifications && (
|
||||
<>
|
||||
<div
|
||||
className="group flex cursor-pointer items-center gap-2 py-1.5"
|
||||
role="button"
|
||||
@@ -567,6 +593,18 @@ export const NotificationSettings: React.FC = () => {
|
||||
/>
|
||||
<span className="typography-ui-label text-foreground">Notify While App is Focused</span>
|
||||
</div>
|
||||
|
||||
<div className="py-2">
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => void handleTestNotification()}
|
||||
>
|
||||
Send test notification
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user