fix: add test notification button (closes #930) (#948)

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:
ricautomation
2026-04-21 22:52:07 +03:00
committed by GitHub
parent a8719f0a8e
commit 3509a5f98b
@@ -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 () => { const handleEnableBackgroundNotifications = async () => {
if (!pushSupported) { if (!pushSupported) {
toast.error('Push notifications not supported'); toast.error('Push notifications not supported');
@@ -547,6 +572,7 @@ export const NotificationSettings: React.FC = () => {
</div> </div>
{nativeNotificationsEnabled && canShowNotifications && ( {nativeNotificationsEnabled && canShowNotifications && (
<>
<div <div
className="group flex cursor-pointer items-center gap-2 py-1.5" className="group flex cursor-pointer items-center gap-2 py-1.5"
role="button" role="button"
@@ -567,6 +593,18 @@ export const NotificationSettings: React.FC = () => {
/> />
<span className="typography-ui-label text-foreground">Notify While App is Focused</span> <span className="typography-ui-label text-foreground">Notify While App is Focused</span>
</div> </div>
<div className="py-2">
<Button
type="button"
variant="outline"
size="sm"
onClick={() => void handleTestNotification()}
>
Send test notification
</Button>
</div>
</>
)} )}
</section> </section>