- extractErrorMessage(err: unknown) normalizes any error shape to string - handleError/handleInfraError dual utilities (user-facing vs infra-only) - error-classifier extended with ipc/database/filesystem types (9 total) - Toast rate-limiting (max 3 per type per 30s) in notifications store - Infrastructure bridges use documented console.warn (recursion prevention) - 13 new tests for extractErrorMessage
22 lines
845 B
TypeScript
22 lines
845 B
TypeScript
// Notifications bridge — wraps Tauri desktop notification command
|
|
|
|
import { invoke } from '@tauri-apps/api/core';
|
|
|
|
export type NotificationUrgency = 'low' | 'normal' | 'critical';
|
|
|
|
/**
|
|
* Send an OS desktop notification via notify-rust.
|
|
* Fire-and-forget: errors are swallowed (notification daemon may not be running).
|
|
*/
|
|
export function sendDesktopNotification(
|
|
title: string,
|
|
body: string,
|
|
urgency: NotificationUrgency = 'normal',
|
|
): void {
|
|
invoke('notify_desktop', { title, body, urgency }).catch((_e: unknown) => {
|
|
// Intentional: notification daemon may not be running. Cannot use handleInfraError
|
|
// here — it calls tel.error, and notify() calls sendDesktopNotification, creating a loop.
|
|
// eslint-disable-next-line no-console
|
|
console.warn('[notifications-bridge] Desktop notification failed:', _e);
|
|
});
|
|
}
|