Skip to content

Commit

Permalink
Revert "Link to assistant (assistant gallery) with panel open (#3895)" (
Browse files Browse the repository at this point in the history
#3902)

This reverts commit b20ab34.
  • Loading branch information
spolu authored Feb 22, 2024
1 parent b01ecf1 commit d463722
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 47 deletions.
2 changes: 1 addition & 1 deletion front/pages/w/[wId]/assistant/assistants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export default function MyAssistants({
</Link>
</Tooltip>
)}
<Link href={`/w/${owner.sId}/assistant/gallery`}>
<Link href={`/w/${owner.sId}/assistant/gallery?flow=personal_add`}>
<Button
variant="primary"
icon={BookOpenIcon}
Expand Down
53 changes: 7 additions & 46 deletions front/pages/w/[wId]/assistant/gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { assertNever } from "@dust-tt/types";
import type { InferGetServerSidePropsType } from "next";
import { useRouter } from "next/router";
import type { ComponentType } from "react";
import { useEffect, useMemo, useState } from "react";
import { useMemo, useState } from "react";

import { AssistantDetails } from "@app/components/assistant/AssistantDetails";
import { GalleryAssistantPreviewContainer } from "@app/components/assistant/GalleryAssistantPreviewContainer";
Expand Down Expand Up @@ -135,43 +135,11 @@ export default function AssistantsGallery({
assertNever(orderBy);
}

const [showDetails, setShowDetails] =
useState<LightAgentConfigurationType | null>(null);
const [testModalAssistant, setTestModalAssistant] =
useState<LightAgentConfigurationType | null>(null);

const [showDetails, setShowDetails] = useState<string | null>(null);

useEffect(() => {
const handleRouteChange = () => {
const assistantSId = router.query.assistantDetails ?? [];
if (assistantSId && typeof assistantSId === "string") {
setShowDetails(assistantSId);
} else {
setShowDetails(null);
}
};

// Initial check in case the component mounts with the query already set.
handleRouteChange();

router.events.on("routeChangeComplete", handleRouteChange);
return () => {
router.events.off("routeChangeComplete", handleRouteChange);
};
}, [router.query, router.events]);

const handleCloseAssistantDetails = () => {
const currentPathname = router.pathname;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { assistantDetails, ...restQuery } = router.query;
void router.push(
{ pathname: currentPathname, query: restQuery },
undefined,
{
shallow: true,
}
);
};

const tabs: {
label: string;
current: boolean;
Expand Down Expand Up @@ -256,8 +224,8 @@ export default function AssistantsGallery({
>
<AssistantDetails
owner={owner}
assistantId={showDetails}
onClose={handleCloseAssistantDetails}
assistantId={showDetails?.sId || null}
onClose={() => setShowDetails(null)}
mutateAgentConfigurations={mutateAgentConfigurations}
/>
{testModalAssistant && (
Expand Down Expand Up @@ -295,15 +263,8 @@ export default function AssistantsGallery({
owner={owner}
plan={plan}
agentConfiguration={a}
onShowDetails={async () => {
const href = {
pathname: router.pathname,
query: {
...router.query,
assistantDetails: a.sId,
},
};
await router.push(href);
onShowDetails={() => {
setShowDetails(a);
}}
onUpdate={() => {
void mutateAgentConfigurations();
Expand Down

0 comments on commit d463722

Please sign in to comment.