Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
Wrap long Copilot messages inside the chat pane (#8373)
Andrew Neilson8521ac22245c
diff --git a/skyvern-frontend/src/components/onboarding/OnboardingProgressBand.test.tsx b/skyvern-frontend/src/components/onboarding/OnboardingProgressBand.test.tsxnew file mode 100644index 000000000..c63fe49b9--- /dev/null+++ b/skyvern-frontend/src/components/onboarding/OnboardingProgressBand.test.tsx@@ -0,0 +1,218 @@+// @vitest-environment jsdom+import { act, fireEvent, render, screen } from "@testing-library/react";+import { MemoryRouter } from "react-router-dom";+import { expect, it, vi } from "vitest";++import { OnboardingProgressBand } from "./OnboardingProgressBand";++const activeProgress = (completedCount: 0 | 1) => ({+ state: "active" as const,+ completed_count: completedCount,+ next_action_key:+ completedCount === 0+ ? ("first_agent_created" as const)+ : ("first_successful_run" as const),+ items: [+ {+ key: "first_agent_created" as const,+ completed_at: completedCount === 0 ? null : "2026-08-20T12:00:00Z",+ },+ { key: "first_successful_run" as const, completed_at: null },+ ],+});++const completedProgress = {+ state: "completed" as const,+};++const forbiddenCopy =+ /heuristic|reward|credential|api|mcp|channel|schedule|questionnaire|social|follow|role|company|referral|credits?|points?|survey/i;++it.each([+ [+ 0,+ "1 of 3",+ "Describe your first agent",+ "How to build an agent",+ "https://www.skyvern.com/docs/cloud/building-agents/build-an-agent",+ ],+ [+ 1,+ "2 of 3",+ "Run agent",+ "How to run an agent",+ "https://www.skyvern.com/docs/cloud/building-agents/run-an-agent",+ ],+] as const)(+ "renders %s server milestones as endowed progress",+ (completedCount, displayCount, primaryLabel, resourceLabel, resourceHref) => {+ const onDismiss = vi.fn();+ const onDescribeAgent = vi.fn();+ render(+ <OnboardingProgressBand+ progress={activeProgress(completedCount)}+ isPending={false}+ onDismiss={onDismiss}+ onRestore={vi.fn()}+ onDescribeAgent={onDescribeAgent}+ />,+ { wrapper: MemoryRouter },+ );++ expect(screen.getByText(displayCount)).toBeTruthy();+ expect(screen.getByRole("progressbar").getAttribute("aria-valuenow")).toBe(+ String(completedCount + 1),+ );+ const accountRow = screen.getByText("Account created").parentElement;+ expect(accountRow?.textContent).toContain("Complete: Account created");+ expect(accountRow?.querySelector(".sr-only")?.textContent).toBe(+ "Complete: ",+ );+ const primaryAction = screen.getByRole(+ completedCount === 0 ? "button" : "link",+ { name: primaryLabel },+ );+ if (completedCount === 0) {+ fireEvent.click(primaryAction);+ expect(onDescribeAgent).toHaveBeenCalledOnce();+ } else {+ expect(primaryAction.getAttribute("href")).toBe("/agents");+ expect(onDescribeAgent).not.toHaveBeenCalled();+ }+ expect(+ screen.getByRole("link", { name: resourceLabel }).getAttribute("href"),+ ).toBe(resourceHref);+ expect(screen.getByRole("region").textContent).not.toMatch(forbiddenCopy);+ expect(+ screen.getByText(+ "An agent is a browser automation you describe in plain words.",+ ),+ ).toBeTruthy();++ fireEvent.click(screen.getByRole("button", { name: "Hide setup" }));+ expect(onDismiss).toHaveBeenCalledOnce();+ },+);++it("announces pending progress and prevents another visibility mutation", () => {+ const onDismiss = vi.fn();+ render(+ <OnboardingProgressBand+ progress={activeProgress(0)}+ isPending+ onDismiss={onDismiss}+ onRestore={vi.fn()}+ onDescribeAgent={vi.fn()}+ />,+ { wrapper: MemoryRouter },+ );++ expect(screen.getByRole("region").getAttribute("aria-busy")).toBe("true");+ expect(+ screen.getByText("Saving setup progress…").getAttribute("aria-live"),+ ).toBe("polite");+ const hide = screen.getByRole("button", { name: "Hide setup" });+ expect(hide.getAttribute("aria-disabled")).toBe("true");+ expect(+ screen+ .getByRole("button", { name: "Describe your first agent" })+ .hasAttribute("disabled"),+ ).toBe(true);+ expect(+ screen+ .getByRole("button", { name: "How to build an agent" })+ .hasAttribute("disabled"),+ ).toBe(true);+ fireEvent.click(hide);+ expect(onDismiss).not.toHaveBeenCalled();+});++it("restores a dismissed band", () => {+ const onRestore = vi.fn();+ render(+ <OnboardingProgressBand+ progress={{ state: "dismissed" }}+ isPending={false}+ onDismiss={vi.fn()}+ onRestore={onRestore}+ onDescribeAgent={vi.fn()}+ />,+ { wrapper: MemoryRouter },+ );++ expect(screen.queryByText("Build your first agent")).toBeNull();+ fireEvent.click(screen.getByRole("button", { name: "Resume setup" }));+ expect(onRestore).toHaveBeenCalledOnce();+});++it("celebrates only an active to completed transition", () => {+ vi.useFakeTimers();+ const props = {+ isPending: false,+ onDismiss: vi.fn(),+ onRestore: vi.fn(),+ onDescribeAgent: vi.fn(),+ };+ const view = render(+ <MemoryRouter>+ <OnboardingProgressBand progress={activeProgress(1)} {...props} />+ </MemoryRouter>,+ );++ view.rerender(+ <MemoryRouter>+ <OnboardingProgressBand progress={completedProgress} {...props} />+ </MemoryRouter>,+ );+ expect(screen.getByRole("status").textContent).toContain("3 of 3 complete");+ expect(screen.getByText("First agent ready")).toBeTruthy();++ act(() => vi.advanceTimersByTime(1800));+ expect(screen.queryByText("First agent ready")).toBeNull();+ vi.useRealTimers();+});++it.each([+ [{ state: "completed" }],+ [{ state: "ineligible" }],+ [{ state: "unknown" }],+ [null],+])("fails closed for non-renderable progress %#", (progress) => {+ const { container } = render(+ <OnboardingProgressBand+ progress={progress}+ isPending={false}+ onDismiss={vi.fn()}+ onRestore={vi.fn()}+ onDescribeAgent={vi.fn()}+ />,+ { wrapper: MemoryRouter },+ );+ expect(container.innerHTML).toBe("");+});++it("offers the working example as a quiet focus handoff from step 2", () => {+ render(+ <OnboardingProgressBand+ progress={activeProgress(0)}+ isPending={false}+ onDismiss={vi.fn()}+ onRestore={vi.fn()}+ onDescribeAgent={vi.fn()}+ >+ <h2 id="working-example-heading" tabIndex={-1}>+ See how an agent run is organized+ </h2>+ </OnboardingProgressBand>,+ { wrapper: MemoryRouter },+ );++ const affordance = screen.getByRole("link", {+ name: "or copy a working example",+ });+ expect(affordance.getAttribute("href")).toBe("#working-example-heading");+ fireEvent.click(affordance);+ expect(document.activeElement).toBe(+ screen.getByRole("heading", { name: "See how an agent run is organized" }),+ );+});diff --git a/skyvern-frontend/src/components/onboarding/OnboardingProgressBand.tsx b/skyvern-frontend/src/components/onboarding/OnboardingProgressBand.tsxnew file mode 100644index 000000000..16d9b735e--- /dev/null+++ b/skyvern-frontend/src/components/onboarding/OnboardingProgressBand.tsx@@ -0,0 +1,442 @@+import { CheckIcon, ExternalLinkIcon, ReloadIcon } from "@radix-ui/react-icons";+import { useEffect, useRef, useState, type ReactNode } from "react";+import { Link } from "react-router-dom";++import { Button } from "@/components/ui/button";++type ProgressActionKey = "first_agent_created" | "first_successful_run";+type Progress = {+ state: string;+ completed_count?: number;+ next_action_key?: ProgressActionKey | null;+ items?: Array<{+ key: ProgressActionKey;+ completed_at: string | null;+ }>;+};+type ActiveProgress = Progress & {+ state: "active";+ completed_count: 0 | 1;+ next_action_key: ProgressActionKey;+ items: NonNullable<Progress["items"]>;+};+type OnboardingProgressBandProps = {+ progress: Progress | null;+ isPending: boolean;+ onDismiss: () => void;+ onRestore: () => void;+ onDescribeAgent: () => void;+ children?: ReactNode;+};+type StepState = "complete" | "active" | "pending" | "upcoming";++const milestoneLabels = [+ "Account created",+ "Create your first agent",+ "Run your first agent",+] as const;++const primaryActions = {+ first_agent_created: {+ label: "Describe your first agent",+ resourceLabel: "How to build an agent",+ resourceHref:+ "https://www.skyvern.com/docs/cloud/building-agents/build-an-agent",+ },+ first_successful_run: {+ label: "Run agent",+ href: "/agents",+ resourceLabel: "How to run an agent",+ resourceHref:+ "https://www.skyvern.com/docs/cloud/building-agents/run-an-agent",+ },+} as const;++function PendingIcon() {+ return (+ <ReloadIcon+ aria-hidden="true"+ className="mr-2 h-4 w-4 motion-safe:animate-spin motion-reduce:animate-none"+ />+ );+}++function StepDot({ state, index }: { state: StepState; index: number }) {+ const isComplete = state === "complete";+ return (+ <span+ aria-hidden="true"+ className={`flex size-6 shrink-0 items-center justify-center rounded-full text-xs font-semibold ${+ isComplete+ ? "bg-badge-success text-foreground"+ : state === "active"+ ? "border border-primary bg-primary/10 text-primary"+ : state === "pending"+ ? "border border-primary/50 bg-primary/5 text-primary"+ : "border border-border text-muted-foreground"+ }`}+ >+ {isComplete ? "✓" : index + 1}+ </span>+ );+}++function ProgressSegments({ completedSteps }: { completedSteps: number }) {+ return (+ <div+ className="grid grid-cols-3 gap-1"+ role="progressbar"+ aria-label="Setup progress"+ aria-valuemin={0}+ aria-valuemax={3}+ aria-valuenow={completedSteps}+ >+ {milestoneLabels.map((label, index) => (+ <span+ key={label}+ aria-hidden="true"+ className={`h-1.5 rounded-full ${+ index < completedSteps ? "bg-primary" : "bg-muted"+ }`}+ />+ ))}+ </div>+ );+}++function SetupRow({+ label,+ index,+ state,+ affordance,+ secondaryAffordance,+}: {+ label: string;+ index: number;+ state: StepState;+ affordance?: ReactNode;+ secondaryAffordance?: ReactNode;+}) {+ const isComplete = state === "complete";+ return (+ <li className="grid min-h-11 grid-cols-[auto_1fr_2.75rem] items-center gap-3 rounded-md border border-border/70 bg-background/70 px-3 py-2 text-sm">+ <StepDot state={state} index={index} />+ <div>+ <span+ className={+ isComplete ? "text-muted-foreground" : "font-medium text-foreground"+ }+ >+ <span className="sr-only">+ {isComplete+ ? "Complete: "+ : state === "active"+ ? "Current step: "+ : state === "pending"+ ? "Saving current step: "+ : "Upcoming step: "}+ </span>+ {label}+ </span>+ {secondaryAffordance}+ </div>+ <span className="flex min-h-11 items-center justify-end">+ {affordance}+ </span>+ </li>+ );+}++function QuietResourceLink({+ href,+ label,+ isPending,+}: {+ href: string;+ label: string;+ isPending: boolean;+}) {+ if (isPending) {+ return (+ <Button+ type="button"+ variant="disabled"+ disabled+ aria-label={label}+ className="size-11 p-0"+ >+ <ExternalLinkIcon aria-hidden="true" className="size-4" />+ </Button>+ );+ }++ return (+ <a+ href={href}+ target="_blank"+ rel="noopener noreferrer"+ title={label}+ aria-label={label}+ className="inline-flex size-11 touch-manipulation items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"+ >+ <ExternalLinkIcon aria-hidden="true" className="size-4" />+ </a>+ );+}++function ProgressPrimaryAction({+ nextActionKey,+ isPending,+ onDescribeAgent,+}: {+ nextActionKey: ProgressActionKey;+ isPending: boolean;+ onDescribeAgent: () => void;+}) {+ const action = primaryActions[nextActionKey];+ if (isPending) {+ return (+ <Button+ type="button"+ variant="disabled"+ disabled+ className="h-11 w-full sm:w-auto"+ >+ {action.label}+ </Button>+ );+ }++ if (nextActionKey === "first_agent_created") {+ return (+ <Button+ type="button"+ className="h-11 w-full touch-manipulation sm:w-auto"+ onClick={onDescribeAgent}+ >+ {action.label}+ </Button>+ );+ }++ return (+ <Button asChild className="h-11 w-full touch-manipulation sm:w-auto">+ <Link to={primaryActions.first_successful_run.href}>{action.label}</Link>+ </Button>+ );+}++function WorkingExampleAffordance() {+ return (+ <a+ href="#working-example-heading"+ className="ml-2 inline-flex min-h-11 touch-manipulation items-center text-xs font-normal text-muted-foreground underline-offset-4 hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"+ onClick={() => {+ document+ .getElementById("working-example-heading")+ ?.focus({ preventScroll: true });+ }}+ >+ or copy a working example+ </a>+ );+}++function CompletionBand() {+ return (+ <section+ aria-labelledby="onboarding-progress-heading"+ aria-live="polite"+ role="status"+ className="overflow-hidden rounded-lg border border-border bg-background shadow-sm"+ >+ <div className="border-b border-border bg-card px-5 py-4 sm:px-6">+ <div className="flex items-center gap-3">+ <span className="flex size-8 items-center justify-center rounded-full bg-badge-success text-foreground motion-safe:animate-in motion-safe:fade-in motion-safe:zoom-in-75 motion-reduce:animate-none">+ <CheckIcon aria-hidden="true" className="size-4" />+ </span>+ <h2+ id="onboarding-progress-heading"+ className="text-base font-semibold tracking-tight"+ >+ First agent ready+ </h2>+ </div>+ <p className="mt-1 text-sm text-muted-foreground">+ <span className="sr-only">Complete: </span>3 of 3 complete+ </p>+ <div className="mt-3">+ <ProgressSegments completedSteps={3} />+ </div>+ </div>+ </section>+ );+}++function isActiveProgress(+ progress: Progress | null,+): progress is ActiveProgress {+ return (+ progress?.state === "active" &&+ (progress.completed_count === 0 || progress.completed_count === 1) &&+ (progress.next_action_key === "first_agent_created" ||+ progress.next_action_key === "first_successful_run") &&+ Array.isArray(progress.items)+ );+}++function OnboardingProgressBand({+ progress,+ isPending,+ onDismiss,+ onRestore,+ onDescribeAgent,+ children,+}: OnboardingProgressBandProps) {+ const previousState = useRef(progress?.state);+ const [isCelebrating, setIsCelebrating] = useState(false);++ useEffect(() => {+ const completedFromActive =+ previousState.current === "active" && progress?.state === "completed";+ previousState.current = progress?.state;+ if (!completedFromActive) {+ setIsCelebrating(false);+ return;+ }++ setIsCelebrating(true);+ const timeout = window.setTimeout(() => setIsCelebrating(false), 1800);+ return () => window.clearTimeout(timeout);+ }, [progress?.state]);++ if (isCelebrating) return <CompletionBand />;++ const activeProgress = isActiveProgress(progress) ? progress : null;+ const isDismissed = progress?.state === "dismissed";+ if (!activeProgress && !isDismissed) return null;++ const completedSteps = activeProgress+ ? activeProgress.completed_count + 1+ : 0;+ const action = activeProgress+ ? primaryActions[activeProgress.next_action_key]+ : null;+ const activeIndex = activeProgress?.items.some(+ (item) => item.key === "first_agent_created" && item.completed_at !== null,+ )+ ? 2+ : 1;++ return (+ <div className={activeProgress ? "relative" : "flex justify-end"}>+ <Button+ type="button"+ variant={isPending ? "disabled" : "ghost"}+ className={`z-10 h-11 touch-manipulation text-muted-foreground hover:text-foreground ${+ activeProgress ? "absolute right-5 top-4" : ""+ }`}+ aria-disabled={isPending}+ aria-busy={isPending}+ onClick={() => {+ if (isPending) return;+ if (activeProgress) onDismiss();+ else onRestore();+ }}+ >+ {isPending && <PendingIcon />}+ {activeProgress ? "Hide setup" : "Resume setup"}+ </Button>++ {activeProgress && action ? (+ <section+ aria-labelledby="onboarding-progress-heading"+ aria-busy={isPending}+ className="overflow-hidden rounded-lg border border-border bg-background shadow-sm"+ >+ {isPending ? (+ <span className="sr-only" aria-live="polite">+ Saving setup progress…+ </span>+ ) : null}+ <div className="border-b border-border bg-card px-5 py-4 sm:px-6">+ <div className="pr-28">+ <h2+ id="onboarding-progress-heading"+ className="text-base font-semibold tracking-tight"+ >+ Build your first agent+ </h2>+ <p className="mt-1 text-sm text-muted-foreground">+ An agent is a browser automation you describe in plain words.+ </p>+ <p className="mt-1 text-sm text-muted-foreground">+ <span className="font-semibold tabular-nums text-foreground">+ {completedSteps} of 3+ </span>{" "}+ complete+ </p>+ </div>++ <div className="mt-4">+ <ProgressSegments completedSteps={completedSteps} />+ </div>++ <ol aria-label="Setup milestones" className="mt-4 grid gap-2">+ {milestoneLabels.map((label, index) => {+ const state: StepState =+ index < completedSteps+ ? "complete"+ : isPending && index === activeIndex+ ? "pending"+ : index === activeIndex+ ? "active"+ : "upcoming";+ return (+ <SetupRow+ key={label}+ label={label}+ index={index}+ state={state}+ secondaryAffordance={+ index === 1 &&+ activeProgress.next_action_key ===+ "first_agent_created" ? (+ <WorkingExampleAffordance />+ ) : undefined+ }+ affordance={+ index === activeIndex ? (+ <QuietResourceLink+ href={action.resourceHref}+ label={action.resourceLabel}+ isPending={isPending}+ />+ ) : undefined+ }+ />+ );+ })}+ </ol>++ <div className="mt-4 flex flex-col items-stretch gap-2 sm:flex-row sm:items-center">+ <ProgressPrimaryAction+ nextActionKey={activeProgress.next_action_key}+ isPending={isPending}+ onDescribeAgent={onDescribeAgent}+ />+ </div>+ </div>++ {children && (+ <div className="[&>section]:rounded-none [&>section]:border-0">+ {children}+ </div>+ )}+ </section>+ ) : null}+ </div>+ );+}++export { OnboardingProgressBand };diff --git a/skyvern-frontend/src/components/onboarding/OnboardingProgressCard.test.tsx b/skyvern-frontend/src/components/onboarding/OnboardingProgressCard.test.tsxdeleted file mode 100644index edc788386..000000000--- a/skyvern-frontend/src/components/onboarding/OnboardingProgressCard.test.tsx+++ /dev/null@@ -1,63 +0,0 @@-import { fireEvent, render, screen } from "@testing-library/react";-import { MemoryRouter } from "react-router-dom";-import { expect, it, vi } from "vitest";-import { OnboardingProgressCard } from "./OnboardingProgressCard";--const forbiddenCopy =- /heuristic|reward|credential|api|mcp|channel|schedule|questionnaire|social|follow|role|company|referral|credits?|points?|survey/i;-it.each([- [- 0,- false,- "first_agent_created",- "Use the working example",- "#working-example-heading",- "How to build an agent",- "https://www.skyvern.com/docs/cloud/building-agents/build-an-agent",- ],- [- 1,- true,- "first_successful_run",- "Run agent",- "/agents",- "How to run an agent",- "https://www.skyvern.com/docs/cloud/building-agents/run-an-agent",- ],-] as const)(- "renders %s progress with its primary destination",- (- completedCount,- firstMilestoneComplete,- nextActionKey,- primaryLabel,- href,- resourceLabel,- resourceHref,- ) => {- const onDismiss = vi.fn();- render(- <OnboardingProgressCard- state="active"- completedCount={completedCount}- firstMilestoneComplete={firstMilestoneComplete}- nextActionKey={nextActionKey}- isPending={false}- onDismiss={onDismiss}- />,- { wrapper: href === "/agents" ? MemoryRouter : undefined },- );- const primaryLink = screen.getByRole("link", { name: primaryLabel });- expect(primaryLink.getAttribute("href")).toBe(href);- const resourceLink = screen.getByRole("link", { name: resourceLabel });- expect(resourceLink.getAttribute("href")).toBe(resourceHref);- expect(screen.getByRole("region").textContent).not.toMatch(forbiddenCopy);- if (firstMilestoneComplete) {- expect(screen.getByText("Complete:").className).toContain("sr-only");- } else {- expect(screen.queryByText("Complete:")).toBeNull();- }- fireEvent.click(screen.getByRole("button", { name: "Hide setup" }));- expect(onDismiss).toHaveBeenCalledTimes(1);- },-);diff --git a/skyvern-frontend/src/components/onboarding/OnboardingProgressCard.tsx b/skyvern-frontend/src/components/onboarding/OnboardingProgressCard.tsxdeleted file mode 100644index ca04b066d..000000000--- a/skyvern-frontend/src/components/onboarding/OnboardingProgressCard.tsx+++ /dev/null@@ -1,191 +0,0 @@-import { ReloadIcon } from "@radix-ui/react-icons";--import { Link } from "react-router-dom";-import { Button } from "@/components/ui/button";--type ProgressActionKey = "first_agent_created" | "first_successful_run";--type ActiveProgressCardProps = {- state: "active";- completedCount: 0 | 1;- nextActionKey: ProgressActionKey;- firstMilestoneComplete: boolean;- isPending: boolean;- onDismiss: () => void;-};--type DismissedProgressCardProps = {- state: "dismissed";- isPending: boolean;- onRestore: () => void;-};--type OnboardingProgressCardProps =- | ActiveProgressCardProps- | DismissedProgressCardProps;--const primaryActions = {- first_agent_created: {- label: "Use the working example",- href: "#working-example-heading",- resourceLabel: "How to build an agent",- resourceHref:- "https://www.skyvern.com/docs/cloud/building-agents/build-an-agent",- },- first_successful_run: {- label: "Run agent",- href: "/agents",- resourceLabel: "How to run an agent",- resourceHref:- "https://www.skyvern.com/docs/cloud/building-agents/run-an-agent",- },-} satisfies Record<- ProgressActionKey,- {- label: string;- href: string;- resourceLabel: string;- resourceHref: string;- }->;--function OnboardingProgressCard(props: OnboardingProgressCardProps) {- const activeProgress = props.state === "active" ? props : null;- const primaryAction = activeProgress- ? primaryActions[activeProgress.nextActionKey]- : null;- const firstMilestoneComplete =- activeProgress?.firstMilestoneComplete === true;- const handleVisibilityChange = () => {- if (props.isPending) return;- if (props.state === "active") {- props.onDismiss();- return;- }- props.onRestore();- };-- return (- <div- className={- activeProgress- ? "relative rounded-lg border border-border bg-card px-4 py-4 shadow-sm sm:px-5"- : "flex justify-end"- }- >- <Button- type="button"- variant={props.isPending ? "disabled" : "ghost"}- className={`h-11 touch-manipulation text-muted-foreground hover:text-foreground ${- activeProgress ? "absolute right-4 top-4 sm:right-5" : ""- }`}- aria-disabled={props.isPending}- aria-busy={props.isPending}- onClick={handleVisibilityChange}- >- {props.isPending && (- <ReloadIcon- aria-hidden="true"- className="mr-2 h-4 w-4 motion-safe:animate-spin motion-reduce:animate-none"- />- )}- {activeProgress ? "Hide setup" : "Resume setup"}- </Button>-- {activeProgress && primaryAction && (- <section- aria-labelledby="onboarding-progress-heading"- aria-busy={activeProgress.isPending}- >- <header className="pr-28">- <h2- id="onboarding-progress-heading"- className="text-base font-semibold tracking-tight"- >- Build your first agent- </h2>- <p className="mt-1 text-sm text-muted-foreground">- <span className="font-semibold text-foreground">- {activeProgress.completedCount} of 2- </span>{" "}- complete- </p>- </header>-- <ol- aria-label="Setup milestones"- className="mt-4 grid gap-2 sm:grid-cols-2"- >- <li className="flex min-h-11 items-center gap-2 rounded-md border border-border/70 bg-muted/20 px-3 py-2 text-sm">- <span- aria-hidden="true"- className={`flex size-6 shrink-0 items-center justify-center rounded-full text-xs font-semibold ${- firstMilestoneComplete- ? "bg-badge-success text-foreground"- : "border border-border text-muted-foreground"- }`}- >- {firstMilestoneComplete ? "✓" : "1"}- </span>- <span- className={- firstMilestoneComplete- ? "text-muted-foreground"- : "font-medium text-foreground"- }- >- {firstMilestoneComplete && (- <span className="sr-only">Complete: </span>- )}- Create your first agent- </span>- </li>- <li className="flex min-h-11 items-center gap-2 rounded-md border border-border/70 bg-muted/20 px-3 py-2 text-sm">- <span- aria-hidden="true"- className="flex size-6 shrink-0 items-center justify-center rounded-full border border-border text-muted-foreground"- >- 2- </span>- <span className="font-medium text-foreground">- Run your first agent- </span>- </li>- </ol>-- <div className="mt-4 flex flex-col items-start gap-2 sm:flex-row sm:items-center">- <Button- asChild- className="h-11 w-full touch-manipulation sm:w-auto"- >- {activeProgress.nextActionKey === "first_successful_run" ? (- <Link to={primaryAction.href}>{primaryAction.label}</Link>- ) : (- <a- href={primaryAction.href}- onClick={() => {- document- .getElementById("working-example-heading")- ?.focus({ preventScroll: true });- }}- >- {primaryAction.label}- </a>- )}- </Button>- <a- href={primaryAction.resourceHref}- target="_blank"- rel="noopener noreferrer"- className="inline-flex min-h-11 items-center rounded-md px-3 text-sm font-medium text-muted-foreground underline underline-offset-4 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"- >- {primaryAction.resourceLabel}- </a>- </div>- </section>- )}- </div>- );-}--export { OnboardingProgressCard };diff --git a/skyvern-frontend/src/components/onboarding/WorkingExampleInspector.test.tsx b/skyvern-frontend/src/components/onboarding/WorkingExampleInspector.test.tsxindex 0f13a9dc0..0363c9353 100644--- a/skyvern-frontend/src/components/onboarding/WorkingExampleInspector.test.tsx+++ b/skyvern-frontend/src/components/onboarding/WorkingExampleInspector.test.tsx@@ -6,22 +6,23 @@ it("shows provenance, structure, playback, and result before one safe copy", ()const onMakeCopy = vi.fn();render(<WorkingExampleInspector isPending={false} onMakeCopy={onMakeCopy} />);expect(screen.getByText("Example data, not your run")).toBeTruthy();- expect(- screen.getByRole("heading", { name: "Workflow structure" }),- ).toBeTruthy();+ expect(screen.getByRole("heading", { name: "Agent structure" })).toBeTruthy();expect(screen.getByText("Visit a public page")).toBeTruthy();+ expect(screen.getByRole("heading", { name: "Agent playback" })).toBeTruthy();expect(- screen.getByRole("heading", { name: "Example playback" }),- ).toBeTruthy();- expect(- screen.getByText("Opened https://www.skyvern.com/ in this static example."),+ screen.getByText(+ "Opened https://www.skyvern.com/ in this static agent example.",+ ),).toBeTruthy();expect(- screen.getByRole("heading", { name: "Synthetic example result" }),+ screen.getByRole("heading", { name: "Synthetic agent result" }),).toBeTruthy();expect(screen.getByText("Product summary")).toBeTruthy();+ expect(screen.getByRole("region").textContent).not.toMatch(/workflow/i);expect(onMakeCopy).not.toHaveBeenCalled();- fireEvent.click(screen.getByRole("button", { name: "Make a copy" }));+ const copy = screen.getByRole("button", { name: "Make a copy" });+ expect(copy.className).toContain("border-input");+ fireEvent.click(copy);expect(onMakeCopy).toHaveBeenCalledTimes(1);});diff --git a/skyvern-frontend/src/components/onboarding/WorkingExampleInspector.tsx b/skyvern-frontend/src/components/onboarding/WorkingExampleInspector.tsxindex 7e85efc09..3f049aeba 100644--- a/skyvern-frontend/src/components/onboarding/WorkingExampleInspector.tsx+++ b/skyvern-frontend/src/components/onboarding/WorkingExampleInspector.tsx@@ -24,7 +24,7 @@ function WorkingExampleInspector({<h2id="working-example-heading"tabIndex={-1}- className="text-base font-semibold"+ className="scroll-mt-24 text-base font-semibold">{title}</h2>@@ -34,7 +34,7 @@ function WorkingExampleInspector({</header><div className="grid gap-5 p-5 sm:p-6 lg:grid-cols-3"><div className="min-w-0">- <h3 className="text-sm font-semibold">Workflow structure</h3>+ <h3 className="text-sm font-semibold">Agent structure</h3><ol className="mt-3 list-decimal space-y-3 pl-4 marker:text-muted-foreground">{structure.map((step) => (<li key={step.title} className="break-words pl-1">@@ -47,7 +47,7 @@ function WorkingExampleInspector({</ol></div><div className="min-w-0">- <h3 className="text-sm font-semibold">Example playback</h3>+ <h3 className="text-sm font-semibold">Agent playback</h3><ol className="mt-3 list-decimal space-y-2 pl-4 marker:text-muted-foreground">{playback.map((detail) => (<li@@ -81,6 +81,7 @@ function WorkingExampleInspector({<footer className="flex justify-end border-t border-border px-5 py-4 sm:px-6"><Buttontype="button"+ variant="outline"className="h-11 w-full touch-manipulation sm:w-auto"disabled={isPending}aria-busy={isPending}diff --git a/skyvern-frontend/src/routes/discover/DiscoverPage.test.tsx b/skyvern-frontend/src/routes/discover/DiscoverPage.test.tsxindex 2fbfc81a4..b4e551acc 100644--- a/skyvern-frontend/src/routes/discover/DiscoverPage.test.tsx+++ b/skyvern-frontend/src/routes/discover/DiscoverPage.test.tsx@@ -96,9 +96,35 @@ vi.mock("@/routes/workflows/hooks/useCreateWorkflowMutation", () => ({isPending: mocks.createPending,}),}));-vi.mock("@/routes/tasks/create/PromptBox", () => ({- PromptBox: () => <div data-testid="discover-prompt">prompt</div>,-}));+vi.mock("@/routes/tasks/create/PromptBox", async () => {+ const React = await vi.importActual<typeof import("react")>("react");+ return {+ PromptBox: React.forwardRef<+ { focusAndPrefillExample: (key: string) => void },+ Record<string, never>+ >(function PromptBoxMock(_, ref) {+ const [value, setValue] = React.useState("");+ const textareaRef = React.useRef<HTMLTextAreaElement>(null);+ React.useImperativeHandle(ref, () => ({+ focusAndPrefillExample: (key) => {+ setValue((current) => (current.trim() ? current : key));+ textareaRef.current?.focus({ preventScroll: true });+ },+ }));+ return (+ <div data-testid="discover-prompt">+ prompt+ <textarea+ ref={textareaRef}+ aria-label="Discover prompt"+ value={value}+ onChange={(event) => setValue(event.target.value)}+ />+ </div>+ );+ }),+ };+});vi.mock("./WorkflowTemplates", () => ({WorkflowTemplates: () => (<div data-testid="discover-templates">templates</div>@@ -402,15 +428,26 @@ describe("DiscoverPage progress surfaces", () => {mocks.progressState = "active";const { container, rerender } = render(<DiscoverPage />);expect(container.innerHTML).toMatch(- /<h1[^>]*>Create an agent<\/h1>.*prompt.*See how a workflow run is organized.*Build your first agent.*templates/s,+ /<h1[^>]*>Create an agent<\/h1>.*prompt.*Build your first agent.*See how an agent run is organized.*templates/s,);+ expect(screen.getByText("1 of 3")).toBeTruthy();+ expect(mocks.createWorkflow).not.toHaveBeenCalled();++ const describeAgent = screen.getByRole("button", {+ name: "Describe your first agent",+ });+ const prompt = screen.getByRole("textbox", { name: "Discover prompt" });+ fireEvent.change(prompt, { target: { value: "Keep my typed prompt" } });+ fireEvent.click(describeAgent);+ expect((prompt as HTMLTextAreaElement).value).toBe("Keep my typed prompt");+ expect(document.activeElement).toBe(prompt);expect(mocks.createWorkflow).not.toHaveBeenCalled();const workingExampleLink = screen.getByRole("link", {- name: "Use the working example",+ name: "or copy a working example",});const workingExampleHeading = screen.getByRole("heading", {- name: "See how a workflow run is organized",+ name: "See how an agent run is organized",});expect(workingExampleLink.getAttribute("href")).toBe("#working-example-heading",@@ -461,20 +498,71 @@ describe("DiscoverPage progress surfaces", () => {const resume = screen.getByRole("button", { name: "Resume setup" });expect(resume).toBe(hide);expect(document.activeElement).toBe(resume);- expect(- screen.queryByText("See how a workflow run is organized"),- ).toBeNull();+ expect(screen.queryByText("See how an agent run is organized")).toBeNull();fireEvent.click(resume);expect(mocks.restore).toHaveBeenCalledTimes(1);});+ it.each([+ ["fill_forms", "contact_us_forms"],+ ["extract_data", "hackernews"],+ ["monitor_website", "AAPLStockPrice"],+ ["something_else", "finditparts"],+ [null, "finditparts"],+ ] as const)(+ "prefills the %s intent example without creating",+ (intent, key) => {+ mocks.progressState = "active";+ renderDiscover({+ ...baseState,+ user_intent: intent,+ questionnaire_prompted_at: "2026-08-27T00:00:00Z",+ questionnaire: questionnaire(true),+ });++ fireEvent.click(+ screen.getByRole("button", { name: "Describe your first agent" }),+ );+ const prompt = screen.getByRole("textbox", { name: "Discover prompt" });+ expect((prompt as HTMLTextAreaElement).value).toBe(key);+ expect(document.activeElement).toBe(prompt);+ expect(mocks.createWorkflow).not.toHaveBeenCalled();+ },+ );++ it("briefly celebrates an active to completed transition", () => {+ vi.useFakeTimers();+ mocks.progressState = "active";+ mocks.completedCount = 1;+ mocks.firstMilestoneComplete = true;+ mocks.nextActionKey = "first_successful_run";+ const { rerender } = render(+ <MemoryRouter>+ <DiscoverPage />+ </MemoryRouter>,+ );++ mocks.progressState = "completed";+ rerender(+ <MemoryRouter>+ <DiscoverPage />+ </MemoryRouter>,+ );+ expect(screen.getByRole("status").textContent).toContain("3 of 3 complete");+ expect(screen.queryByText("See how an agent run is organized")).toBeNull();++ act(() => vi.advanceTimersByTime(1800));+ expect(screen.queryByText("First agent ready")).toBeNull();+ vi.useRealTimers();+ });+it.each(["completed", "ineligible", null] as const)("retires all progress surfaces for %s progress",(state) => {mocks.progressState = state;render(<DiscoverPage />);expect(document.body.textContent).not.toMatch(- /Build your first agent|See how a workflow run is organized|Hide setup|Resume setup/,+ /Build your first agent|See how an agent run is organized|Hide setup|Resume setup/,);},);diff --git a/skyvern-frontend/src/routes/discover/DiscoverPage.tsx b/skyvern-frontend/src/routes/discover/DiscoverPage.tsxindex b32acae78..176129284 100644--- a/skyvern-frontend/src/routes/discover/DiscoverPage.tsx+++ b/skyvern-frontend/src/routes/discover/DiscoverPage.tsx@@ -4,22 +4,43 @@ import { OnboardingErrorBoundary } from "@/components/onboarding/OnboardingErrorimport { OnboardingTelemetry } from "@/util/onboarding/OnboardingTelemetry";import { useOnboardingStateOptional } from "@/store/onboarding/useOnboardingState";import { useFeatureFlag } from "@/hooks/useFeatureFlag";-import { PromptBox } from "../tasks/create/PromptBox";+import {+ PromptBox,+ type ExamplePromptKey,+ type PromptBoxHandle,+} from "../tasks/create/PromptBox";import { WorkflowTemplates } from "./WorkflowTemplates";import { useCreateWorkflowMutation } from "../workflows/hooks/useCreateWorkflowMutation";import { Button } from "@/components/ui/button";import { ReloadIcon } from "@radix-ui/react-icons";import { defaultWorkflowRequest } from "../workflows/defaultWorkflowRequest";import { WorkingExampleInspector } from "@/components/onboarding/WorkingExampleInspector";-import { OnboardingProgressCard } from "@/components/onboarding/OnboardingProgressCard";+import { OnboardingProgressBand } from "@/components/onboarding/OnboardingProgressBand";import { useOnboardingProgress } from "./useOnboardingProgress";import { onboardingExampleRequest } from "./onboardingExample";+function getIntentExampleKey(+ intent: string | null | undefined,+): ExamplePromptKey {+ switch (intent) {+ case "fill_forms":+ return "contact_us_forms";+ case "extract_data":+ return "hackernews";+ case "monitor_website":+ return "AAPLStockPrice";+ default:+ return "finditparts";+ }+}+function DiscoverPage() {const enableCopilotHandoff =useFeatureFlag("ENABLE_DISCOVER_COPILOT_HANDOFF") === true;const createWorkflowMutation = useCreateWorkflowMutation();const createInFlight = useRef(false);+ const promptBoxRef = useRef<PromptBoxHandle>(null);+ const onboarding = useOnboardingStateOptional();const {progress,isPending: onboardingProgressPending,@@ -46,13 +67,20 @@ function DiscoverPage() {});};- const onboarding = useOnboardingStateOptional();+ const handleDescribeAgent = () => {+ promptBoxRef.current?.focusAndPrefillExample(+ getIntentExampleKey(onboarding?.state?.user_intent),+ );+ };return (<div className="space-y-10"><h1 className="sr-only">Create an agent</h1><div className="space-y-3">- <PromptBox enableCopilotHandoff={enableCopilotHandoff} />+ <PromptBox+ ref={promptBoxRef}+ enableCopilotHandoff={enableCopilotHandoff}+ /><div className="flex justify-end"><Buttonvariant="ghost"@@ -76,33 +104,22 @@ function DiscoverPage() {</Button></div></div>- {progress?.state === "active" && (- <WorkingExampleInspector- isPending={createWorkflowMutation.isPending}- onMakeCopy={handleExampleCopy}- />- )}- {progress?.state === "active" &&- (progress.completed_count === 0 || progress.completed_count === 1) &&- progress.next_action_key !== null ? (- <OnboardingProgressCard- state="active"- completedCount={progress.completed_count}- firstMilestoneComplete={progress.items.some(- (item) =>- item.key === "first_agent_created" && item.completed_at !== null,- )}- nextActionKey={progress.next_action_key}- isPending={onboardingProgressPending}- onDismiss={dismiss}- />- ) : progress?.state === "dismissed" ? (- <OnboardingProgressCard- state="dismissed"- isPending={onboardingProgressPending}- onRestore={restore}- />- ) : null}+ <OnboardingProgressBand+ progress={progress}+ isPending={onboardingProgressPending}+ onDismiss={dismiss}+ onRestore={restore}+ onDescribeAgent={handleDescribeAgent}+ >+ {progress?.state === "active" ? (+ <WorkingExampleInspector+ isPending={+ createWorkflowMutation.isPending || onboardingProgressPending+ }+ onMakeCopy={handleExampleCopy}+ />+ ) : null}+ </OnboardingProgressBand><WorkflowTemplates />{onboarding ? (<OnboardingErrorBoundarydiff --git a/skyvern-frontend/src/routes/discover/onboardingExample.test.ts b/skyvern-frontend/src/routes/discover/onboardingExample.test.tsindex 90af00081..dfe9f04e2 100644--- a/skyvern-frontend/src/routes/discover/onboardingExample.test.ts+++ b/skyvern-frontend/src/routes/discover/onboardingExample.test.ts@@ -24,14 +24,22 @@ it("keeps the copy payload to one passive public task", () => {assertNoSensitiveKeys(example.onboardingExampleRequest);});it("labels playback and result data as synthetic examples", () => {- const { provenance, playback, result } =+ const { title, provenance, playback, result } =example.onboardingExamplePresentation;+ expect(title).toBe("See how an agent run is organized");expect(provenance).toBe("Example data, not your run");- expect(playback[0]).toMatch(/static example/);- expect(playback[2]).toMatch(/example result/);- expect(result.title).toMatch(/synthetic.*example/i);+ expect(playback[0]).toMatch(/static agent example/);+ expect(playback[2]).toMatch(/agent result/);+ expect(result.title).toMatch(/synthetic.*agent/i);expect(result.fields.map(({ label }) => label)).toEqual(["Headline","Product summary",]);+ expect(+ JSON.stringify({+ presentation: example.onboardingExamplePresentation,+ title: example.onboardingExampleRequest.title,+ description: example.onboardingExampleRequest.description,+ }),+ ).not.toMatch(/workflow/i);});diff --git a/skyvern-frontend/src/routes/discover/onboardingExample.ts b/skyvern-frontend/src/routes/discover/onboardingExample.tsindex 1cf530954..4d09fc376 100644--- a/skyvern-frontend/src/routes/discover/onboardingExample.ts+++ b/skyvern-frontend/src/routes/discover/onboardingExample.ts@@ -2,7 +2,7 @@ import { RunEngine } from "@/api/types";import type { WorkflowCreateYAMLRequest } from "@/routes/workflows/types/workflowYamlTypes";export const onboardingExamplePresentation = {- title: "See how a workflow run is organized",+ title: "See how an agent run is organized",provenance: "Example data, not your run",structure: [{@@ -19,12 +19,12 @@ export const onboardingExamplePresentation = {},],playback: [- "Opened https://www.skyvern.com/ in this static example.",- "Read the public headline and product description.",- "Prepared the bounded example result shown below.",+ "Opened https://www.skyvern.com/ in this static agent example.",+ "The agent read the public headline and product description.",+ "Prepared the bounded agent result shown below.",],result: {- title: "Synthetic example result",+ title: "Synthetic agent result",fields: [{label: "Headline",@@ -33,16 +33,16 @@ export const onboardingExamplePresentation = {{label: "Product summary",value:- "Skyvern runs browser workflows that interact with websites and extract structured data.",+ "Skyvern runs browser agents that interact with websites and extract structured data.",},],},} as const;export const onboardingExampleRequest = {- title: "Copyable example: Skyvern homepage summary",+ title: "Copyable agent example: Skyvern homepage summary",description:- "Create a draft that reads public content from Skyvern's homepage.",+ "Create an agent draft that reads public content from Skyvern's homepage.",workflow_definition: {parameters: [],blocks: [diff --git a/skyvern-frontend/src/routes/discover/useOnboardingProgress.test.tsx b/skyvern-frontend/src/routes/discover/useOnboardingProgress.test.tsxindex 70147d748..70bb1a342 100644--- a/skyvern-frontend/src/routes/discover/useOnboardingProgress.test.tsx+++ b/skyvern-frontend/src/routes/discover/useOnboardingProgress.test.tsx@@ -4,8 +4,16 @@ import {QueryClientProvider,QueryObserver,} from "@tanstack/react-query";-import { act, renderHook, waitFor } from "@testing-library/react";-import { beforeEach, expect, it, vi } from "vitest";+import {+ act,+ render,+ renderHook,+ screen,+ waitFor,+} from "@testing-library/react";+import { MemoryRouter } from "react-router-dom";+import { afterEach, beforeEach, expect, it, vi } from "vitest";+import { OnboardingProgressBand } from "@/components/onboarding/OnboardingProgressBand";const mocks = vi.hoisted<{get: ReturnType<typeof vi.fn>;flag: boolean | undefined;@@ -47,6 +55,23 @@ const validPayload = () => ({{ key: "first_successful_run", completed_at: null },],});+const completedPayload = () => ({+ ...validPayload(),+ state: "completed",+ completed_count: 2,+ next_action_key: null,+ items: [+ { key: "first_agent_created", completed_at: "2026-08-20T12:00:00Z" },+ { key: "first_successful_run", completed_at: "2026-08-20T12:01:00Z" },+ ],+});+function deferred<T>() {+ let resolve!: (value: T) => void;+ const promise = new Promise<T>((resolvePromise) => {+ resolve = resolvePromise;+ });+ return { promise, resolve };+}function renderProgress(client = new QueryClient()) {const wrapper = ({ children }: { children: ReactNode }) => (<QueryClientProvider client={client}>{children}</QueryClientProvider>@@ -54,12 +79,34 @@ function renderProgress(client = new QueryClient()) {const hook = renderHook(() => useOnboardingProgress(), { wrapper });return { client, ...hook };}+function ProgressBand() {+ const { progress, isPending, dismiss, restore } = useOnboardingProgress();+ return (+ <OnboardingProgressBand+ progress={progress}+ isPending={isPending}+ onDismiss={dismiss}+ onRestore={restore}+ onDescribeAgent={vi.fn()}+ />+ );+}+function renderProgressBand(client: QueryClient) {+ return render(+ <QueryClientProvider client={client}>+ <MemoryRouter>+ <ProgressBand />+ </MemoryRouter>+ </QueryClientProvider>,+ );+}beforeEach(() => {vi.clearAllMocks();mocks.flag = true;mocks.org = "org-test";mocks.user = "user-test";});+afterEach(() => vi.useRealTimers());it.each([[false, "org-test", "user-test"],[undefined, "org-test", "user-test"],@@ -124,6 +171,58 @@ it("refetches fresh cached progress when Discover remounts", async () => {);expect(secondMount.result.current.progress).toEqual(refreshedPayload);});+it("celebrates only cached active progress completing on remount", async () => {+ const freshClient = new QueryClient();+ mocks.get.mockResolvedValueOnce({ data: completedPayload() });+ const freshMount = renderProgressBand(freshClient);++ await waitFor(() => expect(mocks.get).toHaveBeenCalledOnce());+ await waitFor(() =>+ expect(+ freshClient.getQueryData([+ "onboarding-progress",+ "user-test",+ "org-test",+ ]),+ ).toEqual(completedPayload()),+ );+ expect(screen.queryByText("First agent ready")).toBeNull();+ expect(screen.queryByRole("status")).toBeNull();+ freshMount.unmount();++ const client = new QueryClient();+ mocks.get.mockResolvedValueOnce({ data: validPayload() });+ const activeMount = renderProgressBand(client);+ expect(await screen.findByText("Build your first agent")).toBeTruthy();+ activeMount.unmount();++ const completedRequest = deferred<{ data: unknown }>();+ mocks.get.mockReturnValueOnce(completedRequest.promise);+ vi.useFakeTimers();+ const completionMount = renderProgressBand(client);+ expect(screen.getByText("Build your first agent")).toBeTruthy();++ completedRequest.resolve({ data: completedPayload() });+ await completedRequest.promise;+ await act(() => vi.advanceTimersByTimeAsync(0));+ expect(screen.getAllByText("First agent ready")).toHaveLength(1);+ expect(screen.getByRole("status").textContent).toContain("3 of 3 complete");++ act(() => vi.advanceTimersByTime(1799));+ expect(screen.getByText("First agent ready")).toBeTruthy();+ act(() => vi.advanceTimersByTime(1));+ expect(screen.queryByText("First agent ready")).toBeNull();+ completionMount.unmount();++ const finalRequest = deferred<{ data: unknown }>();+ mocks.get.mockReturnValueOnce(finalRequest.promise);+ const finalMount = renderProgressBand(client);+ expect(finalMount.container.innerHTML).toBe("");+ finalRequest.resolve({ data: completedPayload() });+ await finalRequest.promise;+ await act(() => vi.advanceTimersByTimeAsync(0));+ expect(finalMount.container.innerHTML).toBe("");+});it("isolates progress cache entries by authenticated user", async () => {mocks.flag = true;mocks.org = "org-test";diff --git a/skyvern-frontend/src/routes/tasks/create/PromptBox.test.tsx b/skyvern-frontend/src/routes/tasks/create/PromptBox.test.tsxindex 254f99676..f33a10f1d 100644--- a/skyvern-frontend/src/routes/tasks/create/PromptBox.test.tsx+++ b/skyvern-frontend/src/routes/tasks/create/PromptBox.test.tsx@@ -6,18 +6,21 @@ import {screen,waitFor,} from "@testing-library/react";-import type {- ButtonHTMLAttributes,- InputHTMLAttributes,- ReactNode,- SVGProps,- TextareaHTMLAttributes,+import {+ act,+ createRef,+ type ButtonHTMLAttributes,+ type InputHTMLAttributes,+ type Ref,+ type ReactNode,+ type SVGProps,+ type TextareaHTMLAttributes,} from "react";import { afterEach, describe, expect, test, vi } from "vitest";import { toast } from "@/components/ui/use-toast";-import { PromptBox } from "./PromptBox";+import { PromptBox, type PromptBoxHandle } from "./PromptBox";const { mockNavigate, mockPost, mockSetAutoplay } = vi.hoisted(() => ({mockNavigate: vi.fn(),@@ -60,11 +63,15 @@ vi.mock("react-router-dom", async () => {};});-vi.mock("@/components/AutoResizingTextarea/AutoResizingTextarea", () => ({- AutoResizingTextarea: (- props: TextareaHTMLAttributes<HTMLTextAreaElement>,- ) => <textarea {...props} />,-}));+vi.mock("@/components/AutoResizingTextarea/AutoResizingTextarea", async () => {+ const React = await vi.importActual<typeof import("react")>("react");+ return {+ AutoResizingTextarea: React.forwardRef<+ HTMLTextAreaElement,+ TextareaHTMLAttributes<HTMLTextAreaElement>+ >((props, ref) => <textarea ref={ref} {...props} />),+ };+});vi.mock("@/components/ui/button", () => ({Button: ({ children, ...props }: ButtonHTMLAttributes<HTMLButtonElement>) => (@@ -132,14 +139,17 @@ vi.mock("@/components/icons/InboxIcon", () => ({ InboxIcon: () => null }));vi.mock("@/components/icons/MessageIcon", () => ({ MessageIcon: () => null }));vi.mock("@/components/icons/TrophyIcon", () => ({ TrophyIcon: () => null }));-function renderPromptBox(enableCopilotHandoff = false) {+function renderPromptBox(+ enableCopilotHandoff = false,+ ref?: Ref<PromptBoxHandle>,+) {const queryClient = new QueryClient({defaultOptions: { queries: { retry: false }, mutations: { retry: false } },});return render(<QueryClientProvider client={queryClient}>- <PromptBox enableCopilotHandoff={enableCopilotHandoff} />+ <PromptBox ref={ref} enableCopilotHandoff={enableCopilotHandoff} /></QueryClientProvider>,);}@@ -164,6 +174,51 @@ async function submitPrompt(text: string) {}describe("PromptBox", () => {+ test("focuses and prefills an empty prompt without submitting or overwriting typed text", () => {+ const ref = createRef<PromptBoxHandle>();+ renderPromptBox(false, ref);+ const textarea = screen.getByPlaceholderText("Enter your prompt...");+ textarea.scrollIntoView = vi.fn();++ act(() => ref.current?.focusAndPrefillExample("hackernews"));+ expect((textarea as HTMLTextAreaElement).value).toBe(+ "Navigate to the Hacker News homepage and get the top 3 posts.",+ );+ expect(document.activeElement).toBe(textarea);+ expect(textarea.scrollIntoView).toHaveBeenCalledWith({ block: "center" });+ expect(textarea.getAttribute("id")).toBe("discover-prompt-input");+ expect(mockPost).not.toHaveBeenCalled();++ fireEvent.change(textarea, { target: { value: "Keep my agent prompt" } });+ act(() => ref.current?.focusAndPrefillExample("contact_us_forms"));+ expect((textarea as HTMLTextAreaElement).value).toBe(+ "Keep my agent prompt",+ );+ expect(document.activeElement).toBe(textarea);+ expect(mockPost).not.toHaveBeenCalled();+ });++ test("reuses the shipped sample prompts for onboarding intent keys", () => {+ const ref = createRef<PromptBoxHandle>();+ renderPromptBox(false, ref);+ const textarea = screen.getByPlaceholderText(+ "Enter your prompt...",+ ) as HTMLTextAreaElement;+ const cases = [+ ["finditparts", "finditparts.com"],+ ["contact_us_forms", "canadahvac.com/contact-hvac-canada"],+ ["hackernews", "Hacker News homepage"],+ ["AAPLStockPrice", "google finance"],+ ] as const;++ for (const [key, expected] of cases) {+ fireEvent.change(textarea, { target: { value: "" } });+ act(() => ref.current?.focusAndPrefillExample(key));+ expect(textarea.value).toContain(expected);+ }+ expect(mockPost).not.toHaveBeenCalled();+ });+test("creates prompt-generated workflows as V1 agent runs", async () => {mockPost.mockResolvedValue({data: {diff --git a/skyvern-frontend/src/routes/tasks/create/PromptBox.tsx b/skyvern-frontend/src/routes/tasks/create/PromptBox.tsxindex db5d36789..a2aafa151 100644--- a/skyvern-frontend/src/routes/tasks/create/PromptBox.tsx+++ b/skyvern-frontend/src/routes/tasks/create/PromptBox.tsx@@ -27,7 +27,13 @@ import {} from "@radix-ui/react-icons";import { useMutation, useQueryClient } from "@tanstack/react-query";import { AxiosError, type AxiosResponse } from "axios";-import { useRef, useState } from "react";+import {+ forwardRef,+ type ForwardedRef,+ useImperativeHandle,+ useRef,+ useState,+} from "react";import { useNavigate } from "react-router-dom";import {generatePhoneNumber,@@ -107,12 +113,18 @@ const exampleCases = ["Go to https://www.gong.io first. Navigate to the 'Integrations' page on the Gong website. Extract the names and descriptions of all integrations listed on the Gong integrations page. Ensure not to click on any external links or advertisements.",icon: <GearIcon className="size-6" />,},-];+] as const;++type ExamplePromptKey = (typeof exampleCases)[number]["key"];type PromptBoxProps = {enableCopilotHandoff?: boolean;};+type PromptBoxHandle = {+ focusAndPrefillExample: (key: ExamplePromptKey) => void;+};+const HANDOFF_TITLE_MAX_LEN = 80;function deriveHandoffTitle(prompt: string): string {@@ -169,10 +181,14 @@ function describeResponseEnvelope(response: AxiosResponse<unknown>): string {return `status=${response.status} content_type=${contentType} body_length=${bodyLength} parsed_as_json=${parsedAsJson}`;}-function PromptBox({ enableCopilotHandoff = false }: PromptBoxProps) {+function PromptBoxImpl(+ { enableCopilotHandoff = false }: PromptBoxProps,+ ref: ForwardedRef<PromptBoxHandle>,+) {const navigate = useNavigate();const studioEnabled = useWorkflowStudioEnabled();const [prompt, setPrompt] = useState<string>("");+ const textareaRef = useRef<HTMLTextAreaElement>(null);const credentialGetter = useCredentialGetter();const queryClient = useQueryClient();const [webhookCallbackUrl, setWebhookCallbackUrl] = useState<string | null>(@@ -199,6 +215,17 @@ function PromptBox({ enableCopilotHandoff = false }: PromptBoxProps) {// double-click can slip past it; the ref is the synchronous guard.const submitInFlightRef = useRef(false);+ useImperativeHandle(ref, () => ({+ focusAndPrefillExample: (key) => {+ const examplePrompt =+ exampleCases.find((example) => example.key === key)?.prompt ??+ exampleCases[0].prompt;+ setPrompt((current) => (current.trim() ? current : examplePrompt));+ textareaRef.current?.scrollIntoView?.({ block: "center" });+ textareaRef.current?.focus({ preventScroll: true });+ },+ }));+const generateWorkflowMutation = useMutation({mutationFn: async ({ prompt }: { prompt: string }) => {const client = await getClient(credentialGetter, "sans-api-v1");@@ -405,6 +432,8 @@ function PromptBox({ enableCopilotHandoff = false }: PromptBoxProps) {iconClassName="h-5 w-5"/><AutoResizingTextarea+ ref={textareaRef}+ id="discover-prompt-input"className="min-h-0 resize-none border-0 bg-transparent px-4 py-0 leading-5 text-foreground shadow-none placeholder:text-muted-foreground hover:border-0 focus-visible:ring-0"value={prompt}onChange={(e) => setPrompt(e.target.value)}@@ -676,4 +705,7 @@ function PromptBox({ enableCopilotHandoff = false }: PromptBoxProps) {);}+const PromptBox = forwardRef(PromptBoxImpl);+export { PromptBox };+export type { ExamplePromptKey, PromptBoxHandle };diff --git a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.queue.test.tsx b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.queue.test.tsxindex 3c72420ff..be25e071f 100644--- a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.queue.test.tsx+++ b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.queue.test.tsx@@ -322,6 +322,27 @@ describe("WorkflowCopilotChat — keep the chat live during a turn", () => {expect(timestamp.className).not.toContain("absolute");});+ it("wraps long unbroken text inside the user-message bubble", async () => {+ const content = `https://example.test/logs?query=${"encoded-query-segment".repeat(20)}`;+ historyResponse.data = {+ workflow_copilot_chat_id: "chat-1",+ chat_history: [+ {+ sender: "user",+ content,+ created_at: "2026-05-25T00:00:00Z",+ },+ ],+ proposed_workflow: null,+ auto_accept: false,+ };++ await renderChat();++ const message = screen.getByText(content);+ expect(message.className).toContain("[overflow-wrap:anywhere]");+ });+it("leaves the input enabled while a turn is in flight", async () => {await renderChat();await submit("build me a workflow");diff --git a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsxindex 92a6c2014..ff649c464 100644--- a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx+++ b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx@@ -509,7 +509,7 @@ const MessageItem = memo(<div className="flex justify-end"><div className="max-w-[85%] rounded-xl border border-white/5 bg-slate-elevation4 px-3.5 py-2.5 text-[13.5px] leading-[1.5] text-foreground"><div className="flex items-end gap-2">- <p className="min-w-0 flex-1 whitespace-pre-wrap">+ <p className="min-w-0 flex-1 whitespace-pre-wrap [overflow-wrap:anywhere]">{message.content}</p>{!queuedStatus && message.timestamp ? (