Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
fix(SKY-11151): gate run-timeline action/step rows to code blocks (#6675)
Aaron Perez9e9519566a4a
diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunBlockDetail.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunBlockDetail.tsxindex c48b2ee26..6f8e5fdcb 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunBlockDetail.tsx+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunBlockDetail.tsx@@ -117,7 +117,13 @@ function renderBodyForBlock(/>);case "conditional":- return <BlockDetailConditional block={block} />;+ return (+ <BlockDetailConditional+ block={block}+ activeItem={activeItem}+ onActionSelect={onActionSelect}+ />+ );case "for_loop":case "while_loop":return <BlockDetailLoop block={block} iterationIndex={activeIteration} />;diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.test.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.test.tsxindex 822c524d6..1af97e6a1 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.test.tsx+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.test.tsx@@ -149,11 +149,11 @@ describe("WorkflowRunTimelineBlockItem", () => {expect(screen.queryByText("0 actions")).toBeNull();});- it("renders action rows under a leaf block and lets the user select an action", () => {+ it("renders action rows under a code block and lets the user select an action", () => {const onActionClick = vi.fn();const block = buildBlock({workflow_run_block_id: "wrb_action_block",- block_type: "task_v2",+ block_type: "code",label: "Open account page",actions: [{@@ -204,7 +204,7 @@ describe("WorkflowRunTimelineBlockItem", () => {});});- it("renders action rows under a container block without requiring expansion", () => {+ it("renders child blocks but not action rows under a non-code container block", () => {const block = buildBlock({workflow_run_block_id: "wrb_container_with_actions",block_type: "conditional",@@ -236,23 +236,26 @@ describe("WorkflowRunTimelineBlockItem", () => {/>,);+ // The nested child block is still revealed...+ expect(screen.getByText("Next step")).toBeDefined();+ // ...but a non-code block never surfaces its own actions as rows.expect(- screen.getByText(/Extract the condition result from the page/),- ).toBeDefined();+ screen.queryByText(/Extract the condition result from the page/),+ ).toBeNull();});- it("renders extract action rows for conditional blocks", () => {+ it("does not render action rows under a non-code leaf block but keeps the count badge", () => {const onActionClick = vi.fn();const block = buildBlock({- workflow_run_block_id: "wrb_condition_action",- block_type: "conditional",- label: "check_signin_ok",+ workflow_run_block_id: "wrb_login_actions",+ block_type: "login",+ label: "block_1",actions: [{- action_id: "act_condition_extract",- action_type: ActionTypes.extract,+ action_id: "act_login_click",+ action_type: ActionTypes.Click,status: Status.Completed,- reasoning: "Extract whether sign-in succeeded from the page",+ reasoning: "Click the login link in the top navigation",created_by: null,confidence_float: 1,},@@ -269,18 +272,13 @@ describe("WorkflowRunTimelineBlockItem", () => {/>,);+ // The block still advertises how many actions it ran...expect(screen.getByText("1 action")).toBeDefined();- expect(screen.getByText("Extract Data")).toBeDefined();+ // ...but those actions are not surfaced as rows in the timeline rail.expect(- screen.getByText(/Extract whether sign-in succeeded from the page/),- ).toBeDefined();-- fireEvent.click(screen.getByRole("button", { name: /#1/i }));-- expect(onActionClick).toHaveBeenCalledWith({- block,- action: expect.objectContaining({ action_id: "act_condition_extract" }),- });+ screen.queryByText(/Click the login link in the top navigation/),+ ).toBeNull();+ expect(onActionClick).not.toHaveBeenCalled();});it("renders loop iterations from first to last", () => {@@ -507,7 +505,7 @@ describe("WorkflowRunTimelineBlockItem", () => {expect(screen.getByText(/ValueError: boom · line 7/)).toBeDefined();});- it("keeps task block action rows unchanged even when output carries line metadata", () => {+ it("does not render action rows for a non-code block even when output carries line metadata", () => {const block = buildBlock({workflow_run_block_id: "wrb_task_null_action",block_type: "task_v2",@@ -535,9 +533,9 @@ describe("WorkflowRunTimelineBlockItem", () => {/>,);- expect(screen.getByText("Screenshot")).toBeDefined();+ expect(screen.queryByText("Screenshot")).toBeNull();expect(screen.queryByText("Error")).toBeNull();- expect(screen.getByText(/Capture failed/)).toBeDefined();+ expect(screen.queryByText(/Capture failed/)).toBeNull();expect(screen.queryByText(/line 5/)).toBeNull();});diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsxindex fa302bf58..bc96da027 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx@@ -29,7 +29,7 @@ import {WorkflowRunBlock,WorkflowRunTimelineItem,} from "../types/workflowRunTypes";-import { CodeBlockStep } from "../types/workflowTypes";+import { type CodeBlockStep, WorkflowBlockTypes } from "../types/workflowTypes";import {ActionItem,WorkflowRunOverviewActiveElement,@@ -447,7 +447,7 @@ function TimelineActionRows({}: TimelineActionRowsProps) {const actions = block.actions ?? [];const actionsTopDown = [...actions].reverse();- const isCodeBlock = block.block_type === "code";+ const isCodeBlock = block.block_type === WorkflowBlockTypes.Code;if (actions.length === 0) return null;@@ -624,10 +624,16 @@ function WorkflowRunTimelineBlockItem({const actionCount = actions.length;const hasActions = actionCount > 0;+ // Only code blocks break their execution down into action/step rows inside the+ // timeline rail. Agent blocks (login, task, navigation, ...) expose their+ // actions through the detail panel instead, so the rail stays a high-level+ // block outline for them.+ const isCodeBlock = block.block_type === WorkflowBlockTypes.Code;+ const showsActionRows = isCodeBlock && hasActions;// Code blocks without recorded actions fall back to their definition step// outline so the timeline still reflects what the block was meant to do.const codeSteps =- block.block_type === "code" && !hasActions+ isCodeBlock && !hasActions? (codeStepsByLabel?.get(block.label ?? "") ?? []): [];const hasCodeSteps = codeSteps.length > 0;@@ -646,7 +652,8 @@ function WorkflowRunTimelineBlockItem({// the runtime didn't model any child blocks under them (e.g. conditionals// whose "next" block is a flat sibling), showing a chevron that reveals// nothing is worse than no chevron at all.- const isContainer = hasRenderableNestedChildren || hasActions || hasCodeSteps;+ const isContainer =+ hasRenderableNestedChildren || showsActionRows || hasCodeSteps;// The loop block itself is only "active" when no specific iteration is// selected — otherwise the iteration row owns the highlight.@@ -683,7 +690,7 @@ function WorkflowRunTimelineBlockItem({const [expanded, setExpanded] = useState(isRunning ||isActiveBlock ||- hasActions ||+ showsActionRows ||hasActiveDescendant ||isLoopWithSelectedIteration ||!hasRenderableNestedChildren,@@ -700,14 +707,19 @@ function WorkflowRunTimelineBlockItem({useEffect(() => {if (userToggledRef.current) return;if (- hasActions ||+ showsActionRows ||hasActiveDescendant ||isRunning ||isLoopWithSelectedIteration) {setExpanded(true);}- }, [hasActions, hasActiveDescendant, isRunning, isLoopWithSelectedIteration]);+ }, [+ showsActionRows,+ hasActiveDescendant,+ isRunning,+ isLoopWithSelectedIteration,+ ]);const loopValues = Array.isArray(block.loop_values) ? block.loop_values : [];@@ -814,7 +826,7 @@ function WorkflowRunTimelineBlockItem({{isContainer && (<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">- {hasActions && (+ {showsActionRows && (<TimelineActionRowsblock={block}activeItem={activeItem}diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/BlockDetailConditional.test.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/BlockDetailConditional.test.tsxindex 3702532fc..fc2db1d06 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/BlockDetailConditional.test.tsx+++ b/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/BlockDetailConditional.test.tsx@@ -5,13 +5,29 @@ vi.mock("@/hooks/useCredentialGetter", () => ({useCredentialGetter: () => null,}));-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 { Status } from "@/api/types";+import { ActionTypes, Status, type ActionsApiResponse } from "@/api/types";import type { WorkflowRunBlock } from "../../types/workflowRunTypes";import { BlockDetailConditional } from "./BlockDetailConditional";+function buildAction(+ overrides: Partial<ActionsApiResponse> = {},+): ActionsApiResponse {+ return {+ action_id: "act_default",+ action_type: ActionTypes.extract,+ status: Status.Completed,+ reasoning: "Extract conditional result",+ text: null,+ response: null,+ confidence_float: null,+ created_by: null,+ ...overrides,+ } as ActionsApiResponse;+}+function buildConditional(overrides: Partial<WorkflowRunBlock> = {},): WorkflowRunBlock {@@ -97,6 +113,47 @@ describe("BlockDetailConditional", () => {expect(screen.getByText("fallback")).toBeDefined();});+ it("renders conditional actions in the detail panel", () => {+ const block = buildConditional({+ actions: [+ buildAction({+ action_id: "act_condition_extract",+ reasoning: "Extract the condition result from the page",+ }),+ ],+ });++ render(<BlockDetailConditional block={block} />);++ expect(screen.getByText("Actions (1)")).toBeDefined();+ expect(+ screen.getByText("Extract the condition result from the page"),+ ).toBeDefined();+ });++ it("fires onActionSelect when a conditional action is selected", () => {+ const onActionSelect = vi.fn();+ const action = buildAction({+ action_id: "act_condition_extract",+ reasoning: "Extract the condition result from the page",+ });+ const block = buildConditional({ actions: [action] });++ render(+ <BlockDetailConditional+ block={block}+ activeItem={null}+ onActionSelect={onActionSelect}+ />,+ );++ fireEvent.click(+ screen.getByText("Extract the condition result from the page"),+ );++ expect(onActionSelect).toHaveBeenCalledWith({ block, action });+ });+it("falls back to the legacy executed_branch_expression rendering when no evaluations array", () => {const block = buildConditional({executed_branch_id: "b_match",diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/BlockDetailConditional.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/BlockDetailConditional.tsxindex 28dd13415..185628cf9 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/BlockDetailConditional.tsx+++ b/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/BlockDetailConditional.tsx@@ -1,13 +1,25 @@+import type { ActionsApiResponse } from "@/api/types";import {hasEvaluations,type WorkflowRunBlock,} from "../../types/workflowRunTypes";+import type { WorkflowRunOverviewActiveElement } from "../WorkflowRunOverview";import { JsonExplorer } from "./BlockInspector";-import { BlockDetailFailure, CodeBlock, Section } from "./shared";+import {+ BlockActionList,+ BlockDetailFailure,+ CodeBlock,+ Section,+} from "./shared";import { cn } from "@/util/utils";type Props = {block: WorkflowRunBlock;+ activeItem?: WorkflowRunOverviewActiveElement;+ onActionSelect?: (payload: {+ block: WorkflowRunBlock;+ action: ActionsApiResponse;+ }) => void;};function tryParseJson(value: string): unknown | null {@@ -32,7 +44,11 @@ function RenderedExpression({ value }: { value: string }) {);}-function BlockDetailConditional({ block }: Props) {+function BlockDetailConditional({+ block,+ activeItem = null,+ onActionSelect,+}: Props) {const evaluations =hasEvaluations(block.output) && block.output.evaluations? block.output.evaluations@@ -45,6 +61,11 @@ function BlockDetailConditional({ block }: Props) {return (<div className="space-y-4 px-3 py-3 empty:hidden"><BlockDetailFailure block={block} />+ <BlockActionList+ block={block}+ activeItem={activeItem}+ onActionSelect={onActionSelect}+ />{hasExecutedBranch && evaluations && evaluations.length > 0 ? (<Section title="Branches"><div className="space-y-2">