From 9c7380a6e14c86c6011f3d52da01fdc40097cb69 Mon Sep 17 00:00:00 2001 From: Shuchang Zheng Date: Thu, 24 Oct 2024 06:51:04 -0700 Subject: [PATCH] Use search params for diagnostics step and artifact (#1047) --- .../src/routes/tasks/detail/StepArtifacts.tsx | 21 +++++++++++++++-- .../tasks/detail/StepArtifactsLayout.tsx | 23 ++++++++++++++----- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/skyvern-frontend/src/routes/tasks/detail/StepArtifacts.tsx b/skyvern-frontend/src/routes/tasks/detail/StepArtifacts.tsx index 6a7f3e05..5a972f94 100644 --- a/skyvern-frontend/src/routes/tasks/detail/StepArtifacts.tsx +++ b/skyvern-frontend/src/routes/tasks/detail/StepArtifacts.tsx @@ -7,7 +7,7 @@ import { import { StatusBadge } from "@/components/StatusBadge"; import { Label } from "@/components/ui/label"; import { useQuery } from "@tanstack/react-query"; -import { useParams } from "react-router-dom"; +import { useParams, useSearchParams } from "react-router-dom"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { ZoomableImage } from "@/components/ZoomableImage"; import { Skeleton } from "@/components/ui/skeleton"; @@ -23,6 +23,8 @@ type Props = { }; function StepArtifacts({ id, stepProps }: Props) { + const [searchParams, setSearchParams] = useSearchParams(); + const artifact = searchParams.get("artifact") ?? "info"; const { taskId } = useParams(); const credentialGetter = useCredentialGetter(); const { @@ -78,7 +80,22 @@ function StepArtifacts({ id, stepProps }: Props) { ); return ( - + { + setSearchParams( + (params) => { + const newParams = new URLSearchParams(params); + newParams.set("artifact", value); + return newParams; + }, + { + replace: true, + }, + ); + }} + className="w-full" + > Info Annotated Screenshots diff --git a/skyvern-frontend/src/routes/tasks/detail/StepArtifactsLayout.tsx b/skyvern-frontend/src/routes/tasks/detail/StepArtifactsLayout.tsx index e39013e8..d8d9ed9c 100644 --- a/skyvern-frontend/src/routes/tasks/detail/StepArtifactsLayout.tsx +++ b/skyvern-frontend/src/routes/tasks/detail/StepArtifactsLayout.tsx @@ -1,14 +1,14 @@ -import { useState } from "react"; import { StepNavigation } from "./StepNavigation"; import { StepArtifacts } from "./StepArtifacts"; import { useQuery } from "@tanstack/react-query"; import { StepApiResponse } from "@/api/types"; -import { useParams } from "react-router-dom"; +import { useParams, useSearchParams } from "react-router-dom"; import { getClient } from "@/api/AxiosClient"; import { useCredentialGetter } from "@/hooks/useCredentialGetter"; function StepArtifactsLayout() { - const [activeIndex, setActiveIndex] = useState(0); + const [searchParams, setSearchParams] = useSearchParams(); + const step = Number(searchParams.get("step")) || 0; const credentialGetter = useCredentialGetter(); const { taskId } = useParams(); @@ -30,14 +30,25 @@ function StepArtifactsLayout() { return
Error: {error?.message}
; } - const activeStep = steps?.[activeIndex]; + const activeStep = steps?.[step]; return (