Skip to content

Automate browser based workflows with AI

Fix run action count showing 0 despite steps executing (#SKY-7936) (#4856)

Celal Zamanoğlu498c8422bacb
diff --git a/skyvern-frontend/src/routes/workflows/debugger/DebuggerRunTimeline.tsx b/skyvern-frontend/src/routes/workflows/debugger/DebuggerRunTimeline.tsx
index 310015435..e66d9e0d1 100644
--- a/skyvern-frontend/src/routes/workflows/debugger/DebuggerRunTimeline.tsx
+++ b/skyvern-frontend/src/routes/workflows/debugger/DebuggerRunTimeline.tsx
@@ -5,13 +5,13 @@ import { cn } from "@/util/utils";
import { useWorkflowRunQuery } from "../hooks/useWorkflowRunQuery";
import { useWorkflowRunTimelineQuery } from "../hooks/useWorkflowRunTimelineQuery";
import {
+ countActionsInTimeline,
isBlockItem,
isObserverThought,
isThoughtItem,
ObserverThought,
WorkflowRunBlock,
} from "../types/workflowRunTypes";
-import { countActions } from "../utils";
import { ThoughtCard } from "@/routes/workflows/workflowRun/ThoughtCard";
import {
ActionItem,
@@ -48,7 +48,7 @@ function DebuggerRunTimeline({
const workflowRunIsFinalized = statusIsFinalized(workflowRun);
- const numberOfActions = countActions(workflowRunTimeline);
+ const numberOfActions = countActionsInTimeline(workflowRunTimeline);
const firstActionOrThoughtIsPending =
!workflowRunIsFinalized && workflowRunTimeline.length === 0;
diff --git a/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts b/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts
index 9dc68b111..ccde53101 100644
--- a/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts
+++ b/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts
@@ -118,10 +118,25 @@ export function isBlockItem(
);
}
-export function isTaskVariantBlockItem(item: unknown) {
+function isTaskVariantBlockItem(item: unknown) {
return isBlockItem(item) && isTaskVariantBlock(item.block);
}
+export function countActionsInTimeline(
+ timelineItems: Array<WorkflowRunTimelineItem>,
+): number {
+ return timelineItems.reduce((total, item) => {
+ let count = 0;
+ if (isTaskVariantBlockItem(item)) {
+ count += item.block?.actions?.length ?? 0;
+ }
+ if (item.children.length > 0) {
+ count += countActionsInTimeline(item.children);
+ }
+ return total + count;
+ }, 0);
+}
+
export function isWorkflowRunBlock(item: unknown): item is WorkflowRunBlock {
return (
typeof item === "object" &&
diff --git a/skyvern-frontend/src/routes/workflows/types/workflowTypes.ts b/skyvern-frontend/src/routes/workflows/types/workflowTypes.ts
index 0607c2356..c50d3fca3 100644
--- a/skyvern-frontend/src/routes/workflows/types/workflowTypes.ts
+++ b/skyvern-frontend/src/routes/workflows/types/workflowTypes.ts
@@ -260,15 +260,7 @@ export const scriptableWorkflowBlockTypes: Set<WorkflowBlockType> = new Set([
export function isTaskVariantBlock(item: {
block_type: WorkflowBlockType;
}): boolean {
- return (
- item.block_type === "task" ||
- item.block_type === "navigation" ||
- item.block_type === "action" ||
- item.block_type === "extraction" ||
- item.block_type === "validation" ||
- item.block_type === "login" ||
- item.block_type === "file_download"
- );
+ return scriptableWorkflowBlockTypes.has(item.block_type);
}
export type WorkflowBlockType =
diff --git a/skyvern-frontend/src/routes/workflows/utils.ts b/skyvern-frontend/src/routes/workflows/utils.ts
index e7c6f74ab..ff68d9ca5 100644
--- a/skyvern-frontend/src/routes/workflows/utils.ts
+++ b/skyvern-frontend/src/routes/workflows/utils.ts
@@ -1,11 +1,6 @@
import { useLocation } from "react-router-dom";
import type { WorkflowParameter } from "./types/workflowTypes";
import { WorkflowApiResponse } from "@/routes/workflows/types/workflowTypes";
-import {
- isBlockItem,
- isTaskVariantBlockItem,
- WorkflowRunTimelineItem,
-} from "./types/workflowRunTypes";
type Location = ReturnType<typeof useLocation>;
@@ -78,20 +73,6 @@ export const formatDuration = (duration: Duration): string => {
}
};
-export function countActions(items: Array<WorkflowRunTimelineItem>): number {
- return items.reduce((total, item) => {
- if (!isBlockItem(item)) {
- return total;
- }
-
- const blockActionCount = isTaskVariantBlockItem(item)
- ? item.block.actions?.length ?? 0
- : 0;
-
- return total + blockActionCount + countActions(item.children);
- }, 0);
-}
-
export const getOrderedBlockLabels = (workflow?: WorkflowApiResponse) => {
if (!workflow) {
return [];
diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.tsx
index 18abf4a2f..f56fe2e66 100644
--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.tsx
+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.tsx
@@ -6,13 +6,13 @@ import { DotFilledIcon } from "@radix-ui/react-icons";
import { useWorkflowRunWithWorkflowQuery } from "../hooks/useWorkflowRunWithWorkflowQuery";
import { useWorkflowRunTimelineQuery } from "../hooks/useWorkflowRunTimelineQuery";
import {
+ countActionsInTimeline,
isBlockItem,
isObserverThought,
isThoughtItem,
ObserverThought,
WorkflowRunBlock,
} from "../types/workflowRunTypes";
-import { countActions } from "../utils";
import { ThoughtCard } from "./ThoughtCard";
import {
ActionItem,
@@ -56,7 +56,7 @@ function WorkflowRunTimeline({
const finallyBlockLabel =
workflowRun.workflow?.workflow_definition?.finally_block_label ?? null;
- const numberOfActions = countActions(workflowRunTimeline);
+ const numberOfActions = countActionsInTimeline(workflowRunTimeline);
return (
<div className="min-w-0 space-y-4 rounded bg-slate-elevation1 p-4">