Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions apps/agent/components/ai-elements/run-result-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
CheckCircle2,
Copy,
Loader2,
Play,
XCircle,
} from 'lucide-react'
import { type FC, useState } from 'react'
Expand All @@ -27,6 +28,7 @@ interface RunResultDialogProps {
run: ScheduledJobRun | null
jobName?: string
onOpenChange: (open: boolean) => void
onRetry?: () => void
}

const formatDateTime = (dateStr: string) =>
Expand All @@ -46,6 +48,7 @@ export const RunResultDialog: FC<RunResultDialogProps> = ({
run,
jobName,
onOpenChange,
onRetry,
}) => {
const [copied, setCopied] = useState(false)

Expand All @@ -56,6 +59,11 @@ export const RunResultDialog: FC<RunResultDialogProps> = ({
setTimeout(() => setCopied(false), 2000)
}

const handleRetry = () => {
onRetry?.()
onOpenChange(false)
}

if (!run) return null

return (
Expand Down Expand Up @@ -118,6 +126,12 @@ export const RunResultDialog: FC<RunResultDialogProps> = ({
)}
</Button>
)}
{run.status === 'failed' && onRetry && (
<Button variant="outline" onClick={handleRetry}>
<Play className="h-4 w-4" />
Retry
</Button>
)}
<Button onClick={() => onOpenChange(false)}>Close</Button>
</DialogFooter>
</DialogContent>
Expand Down
9 changes: 8 additions & 1 deletion apps/agent/entrypoints/newtab/index/ScheduleResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
CollapsibleTrigger,
} from '@/components/ui/collapsible'
import {
SCHEDULED_TASK_TESTED_EVENT,
SCHEDULED_TASK_VIEW_MORE_IN_NEWTAB_EVENT,
SCHEDULED_TASK_VIEW_RESULTS_IN_NEWTAB_EVENT,
} from '@/lib/constants/analyticsEvents'
Expand Down Expand Up @@ -58,7 +59,7 @@ export const ScheduleResults: FC = () => {
const [viewingRun, setViewingRun] = useState<JobRunWithDetails | null>(null)

const { jobRuns } = useScheduledJobRuns()
const { jobs } = useScheduledJobs()
const { jobs, runJob } = useScheduledJobs()

const runningCount = jobRuns.filter((r) => r.status === 'running').length

Expand Down Expand Up @@ -93,6 +94,11 @@ export const ScheduleResults: FC = () => {
setViewingRun(run)
}

const handleRetry = async (jobId: string) => {
await runJob(jobId)
track(SCHEDULED_TASK_TESTED_EVENT)
}

return (
<Collapsible
open={isOpen}
Expand Down Expand Up @@ -165,6 +171,7 @@ export const ScheduleResults: FC = () => {
run={viewingRun}
jobName={viewingRun?.job?.name}
onOpenChange={(open) => !open && setViewingRun(null)}
onRetry={viewingRun ? () => handleRetry(viewingRun.jobId) : undefined}
/>
</Collapsible>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export const ScheduledTasksPage: FC = () => {
: undefined
}
onOpenChange={(open) => !open && setViewingRun(null)}
onRetry={viewingRun ? () => handleRun(viewingRun.jobId) : undefined}
/>

<AlertDialog
Expand Down