Phase 2 complete.

This commit is contained in:
Aodhan Collins
2025-10-06 21:08:25 +01:00
parent 66749a5ce7
commit 8d6a681baa
26 changed files with 3163 additions and 164 deletions

View File

@@ -0,0 +1,43 @@
import { invoke } from '@tauri-apps/api/tauri';
/**
* Send a desktop notification
* @param title Notification title
* @param body Notification body text
*/
export async function sendNotification(title: string, body: string): Promise<void> {
try {
await invoke('send_notification', { title, body });
} catch (error) {
console.error('Failed to send notification:', error);
}
}
/**
* Truncate text to specified length with ellipsis
*/
export function truncateText(text: string, maxLength: number): string {
if (text.length <= maxLength) return text;
return text.substring(0, maxLength - 3) + '...';
}
/**
* Format notification body from message content
* Strips markdown and limits length
*/
export function formatNotificationBody(content: string, maxLength: number = 100): string {
// Remove markdown formatting
let cleaned = content
.replace(/```[\s\S]*?```/g, '[code block]') // Remove code blocks
.replace(/`([^`]+)`/g, '$1') // Remove inline code
.replace(/\*\*([^*]+)\*\*/g, '$1') // Remove bold
.replace(/\*([^*]+)\*/g, '$1') // Remove italic
.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1') // Remove links
.replace(/^#+\s+/gm, '') // Remove headers
.replace(/^\s*[-*+]\s+/gm, '') // Remove list markers
.replace(/^\s*>\s+/gm, '') // Remove blockquotes
.replace(/\n+/g, ' ') // Replace newlines with spaces
.trim();
return truncateText(cleaned, maxLength);
}