Skip to content

Automate browser based workflows with AI

Truthful stop copy and honest run-outcome rendering in copilot chat (#7673)

pedrohsdb0cf768e3d0d2
diff --git a/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.checklist.test.tsx b/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.checklist.test.tsx
index 54851ed84..45d224d83 100644
--- a/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.checklist.test.tsx
+++ b/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.checklist.test.tsx
@@ -35,6 +35,8 @@ const runningBlock = (overrides: Partial<BlockState> = {}): BlockState => ({
endedAt: null,
...overrides,
});
+const LONG_OUTCOME_REASON =
+ "The verification challenge kept reappearing after submit, and each retry landed back on the same gate instead of the requested destination page.";
const liveExploreTurn = (): TurnNarrativeState => ({
...EMPTY_NARRATIVE,
@@ -227,6 +229,99 @@ describe("NarrativeView — phase checklist (SKY-11970)", () => {
expect(screen.getByTitle("Highlight block_1 on canvas")).toBeTruthy();
});
+ it("shows a truncated not-demonstrated reason in the collapsed block row and hides it without the verdict", () => {
+ const notConfirmedBlock = runningBlock({
+ state: "completed",
+ outcome: "not_demonstrated",
+ endedAt: "2026-06-10T00:00:10Z",
+ });
+ const turnWithVerdict: TurnNarrativeState = {
+ ...EMPTY_NARRATIVE,
+ turnId: "turn-3",
+ turnIndex: 0,
+ mode: "build",
+ designStarted: true,
+ designEnded: true,
+ terminal: "response",
+ draft: { blockCount: 1, blockLabels: ["block_1"], summary: null },
+ blocks: [notConfirmedBlock],
+ lastRunOutcome: {
+ verdict: "not_demonstrated",
+ displayReason: LONG_OUTCOME_REASON,
+ activitySeqAtVerdict: 4,
+ },
+ designActivity: [],
+ };
+ const expectedPreview = `${LONG_OUTCOME_REASON.slice(0, 137).trimEnd()}...`;
+ const { rerender } = render(<NarrativeView turn={turnWithVerdict} uxV1 />);
+ const testRow = screen.getByRole("button", { name: /Test-run/ });
+ fireEvent.click(testRow);
+ expect(
+ screen.getByText(
+ (text) =>
+ text.includes("run finished without showing the goal was met") &&
+ text.includes(expectedPreview),
+ ),
+ ).toBeTruthy();
+
+ rerender(
+ <NarrativeView
+ turn={{ ...turnWithVerdict, lastRunOutcome: null }}
+ uxV1
+ />,
+ );
+ const rerenderedTestRow = screen.getByRole("button", { name: /Test-run/ });
+ if (rerenderedTestRow.getAttribute("aria-expanded") === "false") {
+ fireEvent.click(rerenderedTestRow);
+ }
+ expect(screen.queryByText(expectedPreview)).toBeNull();
+ });
+
+ it("uses hydrated block outcomeReason for the collapsed block-row preview when lastRunOutcome is absent", () => {
+ const hydrated = hydrateNarrativeFromPayload({
+ turnId: "turn-4",
+ turnIndex: 0,
+ mode: "build",
+ responseType: "REPLY",
+ designStarted: true,
+ designEnded: true,
+ draft: { blockCount: 1, blockLabels: ["block_1"], summary: null },
+ blocks: [
+ {
+ workflowRunBlockId: "wrb_1",
+ label: "block_1",
+ blockType: "task",
+ state: "completed",
+ outcome: "not_demonstrated",
+ outcomeReason: LONG_OUTCOME_REASON,
+ lastSeenIteration: 0,
+ activity: [],
+ startedAt: "2026-06-10T00:00:00Z",
+ endedAt: "2026-06-10T00:00:10Z",
+ },
+ ],
+ terminal: "response",
+ terminalMessage: "Built and tested the workflow.",
+ narrativeSummary: "Built and tested the workflow.",
+ priorBlockCount: null,
+ designActivity: [],
+ startedAt: "2026-06-10T00:00:00Z",
+ endedAt: "2026-06-10T00:00:10Z",
+ })!;
+ expect(hydrated.lastRunOutcome).toBeNull();
+ const expectedPreview = `${LONG_OUTCOME_REASON.slice(0, 137).trimEnd()}...`;
+ render(<NarrativeView turn={hydrated} uxV1 />);
+ const testRow = screen.getByRole("button", { name: /Test-run/ });
+ fireEvent.click(testRow);
+ expect(
+ screen.getByText(
+ (text) =>
+ text.includes("run finished without showing the goal was met") &&
+ text.includes(expectedPreview),
+ ),
+ ).toBeTruthy();
+ });
+
it("hydration no-replay pin: a reloaded terminal build turn renders all stubs — zero spinners, zero open nests, no pending timers", () => {
vi.useFakeTimers();
const payload = {
diff --git a/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.collapse.test.tsx b/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.collapse.test.tsx
index 481de52b5..9c7b2a2f3 100644
--- a/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.collapse.test.tsx
+++ b/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.collapse.test.tsx
@@ -8,6 +8,7 @@ import {
BlockState,
EMPTY_NARRATIVE,
TurnNarrativeState,
+ hydrateNarrativeFromPayload,
} from "./narrativeState";
const completedBlock = (
@@ -58,6 +59,9 @@ const inFlightTurn = (): TurnNarrativeState => ({
const HEADLINE = "Built and tested the workflow";
const REVIEW_HEADLINE = "Draft needs review";
const REVIEW_TESTED_HEADLINE = "Workflow ready for review";
+const LONG_OUTCOME_REASON =
+ "The verification challenge kept reappearing after submit, and each retry landed back on the same gate instead of the requested destination page.";
+const SHORT_OUTCOME_REASON = "A verification challenge prevented confirmation";
afterEach(() => {
cleanup();
@@ -178,4 +182,178 @@ describe("NarrativeView collapse default", () => {
expect(screen.queryByText("Halted")).toBeNull();
expect(screen.getAllByText("add_to_cart")).toHaveLength(1);
});
+
+ it("appends a truncated not-demonstrated reason to the collapsed subtitle", () => {
+ render(
+ <NarrativeView
+ turn={{
+ ...terminalBuildTurn(),
+ lastRunOutcome: {
+ verdict: "not_demonstrated",
+ displayReason: LONG_OUTCOME_REASON,
+ activitySeqAtVerdict: 8,
+ },
+ }}
+ />,
+ );
+
+ const expectedPreview = `${LONG_OUTCOME_REASON.slice(0, 137).trimEnd()}...`;
+ const head = screen.getByRole("button", { name: new RegExp(HEADLINE) });
+ expect(head.textContent).toContain(
+ `Outcome not confirmed: ${expectedPreview}`,
+ );
+ expect(head.textContent).not.toContain(LONG_OUTCOME_REASON);
+ });
+
+ it("derives the collapsed subtitle reason from hydrated not-demonstrated block outcomes", () => {
+ const hydrated = hydrateNarrativeFromPayload({
+ turnId: "turn-hydrated",
+ turnIndex: 0,
+ mode: "build",
+ responseType: "REPLY",
+ designStarted: true,
+ designEnded: true,
+ draft: { blockCount: 1, blockLabels: ["block_1"], summary: null },
+ blocks: [
+ {
+ ...completedBlock("block_1"),
+ outcome: "not_demonstrated",
+ outcomeReason: LONG_OUTCOME_REASON,
+ },
+ ],
+ terminal: "response",
+ terminalMessage: "Built it.",
+ narrativeSummary: "Built it.",
+ startedAt: "2026-05-30T00:00:00Z",
+ endedAt: "2026-05-30T00:00:12Z",
+ })!;
+ const expectedPreview = `${LONG_OUTCOME_REASON.slice(0, 137).trimEnd()}...`;
+ render(<NarrativeView turn={hydrated} />);
+
+ const head = screen.getByRole("button", { name: new RegExp(HEADLINE) });
+ expect(head.textContent).toContain(
+ `Outcome not confirmed: ${expectedPreview}`,
+ );
+ expect(head.textContent).not.toContain(LONG_OUTCOME_REASON);
+ });
+
+ it("does not append a duplicate not-confirmed reason when closing prose already includes it", () => {
+ render(
+ <NarrativeView
+ turn={{
+ ...terminalBuildTurn(),
+ narrativeSummary:
+ "Could not confirm completion. Reason: a verification challenge prevented confirmation.",
+ lastRunOutcome: {
+ verdict: "not_demonstrated",
+ displayReason: SHORT_OUTCOME_REASON,
+ activitySeqAtVerdict: 9,
+ },
+ }}
+ />,
+ );
+
+ const head = screen.getByRole("button", { name: new RegExp(HEADLINE) });
+ expect(head.textContent).toContain(
+ "Reason: a verification challenge prevented confirmation.",
+ );
+ expect(head.textContent).not.toContain(
+ `Outcome not confirmed: ${SHORT_OUTCOME_REASON}`,
+ );
+ });
+
+ it("does not append a duplicate when closing prose carries only a truncated preview of the reason", () => {
+ const truncatedPreview = `${LONG_OUTCOME_REASON.slice(0, 137).trimEnd()}...`;
+ render(
+ <NarrativeView
+ turn={{
+ ...terminalBuildTurn(),
+ narrativeSummary: `Could not confirm completion. Reason: ${truncatedPreview}`,
+ lastRunOutcome: {
+ verdict: "not_demonstrated",
+ displayReason: LONG_OUTCOME_REASON,
+ activitySeqAtVerdict: 9,
+ },
+ }}
+ />,
+ );
+
+ const head = screen.getByRole("button", { name: new RegExp(HEADLINE) });
+ expect(head.textContent).toContain(`Reason: ${truncatedPreview}`);
+ expect(head.textContent).not.toContain("Outcome not confirmed:");
+ });
+
+ it("appends not-confirmed reason when closing prose does not include it", () => {
+ render(
+ <NarrativeView
+ turn={{
+ ...terminalBuildTurn(),
+ narrativeSummary: "Built it.",
+ lastRunOutcome: {
+ verdict: "not_demonstrated",
+ displayReason: SHORT_OUTCOME_REASON,
+ activitySeqAtVerdict: 9,
+ },
+ }}
+ />,
+ );
+
+ const head = screen.getByRole("button", { name: new RegExp(HEADLINE) });
+ expect(head.textContent).toContain("Built it.");
+ expect(head.textContent).toContain(
+ `Outcome not confirmed: ${SHORT_OUTCOME_REASON}`,
+ );
+ });
+
+ it("uses only the not-confirmed segment when there is no closing prose", () => {
+ render(
+ <NarrativeView
+ turn={{
+ ...terminalBuildTurn(),
+ narrativeSummary: null,
+ terminalMessage: null,
+ lastRunOutcome: {
+ verdict: "not_demonstrated",
+ displayReason: SHORT_OUTCOME_REASON,
+ activitySeqAtVerdict: 9,
+ },
+ }}
+ />,
+ );
+
+ const head = screen.getByRole("button", { name: new RegExp(HEADLINE) });
+ expect(head.textContent).toContain(
+ `Outcome not confirmed: ${SHORT_OUTCOME_REASON}`,
+ );
+ expect(head.textContent).not.toContain("Built it.");
+ });
+
+ it("does not append a not-demonstrated reason when no verdict signal is present", () => {
+ render(<NarrativeView turn={terminalBuildTurn()} />);
+ const head = screen.getByRole("button", { name: new RegExp(HEADLINE) });
+ expect(head.textContent).not.toContain("Outcome not confirmed:");
+ expect(head.textContent).not.toContain("verification challenge");
+ });
+
+ it("keeps hydrated turns with neither signal byte-identical to legacy subtitle behavior", () => {
+ const hydrated = hydrateNarrativeFromPayload({
+ turnId: "turn-hydrated-legacy",
+ turnIndex: 0,
+ mode: "build",
+ responseType: "REPLY",
+ designStarted: true,
+ designEnded: true,
+ draft: { blockCount: 1, blockLabels: ["block_1"], summary: null },
+ blocks: [{ ...completedBlock("block_1") }],
+ terminal: "response",
+ terminalMessage: "Built it.",
+ narrativeSummary: "Built it.",
+ startedAt: "2026-05-30T00:00:00Z",
+ endedAt: "2026-05-30T00:00:12Z",
+ })!;
+ render(<NarrativeView turn={hydrated} />);
+ const head = screen.getByRole("button", { name: new RegExp(HEADLINE) });
+ expect(head.textContent).toContain("Built it.");
+ expect(head.textContent).not.toContain("Outcome not confirmed:");
+ });
});
diff --git a/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.test.ts b/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.test.ts
index 7213ffe8d..a5e228cf2 100644
--- a/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.test.ts
+++ b/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.test.ts
@@ -981,6 +981,177 @@ describe("computeTurnSummary — typed terminal adjudication", () => {
expect(summary.glyph).toBe("✦");
});
+ it("renders non-build REPLY + not_demonstrated as Outcome not confirmed", () => {
+ const summary = computeTurnSummary(
+ buildTurn({
+ responseKind: "clarify",
+ responseType: "REPLY",
+ verifiedSuccess: false,
+ lastRunOutcome: {
+ verdict: "not_demonstrated",
+ displayReason: "The run never reached the target page.",
+ activitySeqAtVerdict: 3,
+ },
+ }),
+ );
+ expect(summary.headline).toBe("Outcome not confirmed");
+ expect(summary.accent).toBe("warn");
+ expect(summary.glyph).toBe("!");
+ });
+
+ it("uses hydrated not_demonstrated block outcomes when lastRunOutcome is absent", () => {
+ const turn = hydrateNarrativeFromPayload(
+ reproClarifyPayload({
+ responseKind: "clarify",
+ verifiedSuccess: false,
+ blocks: [
+ {
+ ...reproBlock("open_registry_find_registrant"),
+ outcome: "demonstrated",
+ },
+ {
+ ...reproBlock("search_jane_doe_credential_a"),
+ outcome: "not_demonstrated",
+ outcomeReason: "A verification challenge prevented confirmation.",
+ },
+ {
+ ...reproBlock("expand_and_extract_certifications"),
+ outcome: "demonstrated",
+ },
+ ],
+ }),
+ )!;
+ expect(turn.lastRunOutcome).toBeNull();
+ const summary = computeTurnSummary(turn);
+ expect(summary.headline).toBe("Outcome not confirmed");
+ expect(summary.accent).toBe("warn");
+ expect(summary.glyph).toBe("!");
+ });
+
+ it("keeps the Question headline when response_type is ASK_QUESTION", () => {
+ const summary = computeTurnSummary(
+ buildTurn({
+ responseKind: "clarify",
+ responseType: "ASK_QUESTION",
+ verifiedSuccess: false,
+ lastRunOutcome: {
+ verdict: "not_demonstrated",
+ displayReason: "The run never reached the target page.",
+ activitySeqAtVerdict: 3,
+ },
+ }),
+ );
+ expect(summary.headline).toBe("Question");
+ expect(summary.accent).toBe("qa");
+ expect(summary.glyph).toBe("✦");
+ });
+
+ it("keeps the Question headline for ASK_QUESTION even when hydrated blocks carry not_demonstrated", () => {
+ const turn = hydrateNarrativeFromPayload(
+ reproClarifyPayload({
+ responseKind: "clarify",
+ responseType: "ASK_QUESTION",
+ verifiedSuccess: false,
+ blocks: [
+ {
+ ...reproBlock("open_registry_find_registrant"),
+ outcome: "not_demonstrated",
+ outcomeReason: "A verification challenge prevented confirmation.",
+ },
+ {
+ ...reproBlock("search_jane_doe_credential_a"),
+ outcome: "demonstrated",
+ },
+ {
+ ...reproBlock("expand_and_extract_certifications"),
+ outcome: "demonstrated",
+ },
+ ],
+ }),
+ )!;
+ expect(turn.lastRunOutcome).toBeNull();
+ const summary = computeTurnSummary(turn);
+ expect(summary.headline).toBe("Question");
+ expect(summary.accent).toBe("qa");
+ expect(summary.glyph).toBe("✦");
+ });
+
+ it("treats build-kind ASK_QUESTION as an ask when no draft review is pending", () => {
+ const turn = buildTurn({
+ draft: draft3,
+ proposalDisposition: "no_proposal",
+ responseKind: "build",
+ responseType: "ASK_QUESTION",
+ verifiedSuccess: true,
+ });
+ const summary = computeTurnSummary(turn);
+ expect(summary.headline).toBe("Question");
+ expect(summary.accent).toBe("qa");
+ expect(summary.glyph).toBe("✦");
+
+ const uxSummary = computeTurnSummary(turn, { uxV1: true });
+ expect(uxSummary.headline).toBe("Needs your input");
+ expect(uxSummary.accent).toBe("qa");
+ expect(uxSummary.glyph).toBe("✦");
+ });
+
+ it("keeps review disposition precedence over build-kind ASK_QUESTION", () => {
+ const turn = buildTurn({
+ draft: draft3,
+ proposalDisposition: "review_untested",
+ responseKind: "build",
+ responseType: "ASK_QUESTION",
+ verifiedSuccess: true,
+ });
+ const summary = computeTurnSummary(turn);
+ expect(summary.headline).toBe("Draft needs review");
+ expect(summary.accent).toBe("qa");
+ expect(summary.glyph).toBe("!");
+ });
+
+ it("keeps build-kind REPLY summary behavior unchanged", () => {
+ const turn = buildTurn({
+ draft: draft3,
+ proposalDisposition: "no_proposal",
+ responseKind: "build",
+ responseType: "REPLY",
+ verifiedSuccess: true,
+ });
+ const summary = computeTurnSummary(turn);
+ expect(summary.headline).toBe("Built and tested the workflow");
+ expect(summary.accent).toBe("ok");
+ expect(summary.glyph).toBe("✓");
+ });
+
+ it("keeps legacy non-build behavior unchanged when responseType and verdict are absent", () => {
+ const summary = computeTurnSummary(
+ buildTurn({
+ responseKind: "clarify",
+ verifiedSuccess: false,
+ }),
+ );
+ expect(summary.headline).toBe("Question");
+ expect(summary.accent).toBe("qa");
+ expect(summary.glyph).toBe("✦");
+ });
+
+ it("keeps legacy non-build behavior unchanged when hydrated turns have neither signal", () => {
+ const turn = hydrateNarrativeFromPayload(
+ reproClarifyPayload({
+ responseKind: "clarify",
+ verifiedSuccess: false,
+ }),
+ )!;
+ expect(turn.lastRunOutcome).toBeNull();
+ expect(
+ turn.blocks.some((block) => block.outcome === "not_demonstrated"),
+ ).toBe(false);
+ const summary = computeTurnSummary(turn);
+ expect(summary.headline).toBe("Question");
+ expect(summary.accent).toBe("qa");
+ expect(summary.glyph).toBe("✦");
+ });
+
it("keeps the factual stats line on an adjudicated clarify build turn", () => {
const turn = hydrateNarrativeFromPayload(
reproClarifyPayload({ responseKind: "clarify", verifiedSuccess: false }),
@@ -1245,7 +1416,11 @@ describe("computeTurnSummary — uxV1 disposition-first reorder (SKY-12136)", ()
it("renames the pure-ask clarify headline to Needs your input", () => {
const summary = computeTurnSummary(
- buildTurn({ responseKind: "clarify", verifiedSuccess: false }),
+ buildTurn({
+ responseKind: "clarify",
+ responseType: "ASK_QUESTION",
+ verifiedSuccess: false,
+ }),
{ uxV1: true },
);
expect(summary.headline).toBe("Needs your input");
diff --git a/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.tsx b/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.tsx
index ff68f8986..bcfa35584 100644
--- a/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.tsx
+++ b/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.tsx
@@ -20,6 +20,7 @@ import {
formatElapsed,
isBlockOk,
latestBlocksByLabel,
+ notConfirmedOutcome,
parseUtcIsoMs,
toolActivityDisplayLabel,
} from "./narrativeState";
@@ -29,6 +30,36 @@ import { useThemeAsDarkOrLight } from "../../../components/useThemeAsDarkOrLight
// Row flashes green/red for 600ms once revealed — must match the tailwind
// copilot-row-flash-* animation duration.
const FLASH_WINDOW_MS = 600;
+const OUTCOME_REASON_PREVIEW_LIMIT = 140;
+
+function normalizeOutcomeReason(
+ reason: string | null | undefined,
+): string | null {
+ const trimmed = reason?.trim();
+ return trimmed && trimmed.length > 0 ? trimmed : null;
+}
+
+function normalizeOutcomeReasonSearchText(
+ text: string | null | undefined,
+): string {
+ const normalized = normalizeOutcomeReason(text);
+ if (!normalized) return "";
+ return normalized
+ .toLowerCase()
+ .replace(/\s+/g, " ")
+ .replace(/[.,!?;:]+$/g, "")
+ .trim();
+}
+
+function truncateOutcomeReason(reason: string): string {
+ if (reason.length <= OUTCOME_REASON_PREVIEW_LIMIT) return reason;
+ const slice = reason.slice(0, OUTCOME_REASON_PREVIEW_LIMIT - 3).trimEnd();
+ return `${slice}...`;
+}
+
+function notConfirmedDisplayReason(turn: TurnNarrativeState): string | null {
+ return normalizeOutcomeReason(notConfirmedOutcome(turn)?.displayReason);
+}
interface BlockPalette {
fg: string;
@@ -307,9 +338,16 @@ interface FBlockRunProps {
turnEnded: boolean;
onSelect?: (label: string) => void;
uxV1?: boolean;
+ outcomeReasonFallback?: string | null;
}
-function FBlockRun({ block, turnEnded, onSelect, uxV1 }: FBlockRunProps) {
+function FBlockRun({
+ block,
+ turnEnded,
+ onSelect,
+ uxV1,
+ outcomeReasonFallback,
+}: FBlockRunProps) {
const displayLabel = uxV1 ? humanizeBlockLabel(block.label) : block.label;
const palette = paletteFor(block.blockType);
const isRunning = block.state === "running";
@@ -404,6 +442,9 @@ function FBlockRun({ block, turnEnded, onSelect, uxV1 }: FBlockRunProps) {
: isDraft
? "drafted"
: "queued";
+ const collapsedOutcomeReason = isOutcomeNotShown
+ ? normalizeOutcomeReason(block.outcomeReason ?? outcomeReasonFallback)
+ : null;
return (
<div className="flex flex-col">
@@ -468,7 +509,10 @@ function FBlockRun({ block, turnEnded, onSelect, uxV1 }: FBlockRunProps) {
{!open && isOutcomeNotShown ? (
<div className="mt-0.5 text-[12px] leading-[1.5] text-amber-700 dark:text-amber-200/80">
Outcome not confirmed — the run finished without showing the goal
- was met.
+ was met
+ {collapsedOutcomeReason
+ ? `: ${truncateOutcomeReason(collapsedOutcomeReason)}`
+ : "."}
</div>
) : null}
</div>
@@ -797,6 +841,7 @@ function FPhaseChecklist({
onBlockSelect,
uxV1,
}: FPhaseChecklistProps) {
+ const collapsedOutcomeReason = notConfirmedDisplayReason(turn);
const rows = useMemo(() => derivePhases(turn), [turn]);
const condensedBlocks = useMemo(
() =>
@@ -933,6 +978,7 @@ function FPhaseChecklist({
turnEnded={turnEnded}
onSelect={onBlockSelect}
uxV1={uxV1}
+ outcomeReasonFallback={collapsedOutcomeReason}
/>
))}
</>
@@ -954,6 +1000,9 @@ function accentBg(accent: TurnSummary["accent"]): string {
if (accent === "fail") {
return "border-rose-400/60 bg-rose-500/15 text-rose-700 dark:text-rose-300";
}
+ if (accent === "warn") {
+ return "border-amber-400/60 bg-amber-500/15 text-amber-700 dark:text-amber-300";
+ }
if (accent === "qa") {
return "border-sky-400/60 bg-sky-500/15 text-sky-700 dark:text-sky-300";
}
@@ -1025,6 +1074,24 @@ function RollupCard({
}: RollupCardProps) {
const closing =
turn.narrativeSummary?.trim() || turn.terminalMessage?.trim() || "";
+ const collapsedOutcomeReason = notConfirmedDisplayReason(turn);
+ const truncatedOutcomeReason = collapsedOutcomeReason
+ ? truncateOutcomeReason(collapsedOutcomeReason)
+ : null;
+ const normalizedClosing = normalizeOutcomeReasonSearchText(closing);
+ // Normalizing the truncated preview (its trailing "..." strips as punctuation)
+ // makes the containment check a prefix match, so closings carrying either the
+ // full reason or a truncated form of it both suppress the appended segment.
+ const normalizedOutcomeReason = normalizeOutcomeReasonSearchText(
+ truncatedOutcomeReason,
+ );
+ const shouldAppendOutcomeReason =
+ normalizedOutcomeReason.length > 0 &&
+ !normalizedClosing.includes(normalizedOutcomeReason);
+ const outcomeReasonSubtitle = shouldAppendOutcomeReason
+ ? `Outcome not confirmed: ${truncatedOutcomeReason!}`
+ : "";
+ const subtitle = [closing, outcomeReasonSubtitle].filter(Boolean).join(" · ");
const rollupBlocks = latestBlocksByLabel(turn.blocks);
const completed = rollupBlocks.filter((b) => isBlockOk(b));
const failed = rollupBlocks.filter((b) => b.state === "failed");
@@ -1038,7 +1105,7 @@ function RollupCard({
expanded={false}
onClick={onExpand}
subtitle={
- closing ? (
+ subtitle ? (
<div
className={`mt-0.5 text-[12.5px] leading-[1.5] ${
summary.isFail && !summary.isStoppedWithDraft
@@ -1046,7 +1113,7 @@ function RollupCard({
: "text-muted-foreground"
}`}
>
- {closing}
+ {subtitle}
</div>
) : null
}
@@ -1152,6 +1219,7 @@ function DetailView({
onBlockSelect,
uxV1,
}: DetailViewProps) {
+ const collapsedOutcomeReason = notConfirmedDisplayReason(turn);
const hasBlocks = turn.blocks.length > 0;
const designStarted = turn.designStarted;
const designOpen = designStarted && !turn.designEnded;
@@ -1214,6 +1282,7 @@ function DetailView({
turnEnded={turn.terminal !== null}
onSelect={onBlockSelect}
uxV1={uxV1}
+ outcomeReasonFallback={collapsedOutcomeReason}
/>
))}
</div>
diff --git a/skyvern-frontend/src/routes/workflows/copilot/narrativeState.ts b/skyvern-frontend/src/routes/workflows/copilot/narrativeState.ts
index ef1a15541..11eba0e23 100644
--- a/skyvern-frontend/src/routes/workflows/copilot/narrativeState.ts
+++ b/skyvern-frontend/src/routes/workflows/copilot/narrativeState.ts
@@ -1260,7 +1260,7 @@ export function formatElapsed(
export interface TurnSummary {
headline: string;
stats: string[];
- accent: "ok" | "fail" | "qa";
+ accent: "ok" | "fail" | "qa" | "warn";
glyph: string;
isFail: boolean;
isQA: boolean;
@@ -1299,6 +1299,34 @@ interface AdjudicatedParts {
glyph: string;
}
+export interface NotConfirmedOutcome {
+ verdict: "not_demonstrated";
+ displayReason: string | null;
+}
+
+export function notConfirmedOutcome(
+ turn: Pick<TurnNarrativeState, "lastRunOutcome" | "blocks">,
+): NotConfirmedOutcome | null {
+ if (turn.lastRunOutcome !== null) {
+ return turn.lastRunOutcome.verdict === "not_demonstrated"
+ ? {
+ verdict: "not_demonstrated",
+ displayReason: turn.lastRunOutcome.displayReason,
+ }
+ : null;
+ }
+ for (let i = turn.blocks.length - 1; i >= 0; i -= 1) {
+ const block = turn.blocks[i]!;
+ if (block.outcome === "not_demonstrated") {
+ return {
+ verdict: "not_demonstrated",
+ displayReason: block.outcomeReason ?? null,
+ };
+ }
+ }
+ return null;
+}
+
// Headline parts from the typed terminal adjudication. Returns null when the
// turn predates the typed signal; a build kind without a verdict also falls
// back to the legacy inference chain so genuinely-tested historical turns
@@ -1324,15 +1352,20 @@ function adjudicatedSummaryParts(
return { headline: "Workflow ready for review", accent: "qa", glyph: "!" };
}
if (turn.responseKind !== "build") {
+ if (turn.responseKind === "refuse") {
+ return { headline: "Declined", accent: "qa", glyph: "✦" };
+ }
+ if (turn.responseKind === "diagnose") {
+ return { headline: "Answered", accent: "qa", glyph: "✦" };
+ }
+ if (
+ turn.responseType !== "ASK_QUESTION" &&
+ notConfirmedOutcome(turn)?.verdict === "not_demonstrated"
+ ) {
+ return { headline: "Outcome not confirmed", accent: "warn", glyph: "!" };
+ }
return {
- headline:
- turn.responseKind === "refuse"
- ? "Declined"
- : turn.responseKind === "diagnose"
- ? "Answered"
- : uxV1
- ? "Needs your input"
- : "Question",
+ headline: uxV1 ? "Needs your input" : "Question",
accent: "qa",
glyph: "✦",
};
@@ -1344,6 +1377,13 @@ function adjudicatedSummaryParts(
if (flags.needsTestedProposalReview) {
return { headline: "Workflow ready for review", accent: "qa", glyph: "!" };
}
+ if (turn.responseType === "ASK_QUESTION") {
+ return {
+ headline: uxV1 ? "Needs your input" : "Question",
+ accent: "qa",
+ glyph: "✦",
+ };
+ }
if (!turn.verifiedSuccess) {
if (flags.hasCleanCompletedBuild) {
return {
diff --git a/skyvern/forge/sdk/copilot/build_phase.py b/skyvern/forge/sdk/copilot/build_phase.py
index a28cf1083..b519c49ed 100644
--- a/skyvern/forge/sdk/copilot/build_phase.py
+++ b/skyvern/forge/sdk/copilot/build_phase.py
@@ -210,7 +210,7 @@ def _phase_blocker_signal(ctx: Any, tool_name: str) -> CopilotToolBlockerSignal
"The workflow already has a target URL — scout it with the browser tools and author with update_workflow. "
"safe_reason_code=build_phase_discovery_disallowed_post_compose."
),
- user_facing_reason="I already have a target for this workflow — I'll keep working on it instead of starting over.",
+ user_facing_reason="I kept the existing target for this workflow instead of starting over.",
recovery_hint="retry_with_different_tool",
cleared_by_tools=frozenset({"update_workflow", "update_and_run_blocks"}),
internal_reason_code="build_phase_discovery_disallowed_post_compose",
diff --git a/tests/unit/test_copilot_build_phase.py b/tests/unit/test_copilot_build_phase.py
index 977f8e5a9..3cafbc6e3 100644
--- a/tests/unit/test_copilot_build_phase.py
+++ b/tests/unit/test_copilot_build_phase.py
@@ -374,3 +374,29 @@ def test_phase_blocker_signal_returns_none_when_phase_attr_missing() -> None:
pass
assert _phase_blocker_signal(_NoPhase(), "navigate_browser") is None
+
+
+def test_discovery_during_mutation_user_facing_reason_is_truthful_and_not_future_tense() -> None:
+ from skyvern.forge.sdk.copilot.build_phase import _phase_blocker_signal
+
+ ctx = _Ctx(BuildPhase.COMPOSING)
+ signal = _phase_blocker_signal(ctx, "discover_workflow_entrypoint")
+ assert signal is not None
+ assert signal.user_facing_reason == "I kept the existing target for this workflow instead of starting over."
+
+ forbidden_phrases = [
+ "i'll keep working",
+ "i will keep working",
+ "i'll continue",
+ "i will continue",
+ "i'm still working",
+ "keep working on it",
+ "next i will",
+ "next, i will",
+ "i'll now ",
+ "i will now ",
+ "going to try again",
+ ]
+ user_facing_reason_lower = signal.user_facing_reason.lower()
+ for phrase in forbidden_phrases:
+ assert phrase not in user_facing_reason_lower