Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bad error handling in task recording #737

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding retry: false to the useQuery options to prevent unnecessary retries when the recording URL is missing.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider returning null instead of undefined for consistency with getRecordingURL.

}
if (task.recording_url?.startsWith("file://")) {
return `${artifactApiBaseUrl}/artifact/recording?path=${task.recording_url.slice(7)}`;
Expand Down
Loading