Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
Group skipped workflow branches in run timeline (#6934)
Suchintan86095f81b87d
diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.test.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.test.tsxindex b7c74a31c..1fd87a358 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.test.tsx+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.test.tsx@@ -1,6 +1,6 @@// @vitest-environment jsdom-import { cleanup, render, screen } from "@testing-library/react";+import { cleanup, fireEvent, render, screen } from "@testing-library/react";import { afterEach, describe, expect, it, vi } from "vitest";import { type ReactNode } from "react";@@ -285,8 +285,30 @@ describe("WorkflowRunTimeline", () => {created_at: "2026-06-10T07:16:29Z",output: {evaluations: [- { is_matched: true, next_block_label: "block_8" },- { is_matched: false, next_block_label: "other_path" },+ {+ branch_id: "br_taken",+ branch_index: 0,+ criteria_type: "jinja2_template",+ original_expression: "{{ found }}",+ rendered_expression: "true",+ result: true,+ is_matched: true,+ is_default: false,+ next_block_label: "block_8",+ error: null,+ },+ {+ branch_id: "br_other",+ branch_index: 1,+ criteria_type: "jinja2_template",+ original_expression: "{{ needs_other_path }}",+ rendered_expression: "false",+ result: false,+ is_matched: false,+ is_default: false,+ next_block_label: "other_path",+ error: null,+ },],} as WorkflowRunBlock["output"],});@@ -319,8 +341,12 @@ describe("WorkflowRunTimeline", () => {},{id: "br_other",+ description: "Use alternate path",+ criteria: {+ description: "Alternate path needed",+ },next_block_label: "other_path",- is_default: true,+ is_default: false,},],},@@ -341,13 +367,29 @@ describe("WorkflowRunTimeline", () => {renderTimeline(null);+ expect(screen.getByText("B • Else If")).toBeDefined();+ expect(screen.getByText("· Use alternate path")).toBeDefined();+ expect(screen.getByText("condition false")).toBeDefined();+ expect(screen.getByText("1 block")).toBeDefined();+ expect(screen.queryByText("skipped")).toBeNull();+ const notReachedBadge = screen.getByText("did not execute");+ expect(notReachedBadge.closest("div.min-w-0")?.textContent).toContain(+ "tail_block",+ );++ fireEvent.click(+ screen.getByRole("button", { name: "Expand skipped branch" }),+ );const skippedBadge = screen.getByText("skipped");expect(skippedBadge.closest("div.min-w-0")?.textContent).toContain("other_path",);- const notReachedBadge = screen.getByText("did not execute");- expect(notReachedBadge.closest("div.min-w-0")?.textContent).toContain(+ expectDomOrder([+ "branch_check",+ "B • Else If",+ "other_path",+ "block_8","tail_block",- );+ ]);});});diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.tsxindex 2366a08d8..208665f55 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.tsx+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.tsx@@ -21,12 +21,16 @@ import {WorkflowRunOverviewActiveElement,} from "./WorkflowRunOverview";import { ThoughtCard } from "./ThoughtCard";-import { WorkflowRunTimelineBlockItem } from "./WorkflowRunTimelineBlockItem";+import {+ type SkippedBranchGroup,+ WorkflowRunTimelineBlockItem,+} from "./WorkflowRunTimelineBlockItem";import { WorkflowRunTimelineUnexecutedBlockItem } from "./WorkflowRunTimelineUnexecutedBlockItem";import { buildCodeStepsByLabel } from "../workflowBlockUtils";import {classifyUnexecutedDefinedBlocks,flattenTimelineChronologically,+ type UnexecutedDefinedBlock,} from "./workflowTimelineUtils";type Props = {@@ -113,6 +117,76 @@ function WorkflowRunTimeline({),[workflowRun],);+ const workflowRunIsNotFinalized = workflowRun+ ? statusIsNotFinalized(workflowRun)+ : false;+ const workflowRunIsFinalized = workflowRun+ ? statusIsFinalized(workflowRun)+ : false;+ const definedBlocks = useMemo(+ () => workflowRun?.workflow?.workflow_definition?.blocks ?? [],+ [workflowRun?.workflow?.workflow_definition?.blocks],+ );+ const unexecutedBlocks = useMemo(+ () =>+ workflowRunIsFinalized+ ? classifyUnexecutedDefinedBlocks(+ definedBlocks,+ workflowRunTimeline ?? [],+ )+ : [],+ [definedBlocks, workflowRunIsFinalized, workflowRunTimeline],+ );+ const { skippedBranchBlocksByConditionalId, trailingUnexecutedBlocks } =+ useMemo(() => {+ const skippedBranchGroupsByConditionalId = new Map<+ string,+ Array<SkippedBranchGroup>+ >();+ const trailingBlocks: Array<UnexecutedDefinedBlock> = [];++ unexecutedBlocks.forEach((item) => {+ if (+ item.reason === "branch_not_taken" &&+ item.skippedByWorkflowRunBlockId+ ) {+ const skippedBranchGroups =+ skippedBranchGroupsByConditionalId.get(+ item.skippedByWorkflowRunBlockId,+ ) ?? [];+ const branchKey =+ item.skippedBranch?.key ?? item.skippedBranch?.nextBlockLabel;+ const skippedBranch = item.skippedBranch;+ if (!branchKey || !skippedBranch) {+ trailingBlocks.push(item);+ return;+ }+ const skippedBranchGroup = skippedBranchGroups.find(+ (group) => group.key === branchKey,+ );+ if (skippedBranchGroup) {+ skippedBranchGroup.blocks.push(item);+ } else {+ skippedBranchGroups.push({+ key: branchKey,+ branch: skippedBranch,+ blocks: [item],+ });+ }+ skippedBranchGroupsByConditionalId.set(+ item.skippedByWorkflowRunBlockId,+ skippedBranchGroups,+ );+ return;+ }+ trailingBlocks.push(item);+ });++ return {+ skippedBranchBlocksByConditionalId: skippedBranchGroupsByConditionalId,+ trailingUnexecutedBlocks: trailingBlocks,+ };+ }, [unexecutedBlocks]);// Track known item IDs so we can animate only newly-arrived itemsconst knownItemIdsRef = useRef<Set<string>>(new Set());@@ -143,20 +217,12 @@ function WorkflowRunTimeline({return null;}- // bit redundant but better read- const workflowRunIsNotFinalized = statusIsNotFinalized(workflowRun);- const workflowRunIsFinalized = statusIsFinalized(workflowRun);-const finallyBlockLabel =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- ? classifyUnexecutedDefinedBlocks(definedBlocks, workflowRunTimeline)- : [];return (<div className="flex h-full min-w-0 flex-col overflow-hidden rounded-md border border-slate-700 bg-slate-elevation1">@@ -245,6 +311,9 @@ function WorkflowRunTimeline({block={timelineItem.block}blockOrder={blockOrder}codeStepsByLabel={codeStepsByLabel}+ skippedBranchBlocksByConditionalId={+ skippedBranchBlocksByConditionalId+ }onActionClick={onActionItemSelected}onBlockItemClick={onBlockItemSelected}onIterationClick={onIterationSelected}@@ -279,7 +348,7 @@ function WorkflowRunTimeline({}return null;})}- {unexecutedBlocks.map(({ block, reason }) => (+ {trailingUnexecutedBlocks.map(({ block, reason }) => (<WorkflowRunTimelineUnexecutedBlockItemkey={`unexecuted-${block.label}`}block={block}diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsxindex 7508626c0..956d94344 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx@@ -42,7 +42,18 @@ import {WorkflowRunOverviewActiveElement,} from "./WorkflowRunOverview";import { ThoughtCard } from "./ThoughtCard";-import { aggregateIterationStatus } from "./workflowTimelineUtils";+import {+ aggregateIterationStatus,+ type SkippedBranchMetadata,+ type UnexecutedDefinedBlock,+} from "./workflowTimelineUtils";+import { WorkflowRunTimelineUnexecutedBlockItem } from "./WorkflowRunTimelineUnexecutedBlockItem";++type SkippedBranchGroup = {+ key: string;+ branch: SkippedBranchMetadata;+ blocks: Array<UnexecutedDefinedBlock>;+};type Props = {activeItem: WorkflowRunOverviewActiveElement;@@ -52,6 +63,10 @@ type Props = {depth?: number;blockOrder?: ReadonlyMap<string, number>;codeStepsByLabel?: ReadonlyMap<string, Array<CodeBlockStep>>;+ skippedBranchBlocksByConditionalId?: ReadonlyMap<+ string,+ Array<SkippedBranchGroup>+ >;onBlockItemClick: (block: WorkflowRunBlock) => void;onIterationClick?: (loopBlock: WorkflowRunBlock,@@ -71,6 +86,7 @@ type LoopIterationGroup = {};const INDENT_PX = 14;+const MAX_INDENT_RAIL_DEPTH = 6;const RAIL_HIGHLIGHT_OFFSET_PX = INDENT_PX / 2;const RAIL_CONTENT_PADDING_PX = INDENT_PX - 1;@@ -82,7 +98,8 @@ const railHighlightStyle = {function IndentRails({ depth }: { depth: number }) {// Render guide rails only for nested rows. Top-level rows should start with// content, not a phantom outer timeline rail.- const rails = depth;+ // Cap rails so deeply nested loops/conditionals do not squeeze row content.+ const rails = Math.min(depth, MAX_INDENT_RAIL_DEPTH);return (<>{Array.from({ length: rails }).map((_, i) => (@@ -408,6 +425,10 @@ type TimelineSubItemsProps = {depth: number;blockOrder?: ReadonlyMap<string, number>;codeStepsByLabel?: ReadonlyMap<string, Array<CodeBlockStep>>;+ skippedBranchBlocksByConditionalId?: ReadonlyMap<+ string,+ Array<SkippedBranchGroup>+ >;onBlockItemClick: (block: WorkflowRunBlock) => void;onIterationClick?: (loopBlock: WorkflowRunBlock,@@ -427,6 +448,7 @@ function TimelineSubItems({depth,blockOrder,codeStepsByLabel,+ skippedBranchBlocksByConditionalId,onBlockItemClick,onIterationClick,onActionClick,@@ -449,6 +471,9 @@ function TimelineSubItems({depth={depth}blockOrder={blockOrder}codeStepsByLabel={codeStepsByLabel}+ skippedBranchBlocksByConditionalId={+ skippedBranchBlocksByConditionalId+ }onActionClick={onActionClick}onBlockItemClick={onBlockItemClick}onIterationClick={onIterationClick}@@ -778,12 +803,183 @@ function TimelineSkippedStepRows({);}+type TimelineSkippedBranchRowsProps = {+ groups: Array<SkippedBranchGroup>;+ depth: number;+};++function getSkippedBranchLabel(branch: SkippedBranchMetadata): string {+ if (branch.description) {+ return branch.description;+ }+ if (branch.criteriaDescription) {+ return branch.criteriaDescription;+ }+ return branch.isDefault+ ? `Default target ${branch.nextBlockLabel}`+ : `Target ${branch.nextBlockLabel}`;+}++function getExcelStyleLetter(index: number): string {+ let result = "";+ let num = index;++ while (num >= 0) {+ result = String.fromCharCode(65 + (num % 26)) + result;+ num = Math.floor(num / 26) - 1;+ }++ return result;+}++function getSkippedBranchMarker(branch: SkippedBranchMetadata): string {+ if (branch.branchIndex === null) {+ return branch.isDefault ? "Else" : "Branch";+ }++ const letter = getExcelStyleLetter(branch.branchIndex);+ if (branch.isDefault) {+ return `${letter} • Else`;+ }+ if (branch.branchIndex === 0) {+ return `${letter} • If`;+ }+ return `${letter} • Else If`;+}++function getSkippedBranchReason(branch: SkippedBranchMetadata): string {+ if (branch.error) return "eval error";+ if (branch.result === false) return "condition false";+ if (branch.wasEvaluated && branch.result === null) return "no match";+ if (branch.isDefault) return "another branch matched";+ if (!branch.wasEvaluated) return "not evaluated";+ return "another branch matched";+}++function getSkippedBranchTitle(branch: SkippedBranchMetadata): string {+ const parts = [+ `Skipped ${getSkippedBranchMarker(branch)}: ${getSkippedBranchLabel(branch)}`,+ `Reason: ${getSkippedBranchReason(branch)}`,+ `Target: ${branch.nextBlockLabel}`,+ ];+ if (branch.expression) {+ parts.push(`Expression: ${branch.expression}`);+ }+ if (+ branch.renderedExpression &&+ branch.renderedExpression !== branch.expression+ ) {+ parts.push(`Rendered: ${branch.renderedExpression}`);+ }+ if (branch.error) {+ parts.push(`Error: ${branch.error}`);+ }+ return parts.join("\n");+}++function TimelineSkippedBranchRows({+ groups,+ depth,+}: TimelineSkippedBranchRowsProps) {+ if (groups.length === 0) return null;++ return (+ <div className="space-y-1 py-1">+ {groups.map((group) => (+ <TimelineSkippedBranchGroup+ key={group.key}+ group={group}+ depth={depth}+ />+ ))}+ </div>+ );+}++function TimelineSkippedBranchGroup({+ group,+ depth,+}: {+ group: SkippedBranchGroup;+ depth: number;+}) {+ const [expanded, setExpanded] = useState(false);+ const branchMarker = getSkippedBranchMarker(group.branch);+ const branchLabel = getSkippedBranchLabel(group.branch);+ const branchReason = getSkippedBranchReason(group.branch);+ const title = getSkippedBranchTitle(group.branch);++ return (+ <div>+ <div className="flex min-h-[24px] items-stretch text-xs opacity-70">+ <IndentRails depth={depth} />+ <div+ className="flex min-w-0 flex-1 items-center gap-1.5 rounded-r py-0.5 pr-1.5 text-slate-400"+ style={railHighlightStyle}+ title={title}+ >+ <button+ type="button"+ className="inline-flex size-4 shrink-0 items-center justify-center rounded text-slate-400 outline-none hover:bg-slate-700 hover:text-slate-200 focus-visible:ring-1 focus-visible:ring-white/40"+ onClick={(event) => {+ event.stopPropagation();+ setExpanded((prev) => !prev);+ }}+ aria-label={+ expanded ? "Collapse skipped branch" : "Expand skipped branch"+ }+ aria-expanded={expanded}+ >+ {expanded ? (+ <ChevronDownIcon className="size-4" />+ ) : (+ <ChevronRightIcon className="size-4" />+ )}+ </button>+ <div className="flex min-w-0 flex-1 items-center gap-1.5">+ <span+ className="size-2 shrink-0 rounded-full border border-dashed border-slate-500"+ aria-hidden="true"+ />+ <span className="shrink-0 rounded border border-slate-700 bg-slate-800/50 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-slate-400">+ {branchMarker}+ </span>+ <span className="min-w-0 flex-1 truncate text-slate-500">+ · {branchLabel}+ </span>+ <span className="shrink-0 rounded bg-slate-800/60 px-1 text-[10px] text-slate-400">+ {branchReason}+ </span>+ <span className="shrink-0 rounded bg-slate-800 px-1 text-[10px] tabular-nums text-slate-400">+ {group.blocks.length}{" "}+ {group.blocks.length === 1 ? "block" : "blocks"}+ </span>+ </div>+ </div>+ </div>+ <Collapsible open={expanded}>+ <CollapsibleContent className="overflow-hidden motion-safe:data-[state=closed]:animate-collapsible-up-fade motion-safe:data-[state=open]:animate-collapsible-down-fade">+ {group.blocks.map(({ block, reason }) => (+ <WorkflowRunTimelineUnexecutedBlockItem+ key={`skipped-branch-${block.label}`}+ block={block}+ depth={depth + 1}+ reason={reason}+ />+ ))}+ </CollapsibleContent>+ </Collapsible>+ </div>+ );+}+function WorkflowRunTimelineBlockItem({activeItem,activeIteration = null,block,blockOrder,codeStepsByLabel,+ skippedBranchBlocksByConditionalId,subItems,depth = 0,onBlockItemClick,@@ -833,6 +1029,12 @@ function WorkflowRunTimelineBlockItem({? getUnfiredCodeSteps(definitionCodeSteps, actions): [];const hasSkippedCodeSteps = skippedCodeSteps.length > 0;+ const skippedBranchGroups =+ block.block_type === "conditional"+ ? (skippedBranchBlocksByConditionalId?.get(block.workflow_run_block_id) ??+ [])+ : [];+ const hasSkippedBranchBlocks = skippedBranchGroups.length > 0;const isForLoopBlock = block.block_type === "for_loop";const isWhileLoopBlock = block.block_type === "while_loop";const isLoopBlock = isForLoopBlock || isWhileLoopBlock;@@ -849,7 +1051,10 @@ function WorkflowRunTimelineBlockItem({// whose "next" block is a flat sibling), showing a chevron that reveals// nothing is worse than no chevron at all.const isContainer =- hasRenderableNestedChildren || showsActionRows || hasCodeSteps;+ hasRenderableNestedChildren ||+ showsActionRows ||+ hasCodeSteps ||+ hasSkippedBranchBlocks;// The loop block itself is only "active" when no specific iteration is// selected — otherwise the iteration row owns the highlight.@@ -887,6 +1092,7 @@ function WorkflowRunTimelineBlockItem({isRunning ||isActiveBlock ||showsActionRows ||+ hasSkippedBranchBlocks ||hasActiveDescendant ||isLoopWithSelectedIteration ||!hasRenderableNestedChildren,@@ -904,6 +1110,7 @@ function WorkflowRunTimelineBlockItem({if (userToggledRef.current) return;if (showsActionRows ||+ hasSkippedBranchBlocks ||hasActiveDescendant ||isRunning ||isLoopWithSelectedIteration@@ -912,6 +1119,7 @@ function WorkflowRunTimelineBlockItem({}}, [showsActionRows,+ hasSkippedBranchBlocks,hasActiveDescendant,isRunning,isLoopWithSelectedIteration,@@ -1048,6 +1256,12 @@ function WorkflowRunTimelineBlockItem({onBlockItemClick={onBlockItemClick}/>)}+ {hasSkippedBranchBlocks && (+ <TimelineSkippedBranchRows+ groups={skippedBranchGroups}+ depth={depth + 1}+ />+ )}{isLoopBlock && loopIterationGroups.length > 0 ? (<LoopIterationRowsloopBlock={block}@@ -1057,6 +1271,9 @@ function WorkflowRunTimelineBlockItem({depth={depth + 1}blockOrder={blockOrder}codeStepsByLabel={codeStepsByLabel}+ skippedBranchBlocksByConditionalId={+ skippedBranchBlocksByConditionalId+ }onBlockItemClick={onBlockItemClick}onIterationClick={onIterationClick}onActionClick={onActionClick}@@ -1074,6 +1291,9 @@ function WorkflowRunTimelineBlockItem({depth={depth + 1}blockOrder={blockOrder}codeStepsByLabel={codeStepsByLabel}+ skippedBranchBlocksByConditionalId={+ skippedBranchBlocksByConditionalId+ }onActionClick={onActionClick}onBlockItemClick={onBlockItemClick}onIterationClick={onIterationClick}@@ -1099,6 +1319,10 @@ type LoopIterationRowsProps = {depth: number;blockOrder?: ReadonlyMap<string, number>;codeStepsByLabel?: ReadonlyMap<string, Array<CodeBlockStep>>;+ skippedBranchBlocksByConditionalId?: ReadonlyMap<+ string,+ Array<SkippedBranchGroup>+ >;onBlockItemClick: (block: WorkflowRunBlock) => void;onIterationClick?: (loopBlock: WorkflowRunBlock,@@ -1119,6 +1343,7 @@ function LoopIterationRows({depth,blockOrder,codeStepsByLabel,+ skippedBranchBlocksByConditionalId,onBlockItemClick,onIterationClick,onActionClick,@@ -1145,6 +1370,9 @@ function LoopIterationRows({depth={depth}blockOrder={blockOrder}codeStepsByLabel={codeStepsByLabel}+ skippedBranchBlocksByConditionalId={+ skippedBranchBlocksByConditionalId+ }onBlockItemClick={onBlockItemClick}onIterationClick={onIterationClick}onActionClick={onActionClick}@@ -1168,6 +1396,10 @@ type LoopIterationRowProps = {depth: number;blockOrder?: ReadonlyMap<string, number>;codeStepsByLabel?: ReadonlyMap<string, Array<CodeBlockStep>>;+ skippedBranchBlocksByConditionalId?: ReadonlyMap<+ string,+ Array<SkippedBranchGroup>+ >;onBlockItemClick: (block: WorkflowRunBlock) => void;onIterationClick?: (loopBlock: WorkflowRunBlock,@@ -1190,6 +1422,7 @@ function LoopIterationRow({depth,blockOrder,codeStepsByLabel,+ skippedBranchBlocksByConditionalId,onBlockItemClick,onIterationClick,onActionClick,@@ -1300,6 +1533,9 @@ function LoopIterationRow({depth={depth + 1}blockOrder={blockOrder}codeStepsByLabel={codeStepsByLabel}+ skippedBranchBlocksByConditionalId={+ skippedBranchBlocksByConditionalId+ }onActionClick={onActionClick}onBlockItemClick={onBlockItemClick}onIterationClick={onIterationClick}@@ -1315,3 +1551,4 @@ function LoopIterationRow({}export { WorkflowRunTimelineBlockItem };+export type { SkippedBranchGroup };diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineUnexecutedBlockItem.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineUnexecutedBlockItem.tsxindex a8b1b869d..bf2779385 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineUnexecutedBlockItem.tsx+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineUnexecutedBlockItem.tsx@@ -5,9 +5,38 @@ import { type UnexecutedBlockReason } from "./workflowTimelineUtils";type Props = {block: WorkflowBlock;+ depth?: number;reason?: UnexecutedBlockReason;};+const INDENT_PX = 14;+const MAX_INDENT_RAIL_DEPTH = 6;+const RAIL_HIGHLIGHT_OFFSET_PX = INDENT_PX / 2;+const RAIL_CONTENT_PADDING_PX = INDENT_PX - 1;++const railHighlightStyle = {+ marginLeft: `-${RAIL_HIGHLIGHT_OFFSET_PX}px`,+ paddingLeft: `${RAIL_CONTENT_PADDING_PX}px`,+};++function IndentRails({ depth }: { depth: number }) {+ // Cap rails so deeply nested skipped/unreached rows stay readable.+ const rails = Math.min(depth, MAX_INDENT_RAIL_DEPTH);+ return (+ <>+ {Array.from({ length: rails }).map((_, i) => (+ <div+ key={i}+ className="relative shrink-0 self-stretch"+ style={{ width: `${INDENT_PX}px` }}+ >+ <div className="absolute inset-y-0 left-1/2 w-px bg-slate-700" />+ </div>+ ))}+ </>+ );+}+const reasonBadge: Record<UnexecutedBlockReason,{ label: string; title: string }@@ -44,6 +73,7 @@ function getTypeLabel(block: WorkflowBlock): string {function WorkflowRunTimelineUnexecutedBlockItem({block,+ depth = 0,reason = "not_reached",}: Props) {const typeLabel = getTypeLabel(block);@@ -52,9 +82,10 @@ function WorkflowRunTimelineUnexecutedBlockItem({return (<div className="min-w-0 opacity-60"><div className="flex min-h-[28px] items-stretch text-xs">+ <IndentRails depth={depth} /><divclassName="flex min-w-0 flex-1 items-center gap-1.5 rounded-r py-1 pr-1.5"- style={{ marginLeft: "-7px", paddingLeft: "13px" }}+ style={railHighlightStyle}><div className="size-4 shrink-0" /><div className="flex min-w-0 flex-1 items-center gap-1.5">diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/workflowTimelineUtils.test.ts b/skyvern-frontend/src/routes/workflows/workflowRun/workflowTimelineUtils.test.tsindex b60132ed5..84730ae81 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/workflowTimelineUtils.test.ts+++ b/skyvern-frontend/src/routes/workflows/workflowRun/workflowTimelineUtils.test.ts@@ -661,6 +661,10 @@ describe("classifyUnexecutedDefinedBlocks", () => {next_block_label: string | null;branch_conditions: Array<{id: string;+ criteria?: {+ description?: string | null;+ } | null;+ description?: string | null;next_block_label: string | null;is_default: boolean;}>;@@ -687,7 +691,13 @@ describe("classifyUnexecutedDefinedBlocks", () => {block_type: "conditional",branch_conditions: [{ id: "br_a", next_block_label: "block_a", is_default: false },- { id: "br_b", next_block_label: "block_b", is_default: true },+ {+ id: "br_b",+ description: "Try fallback path",+ criteria: { description: "Fallback path needed" },+ next_block_label: "block_b",+ is_default: false,+ },],}),buildDefinedBlock({ label: "block_a", next_block_label: null }),@@ -700,8 +710,30 @@ describe("classifyUnexecutedDefinedBlocks", () => {label: "cond",output: {evaluations: [- { is_matched: true, next_block_label: "block_a" },- { is_matched: false, next_block_label: "block_b" },+ {+ branch_id: "br_a",+ branch_index: 0,+ criteria_type: "jinja2_template",+ original_expression: "{{ found }}",+ rendered_expression: "true",+ result: true,+ is_matched: true,+ is_default: false,+ next_block_label: "block_a",+ error: null,+ },+ {+ branch_id: "br_b",+ branch_index: 1,+ criteria_type: "jinja2_template",+ original_expression: "{{ use_fallback }}",+ rendered_expression: "false",+ result: false,+ is_matched: false,+ is_default: false,+ next_block_label: "block_b",+ error: null,+ },],} as WorkflowRunBlock["output"],});@@ -719,6 +751,111 @@ describe("classifyUnexecutedDefinedBlocks", () => {block_b: "branch_not_taken",block_b2: "branch_not_taken",});+ expect(+ result.map((item) => [+ item.block.label,+ item.skippedByWorkflowRunBlockId,+ ]),+ ).toEqual([+ ["block_b", "wrb_cond"],+ ["block_b2", "wrb_cond"],+ ]);+ expect(result[0]?.skippedBranch).toMatchObject({+ key: "br_b",+ nextBlockLabel: "block_b",+ description: "Try fallback path",+ criteriaDescription: "Fallback path needed",+ expression: "{{ use_fallback }}",+ renderedExpression: "false",+ result: false,+ isDefault: false,+ branchIndex: 1,+ wasEvaluated: true,+ });+ });++ test("labels definition branches omitted after a matched runtime evaluation as branch_not_taken", () => {+ const defined = [+ buildDefinedBlock({+ label: "cond",+ block_type: "conditional",+ branch_conditions: [+ { id: "br_a", next_block_label: "block_a", is_default: false },+ {+ id: "br_b",+ description: "Try the alternate path",+ next_block_label: "block_b",+ is_default: false,+ },+ {+ id: "br_default",+ description: "Use default fallback",+ next_block_label: "block_default",+ is_default: true,+ },+ ],+ }),+ buildDefinedBlock({ label: "block_a", next_block_label: null }),+ buildDefinedBlock({ label: "block_b", next_block_label: null }),+ buildDefinedBlock({ label: "block_default", next_block_label: null }),+ ];+ const conditional = buildBlock({+ workflow_run_block_id: "wrb_cond",+ block_type: "conditional",+ label: "cond",+ output: {+ evaluations: [+ {+ branch_id: "br_a",+ branch_index: 0,+ criteria_type: "jinja2_template",+ original_expression: "{{ found }}",+ rendered_expression: "true",+ result: true,+ is_matched: true,+ is_default: false,+ next_block_label: "block_a",+ error: null,+ },+ ],+ } as WorkflowRunBlock["output"],+ });+ const taken = buildBlock({+ workflow_run_block_id: "wrb_a",+ label: "block_a",+ parent_workflow_run_block_id: "wrb_cond",+ });++ const result = classifyUnexecutedDefinedBlocks(defined, [+ buildBlockItem(conditional, [buildBlockItem(taken)]),+ ]);++ expect(reasonsByLabel(result)).toEqual({+ block_b: "branch_not_taken",+ block_default: "branch_not_taken",+ });+ expect(result.map((item) => item.skippedByWorkflowRunBlockId)).toEqual([+ "wrb_cond",+ "wrb_cond",+ ]);+ expect(result[0]?.skippedBranch).toMatchObject({+ key: "br_b",+ nextBlockLabel: "block_b",+ description: "Try the alternate path",+ result: null,+ isDefault: false,+ branchIndex: 1,+ wasEvaluated: false,+ });+ expect(result[1]?.skippedBranch).toMatchObject({+ key: "br_default",+ nextBlockLabel: "block_default",+ description: "Use default fallback",+ result: null,+ isDefault: true,+ branchIndex: 2,+ wasEvaluated: false,+ });});test("labels an unexecuted block on the TAKEN branch as not_reached (run ended first)", () => {@@ -762,6 +899,14 @@ describe("classifyUnexecutedDefinedBlocks", () => {block_a2: "not_reached",block_b: "branch_not_taken",});+ expect(+ result.find((item) => item.block.label === "block_a2")+ ?.skippedByWorkflowRunBlockId,+ ).toBeUndefined();+ expect(+ result.find((item) => item.block.label === "block_b")+ ?.skippedByWorkflowRunBlockId,+ ).toBe("wrb_cond");});test("labels everything not_reached when the conditional itself never executed", () => {diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/workflowTimelineUtils.ts b/skyvern-frontend/src/routes/workflows/workflowRun/workflowTimelineUtils.tsindex 64214e171..cb77bc0fc 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/workflowTimelineUtils.ts+++ b/skyvern-frontend/src/routes/workflows/workflowRun/workflowTimelineUtils.ts@@ -9,7 +9,7 @@ import {WorkflowRunBlock,WorkflowRunTimelineItem,} from "../types/workflowRunTypes";-import { WorkflowBlock } from "../types/workflowTypes";+import { BranchCondition, WorkflowBlock } from "../types/workflowTypes";import { WorkflowRunOverviewActiveElement } from "./WorkflowRunOverview";const containerBlockTypes = new Set(["for_loop", "while_loop", "conditional"]);@@ -66,6 +66,32 @@ type UnexecutedBlockReason = "branch_not_taken" | "not_reached";type UnexecutedDefinedBlock = {block: WorkflowBlock;reason: UnexecutedBlockReason;+ skippedByWorkflowRunBlockId?: string;+ skippedBranch?: SkippedBranchMetadata;+};++type SkippedBranchMetadata = {+ key: string;+ nextBlockLabel: string;+ description: string | null;+ criteriaDescription: string | null;+ expression: string | null;+ renderedExpression: string | null;+ result: boolean | null;+ error: string | null;+ isDefault: boolean;+ branchIndex: number | null;+ wasEvaluated: boolean;+};++type DefinedBranch = {+ branch: BranchCondition;+ index: number;+};++type BranchOutcome = {+ takenTargets: Array<SkippedBranchMetadata>;+ notTakenTargets: Array<SkippedBranchMetadata>;};function collectExecutedConditionals(@@ -93,16 +119,125 @@ function collectExecutedConditionals(function getBranchOutcome(runtimeBlock: WorkflowRunBlock,definedBlock: WorkflowBlock | undefined,-): { takenTargets: Array<string>; notTakenTargets: Array<string> } | null {+): BranchOutcome | null {+ const branchesById = new Map<string, DefinedBranch>();+ const branchesByTarget = new Map<string, DefinedBranch>();+ if (definedBlock?.block_type === "conditional") {+ definedBlock.branch_conditions.forEach((branch, index) => {+ const definedBranch = { branch, index };+ branchesById.set(branch.id, definedBranch);+ if (branch.next_block_label) {+ branchesByTarget.set(branch.next_block_label, definedBranch);+ }+ });+ }++ const toBranchTarget = ({+ branch,+ fallbackKey,+ nextBlockLabel,+ branchIndex = null,+ wasEvaluated = false,+ }: {+ branch: DefinedBranch | undefined;+ fallbackKey: string;+ nextBlockLabel: string;+ branchIndex?: number | null;+ wasEvaluated?: boolean;+ }): SkippedBranchMetadata => ({+ key: branch?.branch.id ?? fallbackKey,+ nextBlockLabel,+ description: branch?.branch.description ?? null,+ criteriaDescription: branch?.branch.criteria?.description ?? null,+ expression: null,+ renderedExpression: null,+ result: null,+ error: null,+ isDefault: branch?.branch.is_default ?? false,+ branchIndex: branchIndex ?? branch?.index ?? null,+ wasEvaluated,+ });+if (hasEvaluations(runtimeBlock.output)) {const evaluations = runtimeBlock.output.evaluations ?? [];+ const takenTargets = evaluations+ .filter((e) => e.is_matched && e.next_block_label)+ .map((evaluation) => {+ const nextBlockLabel = evaluation.next_block_label!;+ const branch =+ branchesById.get(evaluation.branch_id) ??+ branchesByTarget.get(nextBlockLabel);+ return {+ ...toBranchTarget({+ branch,+ fallbackKey: evaluation.branch_id ?? nextBlockLabel,+ nextBlockLabel,+ branchIndex: evaluation.branch_index ?? branch?.index ?? null,+ wasEvaluated: true,+ }),+ expression: evaluation.original_expression ?? null,+ renderedExpression: evaluation.rendered_expression ?? null,+ result: evaluation.result ?? null,+ error: evaluation.error ?? null,+ isDefault:+ evaluation.is_default ?? branch?.branch.is_default ?? false,+ };+ });+ const notTakenTargets = evaluations+ .filter((e) => !e.is_matched && e.next_block_label)+ .map((evaluation) => {+ const nextBlockLabel = evaluation.next_block_label!;+ const branch =+ branchesById.get(evaluation.branch_id) ??+ branchesByTarget.get(nextBlockLabel);+ return {+ ...toBranchTarget({+ branch,+ fallbackKey: evaluation.branch_id ?? nextBlockLabel,+ nextBlockLabel,+ branchIndex: evaluation.branch_index ?? branch?.index ?? null,+ wasEvaluated: true,+ }),+ expression: evaluation.original_expression ?? null,+ renderedExpression: evaluation.rendered_expression ?? null,+ result: evaluation.result ?? null,+ error: evaluation.error ?? null,+ isDefault:+ evaluation.is_default ?? branch?.branch.is_default ?? false,+ };+ });+ if (definedBlock?.block_type === "conditional") {+ const takenKeys = new Set(takenTargets.map((target) => target.key));+ const takenLabels = new Set(+ takenTargets.map((target) => target.nextBlockLabel),+ );+ const notTakenKeys = new Set(notTakenTargets.map((target) => target.key));+ const notTakenLabels = new Set(+ notTakenTargets.map((target) => target.nextBlockLabel),+ );+ definedBlock.branch_conditions.forEach((branch, index) => {+ if (!branch.next_block_label) return;+ const branchKey = branch.id ?? branch.next_block_label;+ if (+ takenKeys.has(branchKey) ||+ takenLabels.has(branch.next_block_label!) ||+ notTakenKeys.has(branchKey) ||+ notTakenLabels.has(branch.next_block_label!)+ ) {+ return;+ }+ notTakenTargets.push(+ toBranchTarget({+ branch: { branch, index },+ fallbackKey: branchKey,+ nextBlockLabel: branch.next_block_label,+ }),+ );+ });+ }return {- takenTargets: evaluations- .filter((e) => e.is_matched && e.next_block_label)- .map((e) => e.next_block_label!),- notTakenTargets: evaluations- .filter((e) => !e.is_matched && e.next_block_label)- .map((e) => e.next_block_label!),+ takenTargets,+ notTakenTargets,};}const taken = runtimeBlock.executed_branch_next_block;@@ -110,10 +245,25 @@ function getBranchOutcome(return null;}return {- takenTargets: [taken],+ takenTargets: [+ toBranchTarget({+ branch: branchesByTarget.get(taken),+ fallbackKey: taken,+ nextBlockLabel: taken,+ }),+ ],notTakenTargets: definedBlock.branch_conditions- .map((branch) => branch.next_block_label)- .filter((label): label is string => !!label && label !== taken),+ .filter(+ (branch) =>+ branch.next_block_label && branch.next_block_label !== taken,+ )+ .map((branch, index) =>+ toBranchTarget({+ branch: { branch, index },+ fallbackKey: branch.next_block_label!,+ nextBlockLabel: branch.next_block_label!,+ }),+ ),};}@@ -170,6 +320,8 @@ function classifyUnexecutedDefinedBlocks();const skipped = new Set<string>();+ const skippedByWorkflowRunBlockId = new Map<string, string>();+ const skippedBranchByLabel = new Map<string, SkippedBranchMetadata>();const onTakenPath = new Set<string>();for (const conditional of collectExecutedConditionals(timelineItems)) {const definedBlock = conditional.label@@ -178,20 +330,50 @@ function classifyUnexecutedDefinedBlocks(const outcome = getBranchOutcome(conditional, definedBlock);if (!outcome) continue;for (const target of outcome.notTakenTargets) {- traceDefinitionChain(target, blocksByLabel, executedLabels, skipped);+ const branchSkipped = new Set<string>();+ traceDefinitionChain(+ target.nextBlockLabel,+ blocksByLabel,+ executedLabels,+ branchSkipped,+ );+ for (const label of branchSkipped) {+ skipped.add(label);+ if (!skippedByWorkflowRunBlockId.has(label)) {+ skippedByWorkflowRunBlockId.set(+ label,+ conditional.workflow_run_block_id,+ );+ }+ if (!skippedBranchByLabel.has(label)) {+ skippedBranchByLabel.set(label, target);+ }+ }}for (const target of outcome.takenTargets) {- traceDefinitionChain(target, blocksByLabel, executedLabels, onTakenPath);+ traceDefinitionChain(+ target.nextBlockLabel,+ blocksByLabel,+ executedLabels,+ onTakenPath,+ );}}- return unexecuted.map((block) => ({- block,- reason:- skipped.has(block.label) && !onTakenPath.has(block.label)- ? "branch_not_taken"- : "not_reached",- }));+ return unexecuted.map((block) => {+ const isBranchNotTaken =+ skipped.has(block.label) && !onTakenPath.has(block.label);+ return {+ block,+ reason: isBranchNotTaken ? "branch_not_taken" : "not_reached",+ skippedByWorkflowRunBlockId: isBranchNotTaken+ ? skippedByWorkflowRunBlockId.get(block.label)+ : undefined,+ skippedBranch: isBranchNotTaken+ ? skippedBranchByLabel.get(block.label)+ : undefined,+ };+ });}function findBlockSurroundingAction(@@ -630,4 +812,8 @@ export {parseActiveIterationParam,resolveScreenshotBlockId,};-export type { UnexecutedBlockReason, UnexecutedDefinedBlock };+export type {+ SkippedBranchMetadata,+ UnexecutedBlockReason,+ UnexecutedDefinedBlock,+};