Skip to content

Commit

Permalink
Fix bad error handling in task recording (#737)
Browse files Browse the repository at this point in the history
  • Loading branch information
ykeremy authored Aug 26, 2024
1 parent c7ca6fe commit 106f779
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions skyvern-frontend/src/routes/tasks/detail/TaskRecording.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useQuery } from "@tanstack/react-query";
import { getRecordingURL } from "./artifactUtils";
import { useParams } from "react-router-dom";
import { Skeleton } from "@/components/ui/skeleton";
import { TaskApiResponse } from "@/api/types";

function TaskRecording() {
const { taskId } = useParams();
Expand All @@ -13,11 +14,11 @@ function TaskRecording() {
data: recordingURL,
isLoading: taskIsLoading,
isError: taskIsError,
} = useQuery<string | undefined>({
} = useQuery<string | null>({
queryKey: ["task", taskId, "recordingURL"],
queryFn: async () => {
const client = await getClient(credentialGetter);
const task = await client
const task: TaskApiResponse = await client
.get(`/tasks/${taskId}`)
.then((response) => response.data);
return getRecordingURL(task);
Expand All @@ -39,14 +40,12 @@ function TaskRecording() {
return <div>Error loading recording</div>;
}

return (
return recordingURL ? (
<div className="mx-auto flex">
{recordingURL ? (
<video width={800} height={450} src={recordingURL} controls />
) : (
<div>No recording available</div>
)}
<video width={800} height={450} src={recordingURL} controls />
</div>
) : (
<div>No recording available for this task</div>
);
}

Expand Down
2 changes: 1 addition & 1 deletion skyvern-frontend/src/routes/tasks/detail/artifactUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function getScreenshotURL(task: TaskApiResponse) {

export function getRecordingURL(task: TaskApiResponse) {
if (!task.recording_url) {
return;
return null;
}
if (task.recording_url?.startsWith("file://")) {
return `${artifactApiBaseUrl}/artifact/recording?path=${task.recording_url.slice(7)}`;
Expand Down

0 comments on commit 106f779

Please sign in to comment.