Skip to content

Commit

Permalink
Use search params for diagnostics step and artifact (Skyvern-AI#1047)
Browse files Browse the repository at this point in the history
  • Loading branch information
wintonzheng authored Oct 24, 2024
1 parent afae80f commit 9c7380a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
21 changes: 19 additions & 2 deletions skyvern-frontend/src/routes/tasks/detail/StepArtifacts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 {
Expand Down Expand Up @@ -78,7 +80,22 @@ function StepArtifacts({ id, stepProps }: Props) {
);

return (
<Tabs defaultValue="info" className="w-full">
<Tabs
value={artifact}
onValueChange={(value) => {
setSearchParams(
(params) => {
const newParams = new URLSearchParams(params);
newParams.set("artifact", value);
return newParams;
},
{
replace: true,
},
);
}}
className="w-full"
>
<TabsList className="grid h-16 w-full grid-cols-5">
<TabsTrigger value="info">Info</TabsTrigger>
<TabsTrigger value="screenshot_llm">Annotated Screenshots</TabsTrigger>
Expand Down
23 changes: 17 additions & 6 deletions skyvern-frontend/src/routes/tasks/detail/StepArtifactsLayout.tsx
Original file line number Diff line number Diff line change
@@ -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();

Expand All @@ -30,14 +30,25 @@ function StepArtifactsLayout() {
return <div>Error: {error?.message}</div>;
}

const activeStep = steps?.[activeIndex];
const activeStep = steps?.[step];

return (
<div className="flex">
<aside className="w-64 shrink-0">
<StepNavigation
activeIndex={activeIndex}
onActiveIndexChange={setActiveIndex}
activeIndex={step}
onActiveIndexChange={(index) => {
setSearchParams(
(params) => {
const newParams = new URLSearchParams(params);
newParams.set("step", String(index));
return newParams;
},
{
replace: true,
},
);
}}
/>
</aside>
<main className="w-full px-4">
Expand Down

0 comments on commit 9c7380a

Please sign in to comment.