Skip to content

Automate browser based workflows with AI

feat(SKY-10222): show N/M block completion and unexecuted blocks on run UI (#6230)

Trevor Cheung318ab3ee2146
diff --git a/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts b/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts
index 1beb28c7f..82b59edf5 100644
--- a/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts
+++ b/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts
@@ -1,5 +1,5 @@
import { ActionsApiResponse, RunEngine, Status } from "@/api/types";
-import { WorkflowBlockType } from "./workflowTypes";
+import { WorkflowBlock, WorkflowBlockType } from "./workflowTypes";
import { ActionItem } from "../workflowRun/WorkflowRunOverview";
export const WorkflowRunTimelineItemTypes = {
@@ -146,6 +146,34 @@ export function countActionsInTimeline(
}, 0);
}
+export function countCompletedTopLevelBlocks(
+ timelineItems: Array<WorkflowRunTimelineItem>,
+): number {
+ return timelineItems.reduce((total, item) => {
+ if (
+ isBlockItem(item) &&
+ (item.block.status === Status.Completed ||
+ item.block.status === Status.Skipped)
+ ) {
+ return total + 1;
+ }
+ return total;
+ }, 0);
+}
+
+export function findUnexecutedDefinedBlocks(
+ definedBlocks: Array<WorkflowBlock>,
+ timelineItems: Array<WorkflowRunTimelineItem>,
+): Array<WorkflowBlock> {
+ const executedLabels = new Set<string>();
+ for (const item of timelineItems) {
+ if (isBlockItem(item) && item.block.label !== null) {
+ executedLabels.add(item.block.label);
+ }
+ }
+ return definedBlocks.filter((block) => !executedLabels.has(block.label));
+}
+
export function isWorkflowRunBlock(item: unknown): item is WorkflowRunBlock {
return (
typeof item === "object" &&
diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.tsx
index cec714a79..07d80b52f 100644
--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.tsx
+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.tsx
@@ -8,6 +8,8 @@ import { useWorkflowRunWithWorkflowQuery } from "../hooks/useWorkflowRunWithWork
import { useWorkflowRunTimelineQuery } from "../hooks/useWorkflowRunTimelineQuery";
import {
countActionsInTimeline,
+ countCompletedTopLevelBlocks,
+ findUnexecutedDefinedBlocks,
isBlockItem,
isObserverThought,
isThoughtItem,
@@ -21,6 +23,7 @@ import {
} from "./WorkflowRunOverview";
import { ThoughtCard } from "./ThoughtCard";
import { WorkflowRunTimelineBlockItem } from "./WorkflowRunTimelineBlockItem";
+import { WorkflowRunTimelineUnexecutedBlockItem } from "./WorkflowRunTimelineUnexecutedBlockItem";
type Props = {
activeItem: WorkflowRunOverviewActiveElement;
@@ -151,11 +154,25 @@ function WorkflowRunTimeline({
workflowRun.workflow?.workflow_definition?.finally_block_label ?? null;
const numberOfActions = countActionsInTimeline(workflowRunTimeline);
+ const definedBlocks = workflowRun.workflow?.workflow_definition?.blocks ?? [];
+ const totalBlocks = definedBlocks.length;
+ const completedBlocks = countCompletedTopLevelBlocks(workflowRunTimeline);
+ const unexecutedBlocks = workflowRunIsFinalized
+ ? findUnexecutedDefinedBlocks(definedBlocks, workflowRunTimeline)
+ : [];
return (
<div className="flex h-full min-w-0 flex-col overflow-hidden rounded-md border border-slate-700 bg-slate-elevation1">
<div className="flex shrink-0 items-center gap-2 border-b border-slate-700 px-3 py-2 text-xs">
<span className="font-medium text-slate-200">Timeline</span>
+ {totalBlocks > 0 && (
+ <span
+ className="text-slate-500"
+ title="Top-level blocks completed out of the total defined for this workflow"
+ >
+ · {completedBlocks}/{totalBlocks} blocks
+ </span>
+ )}
{numberOfActions > 0 && (
<span className="text-slate-500">
· {numberOfActions} {numberOfActions === 1 ? "action" : "actions"}
@@ -264,6 +281,12 @@ function WorkflowRunTimeline({
}
return null;
})}
+ {unexecutedBlocks.map((block) => (
+ <WorkflowRunTimelineUnexecutedBlockItem
+ key={`unexecuted-${block.label}`}
+ block={block}
+ />
+ ))}
</div>
</ScrollAreaViewport>
</ScrollArea>
diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineUnexecutedBlockItem.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineUnexecutedBlockItem.tsx
new file mode 100644
index 000000000..d3cdf54db
--- /dev/null
+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineUnexecutedBlockItem.tsx
@@ -0,0 +1,65 @@
+import { workflowBlockTitle } from "../editor/nodes/types";
+import { WorkflowBlockIcon } from "../editor/nodes/WorkflowBlockIcon";
+import { WorkflowBlock } from "../types/workflowTypes";
+
+type Props = {
+ block: WorkflowBlock;
+};
+
+function getTypeLabel(block: WorkflowBlock): string {
+ switch (block.block_type) {
+ case "conditional":
+ return "Condition";
+ case "for_loop":
+ case "while_loop":
+ return "Loop";
+ case "navigation":
+ case "task":
+ case "task_v2":
+ return "Task";
+ case "http_request":
+ return "HTTP";
+ default:
+ return workflowBlockTitle[block.block_type];
+ }
+}
+
+function WorkflowRunTimelineUnexecutedBlockItem({ block }: Props) {
+ const typeLabel = getTypeLabel(block);
+ const blockTypeTitle = workflowBlockTitle[block.block_type];
+ return (
+ <div className="min-w-0 opacity-60">
+ <div className="flex min-h-[28px] items-stretch text-xs">
+ <div
+ className="flex min-w-0 flex-1 items-center gap-1.5 rounded-r py-1 pr-1.5"
+ style={{ marginLeft: "-7px", paddingLeft: "13px" }}
+ >
+ <div className="size-4 shrink-0" />
+ <div className="flex min-w-0 flex-1 items-center gap-1.5">
+ <div className="size-2 shrink-0 rounded-full border border-dashed border-slate-500" />
+ <span title={blockTypeTitle} className="shrink-0">
+ <WorkflowBlockIcon
+ workflowBlockType={block.block_type}
+ className="size-3.5 text-slate-400"
+ />
+ </span>
+ <span className="inline-flex min-w-[6rem] max-w-[8rem] shrink-0 justify-center truncate rounded bg-slate-700/70 px-1.5 py-0.5 text-[10px] font-medium text-slate-300">
+ {typeLabel}
+ </span>
+ <span className="min-w-0 max-w-[12rem] truncate text-slate-300">
+ {block.label}
+ </span>
+ <span
+ className="ml-auto shrink-0 rounded bg-slate-800 px-1 text-[10px] uppercase tracking-wide text-slate-400"
+ title="This block did not execute because the workflow ended before reaching it"
+ >
+ did not execute
+ </span>
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
+
+export { WorkflowRunTimelineUnexecutedBlockItem };