task v2 refactor part 9: ObserverTask -> TaskV2 in frontend code (#1822)

This commit is contained in:
Shuchang Zheng
2025-02-28 00:00:59 -05:00
committed by GitHub
parent 14689b53e4
commit 2849a3dc6c
5 changed files with 12 additions and 13 deletions

View File

@@ -247,7 +247,7 @@ export type WorkflowRunStatusApiResponse = {
downloaded_file_urls: Array<string> | null; downloaded_file_urls: Array<string> | null;
total_steps: number | null; total_steps: number | null;
total_cost: number | null; total_cost: number | null;
task_v2: ObserverTask | null; task_v2: TaskV2 | null;
workflow_title: string | null; workflow_title: string | null;
}; };
@@ -275,7 +275,7 @@ export type ActionsApiResponse = {
response: string | null; response: string | null;
}; };
export type ObserverTask = { export type TaskV2 = {
task_id: string; task_id: string;
status: Status; status: Status;
workflow_run_id: string | null; workflow_run_id: string | null;

View File

@@ -1,5 +1,5 @@
import { getClient } from "@/api/AxiosClient"; import { getClient } from "@/api/AxiosClient";
import { ObserverTask } from "@/api/types"; import { TaskV2 } from "@/api/types";
import { toast } from "@/components/ui/use-toast"; import { toast } from "@/components/ui/use-toast";
import { useCredentialGetter } from "@/hooks/useCredentialGetter"; import { useCredentialGetter } from "@/hooks/useCredentialGetter";
import { ReloadIcon } from "@radix-ui/react-icons"; import { ReloadIcon } from "@radix-ui/react-icons";
@@ -23,10 +23,9 @@ function ExampleCasePill({ exampleId, version, icon, label, prompt }: Props) {
const startObserverCruiseMutation = useMutation({ const startObserverCruiseMutation = useMutation({
mutationFn: async (prompt: string) => { mutationFn: async (prompt: string) => {
const client = await getClient(credentialGetter, "v2"); const client = await getClient(credentialGetter, "v2");
return client.post<{ user_prompt: string }, { data: ObserverTask }>( return client.post<{ user_prompt: string }, { data: TaskV2 }>("/tasks", {
"/tasks", user_prompt: prompt,
{ user_prompt: prompt }, });
);
}, },
onSuccess: (response) => { onSuccess: (response) => {
toast({ toast({

View File

@@ -1,7 +1,7 @@
import { getClient } from "@/api/AxiosClient"; import { getClient } from "@/api/AxiosClient";
import { import {
Createv2TaskRequest, Createv2TaskRequest,
ObserverTask, TaskV2,
ProxyLocation, ProxyLocation,
TaskGenerationApiResponse, TaskGenerationApiResponse,
} from "@/api/types"; } from "@/api/types";
@@ -156,7 +156,7 @@ function PromptBox() {
const startObserverCruiseMutation = useMutation({ const startObserverCruiseMutation = useMutation({
mutationFn: async (prompt: string) => { mutationFn: async (prompt: string) => {
const client = await getClient(credentialGetter, "v2"); const client = await getClient(credentialGetter, "v2");
return client.post<Createv2TaskRequest, { data: ObserverTask }>( return client.post<Createv2TaskRequest, { data: TaskV2 }>(
"/tasks", "/tasks",
{ {
user_prompt: prompt, user_prompt: prompt,

View File

@@ -21,7 +21,7 @@ function ObserverThoughtScreenshot({ observerThoughtId, taskStatus }: Props) {
queryFn: async () => { queryFn: async () => {
const client = await getClient(credentialGetter); const client = await getClient(credentialGetter);
return client return client
.get(`${apiPathPrefix}/observer_thought/${observerThoughtId}/artifacts`) .get(`${apiPathPrefix}/thought/${observerThoughtId}/artifacts`)
.then((response) => response.data); .then((response) => response.data);
}, },
refetchInterval: (query) => { refetchInterval: (query) => {

View File

@@ -44,13 +44,13 @@ function WorkflowPostRunParameters() {
} }
const activeBlock = getActiveBlock(); 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.task_v2?.webhook_callback_url
: workflowRun.webhook_callback_url; : workflowRun.webhook_callback_url;
const proxyLocation = isObserverTask const proxyLocation = isTaskV2
? workflowRun.task_v2?.proxy_location ? workflowRun.task_v2?.proxy_location
: workflowRun.proxy_location; : workflowRun.proxy_location;