From 0243ae13754c46510f40b729f002c05a27932937 Mon Sep 17 00:00:00 2001 From: Suchintan Date: Fri, 13 Feb 2026 00:34:18 -0500 Subject: [PATCH] Fix parameter toggle not collapsing auto-expanded rows (#SKY-7982) (#4741) Co-authored-by: Suchintan Singh --- skyvern-frontend/src/routes/workflows/Workflows.tsx | 10 +++++++++- .../routes/workflows/hooks/useParameterExpansion.ts | 13 +++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/skyvern-frontend/src/routes/workflows/Workflows.tsx b/skyvern-frontend/src/routes/workflows/Workflows.tsx index 44083c18..594afb43 100644 --- a/skyvern-frontend/src/routes/workflows/Workflows.tsx +++ b/skyvern-frontend/src/routes/workflows/Workflows.tsx @@ -293,11 +293,13 @@ function Workflows() { expandedRows, toggleExpanded: toggleParametersExpanded, setAutoExpandedRows, + setManuallyExpandedRows, } = useParameterExpansion(); useEffect(() => { if (!isSearchActive) { setAutoExpandedRows([]); + setManuallyExpandedRows(new Set()); return; } @@ -316,7 +318,13 @@ function Workflows() { setAutoExpandedRows( matchingWorkflows.map((workflow) => workflow.workflow_permanent_id), ); - }, [isSearchActive, workflows, matchesParameter, setAutoExpandedRows]); + }, [ + isSearchActive, + workflows, + matchesParameter, + setAutoExpandedRows, + setManuallyExpandedRows, + ]); function handleRowClick( event: React.MouseEvent, diff --git a/skyvern-frontend/src/routes/workflows/hooks/useParameterExpansion.ts b/skyvern-frontend/src/routes/workflows/hooks/useParameterExpansion.ts index 9dbd6df9..f15126ae 100644 --- a/skyvern-frontend/src/routes/workflows/hooks/useParameterExpansion.ts +++ b/skyvern-frontend/src/routes/workflows/hooks/useParameterExpansion.ts @@ -25,9 +25,18 @@ function useParameterExpansion() { }, []); const expandedRows = useMemo(() => { - const combined = new Set(autoExpandedRows); + const combined = new Set(); + // 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) { - combined.add(id); + if (!autoExpandedRows.has(id)) { + combined.add(id); + } } return combined; }, [autoExpandedRows, manuallyExpandedRows]);