enable VNC streaming for task v1 page (#4498)

This commit is contained in:
Shuchang Zheng
2026-01-20 09:21:30 -08:00
committed by GitHub
parent 9ffa03c16a
commit 6f6e837270
2 changed files with 39 additions and 1 deletions

View File

@@ -150,6 +150,7 @@ export type TaskApiResponse = {
max_steps_per_run: number | null;
task_v2: TaskV2 | null;
workflow_run_id: string | null;
browser_session_id: string | null;
};
export type CreateTaskRequest = {

View File

@@ -1,5 +1,7 @@
import { getClient } from "@/api/AxiosClient";
import { Status, StepApiResponse, TaskApiResponse } from "@/api/types";
import { BrowserStream } from "@/components/BrowserStream";
import { AspectRatio } from "@/components/ui/aspect-ratio";
import { Skeleton } from "@/components/ui/skeleton";
import { toast } from "@/components/ui/use-toast";
import { ZoomableImage } from "@/components/ZoomableImage";
@@ -66,8 +68,14 @@ function TaskActions() {
});
const taskIsNotFinalized = task && statusIsNotFinalized(task);
const taskIsRunningOrQueued = task && statusIsRunningOrQueued(task);
const browserSessionId = task?.browser_session_id;
useEffect(() => {
// Skip screenshot WebSocket if VNC streaming is available via browser_session_id
if (browserSessionId) {
return;
}
if (!taskIsRunningOrQueued) {
return;
}
@@ -138,7 +146,13 @@ function TaskActions() {
socket = null;
}
};
}, [credentialGetter, taskId, taskIsRunningOrQueued, queryClient]);
}, [
browserSessionId,
credentialGetter,
taskId,
taskIsRunningOrQueued,
queryClient,
]);
const { data: steps, isLoading: stepsIsLoading } = useQuery<
Array<StepApiResponse>
@@ -192,6 +206,29 @@ function TaskActions() {
activeSelection !== "stream" ? actions[activeSelection] : null;
function getStream() {
// Use VNC streaming via BrowserStream when browser_session_id is available
if (browserSessionId) {
return (
<AspectRatio ratio={16 / 9}>
<BrowserStream
key={browserSessionId}
browserSessionId={browserSessionId}
interactive={false}
showControlButtons={false}
onClose={() => {
queryClient.invalidateQueries({
queryKey: ["task", taskId],
});
queryClient.invalidateQueries({
queryKey: ["tasks"],
});
}}
/>
</AspectRatio>
);
}
// Fall back to screenshot-based streaming
if (task?.status === Status.Created) {
return (
<div className="flex h-full w-full flex-col items-center justify-center gap-4 bg-slate-elevation1 text-lg">