Skip to content

Automate browser based workflows with AI

fix(SKY-11519): vertically center short run-hero screenshots (#6851)

Celal Zamanoğluf5f2fc89e3cd
diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/HeroScreenshot.utils.test.ts b/skyvern-frontend/src/routes/workflows/studio/runview/HeroScreenshot.utils.test.ts
index c7e365581..6fa2a6f86 100644
--- a/skyvern-frontend/src/routes/workflows/studio/runview/HeroScreenshot.utils.test.ts
+++ b/skyvern-frontend/src/routes/workflows/studio/runview/HeroScreenshot.utils.test.ts
@@ -3,10 +3,14 @@ import { describe, expect, it } from "vitest";
import { screenshotZoomClasses } from "./HeroScreenshot.utils";
describe("screenshotZoomClasses", () => {
- it("fits to width and scrolls vertically when not zoomed", () => {
+ it("fits to width, centers when short, scrolls when tall (not zoomed)", () => {
const { container, image } = screenshotZoomClasses(false);
expect(container).toContain("cursor-zoom-in");
expect(container).toContain("overflow-y-auto");
+ // flex + m-auto: vertically centered when shorter than the panel, top-aligned
+ // and scrollable when taller.
+ expect(container).toContain("flex");
+ expect(image).toContain("m-auto");
expect(image).toContain("w-full");
expect(image).not.toContain("max-w-none");
});
diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/HeroScreenshot.utils.ts b/skyvern-frontend/src/routes/workflows/studio/runview/HeroScreenshot.utils.ts
index f85ad9bcd..00e3595cc 100644
--- a/skyvern-frontend/src/routes/workflows/studio/runview/HeroScreenshot.utils.ts
+++ b/skyvern-frontend/src/routes/workflows/studio/runview/HeroScreenshot.utils.ts
@@ -1,11 +1,10 @@
import { cn } from "@/util/utils";
/**
- * Classes for the run-hero screenshot. The default view fits the screenshot to
- * the panel width and scrolls vertically, so long full-page captures aren't
- * cropped (object-contain shrank tall captures to an unreadable sliver and the
- * overflow was clipped). Click toggles to natural size (`zoomed`), scrollable on
- * both axes; the caller sets the initial scroll to top-center.
+ * Classes for the run-hero screenshot. Default view fits to panel width with
+ * `margin:auto` in a flex scroll container — centered when shorter than the panel,
+ * top-aligned and scrollable when taller. Zoomed = natural size, scrollable on both
+ * axes (caller sets the initial top-center scroll).
*/
export function screenshotZoomClasses(zoomed: boolean): {
container: string;
@@ -16,8 +15,8 @@ export function screenshotZoomClasses(zoomed: boolean): {
"absolute inset-0",
zoomed
? "overflow-auto cursor-zoom-out bg-slate-950"
- : "overflow-y-auto overflow-x-hidden cursor-zoom-in",
+ : "flex overflow-y-auto overflow-x-hidden cursor-zoom-in",
),
- image: zoomed ? "mx-auto block max-w-none" : "block w-full",
+ image: zoomed ? "mx-auto block max-w-none" : "m-auto w-full",
};
}