enable VNC streaming for task v1 page (#4498)
This commit is contained in:
@@ -150,6 +150,7 @@ export type TaskApiResponse = {
|
|||||||
max_steps_per_run: number | null;
|
max_steps_per_run: number | null;
|
||||||
task_v2: TaskV2 | null;
|
task_v2: TaskV2 | null;
|
||||||
workflow_run_id: string | null;
|
workflow_run_id: string | null;
|
||||||
|
browser_session_id: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CreateTaskRequest = {
|
export type CreateTaskRequest = {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { getClient } from "@/api/AxiosClient";
|
import { getClient } from "@/api/AxiosClient";
|
||||||
import { Status, StepApiResponse, TaskApiResponse } from "@/api/types";
|
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 { Skeleton } from "@/components/ui/skeleton";
|
||||||
import { toast } from "@/components/ui/use-toast";
|
import { toast } from "@/components/ui/use-toast";
|
||||||
import { ZoomableImage } from "@/components/ZoomableImage";
|
import { ZoomableImage } from "@/components/ZoomableImage";
|
||||||
@@ -66,8 +68,14 @@ function TaskActions() {
|
|||||||
});
|
});
|
||||||
const taskIsNotFinalized = task && statusIsNotFinalized(task);
|
const taskIsNotFinalized = task && statusIsNotFinalized(task);
|
||||||
const taskIsRunningOrQueued = task && statusIsRunningOrQueued(task);
|
const taskIsRunningOrQueued = task && statusIsRunningOrQueued(task);
|
||||||
|
const browserSessionId = task?.browser_session_id;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// Skip screenshot WebSocket if VNC streaming is available via browser_session_id
|
||||||
|
if (browserSessionId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!taskIsRunningOrQueued) {
|
if (!taskIsRunningOrQueued) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -138,7 +146,13 @@ function TaskActions() {
|
|||||||
socket = null;
|
socket = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, [credentialGetter, taskId, taskIsRunningOrQueued, queryClient]);
|
}, [
|
||||||
|
browserSessionId,
|
||||||
|
credentialGetter,
|
||||||
|
taskId,
|
||||||
|
taskIsRunningOrQueued,
|
||||||
|
queryClient,
|
||||||
|
]);
|
||||||
|
|
||||||
const { data: steps, isLoading: stepsIsLoading } = useQuery<
|
const { data: steps, isLoading: stepsIsLoading } = useQuery<
|
||||||
Array<StepApiResponse>
|
Array<StepApiResponse>
|
||||||
@@ -192,6 +206,29 @@ function TaskActions() {
|
|||||||
activeSelection !== "stream" ? actions[activeSelection] : null;
|
activeSelection !== "stream" ? actions[activeSelection] : null;
|
||||||
|
|
||||||
function getStream() {
|
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) {
|
if (task?.status === Status.Created) {
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full w-full flex-col items-center justify-center gap-4 bg-slate-elevation1 text-lg">
|
<div className="flex h-full w-full flex-col items-center justify-center gap-4 bg-slate-elevation1 text-lg">
|
||||||
|
|||||||
Reference in New Issue
Block a user