Skip to content

Commit

Permalink
Move mutateAgentConfigurations to AssistantDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
Alban Dumouilla committed Jan 24, 2024
1 parent 4430287 commit 1db5237
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 29 deletions.
11 changes: 8 additions & 3 deletions front/components/assistant/AssistantDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { SendNotificationsContext } from "@app/components/sparkle/Notification";
import { assistantUsageMessage } from "@app/lib/assistant";
import { CONNECTOR_CONFIGURATIONS } from "@app/lib/connector_providers";
import { useAgentConfiguration, useAgentUsage, useApp } from "@app/lib/swr";
import { useAgentConfigurations } from "@app/lib/swr";
import type { PostAgentListStatusRequestBody } from "@app/pages/api/w/[wId]/members/me/agent_list_status";

type AssistantDetailsFlow = "personal" | "workspace";
Expand All @@ -46,14 +47,12 @@ export function AssistantDetails({
assistant,
show,
onClose,
onUpdate,
flow,
}: {
owner: WorkspaceType;
assistant: LightAgentConfigurationType;
show: boolean;
onClose: () => void;
onUpdate: () => void;
flow: AssistantDetailsFlow;
}) {
const agentUsage = useAgentUsage({
Expand Down Expand Up @@ -126,6 +125,12 @@ export function AssistantDetails({
) : null
) : null;

const { mutateAgentConfigurations } = useAgentConfigurations({
workspaceId: owner.sId,
agentsGetView: "list",
includes: ["authors"],
});

return (
<Modal
isOpen={show}
Expand All @@ -139,7 +144,7 @@ export function AssistantDetails({
owner={owner}
agentConfiguration={assistant}
detailsModalClose={onClose}
onUpdate={onUpdate}
onUpdate={mutateAgentConfigurations}
onClose={onClose}
flow={flow}
/>
Expand Down
12 changes: 0 additions & 12 deletions front/components/assistant/AssistantPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { isBuilder } from "@dust-tt/types";
import Link from "next/link";
import { useEffect, useState } from "react";

import { useAgentConfigurations } from "@app/lib/swr";
import { filterAndSortAgents } from "@app/lib/utils";

import { AssistantDetails } from "./AssistantDetails";
Expand All @@ -42,14 +41,6 @@ export function AssistantPicker({
const [showDetails, setShowDetails] =
useState<LightAgentConfigurationType | null>(null);


const { mutateAgentConfigurations } =
useAgentConfigurations({
workspaceId: owner.sId,
agentsGetView: "list",
includes: ["authors"],
});

useEffect(() => {
setSearchedAssistants(filterAndSortAgents(assistants, searchText));
}, [searchText, assistants]);
Expand All @@ -64,9 +55,6 @@ export function AssistantPicker({
onClose={() => {
setShowDetails(null);
}}
onUpdate={() => {
void mutateAgentConfigurations();
}}
flow="personal"
/>
)}
Expand Down
3 changes: 0 additions & 3 deletions front/pages/w/[wId]/assistant/assistants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,6 @@ export default function PersonalAssistants({
onClose={() => {
setShowDetails(null);
}}
onUpdate={() => {
void mutateAgentConfigurations();
}}
flow="personal"
/>
)}
Expand Down
3 changes: 0 additions & 3 deletions front/pages/w/[wId]/assistant/gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,6 @@ export default function AssistantsGallery({
onClose={() => {
setShowDetails(null);
}}
onUpdate={() => {
void mutateAgentConfigurations();
}}
flow={flow === "workspace_add" ? "workspace" : "personal"}
/>
)}
Expand Down
12 changes: 4 additions & 8 deletions front/pages/w/[wId]/assistant/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,10 @@ export default function AssistantNew({
const [conversation, setConversation] = useState<ConversationType | null>(
null
);
const { agentConfigurations, mutateAgentConfigurations } =
useAgentConfigurations({
workspaceId: owner.sId,
agentsGetView: "list",
});
const { agentConfigurations } = useAgentConfigurations({
workspaceId: owner.sId,
agentsGetView: "list",
});

const activeAgents = agentConfigurations.filter((a) => a.status === "active");
activeAgents.sort(compareAgentsForSort);
Expand Down Expand Up @@ -193,9 +192,6 @@ export default function AssistantNew({
onClose={() => {
setShowDetails(null);
}}
onUpdate={async () => {
await mutateAgentConfigurations();
}}
flow="personal"
/>
)}
Expand Down

0 comments on commit 1db5237

Please sign in to comment.