Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
Jump the studio editor to a workflow block when its timeline item is clicked (#7409)
Celal Zamanoğlu70e293955d23
diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsxindex 2bd100a53..8b3aec2cd 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx@@ -11,6 +11,7 @@ import { TooltipProvider } from "@/components/ui/tooltip";import { useRunPaneViewStore } from "@/store/useRunPaneViewStore";import { useRunViewStore } from "@/store/RunViewStore";import { useStudioBrowserStore } from "@/store/useStudioBrowserStore";+import { useWorkflowBlockSearchStore } from "@/store/WorkflowBlockSearchStore";import type {WorkflowRunBlock,WorkflowRunTimelineItem,@@ -570,6 +571,64 @@ describe("RunView iteration selection", () => {}, 20_000);});+describe("RunView timeline → editor jump", () => {+ function seedRunWithBlock(label: string) {+ mocks.timeline = [+ buildBlockItem(buildBlock({ workflow_run_block_id: "wrb_jump", label })),+ ];+ mocks.workflowRun = {+ workflow_run_id: "wr_1",+ status: Status.Completed,+ workflow: {+ workflow_definition: { blocks: [], finally_block_label: null },+ },+ };+ }++ function registerHandle() {+ const focusBlock = vi.fn();+ useWorkflowBlockSearchStore.getState().registerHandle({+ getTargets: () => [+ { nodeId: "node-jump", label: "jump-target-block", blockType: null },+ ],+ focusBlock,+ });+ return focusBlock;+ }++ function clickBlock(container: HTMLElement) {+ const [blockButton] = within(container).getAllByText("jump-target-block");+ if (!blockButton) {+ throw new Error("timeline block did not render");+ }+ fireEvent.click(blockButton);+ }++ afterEach(() => {+ useWorkflowBlockSearchStore.getState().registerHandle(null);+ });++ test("clicking a timeline block jumps the editor when the editor pane is open", () => {+ seedRunWithBlock("jump-target-block");+ const focusBlock = registerHandle();++ const { container } = renderRunView({}, "/?wr=wr_1&panes=editor,overview");+ clickBlock(container);++ expect(focusBlock).toHaveBeenCalledWith("node-jump");+ });++ test("clicking a timeline block does not jump when the editor pane is closed", () => {+ seedRunWithBlock("jump-target-block");+ const focusBlock = registerHandle();++ const { container } = renderRunView({}, "/?wr=wr_1&panes=overview");+ clickBlock(container);++ expect(focusBlock).not.toHaveBeenCalled();+ });+});+describe("RunView output signals", () => {test("surfaces run errors, error codes, and rich downloaded files", () => {seedCompletedRun({diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsxindex fb4eb3c87..3126ceb1a 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx@@ -12,6 +12,7 @@ import { statusIsFinalized } from "@/routes/tasks/types";import { useRunPaneViewStore } from "@/store/useRunPaneViewStore";import { useRunViewStore } from "@/store/RunViewStore";import { useStudioBrowserStore } from "@/store/useStudioBrowserStore";+import { useWorkflowBlockSearchStore } from "@/store/WorkflowBlockSearchStore";import { isRecord } from "@/util/utils";import { useWorkflowRunTimelineQuery } from "../../hooks/useWorkflowRunTimelineQuery";@@ -42,6 +43,7 @@ import {} from "./RunOutputsSection";import { RunPlaceholder } from "./RunPlaceholder";import { RunSummaryStrip } from "./RunSummaryStrip";+import { resolveTimelineBlockJumpNodeId } from "./timelineBlockJump";type RunViewProps = {workflowRunId?: string;@@ -406,6 +408,19 @@ export function RunView({}}onBlockItemSelected={(block) => {pinFrame(block.workflow_run_block_id);+ const handle =+ useWorkflowBlockSearchStore.getState().handle;+ if (!handle) {+ return;+ }+ const nodeId = resolveTimelineBlockJumpNodeId({+ editorOpen: studioPanes.includes("editor"),+ targets: handle.getTargets(),+ label: block.label,+ });+ if (nodeId) {+ handle.focusBlock(nodeId);+ }}}onThoughtItemSelected={(thought) => {pinFrame(thought.thought_id);diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/timelineBlockJump.test.ts b/skyvern-frontend/src/routes/workflows/studio/runview/timelineBlockJump.test.tsnew file mode 100644index 000000000..f4bcead03--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/studio/runview/timelineBlockJump.test.ts@@ -0,0 +1,65 @@+import { describe, expect, it } from "vitest";++import { type BlockSearchTarget } from "@/routes/workflows/studio/blockSearch";+import { resolveTimelineBlockJumpNodeId } from "./timelineBlockJump";++const targets: Array<BlockSearchTarget> = [+ { nodeId: "node-a", label: "Login", blockType: null },+ { nodeId: "node-b", label: "Extract data", blockType: null },+];++describe("resolveTimelineBlockJumpNodeId", () => {+ it("returns null when the editor pane is closed, even with a matching block", () => {+ expect(+ resolveTimelineBlockJumpNodeId({+ editorOpen: false,+ targets,+ label: "Login",+ }),+ ).toBeNull();+ });++ it("returns null for a block with no label", () => {+ expect(+ resolveTimelineBlockJumpNodeId({+ editorOpen: true,+ targets,+ label: null,+ }),+ ).toBeNull();+ });++ it("returns null when the label matches no editor node (renamed/deleted since the run)", () => {+ expect(+ resolveTimelineBlockJumpNodeId({+ editorOpen: true,+ targets,+ label: "Gone",+ }),+ ).toBeNull();+ });++ it("returns the matching node id when the editor is open and the label matches", () => {+ expect(+ resolveTimelineBlockJumpNodeId({+ editorOpen: true,+ targets,+ label: "Extract data",+ }),+ ).toBe("node-b");+ });++ it("returns null when the label matches more than one node (ambiguous, degrade to no-op)", () => {+ const duplicated: Array<BlockSearchTarget> = [+ { nodeId: "node-a", label: "Login", blockType: null },+ { nodeId: "node-c", label: "Login", blockType: null },+ ];+ expect(+ resolveTimelineBlockJumpNodeId({+ editorOpen: true,+ targets: duplicated,+ label: "Login",+ }),+ ).toBeNull();+ });+});diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/timelineBlockJump.ts b/skyvern-frontend/src/routes/workflows/studio/runview/timelineBlockJump.tsnew file mode 100644index 000000000..e6a7e3bac--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/studio/runview/timelineBlockJump.ts@@ -0,0 +1,21 @@+import { type BlockSearchTarget } from "@/routes/workflows/studio/blockSearch";++// null = no jump: editor pane closed (selection must not move a hidden canvas),+// unlabeled block, or a label that isn't a single match in the current draft —+// absent (edited since the run) or, since labels are only softly unique,+// ambiguous, where a jump can't tell which node was meant.+export function resolveTimelineBlockJumpNodeId({+ editorOpen,+ targets,+ label,+}: {+ editorOpen: boolean;+ targets: Array<BlockSearchTarget>;+ label: string | null;+}): string | null {+ if (!editorOpen || !label) {+ return null;+ }+ const [match, ...rest] = targets.filter((target) => target.label === label);+ return match !== undefined && rest.length === 0 ? match.nodeId : null;+}