Skip to content

Commit

Permalink
🔄 synced local 'skyvern-frontend/src/' with remote 'skyvern-frontend/…
Browse files Browse the repository at this point in the history
…src/'

<!-- ELLIPSIS_HIDDEN -->

| 🚀 | This description was created by [Ellipsis](https://www.ellipsis.dev) for commit 868509b6e6be2d47e58422f6bc214715b1a12c9f  |
|--------|--------|

### Summary:
This PR improves error handling in `TaskRecording` by changing `useQuery` to return `string | null` and updating `getRecordingURL` to return `null` when no recording URL is available.

**Key points**:
- Update `useQuery` in `skyvern-frontend/src/routes/tasks/detail/TaskRecording.tsx` to return `string | null` instead of `string | undefined`.
- Modify `getRecordingURL` in `skyvern-frontend/src/routes/tasks/detail/artifactUtils.ts` to return `null` when `task.recording_url` is absent.
- Adjust error handling in `TaskRecording` to display "No recording available for this task" when `recordingURL` is `null`.

----
Generated with ❤️ by [ellipsis.dev](https://www.ellipsis.dev)

<!-- ELLIPSIS_HIDDEN -->
  • Loading branch information
ykeremy committed Aug 26, 2024
1 parent c7ca6fe commit 04a1b19
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 04a1b19

Please sign in to comment.