import { ScrollArea, ScrollAreaViewport } from "@/components/ui/scroll-area"; import { Skeleton } from "@/components/ui/skeleton"; import { statusIsFinalized } from "@/routes/tasks/types"; import { useWorkflowRunQuery } from "../hooks/useWorkflowRunQuery"; import { useWorkflowRunTimelineQuery } from "../hooks/useWorkflowRunTimelineQuery"; import { isBlockItem, isObserverThought, isTaskVariantBlockItem, isThoughtItem, ObserverThought, WorkflowRunBlock, } from "../types/workflowRunTypes"; import { ThoughtCard } from "@/routes/workflows/workflowRun/ThoughtCard"; import { ActionItem, WorkflowRunOverviewActiveElement, } from "@/routes/workflows/workflowRun/WorkflowRunOverview"; import { WorkflowRunTimelineBlockItem } from "@/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem"; type Props = { activeItem: WorkflowRunOverviewActiveElement; onObserverThoughtCardSelected: (item: ObserverThought) => void; onActionItemSelected: (item: ActionItem) => void; onBlockItemSelected: (item: WorkflowRunBlock) => void; }; function DebuggerRunTimeline({ activeItem, onObserverThoughtCardSelected, onActionItemSelected, onBlockItemSelected, }: Props) { const { data: workflowRun, isLoading: workflowRunIsLoading } = useWorkflowRunQuery(); const { data: workflowRunTimeline, isLoading: workflowRunTimelineIsLoading } = useWorkflowRunTimelineQuery(); if (workflowRunIsLoading || workflowRunTimelineIsLoading) { return ; } if (!workflowRun || !workflowRunTimeline) { return (
Hi! 👋 We're experimenting with a new feature called debugger.
This debugger allows you to see the state of your workflow in a live browser.
You can run individual blocks, instead of the whole workflow.
To get started, press the play button on a block in your workflow.
); } const workflowRunIsFinalized = statusIsFinalized(workflowRun); const numberOfActions = workflowRunTimeline.reduce((total, current) => { if (isTaskVariantBlockItem(current)) { return total + current.block!.actions!.length; } return total + 0; }, 0); return (
Actions: {numberOfActions}
Steps: {workflowRun.total_steps ?? 0}
{!workflowRunIsFinalized && workflowRunTimeline.length === 0 && ( )}
{workflowRunIsFinalized && workflowRunTimeline.length === 0 && (
Workflow timeline is empty
)} {workflowRunTimeline?.map((timelineItem) => { if (isBlockItem(timelineItem)) { return ( ); } if (isThoughtItem(timelineItem)) { return ( ); } })}
); } export { DebuggerRunTimeline };