Add title and remove type from the runs table (#1717)

This commit is contained in:
Shuchang Zheng
2025-02-05 00:45:15 +08:00
committed by GitHub
parent 95ee4c6088
commit 9b5c4f018f
3 changed files with 40 additions and 12 deletions

View File

@@ -82,6 +82,31 @@ export type StepApiResponse = {
step_cost: number;
};
export type Task = {
task_id: string;
status: Status;
created_at: string; // ISO 8601
modified_at: string; // ISO 8601
extracted_information: Record<string, unknown> | string | null;
screenshot_url: string | null;
recording_url: string | null;
organization_id: string;
workflow_run_id: string | null;
order: number | null;
retry: number | null;
max_steps_per_run: number | null;
errors: Array<Record<string, unknown>>;
title: string | null;
url: string;
webhook_callback_url: string | null;
navigation_goal: string | null;
data_extraction_goal: string | null;
navigation_payload: Record<string, unknown> | string | null;
complete_criterion: string | null;
terminate_criterion: string | null;
application: string | null;
};
export type TaskApiResponse = {
request: CreateTaskRequest;
task_id: string;

View File

@@ -1,9 +1,9 @@
import { getClient } from "@/api/AxiosClient";
import { useCredentialGetter } from "@/hooks/useCredentialGetter";
import { useQuery } from "@tanstack/react-query";
import { Status, TaskApiResponse, WorkflowRunApiResponse } from "@/api/types";
import { Status, Task, WorkflowRunApiResponse } from "@/api/types";
type QueryReturnType = Array<TaskApiResponse | WorkflowRunApiResponse>;
type QueryReturnType = Array<Task | WorkflowRunApiResponse>;
type UseQueryOptions = Omit<
Parameters<typeof useQuery<QueryReturnType>>[0],
"queryKey" | "queryFn"
@@ -16,7 +16,7 @@ type Props = {
function useRunsQuery({ page = 1, statusFilters }: Props) {
const credentialGetter = useCredentialGetter();
return useQuery<Array<TaskApiResponse | WorkflowRunApiResponse>>({
return useQuery<Array<Task | WorkflowRunApiResponse>>({
queryKey: ["runs", { statusFilters }, page],
queryFn: async () => {
const client = await getClient(credentialGetter);

View File

@@ -1,4 +1,4 @@
import { Status, TaskApiResponse, WorkflowRunApiResponse } from "@/api/types";
import { Status, Task, WorkflowRunApiResponse } from "@/api/types";
import { StatusBadge } from "@/components/StatusBadge";
import { StatusFilterDropdown } from "@/components/StatusFilterDropdown";
import {
@@ -23,10 +23,9 @@ import { basicLocalTimeFormat, basicTimeFormat } from "@/util/timeFormat";
import { cn } from "@/util/utils";
import { useState } from "react";
import { useSearchParams, useNavigate } from "react-router-dom";
import { WorkflowTitle } from "../workflows/WorkflowTitle";
function isTaskApiResponse(
run: TaskApiResponse | WorkflowRunApiResponse,
): run is TaskApiResponse {
function isTask(run: Task | WorkflowRunApiResponse): run is Task {
return "task_id" in run;
}
@@ -62,9 +61,9 @@ function RunHistory() {
<TableHeader className="rounded-t-lg bg-slate-elevation2">
<TableRow>
<TableHead className="w-1/4 rounded-tl-lg text-slate-400">
Type
Run ID
</TableHead>
<TableHead className="w-1/4 text-slate-400">Run ID</TableHead>
<TableHead className="w-1/4 text-slate-400">Title</TableHead>
<TableHead className="w-1/4 text-slate-400">Status</TableHead>
<TableHead className="w-1/4 rounded-tr-lg text-slate-400">
Created At
@@ -89,7 +88,7 @@ function RunHistory() {
</TableRow>
) : null}
{runs?.map((run) => {
if (isTaskApiResponse(run)) {
if (isTask(run)) {
return (
<TableRow
key={run.task_id}
@@ -98,8 +97,8 @@ function RunHistory() {
handleNavigate(event, `/tasks/${run.task_id}/actions`);
}}
>
<TableCell>Task</TableCell>
<TableCell>{run.task_id}</TableCell>
<TableCell>{run.title ?? "Untitled Task"}</TableCell>
<TableCell>
<StatusBadge status={run.status} />
</TableCell>
@@ -120,8 +119,12 @@ function RunHistory() {
);
}}
>
<TableCell>Workflow</TableCell>
<TableCell>{run.workflow_run_id}</TableCell>
<TableCell>
<WorkflowTitle
workflowPermanentId={run.workflow_permanent_id}
/>
</TableCell>
<TableCell>
<StatusBadge status={run.status} />
</TableCell>