From d5dd229620fba6d911216dd094cf1baf2f0d4975 Mon Sep 17 00:00:00 2001 From: Jonathan Dobson Date: Tue, 15 Jul 2025 11:09:02 -0400 Subject: [PATCH] Jon/windowing updates (#2955) --- .../src/components/FloatingWindow.tsx | 53 +++++++++++++++---- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/skyvern-frontend/src/components/FloatingWindow.tsx b/skyvern-frontend/src/components/FloatingWindow.tsx index 76d998cd..df9b95e4 100644 --- a/skyvern-frontend/src/components/FloatingWindow.tsx +++ b/skyvern-frontend/src/components/FloatingWindow.tsx @@ -21,6 +21,11 @@ import { cn } from "@/util/utils"; type OS = "Windows" | "macOS" | "Linux" | "Unknown"; +const Constants = { + MinHeight: 52, + MinWidth: 256, +} as const; + function MacOsButton(props: { color: string; children?: React.ReactNode; @@ -93,29 +98,40 @@ function getOs(): OS { function FloatingWindow({ children, + initialWidth, + initialHeight, title, + zIndex, + // -- + onInteract, }: { children: React.ReactNode; + initialHeight?: number; + initialWidth?: number; title: string; + zIndex?: string; + // -- + onInteract?: () => void; }) { + console.log(title, initialWidth, initialHeight); const [position, setPosition] = useState({ x: 0, y: 0 }); const [size, setSize] = useState({ left: 0, top: 0, - width: 800, - height: 680, + height: initialHeight ?? Constants.MinHeight, + width: initialWidth ?? Constants.MinWidth, }); const [lastSize, setLastSize] = useState({ left: 0, top: 0, - width: 800, - height: 680, + height: initialHeight ?? Constants.MinHeight, + width: initialWidth ?? Constants.MinWidth, }); const [sizeBeforeMaximize, setSizeBeforeMaximize] = useState({ left: 0, top: 0, - width: 800, - height: 680, + height: initialHeight ?? Constants.MinHeight, + width: initialWidth ?? Constants.MinWidth, }); const [isMaximized, setIsMaximized] = useState(false); const [isMinimized, setIsMinimized] = useState(false); @@ -198,6 +214,19 @@ function FloatingWindow({ [dragStartSize], ); + useEffect(() => { + if (!initialWidth || !initialHeight) { + return; + } + setSize({ + left: 0, + top: 0, + width: initialWidth, + height: initialHeight, + }); + setPosition({ x: 0, y: 0 }); + }, [initialWidth, initialHeight]); + /** * Forces the sizing to take place after the resize is complete. * @@ -346,6 +375,7 @@ function FloatingWindow({ height: "100%", pointerEvents: "none", padding: "0.5rem", + zIndex, }} > onInteract?.()} onDoubleClick={() => { toggleMaximized(); }} > -
+
{os === "macOS" ? ( <>