Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

860 B
Raw Blame
import type { AppNotification } from "@pi-desktop/shared";

/**
 * The inbox popover surfaces only outcomes that need attention (D295). Successful
 * completions stay in the durable record so the sidebar outcome badge and the
 * native system notification keep working, but listing every one of them
 * buried the failures under noise. The OS shell/taskbar unread overlay is
 * separate and counts all unread task notifications (completed + failed).
 */
export function inboxNotifications(
  notifications: AppNotification[],
): AppNotification[] {
  return notifications.filter(
    (notification) => notification.kind !== "task.completed",
  );
}

export function inboxUnreadCount(notifications: AppNotification[]): number {
  return inboxNotifications(notifications).reduce(
    (count, notification) => count + (notification.readAt ? 0 : 1),
    0,
  );
}