Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
fix(SKY-11513): link studio title to runs page with a blended edit button (#7607)
Celal Zamanoğlu88f12a828fde
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/components/EditableNodeTitle.test.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/components/EditableNodeTitle.test.tsxindex caf363ea5..f20b7a340 100644--- a/skyvern-frontend/src/routes/workflows/editor/nodes/components/EditableNodeTitle.test.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/components/EditableNodeTitle.test.tsx@@ -1,7 +1,7 @@// @vitest-environment jsdomimport { cleanup, fireEvent, render, screen } from "@testing-library/react";-import { afterEach, describe, expect, test } from "vitest";+import { afterEach, describe, expect, test, vi } from "vitest";import { EditableNodeTitle } from "./EditableNodeTitle";@@ -58,3 +58,36 @@ describe("EditableNodeTitle edit-mode input sizing", () => {expect(input.className).toContain("px-1");});});++describe("EditableNodeTitle renderIdle seam", () => {+ test("without renderIdle, idle still renders the default click-to-edit heading (other consumers unchanged)", () => {+ render(<EditableNodeTitle value="Foo" editable onChange={() => {}} />);++ expect(screen.getByRole("heading", { name: "Foo" })).toBeTruthy();+ });++ test("with renderIdle, the custom idle replaces the heading and startEditing enters the shared input and commits", () => {+ const onChange = vi.fn();+ render(+ <EditableNodeTitle+ value="Foo"+ editable+ onChange={onChange}+ renderIdle={({ startEditing }) => (+ <button onClick={startEditing}>go-edit</button>+ )}+ />,+ );++ // default heading is suppressed for renderIdle callers+ expect(screen.queryByRole("heading")).toBeNull();++ fireEvent.click(screen.getByText("go-edit"));++ const input = screen.getByDisplayValue("Foo");+ fireEvent.change(input, { target: { value: "Bar" } });+ fireEvent.blur(input);++ expect(onChange).toHaveBeenCalledWith("Bar");+ });+});diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/components/EditableNodeTitle.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/components/EditableNodeTitle.tsxindex 429f90752..42d68aeba 100644--- a/skyvern-frontend/src/routes/workflows/editor/nodes/components/EditableNodeTitle.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/components/EditableNodeTitle.tsx@@ -6,7 +6,7 @@ import {} from "@/components/ui/tooltip";import { cn } from "@/util/utils";import { HorizontallyResizingInput } from "./HorizontallyResizingInput";-import { useRef, useState } from "react";+import { type ReactNode, useRef, useState } from "react";type Props = {value: string;@@ -14,6 +14,9 @@ type Props = {onChange: (value: string) => void;titleClassName?: string;inputClassName?: string;+ // Replaces the default click-to-edit <h1> in idle mode; the caller renders+ // idle (e.g. a link) and enters edit via startEditing. Edit flow unchanged.+ renderIdle?: (args: { startEditing: () => void }) => ReactNode;};function EditableNodeTitle({@@ -22,6 +25,7 @@ function EditableNodeTitle({onChange,titleClassName,inputClassName,+ renderIdle,}: Props) {const [editing, setEditing] = useState(false);const [isTruncated, setIsTruncated] = useState(false);@@ -37,6 +41,9 @@ function EditableNodeTitle({};if (!editing) {+ if (renderIdle) {+ return <>{renderIdle({ startEditing: () => setEditing(true) })}</>;+ }return (<TooltipProvider><Tooltip>diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.test.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.test.tsxindex dfd090dd8..84728c41b 100644--- a/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.test.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.test.tsx@@ -34,9 +34,10 @@ import {type WorkflowSaveData,} from "@/store/WorkflowHasChangesStore";import { useWorkflowSnapshotStore } from "@/store/WorkflowSnapshotStore";+import { useWorkflowTitleStore } from "@/store/WorkflowTitleStore";import { useWorkflowYamlEditorStore } from "@/store/WorkflowYamlEditorStore";-import { RunStopButton, SaveButton } from "./StudioTopBar";+import { RunStopButton, SaveButton, TitleSection } from "./StudioTopBar";function LocationProbe() {const location = useLocation();@@ -374,3 +375,64 @@ describe("SaveButton confirmation gating", () => {expect(saveWorkflowSpy).not.toHaveBeenCalled();});});++describe("TitleSection title link + edit affordance", () => {+ beforeEach(() => {+ useWorkflowTitleStore.setState({ title: "My Workflow" });+ useWorkflowHasChangesStore.setState({ hasChanges: false });+ useRecordingStore.setState({ isRecording: false });+ });++ function renderTitleSection(editable = true) {+ return render(+ <TooltipProvider delayDuration={0}>+ <MemoryRouter initialEntries={["/agents/wpid_abc/studio"]}>+ <Routes>+ <Route+ path="/agents/:workflowPermanentId/studio"+ element={<TitleSection editable={editable} />}+ />+ </Routes>+ </MemoryRouter>+ </TooltipProvider>,+ );+ }++ test("renders the title as a link to the workflow runs page", () => {+ renderTitleSection();+ const link = screen.getByRole("link", { name: "My Workflow" });+ expect(link.getAttribute("href")).toBe("/agents/wpid_abc/runs");+ });++ test("enters the shared rename input from the edit button and commits into the title + dirty stores", () => {+ renderTitleSection();++ fireEvent.click(+ screen.getByRole("button", { name: "Click to edit title" }),+ );++ const input = screen.getByDisplayValue("My Workflow");+ fireEvent.change(input, { target: { value: "Renamed WF" } });+ fireEvent.blur(input);++ expect(useWorkflowTitleStore.getState().title).toBe("Renamed WF");+ expect(useWorkflowHasChangesStore.getState().hasChanges).toBe(true);+ });++ test("keeps the runs link but hides the edit button when not editable", () => {+ renderTitleSection(false);+ expect(screen.getByRole("link", { name: "My Workflow" })).toBeTruthy();+ expect(+ screen.queryByRole("button", { name: "Click to edit title" }),+ ).toBeNull();+ });++ test("renders the edit pencil visibly at rest with a borderless hover-bg affordance", () => {+ renderTitleSection();+ const button = screen.getByRole("button", { name: "Click to edit title" });+ // Always visible (no opacity reveal), soft hover background, no border/outline.+ expect(button.className).not.toContain("opacity-0");+ expect(button.className).toContain("hover:bg-slate-500/20");+ expect(button.className).not.toContain("border");+ });+});diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.tsxindex 45495649a..50fc5f431 100644--- a/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.tsx@@ -2,12 +2,18 @@ import { type ReactNode, useMemo, useState } from "react";import { AxiosError } from "axios";import {CalendarIcon,+ Pencil1Icon,PlayIcon,ReloadIcon,StopIcon,} from "@radix-ui/react-icons";import { useMutation, useQueryClient } from "@tanstack/react-query";-import { useNavigate, useParams, useSearchParams } from "react-router-dom";+import {+ Link,+ useNavigate,+ useParams,+ useSearchParams,+} from "react-router-dom";import { getClient } from "@/api/AxiosClient";import { SaveIcon } from "@/components/icons/SaveIcon";@@ -54,21 +60,44 @@ import { useStudioPanes } from "./useStudioPanes";import { useStudioRunId } from "./useStudioRunId";import { useStudioWorkflowDeletedAt } from "./StudioShellContext";-function TitleSection({ editable = true }: { editable?: boolean }) {+export function TitleSection({ editable = true }: { editable?: boolean }) {const { title, setTitle } = useWorkflowTitleStore();const setHasChanges = useWorkflowHasChangesStore((s) => s.setHasChanges);const isRecording = useRecordingStore((s) => s.isRecording);+ const { workflowPermanentId } = useParams();+ const canEdit = editable && !isRecording;return (- <div className="flex min-w-0 max-w-[19rem] items-center">+ <div className="flex min-w-0 max-w-[19rem] items-center gap-1"><EditableNodeTitle- editable={editable && !isRecording}+ editable={canEdit}value={title}onChange={(next) => {setTitle(next);setHasChanges(true);}}- titleClassName="px-2 text-base"inputClassName="px-2 text-base"+ renderIdle={({ startEditing }) => (+ <>+ <Link+ to={`/agents/${workflowPermanentId}/runs`}+ className="min-w-0 truncate px-2 text-base hover:underline hover:underline-offset-2"+ >+ {title}+ </Link>+ {canEdit && (+ <ControlTooltip content="Click to edit title">+ <button+ type="button"+ onClick={startEditing}+ aria-label="Click to edit title"+ className="shrink-0 rounded p-1.5 text-muted-foreground transition-colors hover:bg-slate-500/20 hover:text-tertiary-foreground"+ >+ <Pencil1Icon className="h-4 w-4" />+ </button>+ </ControlTooltip>+ )}+ </>+ )}/></div>);