Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
feat(SKY-6661): whimsical loading + error copy across browser streams (#6332)
Suchintanfae6a2a8b222
diff --git a/skyvern-frontend/src/components/BrowserStream.tsx b/skyvern-frontend/src/components/BrowserStream.tsxindex df22c9280..7d31430bd 100644--- a/skyvern-frontend/src/components/BrowserStream.tsx+++ b/skyvern-frontend/src/components/BrowserStream.tsx@@ -1,7 +1,7 @@// @novnc/novnc is CJS with __esModule marker. Vite 8 (Rollup 5) changed// CJS interop so the default import may be the namespace object instead of// exports.default. This guard works across bundler versions.-import _RFB from "@novnc/novnc/lib/rfb.js";+import _RFB, { type RfbEvent } from "@novnc/novnc/lib/rfb.js";type RFB = _RFB;const RFB = (_RFB as typeof _RFB & { default?: typeof _RFB }).default ?? _RFB;import { ExitIcon, HandIcon, InfoCircledIcon } from "@radix-ui/react-icons";@@ -26,7 +26,6 @@ import {DialogTitle,DialogTrigger,} from "@/components/ui/dialog";-import { AnimatedWave } from "@/components/AnimatedWave";import { toast } from "@/components/ui/use-toast";import { useCredentialGetter } from "@/hooks/useCredentialGetter";import { statusIsNotFinalized } from "@/routes/tasks/types";@@ -45,7 +44,6 @@ import {type StreamDiagnostic,} from "@/routes/streaming/StreamDiagnostics";-import { RotateThrough } from "./RotateThrough";import "./browser-stream.css";interface BrowserSession {@@ -204,6 +202,8 @@ function BrowserStream({const prevVncConnectedRef = useRef<boolean>(false);const [isVncConnected, setIsVncConnected] = useState<boolean>(false);const [isCanvasReady, setIsCanvasReady] = useState<boolean>(false);+ const [terminalDiagnostic, setTerminalDiagnostic] =+ useState<StreamDiagnostic | null>(null);const [isReady, setIsReady] = useState(false);const [messagesDisconnectedTrigger, setMessagesDisconnectedTrigger] =useState(0);@@ -233,6 +233,7 @@ function BrowserStream({setIsCanvasReady(false);setIsMessageConnected(false);setHasBrowserSession(true);+ setTerminalDiagnostic(null);if (rfbRef.current) {rfbRef.current.disconnect();rfbRef.current = null;@@ -381,11 +382,29 @@ function BrowserStream({rfb.addEventListener("connect", () => {setIsVncConnected(true);+ setTerminalDiagnostic(null);});- rfb.addEventListener("disconnect", async (/* e: RfbEvent */) => {+ rfb.addEventListener("disconnect", (e: RfbEvent) => {setIsVncConnected(false);setIsCanvasReady(false);+ if (cancelled) return;+ const clean = Boolean(e.detail?.clean);+ setTerminalDiagnostic(+ (prev) =>+ prev ??+ (clean+ ? {+ title: "The stream packed up and left",+ detail: "The browser stream closed cleanly.",+ }+ : {+ title: "The connection slipped away",+ detail:+ "The browser stream dropped before everything wrapped up.",+ hint: "Refresh the page or switch to local browser streaming.",+ }),+ );});}@@ -425,6 +444,7 @@ function BrowserStream({}let ws: WebSocket | null = null;+ let cancelled = false;const connect = async () => {const wsParams = await getWebSocketParams();@@ -452,6 +472,7 @@ function BrowserStream({ws.onopen = () => {setIsMessageConnected(true);setMessageSocket(ws);+ setTerminalDiagnostic(null);};ws.onmessage = (event) => {@@ -472,15 +493,33 @@ function BrowserStream({}};- ws.onclose = () => {+ ws.onclose = (event) => {setIsMessageConnected(false);setMessageSocket(null);+ if (cancelled) return;+ const { code, reason } = event;+ setTerminalDiagnostic(+ (prev) =>+ prev ??+ (code === 1006+ ? {+ title: "The connection slipped away",+ detail:+ "The messages channel dropped before sending a frame.",+ hint: "Check that the API server is reachable from the UI.",+ }+ : {+ title: "The stream packed up and left",+ detail: `Messages channel closed with code ${code}${reason ? ` (${reason})` : ""}.`,+ }),+ );};};connect();return () => {+ cancelled = true;try {ws && ws.close();} catch (e) {@@ -791,31 +830,37 @@ function BrowserStream({}: entity === "browserSession" && browserSessionId && !hasBrowserSession? {- title: "Browser session is no longer live",- detail: "This live browser session is no longer streaming.",- hint: "Refresh the page or create a new browser session.",+ title: "This browser session has wandered off",+ detail: "Looks like it slipped away mid-stream.",+ hint: "Refresh the page or spin up a fresh browser session.",}- : !isBrowserSessionBackendReady- ? {- title: "Waiting for browser session",- detail:- "The session exists, but the backend has not marked the browser as ready yet.",- }- : !isVncConnected+ : terminalDiagnostic+ ? terminalDiagnostic+ : !isBrowserSessionBackendReady? {- title: "Connecting to VNC stream",- detail: "Opening the browser stream and message WebSockets.",- hint: "If this stays here, check VNC support for the session or use local browser streaming.",+ title: "Warming up your browser",+ detail:+ "The session is here — we're just waiting for the backend to give the green light.",+ pending: true,}- : !isCanvasReady+ : !isVncConnected? {- title: "Preparing browser display",- detail:- "The VNC connection is open and the UI is waiting for the browser canvas.",+ title: "Reaching out to your browser",+ detail: "Opening up the live stream and message channels...",+ hint: "If this sticks around, check VNC support for the session or switch to local browser streaming.",+ pending: true,}- : {- title: "Connecting to browser stream",- };+ : !isCanvasReady+ ? {+ title: "Setting the stage",+ detail:+ "The connection is open — now we're waiting for the browser to paint its first frame.",+ pending: true,+ }+ : {+ title: "Tuning in to your browser...",+ pending: true,+ };return (<>@@ -951,18 +996,7 @@ function BrowserStream({)}{!isReady && (<div className="absolute left-0 top-1/2 flex aspect-video max-h-full w-full -translate-y-1/2 flex-col items-center justify-center gap-2 rounded-md border border-neutral-200 bg-white text-sm text-neutral-600 dark:border-slate-800 dark:bg-transparent dark:text-slate-400">- <StreamStatusPanel diagnostic={streamDiagnostic}>- {isBrowserSessionBackendReady && (- <>- <RotateThrough interval={7 * 1000}>- <span>Checking browser stream readiness...</span>- <span>Waiting for the browser display...</span>- <span>Verifying the stream connection...</span>- </RotateThrough>- <AnimatedWave text=". . ." />- </>- )}- </StreamStatusPanel>+ <StreamStatusPanel diagnostic={streamDiagnostic} /></div>)}</div>diff --git a/skyvern-frontend/src/routes/browserSessions/BrowserSessionStream.tsx b/skyvern-frontend/src/routes/browserSessions/BrowserSessionStream.tsxindex f43e86d6a..fcea06d3e 100644--- a/skyvern-frontend/src/routes/browserSessions/BrowserSessionStream.tsx+++ b/skyvern-frontend/src/routes/browserSessions/BrowserSessionStream.tsx@@ -26,9 +26,9 @@ type StreamMessage = {};const STARTING_DIAGNOSTIC: StreamDiagnostic = {- title: "Starting local browser stream",- detail:- "Opening the stream WebSocket and waiting for the first browser frame.",+ title: "Waking up your local browser",+ detail: "Opening the stream and waiting for the first frame...",+ pending: true,};function diagnosticForReconnectExhausted(): StreamDiagnostic {@@ -43,28 +43,28 @@ function diagnosticForStatus(status: string): StreamDiagnostic {switch (status) {case "not_found":return {- title: "Browser session not found",- detail:- "The backend could not find this browser session for the current organization.",- hint: "Refresh the page or create a new browser session.",+ title: "We've misplaced this browser session",+ detail: "The backend can't find it for your org.",+ hint: "Refresh the page or spin up a fresh browser session.",};case "timeout":return {- title: "Timed out waiting for browser state",+ title: "The browser's gone strangely quiet",detail:- "The stream connected, but the backend did not find an active page to screencast.",+ "The stream connected, but no active page showed up to screencast.",hint: "Check backend logs for browser launch errors and verify BROWSER_STREAMING_MODE=cdp.",};case "completed":case "failed":return {- title: "Browser session is no longer live",- detail: `The browser session status is ${status}.`,+ title: "This browser session has wandered off",+ detail: `It's no longer live — status: ${status}.`,};default:return {title: "Waiting for browser frames",detail: `The stream is connected and the session status is ${status}.`,+ pending: true,};}}@@ -72,21 +72,21 @@ function diagnosticForStatus(status: string): StreamDiagnostic {function diagnosticForClose(event: CloseEvent): StreamDiagnostic {if (event.code === 4001 || event.reason === "use-vnc-streaming") {return {- title: "Backend is using VNC streaming",+ title: "Backend wants to use VNC streaming",detail:- "The UI tried local browser streaming, but the backend closed the stream with use-vnc-streaming.",+ "The UI tried local browser streaming, but the backend asked for VNC instead.",hint: "Check BROWSER_STREAMING_MODE on the backend and the runtime config response.",};}if (event.code === 1006) {return {- title: "Stream connection dropped",+ title: "The connection slipped away",detail: "The browser stream WebSocket closed before sending a frame.",hint: "Check that the API server is running and reachable from the UI.",};}return {- title: "Stream connection closed",+ title: "The stream packed up and left",detail: `WebSocket closed with code ${event.code}${event.reason ? ` (${event.reason})` : ""}.`,};}@@ -171,8 +171,9 @@ function BrowserSessionStream({socketRef.current.addEventListener("open", () => {setDiagnostic({- title: "Connected to stream",- detail: "Waiting for the backend to attach to the browser page.",+ title: "Hooked up to the stream",+ detail: "Just waiting for the backend to hand us a browser.",+ pending: true,});});@@ -206,17 +207,16 @@ function BrowserSessionStream({} catch (e) {console.error("Failed to parse message", e);setDiagnostic({- title: "Unexpected stream message",- detail: "The browser stream sent a message the UI could not parse.",+ title: "The stream said something funny",+ detail: "The browser sent a message the UI couldn't parse.",});}});socketRef.current.addEventListener("error", () => {setDiagnostic({- title: "Stream WebSocket error",- detail:- "The browser stream connection hit a network or server error.",+ title: "The stream hit a snag",+ detail: "The connection ran into a network or server error.",});});diff --git a/skyvern-frontend/src/routes/streaming/StreamDiagnostics.tsx b/skyvern-frontend/src/routes/streaming/StreamDiagnostics.tsxindex 86e2fcdfc..f24bd38bd 100644--- a/skyvern-frontend/src/routes/streaming/StreamDiagnostics.tsx+++ b/skyvern-frontend/src/routes/streaming/StreamDiagnostics.tsx@@ -1,13 +1,35 @@import type { ReactNode } from "react";import { InfoCircledIcon } from "@radix-ui/react-icons";import { cn } from "@/util/utils";+import { AnimatedWave } from "@/components/AnimatedWave";+import { RotateThrough } from "@/components/RotateThrough";type StreamDiagnostic = {title: string;detail?: string;hint?: string;+ // When true, the panel shows the whimsical "still working on it" animation.+ pending?: boolean;};+const WHIMSICAL_LOADING_MESSAGES = [+ "Hm, still working on it...",+ "Hang tight, we're almost there...",+ "Reticulating splines...",+ "Backpropagating...",+ "Attention is all I need...",+ "Warming up the pixels...",+ "Consulting the manual...",+ "Teaching the browser some manners...",+ "Looking for the bat phone...",+ "Negotiating with the tubes...",+ "Where's Shu?...",+];++const WHIMSICAL_SPARKLE = "‧₊˚ ⋅ ✦ ✨ ✦ ⋅ ˚₊‧";++const SCREENSHOT_PANEL_CLASS = "bg-slate-elevation1 text-slate-300";+type StreamMode = "cdp" | "vnc" | "fallback" | "unavailable";const STREAM_MODE_COPY: Record<@@ -93,11 +115,21 @@ function StreamStatusPanel({{diagnostic.hint}</div>)}+ {diagnostic.pending && (+ <div className="mt-1 flex flex-col gap-1 text-neutral-600 dark:text-slate-400">+ <RotateThrough interval={7 * 1000}>+ {WHIMSICAL_LOADING_MESSAGES.map((message) => (+ <span key={message}>{message}</span>+ ))}+ </RotateThrough>+ <AnimatedWave text={WHIMSICAL_SPARKLE} />+ </div>+ )}{children}</div></div>);}-export { StreamModeBadge, StreamStatusPanel };+export { SCREENSHOT_PANEL_CLASS, StreamModeBadge, StreamStatusPanel };export type { StreamDiagnostic, StreamMode };diff --git a/skyvern-frontend/src/routes/tasks/detail/TaskActions.tsx b/skyvern-frontend/src/routes/tasks/detail/TaskActions.tsxindex f633d0e6d..c9de36933 100644--- a/skyvern-frontend/src/routes/tasks/detail/TaskActions.tsx+++ b/skyvern-frontend/src/routes/tasks/detail/TaskActions.tsx@@ -42,37 +42,36 @@ type StreamMessage = {};const STARTING_DIAGNOSTIC: StreamDiagnostic = {- title: "Starting browser stream",- detail:- "Opening the stream WebSocket and waiting for the first browser frame.",+ title: "Waking up the browser stream",+ detail: "Opening the stream and waiting for the first frame...",+ pending: true,};function diagnosticForStatus(status: string): StreamDiagnostic {switch (status) {case "not_found":return {- title: "Task not found",- detail:- "The backend could not find this task for the current organization.",+ title: "We've misplaced this task",+ detail: "The backend can't find it for your org.",};case "timeout":return {- title: "Timed out waiting for browser state",- detail:- "The task started, but the backend did not find an active page to stream.",+ title: "The browser's gone strangely quiet",+ detail: "The task started, but no active page showed up to stream.",hint: "Check backend logs for browser launch errors or a streaming-mode mismatch.",};case "completed":case "failed":case "terminated":return {- title: "Task is no longer live",- detail: `The task status is ${status}.`,+ title: "This task has wrapped up",+ detail: `It's no longer live — status: ${status}.`,};default:return {title: "Waiting for browser frames",detail: `The stream is connected and the task status is ${status}.`,+ pending: true,};}}@@ -80,13 +79,13 @@ function diagnosticForStatus(status: string): StreamDiagnostic {function diagnosticForClose(event: CloseEvent): StreamDiagnostic {if (event.code === 1006) {return {- title: "Stream connection dropped",+ title: "The connection slipped away",detail: "The browser stream WebSocket closed before sending a frame.",hint: "Check that the API server is running and reachable from the UI.",};}return {- title: "Stream connection closed",+ title: "The stream packed up and left",detail: `WebSocket closed with code ${event.code}${event.reason ? ` (${event.reason})` : ""}.`,};}@@ -160,8 +159,9 @@ function TaskActions() {socketRef.current.addEventListener("open", () => {setStreamDiagnostic({- title: "Connected to stream",- detail: "Waiting for the backend to attach to the browser page.",+ title: "Hooked up to the stream",+ detail: "Just waiting for the backend to hand us a browser.",+ pending: true,});});@@ -207,17 +207,16 @@ function TaskActions() {} catch (e) {console.error("Failed to parse message", e);setStreamDiagnostic({- title: "Unexpected stream message",- detail: "The browser stream sent a message the UI could not parse.",+ title: "The stream said something funny",+ detail: "The browser sent a message the UI couldn't parse.",});}});socketRef.current.addEventListener("error", () => {setStreamDiagnostic({- title: "Stream WebSocket error",- detail:- "The browser stream connection hit a network or server error.",+ title: "The stream hit a snag",+ detail: "The connection ran into a network or server error.",});});diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/ObserverThoughtScreenshot.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/ObserverThoughtScreenshot.tsxindex fcf7490f1..bb18ec051 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/ObserverThoughtScreenshot.tsx+++ b/skyvern-frontend/src/routes/workflows/workflowRun/ObserverThoughtScreenshot.tsx@@ -1,9 +1,13 @@+import { useEffect, useState } from "react";import { getClient } from "@/api/AxiosClient";import { ArtifactApiResponse, ArtifactType, Status } from "@/api/types";import { ZoomableImage } from "@/components/ZoomableImage";import { useCredentialGetter } from "@/hooks/useCredentialGetter";import { useQuery } from "@tanstack/react-query";-import { ReloadIcon } from "@radix-ui/react-icons";+import {+ SCREENSHOT_PANEL_CLASS,+ StreamStatusPanel,+} from "@/routes/streaming/StreamDiagnostics";import { statusIsNotFinalized } from "@/routes/tasks/types";import { getImageURL } from "@/routes/tasks/detail/artifactUtils";import { apiPathPrefix } from "@/util/env";@@ -15,6 +19,11 @@ type Props = {function ObserverThoughtScreenshot({ observerThoughtId, taskStatus }: Props) {const credentialGetter = useCredentialGetter();+ const [imageFailed, setImageFailed] = useState(false);++ useEffect(() => {+ setImageFailed(false);+ }, [observerThoughtId]);const { data: artifacts, isLoading } = useQuery<Array<ArtifactApiResponse>>({queryKey: ["observerThought", observerThoughtId, "artifacts"],@@ -45,10 +54,14 @@ function ObserverThoughtScreenshot({ observerThoughtId, taskStatus }: Props) {if (isLoading) {return (- <div className="flex h-full items-center justify-center gap-2 bg-slate-elevation1">- <ReloadIcon className="h-6 w-6 animate-spin" />- <div>Loading screenshot...</div>- </div>+ <StreamStatusPanel+ className={SCREENSHOT_PANEL_CLASS}+ diagnostic={{+ title: "Looking for the screenshot",+ detail: "Just a sec while we fetch it.",+ pending: true,+ }}+ />);}@@ -57,20 +70,51 @@ function ObserverThoughtScreenshot({ observerThoughtId, taskStatus }: Props) {taskStatus &&statusIsNotFinalized({ status: taskStatus })) {- return <div>The screenshot for this action is not available yet.</div>;+ return (+ <StreamStatusPanel+ className={SCREENSHOT_PANEL_CLASS}+ diagnostic={{+ title: "Still capturing this screenshot",+ detail:+ "The agent's working on it — checking back every few seconds.",+ pending: true,+ }}+ />+ );}if (!screenshot) {return (- <div className="flex h-full items-center justify-center bg-slate-elevation1">- No screenshot found for this thought.- </div>+ <StreamStatusPanel+ className={SCREENSHOT_PANEL_CLASS}+ diagnostic={{+ title: "No screenshot for this one",+ detail: "The agent didn't capture one here.",+ }}+ />+ );+ }++ if (imageFailed) {+ return (+ <StreamStatusPanel+ className={SCREENSHOT_PANEL_CLASS}+ diagnostic={{+ title: "This screenshot got away from us",+ detail: "The artifact's there, but the image wouldn't load.",+ hint: "Refresh the page or open the artifact directly.",+ }}+ />);}return (<figure className="mx-auto flex max-w-full flex-col items-center gap-2 overflow-hidden rounded">- <ZoomableImage src={getImageURL(screenshot)} alt="llm-screenshot" />+ <ZoomableImage+ src={getImageURL(screenshot)}+ alt="llm-screenshot"+ onError={() => setImageFailed(true)}+ /></figure>);}diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunBlockScreenshot.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunBlockScreenshot.tsxindex acb1d954c..df8951881 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunBlockScreenshot.tsx+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunBlockScreenshot.tsx@@ -1,18 +1,29 @@+import { useEffect, useState } from "react";import { getClient } from "@/api/AxiosClient";-import { ArtifactApiResponse, ArtifactType } from "@/api/types";+import { ArtifactApiResponse, ArtifactType, Status } from "@/api/types";import { ZoomableImage } from "@/components/ZoomableImage";import { useCredentialGetter } from "@/hooks/useCredentialGetter";import { useQuery } from "@tanstack/react-query";-import { ReloadIcon } from "@radix-ui/react-icons";+import {+ SCREENSHOT_PANEL_CLASS,+ StreamStatusPanel,+} from "@/routes/streaming/StreamDiagnostics";+import { statusIsNotFinalized } from "@/routes/tasks/types";import { getImageURL } from "@/routes/tasks/detail/artifactUtils";import { apiPathPrefix } from "@/util/env";type Props = {workflowRunBlockId: string;+ runStatus?: Status;};-function WorkflowRunBlockScreenshot({ workflowRunBlockId }: Props) {+function WorkflowRunBlockScreenshot({ workflowRunBlockId, runStatus }: Props) {const credentialGetter = useCredentialGetter();+ const [imageFailed, setImageFailed] = useState(false);++ useEffect(() => {+ setImageFailed(false);+ }, [workflowRunBlockId]);const { data: artifacts, isLoading } = useQuery<Array<ArtifactApiResponse>>({queryKey: ["workflowRunBlock", workflowRunBlockId, "artifacts"],@@ -44,24 +55,66 @@ function WorkflowRunBlockScreenshot({ workflowRunBlockId }: Props) {if (isLoading) {return (- <div className="flex h-full items-center justify-center gap-2 bg-slate-elevation1">- <ReloadIcon className="h-6 w-6 animate-spin" />- <div>Loading screenshot...</div>- </div>+ <StreamStatusPanel+ className={SCREENSHOT_PANEL_CLASS}+ diagnostic={{+ title: "Looking for the screenshot",+ detail: "Just a sec while we fetch it.",+ pending: true,+ }}+ />+ );+ }++ const runIsActive =+ runStatus !== undefined && statusIsNotFinalized({ status: runStatus });++ if (!screenshot && runIsActive) {+ return (+ <StreamStatusPanel+ className={SCREENSHOT_PANEL_CLASS}+ diagnostic={{+ title: "Still capturing this screenshot",+ detail:+ "The agent's working on it — checking back every few seconds.",+ pending: true,+ }}+ />);}if (!screenshot) {return (- <div className="flex h-full items-center justify-center bg-slate-elevation1">- No screenshot found for this workflow run block.- </div>+ <StreamStatusPanel+ className={SCREENSHOT_PANEL_CLASS}+ diagnostic={{+ title: "No screenshot for this block",+ detail: "The agent didn't capture one here.",+ }}+ />+ );+ }++ if (imageFailed) {+ return (+ <StreamStatusPanel+ className={SCREENSHOT_PANEL_CLASS}+ diagnostic={{+ title: "This screenshot got away from us",+ detail: "The artifact's there, but the image wouldn't load.",+ hint: "Refresh the page or open the artifact directly.",+ }}+ />);}return (<figure className="mx-auto flex max-w-full flex-col items-center gap-2 overflow-hidden rounded">- <ZoomableImage src={getImageURL(screenshot)} alt="llm-screenshot" />+ <ZoomableImage+ src={getImageURL(screenshot)}+ alt="llm-screenshot"+ onError={() => setImageFailed(true)}+ /></figure>);}diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOverview.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOverview.tsxindex 04a62649e..92fb84255 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOverview.tsx+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOverview.tsx@@ -162,6 +162,7 @@ function WorkflowRunOverview() {selection,activeIteration,)}+ runStatus={workflowRun?.status}/>)}{isObserverThought(selection) && (diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunStream.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunStream.tsxindex 78e6a0ca5..1e0f9453d 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunStream.tsx+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunStream.tsx@@ -25,37 +25,36 @@ type StreamMessage = {};const STARTING_DIAGNOSTIC: StreamDiagnostic = {- title: "Starting browser stream",- detail:- "Opening the stream WebSocket and waiting for the first browser frame.",+ title: "Waking up the browser stream",+ detail: "Opening the stream and waiting for the first frame...",+ pending: true,};function diagnosticForStatus(status: string): StreamDiagnostic {switch (status) {case "not_found":return {- title: "Agent run not found",- detail:- "The backend could not find this agent run for the current organization.",+ title: "We've misplaced this agent run",+ detail: "The backend can't find it for your org.",};case "timeout":return {- title: "Timed out waiting for browser state",- detail:- "The run started, but the backend did not find an active page to stream.",+ title: "The browser's gone strangely quiet",+ detail: "The run started, but no active page showed up to stream.",hint: "Check backend logs for browser launch errors or a streaming-mode mismatch.",};case "completed":case "failed":case "terminated":return {- title: "Agent run is no longer live",- detail: `The agent run status is ${status}.`,+ title: "This agent run has wrapped up",+ detail: `It's no longer live — status: ${status}.`,};default:return {title: "Waiting for browser frames",detail: `The stream is connected and the run status is ${status}.`,+ pending: true,};}}@@ -63,13 +62,13 @@ function diagnosticForStatus(status: string): StreamDiagnostic {function diagnosticForClose(event: CloseEvent): StreamDiagnostic {if (event.code === 1006) {return {- title: "Stream connection dropped",+ title: "The connection slipped away",detail: "The browser stream WebSocket closed before sending a frame.",hint: "Check that the API server is running and reachable from the UI.",};}return {- title: "Stream connection closed",+ title: "The stream packed up and left",detail: `WebSocket closed with code ${event.code}${event.reason ? ` (${event.reason})` : ""}.`,};}@@ -146,8 +145,9 @@ function WorkflowRunStream({socketRef.current.addEventListener("open", () => {setDiagnostic({- title: "Connected to stream",- detail: "Waiting for the backend to attach to the browser page.",+ title: "Hooked up to the stream",+ detail: "Just waiting for the backend to hand us a browser.",+ pending: true,});});@@ -214,17 +214,16 @@ function WorkflowRunStream({} catch (e) {console.error("Failed to parse message", e);setDiagnostic({- title: "Unexpected stream message",- detail: "The browser stream sent a message the UI could not parse.",+ title: "The stream said something funny",+ detail: "The browser sent a message the UI couldn't parse.",});}});socketRef.current.addEventListener("error", () => {setDiagnostic({- title: "Stream WebSocket error",- detail:- "The browser stream connection hit a network or server error.",+ title: "The stream hit a snag",+ detail: "The connection ran into a network or server error.",});});