From 2849a3dc6c1ba1aeb6c1869e0de09999eeb1297c Mon Sep 17 00:00:00 2001 From: Shuchang Zheng Date: Fri, 28 Feb 2025 00:00:59 -0500 Subject: [PATCH] task v2 refactor part 9: ObserverTask -> TaskV2 in frontend code (#1822) --- skyvern-frontend/src/api/types.ts | 4 ++-- .../src/routes/tasks/create/ExampleCasePill.tsx | 9 ++++----- skyvern-frontend/src/routes/tasks/create/PromptBox.tsx | 4 ++-- .../workflows/workflowRun/ObserverThoughtScreenshot.tsx | 2 +- .../workflows/workflowRun/WorkflowPostRunParameters.tsx | 6 +++--- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/skyvern-frontend/src/api/types.ts b/skyvern-frontend/src/api/types.ts index f427638e..3d175577 100644 --- a/skyvern-frontend/src/api/types.ts +++ b/skyvern-frontend/src/api/types.ts @@ -247,7 +247,7 @@ export type WorkflowRunStatusApiResponse = { downloaded_file_urls: Array | null; total_steps: number | null; total_cost: number | null; - task_v2: ObserverTask | null; + task_v2: TaskV2 | null; workflow_title: string | null; }; @@ -275,7 +275,7 @@ export type ActionsApiResponse = { response: string | null; }; -export type ObserverTask = { +export type TaskV2 = { task_id: string; status: Status; workflow_run_id: string | null; diff --git a/skyvern-frontend/src/routes/tasks/create/ExampleCasePill.tsx b/skyvern-frontend/src/routes/tasks/create/ExampleCasePill.tsx index d68169a3..587fd408 100644 --- a/skyvern-frontend/src/routes/tasks/create/ExampleCasePill.tsx +++ b/skyvern-frontend/src/routes/tasks/create/ExampleCasePill.tsx @@ -1,5 +1,5 @@ import { getClient } from "@/api/AxiosClient"; -import { ObserverTask } from "@/api/types"; +import { TaskV2 } from "@/api/types"; import { toast } from "@/components/ui/use-toast"; import { useCredentialGetter } from "@/hooks/useCredentialGetter"; import { ReloadIcon } from "@radix-ui/react-icons"; @@ -23,10 +23,9 @@ function ExampleCasePill({ exampleId, version, icon, label, prompt }: Props) { const startObserverCruiseMutation = useMutation({ mutationFn: async (prompt: string) => { const client = await getClient(credentialGetter, "v2"); - return client.post<{ user_prompt: string }, { data: ObserverTask }>( - "/tasks", - { user_prompt: prompt }, - ); + return client.post<{ user_prompt: string }, { data: TaskV2 }>("/tasks", { + user_prompt: prompt, + }); }, onSuccess: (response) => { toast({ diff --git a/skyvern-frontend/src/routes/tasks/create/PromptBox.tsx b/skyvern-frontend/src/routes/tasks/create/PromptBox.tsx index 6e408755..2e1dd795 100644 --- a/skyvern-frontend/src/routes/tasks/create/PromptBox.tsx +++ b/skyvern-frontend/src/routes/tasks/create/PromptBox.tsx @@ -1,7 +1,7 @@ import { getClient } from "@/api/AxiosClient"; import { Createv2TaskRequest, - ObserverTask, + TaskV2, ProxyLocation, TaskGenerationApiResponse, } from "@/api/types"; @@ -156,7 +156,7 @@ function PromptBox() { const startObserverCruiseMutation = useMutation({ mutationFn: async (prompt: string) => { const client = await getClient(credentialGetter, "v2"); - return client.post( + return client.post( "/tasks", { user_prompt: prompt, diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/ObserverThoughtScreenshot.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/ObserverThoughtScreenshot.tsx index b8b23bf3..fcf7490f 100644 --- a/skyvern-frontend/src/routes/workflows/workflowRun/ObserverThoughtScreenshot.tsx +++ b/skyvern-frontend/src/routes/workflows/workflowRun/ObserverThoughtScreenshot.tsx @@ -21,7 +21,7 @@ function ObserverThoughtScreenshot({ observerThoughtId, taskStatus }: Props) { queryFn: async () => { const client = await getClient(credentialGetter); return client - .get(`${apiPathPrefix}/observer_thought/${observerThoughtId}/artifacts`) + .get(`${apiPathPrefix}/thought/${observerThoughtId}/artifacts`) .then((response) => response.data); }, refetchInterval: (query) => { diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowPostRunParameters.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowPostRunParameters.tsx index 51e2a844..a2084237 100644 --- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowPostRunParameters.tsx +++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowPostRunParameters.tsx @@ -44,13 +44,13 @@ function WorkflowPostRunParameters() { } const activeBlock = getActiveBlock(); - const isObserverTask = workflowRun.task_v2 !== null; + const isTaskV2 = workflowRun.task_v2 !== null; - const webhookCallbackUrl = isObserverTask + const webhookCallbackUrl = isTaskV2 ? workflowRun.task_v2?.webhook_callback_url : workflowRun.webhook_callback_url; - const proxyLocation = isObserverTask + const proxyLocation = isTaskV2 ? workflowRun.task_v2?.proxy_location : workflowRun.proxy_location;