Skip to content

Automate browser based workflows with AI

feat(SKY-9577): swap WorkflowRunTimelineBlockItem to ActionCardCompact behind flag (#6016)

Celal Zamanoğlufd56c1617a80
diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.test.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.test.tsx
new file mode 100644
index 000000000..77ae288cb
--- /dev/null
+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.test.tsx
@@ -0,0 +1,147 @@
+// @vitest-environment jsdom
+
+// AxiosClient reads env vars at module load time — stub it before the
+// component tree (which transitively imports it) is resolved.
+vi.mock("@/api/AxiosClient", () => ({ getClient: vi.fn() }));
+vi.mock("@/hooks/useCredentialGetter", () => ({
+ useCredentialGetter: () => null,
+}));
+vi.mock("@/hooks/useWorkflowRunViewingV2", () => ({
+ useWorkflowRunViewingV2: vi.fn(),
+}));
+
+import { cleanup, fireEvent, render, screen } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+import { type ActionsApiResponse, Status } from "@/api/types";
+import { useWorkflowRunViewingV2 } from "@/hooks/useWorkflowRunViewingV2";
+import type { WorkflowRunBlock } from "../types/workflowRunTypes";
+import { WorkflowRunTimelineBlockItem } from "./WorkflowRunTimelineBlockItem";
+
+function buildAction(
+ overrides: Partial<ActionsApiResponse> = {},
+): ActionsApiResponse {
+ return {
+ action_id: "act_1",
+ action_type: "click",
+ status: Status.Completed,
+ task_id: "task_1",
+ step_id: "step_1",
+ step_order: 0,
+ action_order: 0,
+ confidence_float: 0.9,
+ description: null,
+ reasoning: "Click the submit button",
+ intention: null,
+ response: null,
+ created_by: null,
+ text: null,
+ ...overrides,
+ };
+}
+
+function buildBlock(
+ overrides: Partial<WorkflowRunBlock> = {},
+): WorkflowRunBlock {
+ return {
+ workflow_run_block_id: "wrb_1",
+ workflow_run_id: "wr_1",
+ parent_workflow_run_block_id: null,
+ block_type: "task",
+ label: "Sample block",
+ description: null,
+ title: null,
+ status: Status.Completed,
+ failure_reason: null,
+ output: null,
+ continue_on_failure: false,
+ task_id: null,
+ url: null,
+ navigation_goal: null,
+ navigation_payload: null,
+ data_extraction_goal: null,
+ data_schema: null,
+ terminate_criterion: null,
+ complete_criterion: null,
+ include_action_history_in_verification: null,
+ engine: null,
+ actions: [buildAction()],
+ created_at: "2026-05-14T00:00:00Z",
+ modified_at: "2026-05-14T00:00:00Z",
+ duration: null,
+ loop_values: null,
+ current_value: null,
+ current_index: null,
+ ...overrides,
+ };
+}
+
+afterEach(() => {
+ cleanup();
+ vi.clearAllMocks();
+});
+
+describe("WorkflowRunTimelineBlockItem action renderer", () => {
+ it("renders the legacy ActionCard when the v2 flag is off", () => {
+ vi.mocked(useWorkflowRunViewingV2).mockReturnValue(false);
+
+ render(
+ <WorkflowRunTimelineBlockItem
+ activeItem={null}
+ block={buildBlock()}
+ subItems={[]}
+ onBlockItemClick={() => {}}
+ onActionClick={() => {}}
+ onThoughtCardClick={() => {}}
+ />,
+ );
+
+ expect(document.querySelector('[data-slot="runcard"]')).not.toBeNull();
+ expect(
+ document.querySelector('[data-slot="action-card-compact"]'),
+ ).toBeNull();
+ });
+
+ it("renders ActionCardCompact when the v2 flag is on", () => {
+ vi.mocked(useWorkflowRunViewingV2).mockReturnValue(true);
+
+ render(
+ <WorkflowRunTimelineBlockItem
+ activeItem={null}
+ block={buildBlock()}
+ subItems={[]}
+ onBlockItemClick={() => {}}
+ onActionClick={() => {}}
+ onThoughtCardClick={() => {}}
+ />,
+ );
+
+ expect(
+ document.querySelector('[data-slot="action-card-compact"]'),
+ ).not.toBeNull();
+ expect(document.querySelector('[data-slot="runcard"]')).toBeNull();
+ expect(screen.getByText("Click the submit button")).toBeDefined();
+ });
+
+ it("clicking a compact action selects the action without selecting the block", () => {
+ vi.mocked(useWorkflowRunViewingV2).mockReturnValue(true);
+ const onActionClick = vi.fn();
+ const onBlockItemClick = vi.fn();
+
+ render(
+ <WorkflowRunTimelineBlockItem
+ activeItem={null}
+ block={buildBlock()}
+ subItems={[]}
+ onBlockItemClick={onBlockItemClick}
+ onActionClick={onActionClick}
+ onThoughtCardClick={() => {}}
+ />,
+ );
+
+ fireEvent.click(screen.getByText("Click the submit button"));
+
+ expect(onActionClick).toHaveBeenCalledTimes(1);
+ expect(onBlockItemClick).not.toHaveBeenCalled();
+ });
+});
diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx
index c1dae4a92..4b2bcfa67 100644
--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx
+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx
@@ -23,6 +23,8 @@ import {
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";
+import { useWorkflowRunViewingV2 } from "@/hooks/useWorkflowRunViewingV2";
+import { ActionCardCompact } from "@/routes/tasks/detail/ActionCardCompact";
import { formatDuration, toDuration } from "@/routes/workflows/utils";
import { cn } from "@/util/utils";
import { workflowBlockTitle } from "../editor/nodes/types";
@@ -350,6 +352,8 @@ function WorkflowRunTimelineBlockItem({
finallyBlockLabel,
workflowRunIsFinalized = false,
}: Props) {
+ const isViewingV2 = useWorkflowRunViewingV2();
+ const [expandedActionId, setExpandedActionId] = useState<string | null>(null);
const actions = block.actions ?? [];
const isFinallyBlock = finallyBlockLabel && block.label === finallyBlockLabel;
@@ -713,15 +717,39 @@ function WorkflowRunTimelineBlockItem({
)}
{actions.map((action, index) => {
+ const isActive =
+ isAction(activeItem) && activeItem.action_id === action.action_id;
+ const displayIndex = actions.length - index;
+ if (isViewingV2) {
+ return (
+ <div
+ key={action.action_id}
+ onClick={(event) => event.stopPropagation()}
+ >
+ <ActionCardCompact
+ action={action}
+ active={isActive}
+ index={displayIndex}
+ expanded={expandedActionId === action.action_id}
+ onToggleExpanded={() => {
+ setExpandedActionId((prev) =>
+ prev === action.action_id ? null : action.action_id,
+ );
+ }}
+ onSelect={() => {
+ onActionClick({ block, action });
+ }}
+ cardClassName={getCardElevation(depth)}
+ />
+ </div>
+ );
+ }
return (
<ActionCard
key={action.action_id}
action={action}
- active={
- isAction(activeItem) &&
- activeItem.action_id === action.action_id
- }
- index={actions.length - index}
+ active={isActive}
+ index={displayIndex}
onClick={(event) => {
event.stopPropagation();
const actionItem: ActionItem = {