Skip to content

Commit

Permalink
rename progressiveAgentConfigurations to unifiedAgentConfigurations +…
Browse files Browse the repository at this point in the history
… comments (#9566)
  • Loading branch information
spolu authored Dec 20, 2024
1 parent 1f22ddc commit 063966c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
import { useCallback } from "react";

import { AssistantBrowser } from "@app/components/assistant/AssistantBrowser";
import { useProgressiveAgentConfigurations } from "@app/lib/swr/assistants";
import { useUnifiedAgentConfigurations } from "@app/lib/swr/assistants";
import { classNames } from "@app/lib/utils";

interface AssistantBrowserContainerProps {
Expand All @@ -22,7 +22,8 @@ export function AssistantBrowserContainer({
isBuilder,
setAssistantToMention,
}: AssistantBrowserContainerProps) {
const { agentConfigurations, isLoading } = useProgressiveAgentConfigurations({
// We use this specific hook because this component is involved in the new conversation page.
const { agentConfigurations, isLoading } = useUnifiedAgentConfigurations({
workspaceId: owner.sId,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import InputBarContainer, {
import { InputBarContext } from "@app/components/assistant/conversation/input_bar/InputBarContext";
import { useFileUploaderService } from "@app/hooks/useFileUploaderService";
import type { DustError } from "@app/lib/error";
import { useProgressiveAgentConfigurations } from "@app/lib/swr/assistants";
import { useUnifiedAgentConfigurations } from "@app/lib/swr/assistants";
import { useConversation } from "@app/lib/swr/conversations";
import { classNames } from "@app/lib/utils";

Expand Down Expand Up @@ -82,8 +82,9 @@ export function AssistantInputBar({
options: { disabled: true }, // We just want to get the mutation function
});

// We use this specific hook because this component is involved in the new conversation page.
const { agentConfigurations: baseAgentConfigurations } =
useProgressiveAgentConfigurations({
useUnifiedAgentConfigurations({
workspaceId: owner.sId,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
import { compareAgentsForSort } from "@dust-tt/types";
import { useMemo } from "react";

import { useProgressiveAgentConfigurations } from "@app/lib/swr/assistants";
import { useUnifiedAgentConfigurations } from "@app/lib/swr/assistants";

function makeEditorSuggestions(
agentConfigurations: LightAgentConfigurationType[]
Expand All @@ -25,7 +25,8 @@ const useAssistantSuggestions = (
inListAgentConfigurations: LightAgentConfigurationType[],
owner: WorkspaceType
) => {
const { agentConfigurations } = useProgressiveAgentConfigurations({
// We use this specific hook because this component is involved in the new conversation page.
const { agentConfigurations } = useUnifiedAgentConfigurations({
workspaceId: owner.sId,
});

Expand Down
42 changes: 12 additions & 30 deletions front/lib/swr/assistants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,25 +142,16 @@ export function useAgentConfigurations({
};
}

export function useProgressiveAgentConfigurations({
// This is the call that is required for the new conversation page to load all views on that page.
// All elements that are involved in that page should rely on it to avoid concurrent calls to
// getAgentConfigurations at the initial page load.
export function useUnifiedAgentConfigurations({
workspaceId,
disabled,
}: {
workspaceId: string;
disabled?: boolean;
}) {
// const {
// agentConfigurations: initialAgentConfigurations,
// isAgentConfigurationsLoading: isInitialAgentConfigurationsLoading,
// } = useAgentConfigurations({
// workspaceId,
// agentsGetView: "list",
// limit: 24,
// includes: ["usage"],
// disabled,
// revalidate: false,
// });

const {
agentConfigurations: agentConfigurationsWithAuthors,
isAgentConfigurationsLoading: isAgentConfigurationsWithAuthorsLoading,
Expand All @@ -173,13 +164,6 @@ export function useProgressiveAgentConfigurations({
disabled,
});

// const isLoading =
// isInitialAgentConfigurationsLoading ||
// isAgentConfigurationsWithAuthorsLoading;
// const agentConfigurations = isAgentConfigurationsWithAuthorsLoading
// ? initialAgentConfigurations
// : agentConfigurationsWithAuthors;

return {
agentConfigurations: agentConfigurationsWithAuthors,
isLoading: isAgentConfigurationsWithAuthorsLoading,
Expand Down Expand Up @@ -419,11 +403,10 @@ export function useUpdateAgentScope({
agentConfigurationId,
disabled: true,
});
const { mutate: mutateAgentConfigurations } =
useProgressiveAgentConfigurations({
workspaceId: owner.sId,
disabled: true,
});
const { mutate: mutateAgentConfigurations } = useUnifiedAgentConfigurations({
workspaceId: owner.sId,
disabled: true,
});

const doUpdate = useCallback(
async (scope: Exclude<AgentConfigurationScope, "global">) => {
Expand Down Expand Up @@ -500,11 +483,10 @@ export function useUpdateUserFavorite({
agentConfigurationId,
disabled: true,
});
const { mutate: mutateAgentConfigurations } =
useProgressiveAgentConfigurations({
workspaceId: owner.sId,
disabled: true,
});
const { mutate: mutateAgentConfigurations } = useUnifiedAgentConfigurations({
workspaceId: owner.sId,
disabled: true,
});

const [isUpdatingFavorite, setIsUpdatingFavorite] = useState(false);

Expand Down

0 comments on commit 063966c

Please sign in to comment.