Skip to content

Automate browser based workflows with AI

Fix parameter toggle not collapsing auto-expanded rows (#SKY-7982) (#4741)

Suchintan0243ae13754c
diff --git a/skyvern-frontend/src/routes/workflows/Workflows.tsx b/skyvern-frontend/src/routes/workflows/Workflows.tsx
index 44083c188..594afb431 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<HTMLTableCellElement>,
diff --git a/skyvern-frontend/src/routes/workflows/hooks/useParameterExpansion.ts b/skyvern-frontend/src/routes/workflows/hooks/useParameterExpansion.ts
index 9dbd6df9a..f15126aee 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<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) {
- combined.add(id);
+ if (!autoExpandedRows.has(id)) {
+ combined.add(id);
+ }
}
return combined;
}, [autoExpandedRows, manuallyExpandedRows]);