import React from 'react'; import { cn } from '@/lib/utils'; interface PermissionToastActionsProps { sessionTitle: string; permissionBody: string; disabled?: boolean; onOnce: () => Promise | void; onAlways: () => Promise | void; onDeny: () => Promise | void; } const truncateToastText = (value: string, maxLength: number): string => { const normalized = value.trim(); if (normalized.length <= maxLength) { return normalized; } return `${normalized.slice(0, Math.max(0, maxLength - 3))}...`; }; export const PermissionToastActions: React.FC = ({ sessionTitle, permissionBody, disabled = false, onOnce, onAlways, onDeny, }) => { const [isBusy, setIsBusy] = React.useState(false); const actionContext = sessionTitle.trim().length > 0 ? ` for ${sessionTitle}` : ''; const sessionPreview = truncateToastText(sessionTitle, 64) || 'Session'; const permissionPreview = truncateToastText(permissionBody, 120) || 'Permission details unavailable'; const handleAction = async (action: () => Promise | void) => { if (isBusy || disabled) return; setIsBusy(true); try { await action(); } finally { setIsBusy(false); } }; return (

Session:{' '} {sessionPreview}

Permission:{' '} {permissionPreview}

); };