Skip to content

Commit

Permalink
Add title and remove type from the runs table (#1717)
Browse files Browse the repository at this point in the history
  • Loading branch information
wintonzheng authored Feb 4, 2025
1 parent 95ee4c6 commit 9b5c4f0
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
25 changes: 25 additions & 0 deletions skyvern-frontend/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions skyvern-frontend/src/hooks/useRunsQuery.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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);
Expand Down
21 changes: 12 additions & 9 deletions skyvern-frontend/src/routes/history/RunHistory.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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;
}

Expand Down Expand Up @@ -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
Expand All @@ -89,7 +88,7 @@ function RunHistory() {
</TableRow>
) : null}
{runs?.map((run) => {
if (isTaskApiResponse(run)) {
if (isTask(run)) {
return (
<TableRow
key={run.task_id}
Expand All @@ -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>
Expand All @@ -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>
Expand Down

0 comments on commit 9b5c4f0

Please sign in to comment.