Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
fix(SKY-11599): re-stack legacy editor canvas after collapse/accordion animations settle (#6933)
Celal Zamanoğlu0cd6da173c9b
diff --git a/skyvern-frontend/src/routes/workflows/editor/FlowRenderer.tsx b/skyvern-frontend/src/routes/workflows/editor/FlowRenderer.tsxindex 9027bfe13..8f705fc36 100644--- a/skyvern-frontend/src/routes/workflows/editor/FlowRenderer.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/FlowRenderer.tsx@@ -92,6 +92,7 @@ import {WorkflowBlockNode,} from "./nodes";import { GlobalCollapseControl } from "./collapse/GlobalCollapseControl";+import { isHeightCollapseAnimation } from "./collapse/collapseRelayoutAnimations";import { WorkflowScopeContext } from "./WorkflowScopeContext";import { FitViewControl } from "./controls/FitViewControl";import { RedoControl } from "./controls/RedoControl";@@ -1319,6 +1320,41 @@ function FlowRenderer({const editorElementRef = useRef<HTMLDivElement>(null);+ // A collapse/accordion animation settles the node at a new height; the layout+ // budget can drop its final relayout, so force one (delegated via animationend).+ useEffect(() => {+ const root = editorElementRef.current;+ if (!root) {+ return;+ }+ let relayoutFrame: number | null = null;+ const handleAnimationEnd = (event: AnimationEvent) => {+ if (!isHeightCollapseAnimation(event.animationName)) {+ return;+ }+ // Defer two frames so React Flow commits the post-animation measurement+ // (Radix resolves the height back to `auto`) before we read it.+ if (relayoutFrame !== null) {+ cancelAnimationFrame(relayoutFrame);+ }+ relayoutFrame = requestAnimationFrame(() => {+ relayoutFrame = requestAnimationFrame(() => {+ relayoutFrame = null;+ const currentNodes = reactFlowInstance.getNodes() as Array<AppNode>;+ const currentEdges = reactFlowInstance.getEdges();+ debouncedLayoutForDimensions(currentNodes, currentEdges);+ });+ });+ };+ root.addEventListener("animationend", handleAnimationEnd);+ return () => {+ root.removeEventListener("animationend", handleAnimationEnd);+ if (relayoutFrame !== null) {+ cancelAnimationFrame(relayoutFrame);+ }+ };+ }, [reactFlowInstance, debouncedLayoutForDimensions]);+// Ordered ids of the top-level sortable siblings. M2 extends this with a// scope per loop container and per conditional branch// so a drag inside a nested container only reorders thatdiff --git a/skyvern-frontend/src/routes/workflows/editor/collapse/collapseRelayoutAnimations.test.ts b/skyvern-frontend/src/routes/workflows/editor/collapse/collapseRelayoutAnimations.test.tsnew file mode 100644index 000000000..cf3c40a73--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/editor/collapse/collapseRelayoutAnimations.test.ts@@ -0,0 +1,31 @@+import { describe, expect, test } from "vitest";++import {+ HEIGHT_COLLAPSE_ANIMATION_NAMES,+ isHeightCollapseAnimation,+} from "./collapseRelayoutAnimations";++describe("isHeightCollapseAnimation", () => {+ test("matches every height-animating collapse/accordion keyframe", () => {+ for (const name of [+ "accordion-down",+ "accordion-up",+ "collapsible-down",+ "collapsible-up",+ "collapsible-down-fade",+ "collapsible-up-fade",+ ]) {+ expect(isHeightCollapseAnimation(name)).toBe(true);+ }+ });++ test("ignores unrelated animations (no spurious relayout)", () => {+ for (const name of ["glow", "fade-in", "spin", "", "accordion"]) {+ expect(isHeightCollapseAnimation(name)).toBe(false);+ }+ });++ test("the name set stays aligned with the keyframes it gates", () => {+ expect(HEIGHT_COLLAPSE_ANIMATION_NAMES.size).toBe(6);+ });+});diff --git a/skyvern-frontend/src/routes/workflows/editor/collapse/collapseRelayoutAnimations.ts b/skyvern-frontend/src/routes/workflows/editor/collapse/collapseRelayoutAnimations.tsnew file mode 100644index 000000000..d943a1aef--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/editor/collapse/collapseRelayoutAnimations.ts@@ -0,0 +1,14 @@+// Height-animating collapse/accordion keyframes (must match tailwind.config).+// When one ends, the node has settled and the canvas must re-stack below it.+export const HEIGHT_COLLAPSE_ANIMATION_NAMES: ReadonlySet<string> = new Set([+ "accordion-down",+ "accordion-up",+ "collapsible-down",+ "collapsible-up",+ "collapsible-down-fade",+ "collapsible-up-fade",+]);++export function isHeightCollapseAnimation(animationName: string): boolean {+ return HEIGHT_COLLAPSE_ANIMATION_NAMES.has(animationName);+}