"use client"; import { AlertCircle, Braces, Database, ExternalLink, Eye, Hash, Server, Sparkles, } from "lucide-react"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import type { NotificationLogWithRelations } from "@/db/services/notification-log"; type NotificationLogModalProps = { notificationLog: NotificationLogWithRelations; }; const getTroubleshootingForError = (errorMsg?: any) => { if (!errorMsg || String(errorMsg).toLowerCase() === "null") return null; const msg = String(errorMsg).toLowerCase(); if (msg.includes("database connection") || msg.includes("agent")) { return { title: "Agent Connection Issue", resolution: "It appears the agent cannot reach the database. Please ensure that your agent is actively running, your PostgreSQL credentials are correct, and port 5432 is open on your firewall.", docLink: "https://portabase.io/docs/agent/troubleshooting/agent-connection", }; } if (msg.includes("timeout")) { return { title: "Timeout", resolution: "The agent is taking too long to respond. This could be due to high server load, network issues, or a large database.", docLink: "https://portabase.io/docs/agent/troubleshooting/timeout", }; } return { title: "Unexpected Execution Error", resolution: "An unexpected error occurred during execution. Please review the raw system logs or contact support if the issue persists.", docLink: "https://discord.gg/Wgv7xZ8fWJ", }; }; const getIconForKey = (key: string, value: any) => { const isActualError = key.toLowerCase().includes("error") && value !== null && String(value).toLowerCase() !== "null"; if (key.toLowerCase().includes("id")) return ; if (key.toLowerCase().includes("host")) return ; if (isActualError) return ; return ; }; export const NotificationLogModal = ({ notificationLog, }: NotificationLogModalProps) => { const [open, setOpen] = useState(false); const payloadError = notificationLog.payload?.error; const troubleshooting = getTroubleshootingForError(payloadError); return ( Notification Details Execution logs and payload data
Event Trigger
Title {notificationLog.content.title}
Message {notificationLog.content.message}
{notificationLog.payload && Object.keys(notificationLog.payload).length > 0 && (
JSON Payload
{Object.entries(notificationLog.payload).map( ([key, value], index, arr) => { const isActualError = key === "error" && value !== null && String(value).toLowerCase() !== "null"; return (
{getIconForKey(key, value)} {key}
{isActualError ? ( {String(value)} ) : ( {String(value)} )}
); }, )}
{troubleshooting && (
)}
)} {troubleshooting && ( <>
Suggested Resolution

{troubleshooting.title}

{troubleshooting.resolution}

)}
); };