Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
feat(SKY-12835): responsive StatusBadge — collapse to icon-only under container width pressure (#7654)
Celal Zamanoğlu6628d13d29f2
diff --git a/skyvern-frontend/src/components/StatusBadge.test.tsx b/skyvern-frontend/src/components/StatusBadge.test.tsxindex 1497409fa..5889b4b50 100644--- a/skyvern-frontend/src/components/StatusBadge.test.tsx+++ b/skyvern-frontend/src/components/StatusBadge.test.tsx@@ -7,6 +7,12 @@ import { Status } from "@/api/types";import { StatusBadge } from "./StatusBadge";+// No TooltipProvider wrapper on purpose: the collapsible badge self-provides one,+// so it must render without an ancestor provider (Radix Tooltip throws otherwise).+function renderCollapsible(status: Status | "pending") {+ return render(<StatusBadge status={status} collapsible />);+}+describe("StatusBadge", () => {test("always renders the status text, visually hidden below md", () => {render(<StatusBadge status={Status.Completed} />);@@ -45,3 +51,81 @@ describe("StatusBadge", () => {expect(screen.getByTitle("timed out")).not.toBeNull();});});++describe("StatusBadge collapsible", () => {+ test("hides the label until the container is wide (@container, not viewport)", () => {+ renderCollapsible(Status.Completed);++ const label = screen.getByText("completed");+ expect(label.classList.contains("sr-only")).toBe(true);+ expect(+ label.classList.contains(+ "[@container_status_(min-width:384px)]:not-sr-only",+ ),+ ).toBe(true);+ expect(label.classList.contains("md:not-sr-only")).toBe(false);+ });++ test("sizes to the icon until the container is wide", () => {+ const { container } = renderCollapsible(Status.Completed);++ const badge = container.querySelector('[aria-label="completed"]');+ expect(+ badge?.classList.contains("[@container_status_(min-width:384px)]:w-28"),+ ).toBe(true);+ expect(badge?.classList.contains("md:w-28")).toBe(false);+ });++ test("keeps the full status as the accessible name when icon-only", () => {+ renderCollapsible(Status.Running);++ const badge = screen.getByLabelText("running");+ // role=img guarantees AT announces the aria-label for the icon-only pill+ expect(badge.getAttribute("role")).toBe("img");+ });++ test("with alwaysShowLabel the label stays visible (no sr-only collapse)", () => {+ render(+ <StatusBadge status={Status.Completed} collapsible alwaysShowLabel />,+ );++ const label = screen.getByText("completed");+ expect(label.classList.contains("sr-only")).toBe(false);+ expect(+ label.classList.contains(+ "[@container_status_(min-width:384px)]:not-sr-only",+ ),+ ).toBe(false);+ });++ test("wraps the badge in a keyboard-focusable tooltip trigger", () => {+ const { container } = renderCollapsible(Status.Completed);++ const trigger = container.querySelector("span.inline-flex.shrink-0");+ expect(trigger).not.toBeNull();+ expect(trigger?.getAttribute("tabindex")).toBe("0");+ expect(trigger?.querySelector('[aria-label="completed"]')).not.toBeNull();+ });++ test("drops the native title in favor of the tooltip", () => {+ renderCollapsible(Status.Completed);++ expect(screen.queryByTitle("completed")).toBeNull();+ });+});++describe("StatusBadge is pixel-identical when not collapsible", () => {+ test("keeps viewport breakpoints, native title, and no tooltip wrapper", () => {+ const { container } = render(<StatusBadge status={Status.Completed} />);++ const badge = container.firstElementChild;+ expect(badge?.getAttribute("aria-label")).toBeNull();+ expect(badge?.getAttribute("role")).toBeNull();+ expect(badge?.classList.contains("md:w-28")).toBe(true);+ expect(+ badge?.classList.contains("[@container_status_(min-width:384px)]:w-28"),+ ).toBe(false);+ expect(screen.getByTitle("completed")).not.toBeNull();+ expect(container.querySelector("span.inline-flex.shrink-0")).toBeNull();+ });+});diff --git a/skyvern-frontend/src/components/StatusBadge.tsx b/skyvern-frontend/src/components/StatusBadge.tsxindex 3aa829b20..b348e0745 100644--- a/skyvern-frontend/src/components/StatusBadge.tsx+++ b/skyvern-frontend/src/components/StatusBadge.tsx@@ -13,6 +13,12 @@ import {} from "@radix-ui/react-icons";import { Status } from "@/api/types";+import {+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,+} from "@/components/ui/tooltip";import { cn } from "@/util/utils";import { TerminatedIcon } from "./terminatedVisual";@@ -62,6 +68,11 @@ type Props = {// By default the label is sr-only below md (compact pill in dense tables);// set this where the label must stay visible at every width, e.g. a tab chip.alwaysShowLabel?: boolean;+ // Collapse to icon-only under container width pressure instead of the viewport+ // md: breakpoint — for independently-resizable panes. Requires an ancestor+ // declaring the `status` container (`[container-type:inline-size]+ // [container-name:status]`).+ collapsible?: boolean;};function variantForStatus(status: Status | "pending"): StatusVariant {@@ -112,24 +123,73 @@ function iconForStatus(status: Status | "pending") {}}-function StatusBadge({ className, status, alwaysShowLabel = false }: Props) {+function StatusBadge({+ className,+ status,+ alwaysShowLabel = false,+ collapsible = false,+}: Props) {const statusText = status === "timed_out" ? "timed out" : status;- return (+ const badge = (<Badgevariant={variantForStatus(status)}className={cn(- "justify-center gap-1.5 px-1.5 capitalize md:w-28 md:justify-start md:px-2.5",+ "justify-center gap-1.5 px-1.5 capitalize",+ // Container query (no plugin — Tailwind core arbitrary at-rule variant)+ // so the label returns once the `status` container is wide enough.+ collapsible+ ? "[@container_status_(min-width:384px)]:w-28 [@container_status_(min-width:384px)]:justify-start [@container_status_(min-width:384px)]:px-2.5"+ : "md:w-28 md:justify-start md:px-2.5",className,)}- title={statusText}+ // The collapsible variant surfaces the label via the tooltip below and+ // drops the native title to avoid showing two tooltips at once. role=img+ // guarantees the aria-label is announced when the badge collapses to the+ // icon (a bare div computes to role=generic, which AT may prune).+ title={collapsible ? undefined : statusText}+ role={collapsible ? "img" : undefined}+ aria-label={collapsible ? statusText : undefined}>{iconForStatus(status)}- <span className={alwaysShowLabel ? undefined : "sr-only md:not-sr-only"}>+ <span+ className={+ alwaysShowLabel+ ? undefined+ : collapsible+ ? "sr-only [@container_status_(min-width:384px)]:not-sr-only"+ : "sr-only md:not-sr-only"+ }+ >{statusText}</span></Badge>);++ if (!collapsible) {+ return badge;+ }++ // Self-contained provider so a non-studio consumer can't crash (Tooltip.Root+ // throws without one). tabIndex makes the trigger keyboard-focusable so the+ // label is reachable on focus, not hover only (WCAG 1.4.13).+ return (+ <TooltipProvider delayDuration={200}>+ <Tooltip>+ <TooltipTrigger asChild>+ <span+ tabIndex={0}+ className="inline-flex shrink-0 rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"+ >+ {badge}+ </span>+ </TooltipTrigger>+ <TooltipContent side="bottom" className="capitalize">+ {statusText}+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>+ );}export { StatusBadge, Pill };diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunSummaryStrip.test.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunSummaryStrip.test.tsxindex f6d283818..d5aa47a6e 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunSummaryStrip.test.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunSummaryStrip.test.tsx@@ -97,3 +97,15 @@ describe("RunSummaryStrip visible dates", () => {expect(screen.queryByText(/^Started /)).toBeNull();});});++describe("RunSummaryStrip status badge", () => {+ test("adopts the collapsible badge inside its own container", () => {+ const { container } = renderStrip(makeRun({ status: Status.Completed }));++ expect(+ container.querySelector('[class*="container-name:status"]'),+ ).not.toBeNull();+ // aria-label is only present in the badge's collapsible mode+ expect(container.querySelector('[aria-label="completed"]')).not.toBeNull();+ });+});diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunSummaryStrip.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunSummaryStrip.tsxindex 9b0a4b5ac..e8d633ccc 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunSummaryStrip.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunSummaryStrip.tsx@@ -64,8 +64,8 @@ export function RunSummaryStrip({ workflowRun }: RunSummaryStripProps) {return (<div className="flex shrink-0 flex-col gap-2">- <div className="flex flex-wrap items-center gap-x-3 gap-y-1">- <StatusBadge status={workflowRun.status} />+ <div className="flex flex-wrap items-center gap-x-3 gap-y-1 [container-name:status] [container-type:inline-size]">+ <StatusBadge status={workflowRun.status} collapsible />{workflowRun.failure_category?.length ? (<FailureCategoryBadgefailureCategory={workflowRun.failure_category}