Skip to content

Automate browser based workflows with AI

feat(SKY-12446): search run timeline blocks by label and jump to match (#7495)

Celal Zamanoğlu0c767adbd502
diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx
index 937e8f818..535046c46 100644
--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx
@@ -286,6 +286,8 @@ describe("RunView view toggles", () => {
expect(scope.getByRole("group", { name: "Run view" })).not.toBeNull();
// The timeline tree is visible by default (loop row present).
expect(scope.queryAllByText("checkout-loop").length).toBeGreaterThan(0);
+ // Studio opts into label search (legacy run view does not).
+ expect(scope.getByRole("button", { name: "Search blocks" })).not.toBeNull();
});
test("the Timeline view leads with the summary meta line", () => {
diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx
index 4681f0ff8..65c849742 100644
--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx
@@ -406,6 +406,7 @@ export function RunView({
<WorkflowRunTimeline
workflowRunId={workflowRunId}
hideLiveBadge
+ enableSearch
activeItem={activeItem}
activeIteration={activeIteration}
onActionItemSelected={(item) => {
diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.test.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.test.tsx
index 7bbdcd1ef..bd458c4c5 100644
--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.test.tsx
+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.test.tsx
@@ -7,7 +7,16 @@ import {
screen,
within,
} from "@testing-library/react";
-import { afterEach, describe, expect, it, vi } from "vitest";
+import {
+ afterAll,
+ afterEach,
+ beforeAll,
+ beforeEach,
+ describe,
+ expect,
+ it,
+ vi,
+} from "vitest";
import { type ReactNode } from "react";
import { Status } from "@/api/types";
@@ -45,6 +54,40 @@ vi.mock("@/components/ui/scroll-area", () => ({
),
}));
+// The search Popover + cmdk need ResizeObserver and scrollIntoView, which
+// jsdom lacks. Install them for this suite only and restore afterward.
+class MockResizeObserver {
+ observe() {}
+ unobserve() {}
+ disconnect() {}
+}
+
+const originalScrollIntoView = Element.prototype.scrollIntoView;
+let scrollIntoViewMock: ReturnType<typeof vi.fn>;
+
+beforeAll(() => {
+ vi.stubGlobal("ResizeObserver", MockResizeObserver);
+});
+
+afterAll(() => {
+ vi.unstubAllGlobals();
+ if (originalScrollIntoView) {
+ Element.prototype.scrollIntoView = originalScrollIntoView;
+ } else {
+ delete (Element.prototype as { scrollIntoView?: unknown }).scrollIntoView;
+ }
+});
+
+beforeEach(() => {
+ scrollIntoViewMock = vi.fn();
+ Element.prototype.scrollIntoView =
+ scrollIntoViewMock as unknown as typeof Element.prototype.scrollIntoView;
+ // reduced-motion off by default; the jump uses smooth scrolling.
+ window.matchMedia = vi
+ .fn()
+ .mockReturnValue({ matches: false }) as unknown as typeof window.matchMedia;
+});
+
function buildBlock(
overrides: Partial<WorkflowRunBlock> = {},
): WorkflowRunBlock {
@@ -97,13 +140,20 @@ function buildBlockItem(
const noop = () => {};
-function renderTimeline(activeItem: WorkflowRunOverviewActiveElement) {
+function renderTimeline(
+ activeItem: WorkflowRunOverviewActiveElement,
+ options: {
+ enableSearch?: boolean;
+ onBlockItemSelected?: (block: WorkflowRunBlock) => void;
+ } = {},
+) {
return render(
<WorkflowRunTimeline
activeItem={activeItem}
+ enableSearch={options.enableSearch}
onLiveStreamSelected={noop}
onActionItemSelected={noop}
- onBlockItemSelected={noop}
+ onBlockItemSelected={options.onBlockItemSelected ?? noop}
onThoughtItemSelected={noop}
onIterationSelected={noop}
/>,
@@ -403,3 +453,203 @@ describe("WorkflowRunTimeline", () => {
]);
});
});
+
+describe("timeline block search", () => {
+ function seed(blocks: Array<WorkflowRunBlock>) {
+ mocks.workflowRun = {
+ status: Status.Completed,
+ total_steps: 0,
+ credits_used: 0,
+ cached_credits_used: 0,
+ workflow: {
+ workflow_definition: { blocks: [], finally_block_label: null },
+ },
+ };
+ mocks.timeline = blocks.map((block) => buildBlockItem(block));
+ }
+
+ it("renders no search trigger when enableSearch is omitted (legacy parity)", () => {
+ seed([buildBlock({ workflow_run_block_id: "wrb_a", label: "Login" })]);
+
+ renderTimeline(null);
+
+ expect(screen.queryByRole("button", { name: "Search blocks" })).toBeNull();
+ });
+
+ it("lists top-level labeled blocks and filters by case-insensitive substring", () => {
+ seed([
+ buildBlock({
+ workflow_run_block_id: "wrb_a",
+ label: "Login",
+ created_at: "2026-01-01T00:00:00Z",
+ }),
+ buildBlock({
+ workflow_run_block_id: "wrb_b",
+ label: "Extract rows",
+ created_at: "2026-01-01T00:01:00Z",
+ }),
+ buildBlock({
+ workflow_run_block_id: "wrb_c",
+ label: null,
+ created_at: "2026-01-01T00:02:00Z",
+ }),
+ ]);
+
+ renderTimeline(null, { enableSearch: true });
+ fireEvent.click(screen.getByRole("button", { name: "Search blocks" }));
+
+ // The null-label block is not searchable → two options.
+ expect(screen.getAllByRole("option")).toHaveLength(2);
+
+ fireEvent.change(screen.getByPlaceholderText("Search blocks…"), {
+ target: { value: "ROWS" },
+ });
+ const options = screen.getAllByRole("option");
+ expect(options).toHaveLength(1);
+ expect(options[0]?.textContent).toContain("Extract rows");
+ });
+
+ it("shows an empty state when nothing matches", () => {
+ seed([buildBlock({ workflow_run_block_id: "wrb_a", label: "Login" })]);
+
+ renderTimeline(null, { enableSearch: true });
+ fireEvent.click(screen.getByRole("button", { name: "Search blocks" }));
+ fireEvent.change(screen.getByPlaceholderText("Search blocks…"), {
+ target: { value: "no such block" },
+ });
+
+ expect(screen.queryAllByRole("option")).toHaveLength(0);
+ expect(screen.getByText("No blocks found.")).toBeTruthy();
+ });
+
+ it("selecting a result selects the block and scrolls it into view", () => {
+ const onBlockItemSelected = vi.fn();
+ const login = buildBlock({
+ workflow_run_block_id: "wrb_a",
+ label: "Login",
+ created_at: "2026-01-01T00:00:00Z",
+ });
+ const extract = buildBlock({
+ workflow_run_block_id: "wrb_b",
+ label: "Extract rows",
+ created_at: "2026-01-01T00:01:00Z",
+ });
+ seed([login, extract]);
+
+ renderTimeline(null, { enableSearch: true, onBlockItemSelected });
+ fireEvent.click(screen.getByRole("button", { name: "Search blocks" }));
+ fireEvent.change(screen.getByPlaceholderText("Search blocks…"), {
+ target: { value: "extract" },
+ });
+ fireEvent.click(screen.getByRole("option"));
+
+ expect(onBlockItemSelected).toHaveBeenCalledWith(extract);
+ expect(scrollIntoViewMock).toHaveBeenCalledWith({
+ behavior: "smooth",
+ block: "start",
+ });
+ // The popover closes after a jump.
+ expect(screen.queryByPlaceholderText("Search blocks…")).toBeNull();
+ });
+
+ it("honors prefers-reduced-motion for the jump", () => {
+ window.matchMedia = vi.fn().mockReturnValue({
+ matches: true,
+ }) as unknown as typeof window.matchMedia;
+ seed([buildBlock({ workflow_run_block_id: "wrb_a", label: "Login" })]);
+
+ renderTimeline(null, { enableSearch: true });
+ fireEvent.click(screen.getByRole("button", { name: "Search blocks" }));
+ fireEvent.click(screen.getByRole("option"));
+
+ expect(scrollIntoViewMock).toHaveBeenCalledWith({
+ behavior: "auto",
+ block: "start",
+ });
+ });
+
+ it("reopening after a jump starts from a clean query", () => {
+ seed([
+ buildBlock({
+ workflow_run_block_id: "wrb_a",
+ label: "Login",
+ created_at: "2026-01-01T00:00:00Z",
+ }),
+ buildBlock({
+ workflow_run_block_id: "wrb_b",
+ label: "Extract rows",
+ created_at: "2026-01-01T00:01:00Z",
+ }),
+ ]);
+
+ renderTimeline(null, { enableSearch: true });
+ fireEvent.click(screen.getByRole("button", { name: "Search blocks" }));
+ fireEvent.change(screen.getByPlaceholderText("Search blocks…"), {
+ target: { value: "login" },
+ });
+ fireEvent.click(screen.getByRole("option"));
+
+ fireEvent.click(screen.getByRole("button", { name: "Search blocks" }));
+ const reopened = screen.getByPlaceholderText(
+ "Search blocks…",
+ ) as HTMLInputElement;
+ expect(reopened.value).toBe("");
+ expect(screen.getAllByRole("option")).toHaveLength(2);
+ });
+
+ it("closes on Escape without reaching a window keydown handler", () => {
+ // Studio's editor canvas (FlowRenderer) has a window Escape handler that
+ // clears its selection; the popover must not leak Escape to it.
+ const windowEscape = vi.fn();
+ window.addEventListener("keydown", windowEscape);
+ try {
+ seed([buildBlock({ workflow_run_block_id: "wrb_a", label: "Login" })]);
+ renderTimeline(null, { enableSearch: true });
+ fireEvent.click(screen.getByRole("button", { name: "Search blocks" }));
+ fireEvent.keyDown(screen.getByPlaceholderText("Search blocks…"), {
+ key: "Escape",
+ });
+
+ expect(screen.queryByPlaceholderText("Search blocks…")).toBeNull();
+ expect(windowEscape).not.toHaveBeenCalled();
+ } finally {
+ window.removeEventListener("keydown", windowEscape);
+ }
+ });
+
+ it("excludes nested loop children from search results (top-level scope)", () => {
+ const loop = buildBlock({
+ workflow_run_block_id: "wrb_loop",
+ block_type: "for_loop",
+ label: "checkout_loop",
+ created_at: "2026-01-01T00:00:00Z",
+ });
+ const loopChild = buildBlock({
+ workflow_run_block_id: "wrb_child",
+ block_type: "navigation",
+ label: "inner_step",
+ parent_workflow_run_block_id: "wrb_loop",
+ created_at: "2026-01-01T00:00:30Z",
+ });
+ mocks.workflowRun = {
+ status: Status.Completed,
+ total_steps: 0,
+ credits_used: 0,
+ cached_credits_used: 0,
+ workflow: {
+ workflow_definition: { blocks: [], finally_block_label: null },
+ },
+ };
+ mocks.timeline = [buildBlockItem(loop, [buildBlockItem(loopChild)])];
+
+ renderTimeline(null, { enableSearch: true });
+ fireEvent.click(screen.getByRole("button", { name: "Search blocks" }));
+
+ const options = screen.getAllByRole("option");
+ expect(options).toHaveLength(1);
+ expect(options[0]?.textContent).toContain("checkout_loop");
+ expect(options.some((o) => o.textContent?.includes("inner_step"))).toBe(
+ false,
+ );
+ });
+});
diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.tsx
index 76e1d9bb7..81b37fe86 100644
--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.tsx
+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.tsx
@@ -1,9 +1,22 @@
+import {
+ Command,
+ CommandEmpty,
+ CommandGroup,
+ CommandInput,
+ CommandItem,
+ CommandList,
+} from "@/components/ui/command";
+import {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from "@/components/ui/popover";
import { ScrollArea, ScrollAreaViewport } from "@/components/ui/scroll-area";
import { Skeleton } from "@/components/ui/skeleton";
import { statusIsFinalized, statusIsNotFinalized } from "@/routes/tasks/types";
import { cn } from "@/util/utils";
-import { DotFilledIcon } from "@radix-ui/react-icons";
-import { useEffect, useMemo, useRef } from "react";
+import { DotFilledIcon, MagnifyingGlassIcon } from "@radix-ui/react-icons";
+import { useEffect, useMemo, useRef, useState } from "react";
import { useWorkflowRunWithWorkflowQuery } from "../hooks/useWorkflowRunWithWorkflowQuery";
import { useWorkflowRunTimelineQuery } from "../hooks/useWorkflowRunTimelineQuery";
import {
@@ -40,6 +53,9 @@ type Props = {
workflowRunId?: string;
// Studio owns live-status in its own header; let it hide this duplicate badge.
hideLiveBadge?: boolean;
+ // Opt-in label search + jump-to-block; off by default so the legacy run
+ // view renders no search UI and stays unchanged.
+ enableSearch?: boolean;
onLiveStreamSelected: () => void;
onActionItemSelected: (item: ActionItem) => void;
onBlockItemSelected: (item: WorkflowRunBlock) => void;
@@ -86,11 +102,130 @@ function buildBlockOrderIndex(
return new Map(blocks.map((block, index) => [block.id, index + 1]));
}
+type TimelineSearchTarget = {
+ block: WorkflowRunBlock;
+ label: string;
+ order: number | null;
+};
+
+// Top-level rows only: flattenTimelineChronologically hoists conditional
+// branches here, but loop/task_v2 children stay nested with no row to scroll to.
+function collectTimelineSearchTargets(
+ items: Array<WorkflowRunTimelineItem>,
+ blockOrder: ReadonlyMap<string, number>,
+): Array<TimelineSearchTarget> {
+ const targets: Array<TimelineSearchTarget> = [];
+ for (const item of items) {
+ if (!isBlockItem(item)) {
+ continue;
+ }
+ const label = item.block.label;
+ if (!label || label.trim() === "") {
+ continue;
+ }
+ targets.push({
+ block: item.block,
+ label,
+ order: blockOrder.get(item.block.workflow_run_block_id) ?? null,
+ });
+ }
+ return targets;
+}
+
+function filterTimelineSearchTargets(
+ targets: Array<TimelineSearchTarget>,
+ query: string,
+): Array<TimelineSearchTarget> {
+ const needle = query.trim().toLowerCase();
+ if (needle === "") {
+ return targets;
+ }
+ return targets.filter((target) =>
+ target.label.toLowerCase().includes(needle),
+ );
+}
+
+function TimelineBlockSearch({
+ targets,
+ onJump,
+}: {
+ targets: Array<TimelineSearchTarget>;
+ onJump: (target: TimelineSearchTarget) => void;
+}) {
+ const [open, setOpen] = useState(false);
+ const [query, setQuery] = useState("");
+ const results = filterTimelineSearchTargets(targets, query);
+ const closeAndReset = () => {
+ setOpen(false);
+ setQuery("");
+ };
+ return (
+ <Popover
+ open={open}
+ onOpenChange={(next) => (next ? setOpen(true) : closeAndReset())}
+ >
+ <PopoverTrigger asChild>
+ <button
+ type="button"
+ aria-label="Search blocks"
+ className="ml-auto inline-flex shrink-0 cursor-pointer items-center rounded p-1 text-slate-400 transition-colors hover:bg-slate-700 hover:text-slate-200"
+ >
+ <MagnifyingGlassIcon className="size-3.5" />
+ </button>
+ </PopoverTrigger>
+ <PopoverContent align="end" sideOffset={6} className="w-64 p-0">
+ <Command
+ shouldFilter={false}
+ onKeyDown={(event) => {
+ // Keep Escape local: Studio may mount the editor canvas beside the
+ // run view, whose window Escape handler would clear its selection.
+ if (event.key === "Escape") {
+ event.stopPropagation();
+ closeAndReset();
+ }
+ }}
+ >
+ <CommandInput
+ placeholder="Search blocks…"
+ value={query}
+ onValueChange={setQuery}
+ />
+ <CommandList>
+ <CommandEmpty>No blocks found.</CommandEmpty>
+ {results.length > 0 ? (
+ <CommandGroup>
+ {results.map((target) => (
+ <CommandItem
+ key={target.block.workflow_run_block_id}
+ value={target.block.workflow_run_block_id}
+ onSelect={() => {
+ onJump(target);
+ closeAndReset();
+ }}
+ >
+ {target.order !== null ? (
+ <span className="mr-2 shrink-0 text-muted-foreground">
+ #{target.order}
+ </span>
+ ) : null}
+ <span className="truncate">{target.label}</span>
+ </CommandItem>
+ ))}
+ </CommandGroup>
+ ) : null}
+ </CommandList>
+ </Command>
+ </PopoverContent>
+ </Popover>
+ );
+}
+
function WorkflowRunTimeline({
activeItem,
activeIteration = null,
workflowRunId,
hideLiveBadge = false,
+ enableSearch = false,
onLiveStreamSelected,
onActionItemSelected,
onBlockItemSelected,
@@ -110,6 +245,35 @@ function WorkflowRunTimeline({
() => buildBlockOrderIndex(workflowRunTimeline ?? []),
[workflowRunTimeline],
);
+ const searchTargets = useMemo(
+ () =>
+ enableSearch
+ ? collectTimelineSearchTargets(displayTimeline, blockOrder)
+ : [],
+ [enableSearch, displayTimeline, blockOrder],
+ );
+ const blockElementsRef = useRef<Map<string, HTMLDivElement>>(new Map());
+ const registerBlockElement = (id: string, el: HTMLDivElement | null) => {
+ if (el) {
+ blockElementsRef.current.set(id, el);
+ } else {
+ blockElementsRef.current.delete(id);
+ }
+ };
+ const jumpToBlock = (target: TimelineSearchTarget) => {
+ onBlockItemSelected(target.block);
+ const el = blockElementsRef.current.get(target.block.workflow_run_block_id);
+ if (!el) {
+ return;
+ }
+ const reduceMotion =
+ typeof window.matchMedia === "function" &&
+ window.matchMedia("(prefers-reduced-motion: reduce)").matches;
+ el.scrollIntoView({
+ behavior: reduceMotion ? "auto" : "smooth",
+ block: "start",
+ });
+ };
const codeStepsByLabel = useMemo(
() =>
buildCodeStepsByLabel(
@@ -274,6 +438,9 @@ function WorkflowRunTimeline({
<span>Live</span>
</button>
)}
+ {enableSearch && (
+ <TimelineBlockSearch targets={searchTargets} onJump={jumpToBlock} />
+ )}
</div>
<ScrollArea className="min-h-0 flex-1">
<ScrollAreaViewport className="h-full max-h-full [&>div]:!block [&>div]:!overflow-x-hidden">
@@ -301,6 +468,15 @@ function WorkflowRunTimeline({
return (
<div
key={timelineItem.block.workflow_run_block_id}
+ ref={
+ enableSearch
+ ? (el) =>
+ registerBlockElement(
+ timelineItem.block.workflow_run_block_id,
+ el,
+ )
+ : undefined
+ }
className={cn({
"duration-300 animate-in fade-in slide-in-from-top-3":
isNew,