From 107921e0d025106a5545108e49062bbeb88f9669 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Sat, 13 Jun 2026 23:53:39 -0400 Subject: [PATCH] feat: desktop tray unread overlay + taskbar flash on new mention Extends useTauriNotificationBadge to also invoke set_tray_unread (mirror the unread-mention state onto the tray icon, visible when minimized) and flash_window (flash the taskbar button when new mentions arrive while the window is unfocused). No-op outside Tauri. Co-Authored-By: Claude Fable 5 --- src/app/hooks/useTauriNotificationBadge.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/hooks/useTauriNotificationBadge.ts b/src/app/hooks/useTauriNotificationBadge.ts index 37801ea63..927b3fe43 100644 --- a/src/app/hooks/useTauriNotificationBadge.ts +++ b/src/app/hooks/useTauriNotificationBadge.ts @@ -1,4 +1,4 @@ -import { useEffect } from 'react'; +import { useEffect, useRef } from 'react'; import { useAtomValue } from 'jotai'; import { roomToUnreadAtom } from '../state/room/roomToUnread'; @@ -10,6 +10,7 @@ const tauriInvoke = (): TauriInternals['invoke'] | undefined => export function useTauriNotificationBadge() { const roomToUnread = useAtomValue(roomToUnreadAtom); + const prevHighlightsRef = useRef(0); useEffect(() => { const invoke = tauriInvoke(); @@ -21,5 +22,14 @@ export function useTauriNotificationBadge() { }); invoke('set_badge_count', { count: totalHighlights }).catch(() => {}); + // Mirror the unread state onto the tray icon (visible when minimized to tray). + invoke('set_tray_unread', { unread: totalHighlights > 0 }).catch(() => {}); + + // Flash the taskbar button when new mentions arrive and the window is not + // focused, then reset the baseline. + if (totalHighlights > prevHighlightsRef.current && !document.hasFocus()) { + invoke('flash_window').catch(() => {}); + } + prevHighlightsRef.current = totalHighlights; }, [roomToUnread]); }