Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
fix(SKY-12194): humanize block display names in copilot chat (#7358)
Celal Zamanoğlu8051b358fa52
diff --git a/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.checklist.test.tsx b/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.checklist.test.tsxindex 5acfd4ea6..bce78e98c 100644--- a/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.checklist.test.tsx+++ b/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.checklist.test.tsx@@ -123,7 +123,8 @@ describe("NarrativeView — phase checklist (SKY-11970)", () => {it("hosts FBlockRun exactly once, inside the Test-run nest — no double-render with the legacy flat list", () => {render(<NarrativeView turn={testActiveTurn()} uxV1 />);- expect(screen.getAllByText("block_1")).toHaveLength(1);+ // uxV1 humanizes the primary block label ("block_1" -> "Block 1").+ expect(screen.getAllByText("Block 1")).toHaveLength(1);});it("a11y: nest-less rows render a plain div, not a button", () => {@@ -312,4 +313,31 @@ describe("NarrativeView — phase checklist (SKY-11970)", () => {expect(screen.queryByText("Draft code")).toBeNull();expect(screen.queryByText("Test-run")).toBeNull();});++ it("humanizes the primary block label under uxV1, keeping the raw label in a title attribute", () => {+ const turn = testActiveTurn();+ turn.blocks = [+ runningBlock({+ state: "completed",+ endedAt: "2026-06-10T00:00:10Z",+ label: "extract_first_comments_from_top_three_posts_v2",+ }),+ ];+ render(<NarrativeView turn={turn} uxV1 />);+ const label = screen.getByText(+ "Extract First Comments From Top Three Posts",+ );+ expect(label.getAttribute("title")).toBe(+ "extract_first_comments_from_top_three_posts_v2",+ );+ expect(+ screen.queryByText("extract_first_comments_from_top_three_posts_v2"),+ ).toBeNull();+ });++ it("flag-off parity: block labels render raw, unhumanized, when uxV1 is absent", () => {+ render(<NarrativeView turn={testActiveTurn()} />);+ expect(screen.getByText("block_1")).toBeTruthy();+ expect(screen.queryByText("Block 1")).toBeNull();+ });});diff --git a/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.tsx b/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.tsxindex 35c19f3ab..0af02f413 100644--- a/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.tsx+++ b/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.tsx@@ -1,6 +1,7 @@import { type ReactNode, useEffect, useMemo, useState } from "react";import { buildRevealOffsets, revealedCountAt } from "./actionReveal";+import { humanizeBlockLabel } from "./blockLabel";import {CopilotPhaseId,PhaseStatus,@@ -258,9 +259,11 @@ interface FBlockRunProps {block: BlockState;turnEnded: boolean;onSelect?: (label: string) => void;+ uxV1?: boolean;}-function FBlockRun({ block, turnEnded, onSelect }: FBlockRunProps) {+function FBlockRun({ block, turnEnded, onSelect, uxV1 }: FBlockRunProps) {+ const displayLabel = uxV1 ? humanizeBlockLabel(block.label) : block.label;const palette = paletteFor(block.blockType);const isRunning = block.state === "running";const isCompleted = block.state === "completed";@@ -390,8 +393,15 @@ function FBlockRun({ block, turnEnded, onSelect }: FBlockRunProps) {</span><div className="flex min-w-0 flex-1 flex-col"><div className="flex flex-wrap items-baseline gap-x-1.5 gap-y-0.5">- <span className="font-mono text-[12.5px] font-semibold text-slate-100">- {block.label}+ <span+ className={+ uxV1+ ? "text-[12.5px] font-semibold text-slate-100"+ : "font-mono text-[12.5px] font-semibold text-slate-100"+ }+ title={uxV1 ? block.label : undefined}+ >+ {displayLabel}</span><span className="text-[11px] text-slate-500">·</span><span className={`font-mono text-[11px] font-medium ${accentText}`}>@@ -484,9 +494,10 @@ interface FDesignRowProps {done: boolean;blockLabels: string[];activity: ActivityEntry[];+ uxV1?: boolean;}-function FDesignRow({ done, blockLabels, activity }: FDesignRowProps) {+function FDesignRow({ done, blockLabels, activity, uxV1 }: FDesignRowProps) {const [userOpen, setUserOpen] = useState<boolean | null>(null);const open = userOpen === null ? !done : userOpen;const drafts = blockLabels.length;@@ -547,7 +558,12 @@ function FDesignRow({ done, blockLabels, activity }: FDesignRowProps) {{blockLabels.map((label) => (<FSubRow key={label} glyph="✦" glyphClass="text-emerald-300"><span className="text-slate-400">Drafted </span>- <span className="font-mono text-slate-100">{label}</span>+ <span+ className={uxV1 ? "text-slate-100" : "font-mono text-slate-100"}+ title={uxV1 ? label : undefined}+ >+ {uxV1 ? humanizeBlockLabel(label) : label}+ </span></FSubRow>))}</div>@@ -659,12 +675,14 @@ interface FPhaseChecklistProps {turn: TurnNarrativeState;turnEnded: boolean;onBlockSelect?: (label: string) => void;+ uxV1?: boolean;}function FPhaseChecklist({turn,turnEnded,onBlockSelect,+ uxV1,}: FPhaseChecklistProps) {const rows = useMemo(() => derivePhases(turn), [turn]);const [openPhases, setOpenPhases] = useState<Set<CopilotPhaseId>>(@@ -766,8 +784,13 @@ function FPhaseChecklist({glyphClass="text-emerald-300"><span className="text-slate-400">Drafted </span>- <span className="font-mono text-slate-100">- {label}+ <span+ className={+ uxV1 ? "text-slate-100" : "font-mono text-slate-100"+ }+ title={uxV1 ? label : undefined}+ >+ {uxV1 ? humanizeBlockLabel(label) : label}</span></FSubRow>))}@@ -784,6 +807,7 @@ function FPhaseChecklist({block={b}turnEnded={turnEnded}onSelect={onBlockSelect}+ uxV1={uxV1}/>))}</>@@ -909,6 +933,7 @@ function RollupCard({turn={turn}turnEndedonBlockSelect={onBlockSelect}+ uxV1={uxV1}/></div>) : null}@@ -932,8 +957,15 @@ function RollupCard({>{palette.glyph}</span>- <span className="font-mono text-[11px] text-slate-400">- {b.label}+ <span+ className={+ uxV1+ ? "text-[11px] text-slate-400"+ : "font-mono text-[11px] text-slate-400"+ }+ title={uxV1 ? b.label : undefined}+ >+ {uxV1 ? humanizeBlockLabel(b.label) : b.label}</span><span className="text-slate-600">·</span><span className="text-[11.5px] text-slate-200">@@ -963,8 +995,15 @@ function RollupCard({>✕</span>- <span className="font-mono text-[11px] text-rose-300/80">- {b.label}+ <span+ className={+ uxV1+ ? "text-[11px] text-rose-300/80"+ : "font-mono text-[11px] text-rose-300/80"+ }+ title={uxV1 ? b.label : undefined}+ >+ {uxV1 ? humanizeBlockLabel(b.label) : b.label}</span></li>))}@@ -1025,6 +1064,7 @@ function DetailView({turn={turn}turnEnded={turn.terminal !== null}onBlockSelect={onBlockSelect}+ uxV1={uxV1}/></>) : showDesign ? (@@ -1032,6 +1072,7 @@ function DetailView({done={!designOpen}blockLabels={turn.draft?.blockLabels ?? []}activity={turn.designActivity}+ uxV1={uxV1}/>) : preBlockNarration.length > 0 ? (preBlockNarration.map((e) => (@@ -1047,6 +1088,7 @@ function DetailView({block={b}turnEnded={turn.terminal !== null}onSelect={onBlockSelect}+ uxV1={uxV1}/>))}</div>diff --git a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.blockActions.test.tsx b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.blockActions.test.tsxindex bd5eb4d06..a46eb739f 100644--- a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.blockActions.test.tsx+++ b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.blockActions.test.tsx@@ -426,7 +426,9 @@ describe("WorkflowCopilotChat — recorded-action fetch wiring", () => {fireEvent.click(within(statusRegion).getByRole("button", { expanded: false }),);- fireEvent.click(within(statusRegion).getByText("block_1"));+ // uxV1 is on by default in this file, so the row's primary text is the+ // humanized label ("block_1" -> "Block 1"), not the raw block label.+ fireEvent.click(within(statusRegion).getByText("Block 1"));await waitFor(() => expect(screen.getByText("Wobble Gizmo")).toBeTruthy());});diff --git a/skyvern-frontend/src/routes/workflows/copilot/blockLabel.test.ts b/skyvern-frontend/src/routes/workflows/copilot/blockLabel.test.tsnew file mode 100644index 000000000..c4276934d--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/copilot/blockLabel.test.ts@@ -0,0 +1,43 @@+import { describe, expect, it } from "vitest";++import { humanizeBlockLabel } from "./blockLabel";++describe("humanizeBlockLabel", () => {+ it("title-cases underscore-separated words", () => {+ expect(+ humanizeBlockLabel("extract_first_comments_from_top_three_posts"),+ ).toBe("Extract First Comments From Top Three Posts");+ });++ it("strips a trailing retry-count version suffix", () => {+ expect(+ humanizeBlockLabel(+ "hn_visit_first_second_third_comment_pages_extract_top_comments_v2",+ ),+ ).toBe("Hn Visit First Second Third Comment Pages Extract Top Comments");+ });++ it("strips a double-digit version suffix", () => {+ expect(humanizeBlockLabel("log_event_v10")).toBe("Log Event");+ });++ it("does not treat a mid-label _v as a version suffix", () => {+ expect(humanizeBlockLabel("v2_report_summary")).toBe("V2 Report Summary");+ });++ it("leaves an already-uppercase segment intact", () => {+ expect(humanizeBlockLabel("fetch_URL_data")).toBe("Fetch URL Data");+ });++ it("falls back to the raw label when nothing survives stripping", () => {+ expect(humanizeBlockLabel("_v2")).toBe("_v2");+ });++ it("falls back to the raw label for an empty string", () => {+ expect(humanizeBlockLabel("")).toBe("");+ });++ it("handles a single word with no underscores", () => {+ expect(humanizeBlockLabel("block_1")).toBe("Block 1");+ });+});diff --git a/skyvern-frontend/src/routes/workflows/copilot/blockLabel.ts b/skyvern-frontend/src/routes/workflows/copilot/blockLabel.tsnew file mode 100644index 000000000..76ab99ff9--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/copilot/blockLabel.ts@@ -0,0 +1,16 @@+// Copilot block labels are LLM-authored Python identifiers (snake_case,+// occasionally with a trailing retry-count version suffix like `_v2`) —+// readable to whoever wrote the code, not to the person watching the build.+// This derives a display label; callers keep the raw `label` around (e.g. in+// a `title` attribute) for debugging and must keep using it for identity+// (canvas selection, keys) since only the rendered text should change.+const VERSION_SUFFIX_RE = /_v\d+$/i;++export function humanizeBlockLabel(label: string): string {+ const words = label+ .replace(VERSION_SUFFIX_RE, "")+ .split(/[_\s]+/)+ .filter(Boolean);+ if (words.length === 0) return label;+ return words.map((word) => word[0]!.toUpperCase() + word.slice(1)).join(" ");+}diff --git a/skyvern-frontend/src/routes/workflows/copilot/cards/ReviewGateCard.test.ts b/skyvern-frontend/src/routes/workflows/copilot/cards/ReviewGateCard.test.tsxsimilarity index 57%rename from skyvern-frontend/src/routes/workflows/copilot/cards/ReviewGateCard.test.tsrename to skyvern-frontend/src/routes/workflows/copilot/cards/ReviewGateCard.test.tsxindex 7c2c5c97a..e7e4ebc82 100644--- a/skyvern-frontend/src/routes/workflows/copilot/cards/ReviewGateCard.test.ts+++ b/skyvern-frontend/src/routes/workflows/copilot/cards/ReviewGateCard.test.tsx@@ -1,8 +1,15 @@-import { describe, expect, it } from "vitest";+// @vitest-environment jsdom++import { cleanup, render, screen } from "@testing-library/react";+import { afterEach, describe, expect, it } from "vitest";import { EMPTY_NARRATIVE, type TurnNarrativeState } from "../narrativeState";import { WorkflowApiResponse } from "@/routes/workflows/types/workflowTypes";-import { getReviewGateVerdict } from "./ReviewGateCard";+import { ReviewGateCard, getReviewGateVerdict } from "./ReviewGateCard";++afterEach(() => {+ cleanup();+});const turn = (overrides: Partial<TurnNarrativeState> = {},@@ -73,3 +80,47 @@ describe("getReviewGateVerdict", () => {).toBe(null);});});++describe("ReviewGateCard — block label humanization", () => {+ const noop = () => {};++ it("humanizes Added/Removed block labels, keeping the raw label in a title attribute", () => {+ render(+ <ReviewGateCard+ turn={turn({+ draft: {+ blockCount: 1,+ blockLabels: ["extract_titles_v2"],+ summary: null,+ },+ blocks: [+ {+ workflowRunBlockId: "wrb_1",+ label: "old_extract_step",+ blockType: "task",+ state: "drafted",+ lastSeenIteration: 0,+ activity: [],+ startedAt: null,+ endedAt: null,+ },+ ],+ })}+ pending={false}+ verdict={null}+ actionsEnabled={false}+ onAccept={noop}+ onAlwaysAccept={noop}+ onReject={noop}+ onReview={noop}+ />,+ );++ const added = screen.getByText("+ Extract Titles");+ expect(added.getAttribute("title")).toBe("extract_titles_v2");+ expect(screen.queryByText("+ extract_titles_v2")).toBeNull();++ const removed = screen.getByText("- Old Extract Step");+ expect(removed.getAttribute("title")).toBe("old_extract_step");+ });+});diff --git a/skyvern-frontend/src/routes/workflows/copilot/cards/ReviewGateCard.tsx b/skyvern-frontend/src/routes/workflows/copilot/cards/ReviewGateCard.tsxindex 6e14dac87..50b711da2 100644--- a/skyvern-frontend/src/routes/workflows/copilot/cards/ReviewGateCard.tsx+++ b/skyvern-frontend/src/routes/workflows/copilot/cards/ReviewGateCard.tsx@@ -2,6 +2,7 @@ import { MagicWandIcon } from "@radix-ui/react-icons";import { WorkflowApiResponse } from "@/routes/workflows/types/workflowTypes";+import { humanizeBlockLabel } from "../blockLabel";import { TurnNarrativeState } from "../narrativeState";import { getDiffCardTitle } from "./diffCardTitle";@@ -118,8 +119,8 @@ export function ReviewGateCard({Added</div>{draft.blockLabels.map((label) => (- <div key={label} className={itemClassName}>- + {label}+ <div key={label} className={itemClassName} title={label}>+ + {humanizeBlockLabel(label)}</div>))}</div>@@ -130,8 +131,8 @@ export function ReviewGateCard({Removed</div>{removed.map((label) => (- <div key={label} className={itemClassName}>- - {label}+ <div key={label} className={itemClassName} title={label}>+ - {humanizeBlockLabel(label)}</div>))}</div>