Skip to content

Commit

Permalink
Improve latest ss, add queued tasks view (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
ykeremy authored Apr 22, 2024
1 parent 55d14db commit bb723bf
Show file tree
Hide file tree
Showing 6 changed files with 237 additions and 24 deletions.
145 changes: 143 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ httpx = "^0.27.0"
filetype = "^1.2.0"
redis = "^5.0.3"
onnxruntime = "<1.17"
supabase = "^2.4.3"

[tool.poetry.group.dev.dependencies]
isort = "^5.12.0"
Expand Down
1 change: 1 addition & 0 deletions skyvern-frontend/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const Status = {
Failed: "failed",
Terminated: "terminated",
Completed: "completed",
Queued: "queued",
} as const;

export type Status = (typeof Status)[keyof typeof Status];
Expand Down
3 changes: 3 additions & 0 deletions skyvern-frontend/src/routes/tasks/list/TaskList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { cn } from "@/util/utils";
import { PAGE_SIZE } from "../constants";
import { StatusBadge } from "@/components/StatusBadge";
import { basicTimeFormat } from "@/util/timeFormat";
import { QueuedTasks } from "../running/QueuedTasks";

function TaskList() {
const navigate = useNavigate();
Expand Down Expand Up @@ -76,6 +77,8 @@ function TaskList() {
<div className="grid grid-cols-4 gap-4">
<RunningTasks />
</div>
<h1 className="text-2xl py-2 border-b-2">Queued Tasks</h1>
<QueuedTasks />
<h1 className="text-2xl py-2 border-b-2">Task History</h1>
<Table>
<TableHeader>
Expand Down
40 changes: 18 additions & 22 deletions skyvern-frontend/src/routes/tasks/running/LatestScreenshot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import {
StepApiResponse,
} from "@/api/types";
import { Skeleton } from "@/components/ui/skeleton";
import { artifactApiBaseUrl } from "@/util/env";
import { useQuery } from "@tanstack/react-query";
import { keepPreviousData, useQuery } from "@tanstack/react-query";
import { getImageURL } from "../detail/artifactUtils";

type Props = {
id: string;
};

function LatestScreenshot({ id }: Props) {
const {
data: screenshotUri,
data: artifact,
isFetching,
isError,
} = useQuery<string | undefined>({
} = useQuery<ArtifactApiResponse | undefined>({
queryKey: ["task", id, "latestScreenshot"],
queryFn: async () => {
const steps: StepApiResponse[] = await client
Expand All @@ -38,43 +38,39 @@ function LatestScreenshot({ id }: Props) {
.get(`/tasks/${id}/steps/${latestStep.step_id}/artifacts`)
.then((response) => response.data);

const actionScreenshotUris = artifacts
?.filter(
(artifact) =>
artifact.artifact_type === ArtifactType.ActionScreenshot,
)
.map((artifact) => artifact.uri);
const actionScreenshots = artifacts?.filter(
(artifact) => artifact.artifact_type === ArtifactType.ActionScreenshot,
);

if (actionScreenshotUris.length > 0) {
return actionScreenshotUris[0];
if (actionScreenshots.length > 0) {
return actionScreenshots[0];
}

const llmScreenshotUris = artifacts
?.filter(
(artifact) => artifact.artifact_type === ArtifactType.LLMScreenshot,
)
.map((artifact) => artifact.uri);
const llmScreenshots = artifacts?.filter(
(artifact) => artifact.artifact_type === ArtifactType.LLMScreenshot,
);

if (llmScreenshotUris.length > 0) {
return llmScreenshotUris[0];
if (llmScreenshots.length > 0) {
return llmScreenshots[0];
}

return Promise.reject("No screenshots found");
},
refetchInterval: 2000,
placeholderData: keepPreviousData,
});

if (isFetching) {
if (isFetching && !artifact) {
return <Skeleton className="w-full h-full" />;
}

if (isError || !screenshotUri || typeof screenshotUri !== "string") {
if (isError || !artifact) {
return null;
}

return (
<img
src={`${artifactApiBaseUrl}/artifact/image?path=${screenshotUri.slice(7)}`}
src={getImageURL(artifact)}
className="w-full h-full object-contain"
alt="Latest screenshot"
/>
Expand Down
Loading

0 comments on commit bb723bf

Please sign in to comment.