Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
fix(SKY-10969): keep Run Inputs collapsed during Run History filtering (#6573)
Aaron Perezdd62cdcdac2d
diff --git a/skyvern-frontend/src/routes/history/RunHistory.test.tsx b/skyvern-frontend/src/routes/history/RunHistory.test.tsxnew file mode 100644index 000000000..ea267e69f--- /dev/null+++ b/skyvern-frontend/src/routes/history/RunHistory.test.tsx@@ -0,0 +1,145 @@+// @vitest-environment jsdom+import {+ cleanup,+ fireEvent,+ render,+ screen,+ within,+} from "@testing-library/react";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { afterEach, describe, expect, it, vi } from "vitest";+import { MemoryRouter } from "react-router-dom";++import { TaskRunType } from "@/api/types";+import { RunHistory } from "./RunHistory";++const workflowRun = {+ task_run_id: "tr_1",+ task_run_type: TaskRunType.WorkflowRun,+ run_id: "wr_123",+ title: "My Run",+ status: "completed",+ started_at: "2026-06-14T10:00:00Z",+ finished_at: "2026-06-14T10:01:00Z",+ created_at: "2026-06-14T10:00:00Z",+ workflow_permanent_id: "wpid_1",+ workflow_deleted: false,+ script_run: false,+ searchable_text: "city Paris",+};++// Stable references so an active search doesn't churn the runs identity+// across renders (which would retrigger effects under test).+const runsData = [workflowRun];+const runsQueryResult = { data: runsData, isFetching: false };++vi.mock("use-debounce", () => ({+ useDebounce: <T,>(value: T): [T] => [value],+}));++vi.mock("posthog-js/react", () => ({+ useFeatureFlagVariantKey: () => undefined,+}));++vi.mock("@/hooks/useRunsQuery", () => ({+ useRunsQuery: () => runsQueryResult,+}));++vi.mock("@/hooks/useCredentialGetter", () => ({+ useCredentialGetter: () => vi.fn(),+}));++vi.mock("@/routes/workflows/hooks/useGlobalWorkflowsQuery", () => ({+ useGlobalWorkflowsQuery: () => ({ data: [] }),+}));++vi.mock("@/components/StatusFilterDropdown", () => ({+ StatusFilterDropdown: () => <div data-testid="status-filter" />,+}));++vi.mock("@/components/onboarding/OnboardingEmptyState", () => ({+ OnboardingEmptyState: () => <div data-testid="onboarding-empty" />,+}));++vi.mock("@/store/onboarding/useOnboardingState", () => ({+ useOnboardingStateOptional: () => null,+}));++vi.mock("@/components/TableSearchInput", () => ({+ TableSearchInput: ({+ value,+ onChange,+ placeholder,+ disabled,+ }: {+ value: string;+ onChange: (value: string) => void;+ placeholder?: string;+ disabled?: boolean;+ }) => (+ <input+ aria-label="search-runs"+ value={value}+ placeholder={placeholder}+ disabled={disabled}+ onChange={(event) => onChange(event.target.value)}+ />+ ),+}));++vi.mock("@/api/AxiosClient", () => ({+ getClient: vi.fn(async () => ({+ get: vi.fn(async () => ({+ data: { parameters: { city: "Paris" }, extra_http_headers: null },+ })),+ })),+}));++function renderRunHistory() {+ const queryClient = new QueryClient({+ defaultOptions: { queries: { retry: false } },+ });+ return render(+ <QueryClientProvider client={queryClient}>+ <MemoryRouter initialEntries={["/history"]}>+ <RunHistory />+ </MemoryRouter>+ </QueryClientProvider>,+ );+}++function activateSearch() {+ fireEvent.change(screen.getByLabelText("search-runs"), {+ target: { value: "city" },+ });+}++afterEach(() => {+ cleanup();+ vi.clearAllMocks();+});++describe("RunHistory inputs during filtering", () => {+ it("keeps Run Inputs collapsed while a search is active", () => {+ renderRunHistory();+ activateSearch();++ // The run is in the results, but its inputs pane must not auto-expand:+ // only the header row and the single data row should be present.+ expect(screen.getByText("wr_123")).toBeTruthy();+ expect(screen.getAllByRole("row")).toHaveLength(2);+ expect(screen.queryByText("Run Inputs")).toBeNull();+ });++ it("still lets the user expand Run Inputs during a search", async () => {+ renderRunHistory();+ activateSearch();++ const runRow = screen.getByText("wr_123").closest("tr");+ expect(runRow).not.toBeNull();+ fireEvent.click(within(runRow as HTMLElement).getByRole("button"));++ expect(await screen.findByText("Run Inputs")).toBeTruthy();+ expect(screen.getByText("Paris")).toBeTruthy();+ });+});diff --git a/skyvern-frontend/src/routes/history/RunHistory.tsx b/skyvern-frontend/src/routes/history/RunHistory.tsxindex 3a8dfbb8c..4f03dfda7 100644--- a/skyvern-frontend/src/routes/history/RunHistory.tsx+++ b/skyvern-frontend/src/routes/history/RunHistory.tsx@@ -49,7 +49,7 @@ import {} from "@/util/timeFormat";import { cn } from "@/util/utils";import { useQuery } from "@tanstack/react-query";-import React, { useEffect, useMemo, useState } from "react";+import React, { useMemo, useState } from "react";import { useNavigate, useSearchParams } from "react-router-dom";import { getClient } from "@/api/AxiosClient";import { useCredentialGetter } from "@/hooks/useCredentialGetter";@@ -183,28 +183,9 @@ function RunHistory() {const isNextDisabled =isFetching || !nextPageRuns || nextPageRuns.length === 0;- const { matchesParameter, isSearchActive } =- useKeywordSearch(debouncedSearch);- const {- expandedRows,- toggleExpanded: toggleParametersExpanded,- setAutoExpandedRows,- } = useParameterExpansion();-- useEffect(() => {- if (!isSearchActive) {- setAutoExpandedRows([]);- return;- }-- const workflowRunIds =- runs- ?.filter((run) => run.task_run_type === TaskRunType.WorkflowRun)- .map((run) => run.run_id)- .filter((id): id is string => Boolean(id)) ?? [];-- setAutoExpandedRows(workflowRunIds);- }, [isSearchActive, runs, setAutoExpandedRows]);+ const { matchesParameter } = useKeywordSearch(debouncedSearch);+ const { expandedRows, toggleExpanded: toggleParametersExpanded } =+ useParameterExpansion();function handleNavigate(event: React.MouseEvent, path: string) {if (event.ctrlKey || event.metaKey) {diff --git a/skyvern-frontend/src/routes/workflows/WorkflowPage.test.tsx b/skyvern-frontend/src/routes/workflows/WorkflowPage.test.tsxindex 2fea58a41..1a355b0cb 100644--- a/skyvern-frontend/src/routes/workflows/WorkflowPage.test.tsx+++ b/skyvern-frontend/src/routes/workflows/WorkflowPage.test.tsx@@ -75,7 +75,6 @@ vi.mock("./hooks/useTagKeysQuery", () => ({vi.mock("./hooks/useKeywordSearch", () => ({useKeywordSearch: () => ({matchesParameter: () => false,- isSearchActive: false,}),}));@@ -83,7 +82,6 @@ vi.mock("./hooks/useParameterExpansion", () => ({useParameterExpansion: () => ({expandedRows: new Set<string>(),toggleExpanded: vi.fn(),- setAutoExpandedRows: vi.fn(),}),}));diff --git a/skyvern-frontend/src/routes/workflows/WorkflowPage.tsx b/skyvern-frontend/src/routes/workflows/WorkflowPage.tsxindex ee4cf90cb..cf1d3bcd4 100644--- a/skyvern-frontend/src/routes/workflows/WorkflowPage.tsx+++ b/skyvern-frontend/src/routes/workflows/WorkflowPage.tsx@@ -104,13 +104,9 @@ function WorkflowPage() {const [search, setSearch] = useState("");const [debouncedSearch] = useDebounce(search, 500);const [openRunParams, setOpenRunParams] = useState<string | null>(null);- const { matchesParameter, isSearchActive } =- useKeywordSearch(debouncedSearch);- const {- expandedRows,- toggleExpanded: toggleParametersExpanded,- setAutoExpandedRows,- } = useParameterExpansion();+ const { matchesParameter } = useKeywordSearch(debouncedSearch);+ const { expandedRows, toggleExpanded: toggleParametersExpanded } =+ useParameterExpansion();const { data: workflowRuns, isLoading } = useWorkflowRunsQuery({workflowPermanentId,@@ -151,20 +147,6 @@ function WorkflowPage() {[tagKeys],);- useEffect(() => {- if (!isSearchActive) {- setAutoExpandedRows([]);- return;- }-- const runIds =- workflowRuns- ?.map((run) => run.workflow_run_id)- .filter((id): id is string => Boolean(id)) ?? [];-- setAutoExpandedRows(runIds);- }, [isSearchActive, workflowRuns, setAutoExpandedRows]);-if (!workflowPermanentId) {return null; // this should never happen}diff --git a/skyvern-frontend/src/routes/workflows/Workflows.tsx b/skyvern-frontend/src/routes/workflows/Workflows.tsxindex 62d2a6d79..9f2d2c5c5 100644--- a/skyvern-frontend/src/routes/workflows/Workflows.tsx+++ b/skyvern-frontend/src/routes/workflows/Workflows.tsx@@ -442,44 +442,9 @@ function Workflows() {};}, [workflowTagsMap]);- const { matchesParameter, isSearchActive } =- useKeywordSearch(debouncedSearch);- const {- expandedRows,- toggleExpanded: toggleParametersExpanded,- setAutoExpandedRows,- setManuallyExpandedRows,- } = useParameterExpansion();-- useEffect(() => {- if (!isSearchActive) {- setAutoExpandedRows([]);- setManuallyExpandedRows(new Set());- return;- }-- const matchingWorkflows = workflows.filter((workflow) =>- workflow.workflow_definition.parameters?.some((param) => {- const value =- param.parameter_type === "workflow" ? param.default_value : undefined;- return matchesParameter({- key: param.key,- value,- description: param.description ?? null,- });- }),- );-- setAutoExpandedRows(- matchingWorkflows.map((workflow) => workflow.workflow_permanent_id),- );- }, [- isSearchActive,- workflows,- matchesParameter,- setAutoExpandedRows,- setManuallyExpandedRows,- ]);+ const { matchesParameter } = useKeywordSearch(debouncedSearch);+ const { expandedRows, toggleExpanded: toggleParametersExpanded } =+ useParameterExpansion();function handleRowClick(event: React.MouseEvent<HTMLTableCellElement>,diff --git a/skyvern-frontend/src/routes/workflows/hooks/useParameterExpansion.ts b/skyvern-frontend/src/routes/workflows/hooks/useParameterExpansion.tsindex f15126aee..cba91a4f3 100644--- a/skyvern-frontend/src/routes/workflows/hooks/useParameterExpansion.ts+++ b/skyvern-frontend/src/routes/workflows/hooks/useParameterExpansion.ts@@ -1,19 +1,10 @@-import { useCallback, useMemo, useState } from "react";--function toSet(ids: Iterable<string>): Set<string> {- return new Set(ids);-}+import { useCallback, useState } from "react";function useParameterExpansion() {- const [manuallyExpandedRows, setManuallyExpandedRows] = useState<Set<string>>(- new Set(),- );- const [autoExpandedRows, setAutoExpandedRows] = useState<Set<string>>(- new Set(),- );+ const [expandedRows, setExpandedRows] = useState<Set<string>>(new Set());const toggleExpanded = useCallback((id: string) => {- setManuallyExpandedRows((prev) => {+ setExpandedRows((prev) => {const next = new Set(prev);if (next.has(id)) {next.delete(id);@@ -24,33 +15,9 @@ function useParameterExpansion() {});}, []);- const expandedRows = useMemo(() => {- const combined = new Set<string>();- // Symmetric difference (XOR): a row is expanded if it's in one set but not both.- // This lets manual toggles override auto-expansion (and vice versa).- for (const id of autoExpandedRows) {- if (!manuallyExpandedRows.has(id)) {- combined.add(id);- }- }- for (const id of manuallyExpandedRows) {- if (!autoExpandedRows.has(id)) {- combined.add(id);- }- }- return combined;- }, [autoExpandedRows, manuallyExpandedRows]);-- const updateAutoExpandedRows = useCallback((ids: Iterable<string>) => {- setAutoExpandedRows(toSet(ids));- }, []);-return {expandedRows,toggleExpanded,- setManuallyExpandedRows,- manuallyExpandedRows,- setAutoExpandedRows: updateAutoExpandedRows,};}