Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
fix(SKY-13415): hide the copilot rollup chevron when expansion adds no content (#8025)
Celal Zamanoğlua565494b6fdc
diff --git a/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.collapse.test.tsx b/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.collapse.test.tsxindex 9c7b2a2f3..93cd1b23a 100644--- a/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.collapse.test.tsx+++ b/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.collapse.test.tsx@@ -357,3 +357,70 @@ describe("NarrativeView collapse default", () => {expect(head.textContent).not.toContain("Outcome not confirmed:");});});++const pureAskTurn = (): TurnNarrativeState => ({+ ...EMPTY_NARRATIVE,+ turnId: "turn-ask",+ turnIndex: 0,+ mode: "clarify",+ responseType: "ASK_QUESTION",+ terminal: "response",+ narrativeSummary: "Which login should I use?",+});++const SCOUT_NARRATION = "Checked the login page for SSO options.";++const askAfterScoutingTurn = (): TurnNarrativeState => ({+ ...pureAskTurn(),+ turnId: "turn-ask-scouted",+ designStarted: true,+ designActivity: [+ { kind: "narration", text: SCOUT_NARRATION, iteration: 0, id: "n-1" },+ ],+});++describe("NarrativeView rollup expand affordance", () => {+ it("renders a pure needs-input ask as a plain, non-expandable card", () => {+ render(<NarrativeView turn={pureAskTurn()} uxV1 />);++ expect(screen.getByText("Which login should I use?")).toBeTruthy();+ expect(screen.queryByRole("button")).toBeNull();+ expect(document.querySelector("[aria-expanded]")).toBeNull();+ });++ it("keeps the chevron for an ask that follows scouting and reveals the thought stream on expand", () => {+ render(<NarrativeView turn={askAfterScoutingTurn()} uxV1 />);++ const head = screen.getByRole("button");+ expect(head.getAttribute("aria-expanded")).toBe("false");+ expect(screen.queryByText(SCOUT_NARRATION)).toBeNull();++ fireEvent.click(head);+ expect(screen.getByRole("button", { name: "Collapse turn" })).toBeTruthy();+ expect(screen.getByText(SCOUT_NARRATION)).toBeTruthy();+ });++ it("still shows the expand chevron for a build turn with blocks", () => {+ render(<NarrativeView turn={terminalBuildTurn()} />);++ const head = screen.getByRole("button", { name: new RegExp(HEADLINE) });+ expect(head.getAttribute("aria-expanded")).toBe("false");++ fireEvent.click(head);+ expect(screen.getByRole("button", { name: "Collapse turn" })).toBeTruthy();+ });++ it("gains the expand affordance when activity arrives after a content-free render", () => {+ const { rerender } = render(<NarrativeView turn={pureAskTurn()} uxV1 />);+ expect(screen.queryByRole("button")).toBeNull();++ rerender(+ <NarrativeView+ turn={{ ...pureAskTurn(), blocks: [completedBlock("block_1")] }}+ uxV1+ />,+ );+ const head = screen.getByRole("button");+ expect(head.getAttribute("aria-expanded")).toBe("false");+ });+});diff --git a/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.tsx b/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.tsxindex bcfa35584..7050553e6 100644--- a/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.tsx+++ b/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.tsx@@ -1012,18 +1012,15 @@ function accentBg(accent: TurnSummary["accent"]): string {interface TurnHeadProps {summary: TurnSummary;expanded: boolean;- onClick: () => void;+ onClick?: () => void;subtitle?: ReactNode;}function TurnHead({ summary, expanded, onClick, subtitle }: TurnHeadProps) {- return (- <button- type="button"- onClick={onClick}- aria-expanded={expanded}- className="flex w-full items-start gap-3 px-3.5 py-3 text-left"- >+ const expandable = Boolean(onClick);+ const headClass = "flex w-full items-start gap-3 px-3.5 py-3 text-left";+ const body = (+ <><spanclassName={`flex h-[26px] w-[26px] shrink-0 items-center justify-center rounded-full border text-[12px] font-bold ${accentBg(summary.accent,@@ -1045,14 +1042,31 @@ function TurnHead({ summary, expanded, onClick, subtitle }: TurnHeadProps) {</div>{subtitle}</div>- <span- className={`mt-1 shrink-0 text-[14px] text-muted-foreground transition-transform dark:text-slate-500 ${- expanded ? "rotate-90" : ""- }`}- aria-hidden="true"- >- ›- </span>+ {expandable ? (+ <span+ className={`mt-1 shrink-0 text-[14px] text-muted-foreground transition-transform dark:text-slate-500 ${+ expanded ? "rotate-90" : ""+ }`}+ aria-hidden="true"+ >+ ›+ </span>+ ) : null}+ </>+ );++ if (!expandable) {+ return <div className={headClass}>{body}</div>;+ }++ return (+ <button+ type="button"+ onClick={onClick}+ aria-expanded={expanded}+ className={headClass}+ >+ {body}</button>);}@@ -1097,13 +1111,20 @@ function RollupCard({const failed = rollupBlocks.filter((b) => b.state === "failed");const showCommit = !summary.isQA && completed.length > 0;const showChecklist = Boolean(uxV1) && showPhaseChecklist(turn);+ // Expand only earns a chevron when DetailView adds content beyond the head's+ // message — a pure ask (no scouting) re-renders the same text, so no chevron.+ const hasExpandableDetail =+ showChecklist ||+ turn.blocks.length > 0 ||+ (turn.designStarted && (turn.draft?.blockCount ?? 0) > 0) ||+ turn.designActivity.some((e) => e.kind === "narration");return (<div className="overflow-hidden rounded-xl border border-border/60 bg-slate-elevation2"><TurnHeadsummary={summary}expanded={false}- onClick={onExpand}+ onClick={hasExpandableDetail ? onExpand : undefined}subtitle={subtitle ? (<div