AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import { ErrorCode } from '@activepieces/core-utils';
import { ApFlagId, FlowRunWithRetryError } from '@activepieces/shared';
import { t } from 'i18next';
import { ExternalLink } from 'lucide-react';
import { Button } from '@/components/ui/button';
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
} from '@/components/ui/dialog';
import { ScrollArea } from '@/components/ui/scroll-area';
import { flowRunUtils } from '@/features/flow-runs/utils/flow-run-utils';
import { flagsHooks } from '@/hooks/flags-hooks';
import { authenticationSession } from '@/lib/authentication-session';
import { formatUtils } from '@/lib/format-utils';
import { useNewWindow } from '@/lib/navigation-utils';
import { cn } from '@/lib/utils';
type FailedRetryRunsDialogProps = {
open: boolean;
onOpenChange: (open: boolean) => void;
failedRuns: Required<FlowRunWithRetryError>[];
};
export const FailedRetryRunsDialog = ({
open,
onOpenChange,
failedRuns,
}: FailedRetryRunsDialogProps) => {
const openNewWindow = useNewWindow();
const { data: retentionDays } = flagsHooks.useFlag<number>(
ApFlagId.EXECUTION_DATA_RETENTION_DAYS,
);
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-lg">
<DialogHeader>
<DialogTitle>{t('Failed Retries')}</DialogTitle>
</DialogHeader>
<ScrollArea className="max-h-[400px]">
<ul className="flex flex-col gap-3 pr-3">
{failedRuns.map((run) => {
const { Icon, variant } = flowRunUtils.getStatusIcon(run.status);
return (
<li
key={run.id}
className="flex items-start justify-between gap-3 rounded-md border p-3"
>
<div className="flex flex-col gap-1 min-w-0">
<div className="flex items-center gap-1.5 text-sm font-medium">
<Icon
className={cn('size-4 shrink-0', {
'text-danger-11': variant === 'error',
'text-success-11': variant === 'success',
'text-warning-11': variant === 'warning',
'text-accent-11': variant === 'primary',
'text-gray-11':
variant === 'neutral' || variant === 'default',
})}
/>
<span className="truncate">
{t('Previous status')}:{' '}
{formatUtils.convertEnumToHumanReadable(run.status)}
</span>
</div>
<p className="text-xs text-gray-11">
{retryErrorMessage({ run, retentionDays })}
</p>
</div>
<Button
variant="ghost"
size="sm"
className="shrink-0"
onClick={() =>
openNewWindow(
authenticationSession.appendProjectRoutePrefix(
`/runs/${run.id}`,
),
)
}
>
<ExternalLink className="size-4" />
<span className="sr-only">{t('Open run')}</span>
</Button>
</li>
);
})}
</ul>
</ScrollArea>
</DialogContent>
</Dialog>
);
};
function retryErrorMessage({
run,
retentionDays,
}: RetryErrorMessageParams): string {
switch (run.error.errorCode) {
case ErrorCode.FLOW_RUN_RETRY_OUTSIDE_RETENTION:
return t(
'Retry is only available for {failedJobRetentionDays} after a run fails.',
{
failedJobRetentionDays: retentionDays,
},
);
case ErrorCode.FLOW_RUN_NOT_RETRYABLE:
return t('Only failed runs can be retried from failed step');
default:
return run.error.errorMessage ?? t('Internal server error');
}
}
type RetryErrorMessageParams = {
run: Required<FlowRunWithRetryError>;
retentionDays: number | null | undefined;
};