Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
fix(SKY-11402): smooth left-to-right Copilot open animation + collapse chevron (#6845)
Celal Zamanoğlu45d0b0dcff83
diff --git a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsxindex 9f2563d18..060f88d31 100644--- a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx+++ b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx@@ -14,7 +14,7 @@ import {ReloadIcon,Cross2Icon,ChevronDownIcon,- ChevronRightIcon,+ ChevronLeftIcon,CheckIcon,} from "@radix-ui/react-icons";import { createPortal } from "react-dom";@@ -2052,7 +2052,7 @@ export function WorkflowCopilotChat({className="ml-2 rounded p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground"title="Collapse Copilot">- <ChevronRightIcon className="h-4 w-4" />+ <ChevronLeftIcon className="h-4 w-4" /></button>) : null) : (diff --git a/skyvern-frontend/src/routes/workflows/editor/FlowRenderer.tsx b/skyvern-frontend/src/routes/workflows/editor/FlowRenderer.tsxindex b482c58e0..2437c3307 100644--- a/skyvern-frontend/src/routes/workflows/editor/FlowRenderer.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/FlowRenderer.tsx@@ -166,6 +166,7 @@ import { PoliteDndLiveRegionPolicy } from "./sortable/dragLiveRegionPolicy";import { useRecordingStore } from "@/store/useRecordingStore";import { useIsCanvasLocked } from "./controls/useIsCanvasLocked";import { BlockConfigSidebar } from "./panels/BlockConfigSidebar";+import { STUDIO_COPILOT_TRANSITION_MS } from "../studio/constants";// Grace period after nodesInitialized before we start tracking changes.// Allows mount-time effects (ResizeObserver, visibility toggling) to settle.@@ -507,21 +508,84 @@ function FlowRenderer({const runFitViewRef = useRef(runFitView);runFitViewRef.current = runFitView;- // React Flow's viewport is in canvas coords, so a Copilot collapse/expand would- // jump the chain by the width delta — counter-translate to keep blocks put.+ // React Flow's viewport is in canvas coords, so a Copilot collapse/expand+ // would slide the chain by the column-width delta. The column animates over+ // STUDIO_COPILOT_TRANSITION_MS, so a one-shot counter-translate jumps the+ // canvas by the full delta and drifts back. Instead, track the editor pane's+ // real left edge every frame for the transition's duration and counter the+ // measured movement, keeping the chain screen-pinned while the column slides.const prevCenterOffsetRef = useRef(centerOffsetX);+ const viewportCorrectionRafRef = useRef<number | null>(null);useLayoutEffect(() => {const delta = centerOffsetX - prevCenterOffsetRef.current;prevCenterOffsetRef.current = centerOffsetX;if (delta === 0) {return;}- const viewport = reactFlowInstance.getViewport();- reactFlowInstance.setViewport({- x: viewport.x - delta,- y: viewport.y,- zoom: viewport.zoom,- });+ if (viewportCorrectionRafRef.current !== null) {+ cancelAnimationFrame(viewportCorrectionRafRef.current);+ viewportCorrectionRafRef.current = null;+ }++ const startX = reactFlowInstance.getViewport().x;+ // Instant fallback (the prior behavior) when the canvas isn't painting,+ // e.g. the editor tab is hidden — the slide isn't visible there, and this+ // lands on the same final viewport the animated path converges to.+ const applyFinalCorrection = () => {+ const vp = reactFlowInstance.getViewport();+ reactFlowInstance.setViewport({+ x: startX - delta,+ y: vp.y,+ zoom: vp.zoom,+ });+ };++ const el = editorElementRef.current;+ const startRect = el?.getBoundingClientRect();+ if (!el || !startRect || startRect.width === 0) {+ applyFinalCorrection();+ return;+ }++ const startLeft = startRect.left;+ const startTime = performance.now();+ // Suppress constrainPan (debug mode) for the animation so it can't clamp x+ // back mid-flight, mirroring the runFitView guard.+ fitViewInProgressRef.current = true;++ const step = () => {+ const rect = editorElementRef.current?.getBoundingClientRect();+ if (!rect || rect.width === 0) {+ applyFinalCorrection();+ fitViewInProgressRef.current = false;+ viewportCorrectionRafRef.current = null;+ return;+ }+ const vp = reactFlowInstance.getViewport();+ reactFlowInstance.setViewport({+ x: startX - (rect.left - startLeft),+ y: vp.y,+ zoom: vp.zoom,+ });+ if (performance.now() - startTime >= STUDIO_COPILOT_TRANSITION_MS) {+ // Snap to the exact final viewport so CSS/RAF cadence drift can't leave+ // a sub-pixel gap from the measured per-frame correction.+ applyFinalCorrection();+ fitViewInProgressRef.current = false;+ viewportCorrectionRafRef.current = null;+ return;+ }+ viewportCorrectionRafRef.current = requestAnimationFrame(step);+ };+ viewportCorrectionRafRef.current = requestAnimationFrame(step);++ return () => {+ if (viewportCorrectionRafRef.current !== null) {+ cancelAnimationFrame(viewportCorrectionRafRef.current);+ viewportCorrectionRafRef.current = null;+ fitViewInProgressRef.current = false;+ }+ };}, [centerOffsetX, reactFlowInstance]);// Canvas zoom + fit-view keyboard shortcuts. Gated to non-read-onlydiff --git a/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsxindex 349a09074..60a7efaa9 100644--- a/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsx@@ -11,7 +11,10 @@ import { EditorTab, type StudioWorkspaceProps } from "./EditorTab";import { RunTab } from "./RunTab";import { StudioBrowserStream } from "./StudioBrowserStream";import {+ STUDIO_COPILOT_COLLAPSE_EASE,STUDIO_COPILOT_RAIL_WIDTH,+ STUDIO_COPILOT_TRANSITION_EASE,+ STUDIO_COPILOT_TRANSITION_MS,STUDIO_COPILOT_WIDTH,studioPanelId,studioTabId,@@ -19,7 +22,6 @@ import {import { StudioShellContext } from "./StudioShellContext";import { StudioTopBar } from "./StudioTopBar";import { StudioWorkflowPanels } from "./StudioWorkflowPanels";-import { usePresence } from "./usePresence";/*** Spine + Stage shell: a persistent Copilot column beside a Stage that swaps the@@ -107,9 +109,6 @@ export function StudioShell(props: StudioWorkspaceProps) {? STUDIO_COPILOT_RAIL_WIDTH: STUDIO_COPILOT_WIDTH;- // Keep the collapsed rail mounted briefly after expanding so it can fade out.- const railPresent = usePresence(copilotCollapsed, 150);-return (<StudioShellContext.Provider value={shellContextValue}><div className="flex h-full w-full flex-col">@@ -119,30 +118,33 @@ export function StudioShell(props: StudioWorkspaceProps) {style={{gridTemplateColumns: `${copilotWidth}px minmax(0, 1fr)`,gridTemplateRows: "minmax(0, 1fr)",+ transition: `grid-template-columns ${STUDIO_COPILOT_TRANSITION_MS}ms ${+ copilotCollapsed+ ? STUDIO_COPILOT_COLLAPSE_EASE+ : STUDIO_COPILOT_TRANSITION_EASE+ }`,}}>{/* Copilot portal target. Kept mounted (parked offscreen) whencollapsed so an in-flight Copilot stream isn't torn down. */}- <div className="relative h-full min-w-0">+ <div className="relative h-full min-w-0 overflow-hidden">+ {/* Fixed width so the chat doesn't reflow; the widening column clip+ reveals it left→right, so no opacity fade is needed. */}<divref={setCopilotPortalEl}- className={- copilotCollapsed- ? "h-0 w-0 overflow-hidden"- : "h-full w-full py-3 pl-3 duration-150 animate-in fade-in slide-in-from-left-2"- }+ style={{ width: STUDIO_COPILOT_WIDTH }}+ className={cn(+ "h-full py-3 pl-3",+ copilotCollapsed && "pointer-events-none",+ )}/>- {railPresent ? (+ {/* Rail renders only while collapsed and unmounts immediately on+ expand, so the collapsed UI can't linger over the content the+ widening column is revealing (the open-flicker). */}+ {copilotCollapsed ? (<div- // Fixed rail width so it doesn't stretch to the expanded- // column while fading out on expand.style={{ width: STUDIO_COPILOT_RAIL_WIDTH }}- className={cn(- "absolute left-0 top-0 h-full py-3 pl-3 duration-150",- copilotCollapsed- ? "animate-in fade-in"- : "animate-out fade-out",- )}+ className="absolute left-0 top-0 h-full py-3 pl-3 duration-300 animate-in fade-in"><CopilotRail onExpand={() => setCopilotCollapsed(false)} /></div>diff --git a/skyvern-frontend/src/routes/workflows/studio/constants.ts b/skyvern-frontend/src/routes/workflows/studio/constants.tsindex edcb0d3e2..956c6dbb5 100644--- a/skyvern-frontend/src/routes/workflows/studio/constants.ts+++ b/skyvern-frontend/src/routes/workflows/studio/constants.ts@@ -2,6 +2,14 @@export const STUDIO_COPILOT_WIDTH = 450;export const STUDIO_COPILOT_RAIL_WIDTH = 60;+// Duration (ms) of the Copilot column open/collapse transition.+export const STUDIO_COPILOT_TRANSITION_MS = 300;+// Open uses an ease-out (quick reveal that settles). Collapse uses a symmetric+// ease-in-out: the ease-out is front-loaded, so on close it empties in the first+// ~third and reads as faster than the open — the even curve keeps them matched.+export const STUDIO_COPILOT_TRANSITION_EASE = "cubic-bezier(0.22, 1, 0.36, 1)";+export const STUDIO_COPILOT_COLLAPSE_EASE = "cubic-bezier(0.65, 0, 0.35, 1)";+// Stable element ids linking each tab to its panel (WAI-ARIA tabs pattern).export const studioTabId = (tab: string) => `studio-tab-${tab}`;export const studioPanelId = (tab: string) => `studio-panel-${tab}`;