diff --git a/front/components/assistant_builder/AssistantBuilder.tsx b/front/components/assistant_builder/AssistantBuilder.tsx index fdf1bd12a45d..01ec5f353917 100644 --- a/front/components/assistant_builder/AssistantBuilder.tsx +++ b/front/components/assistant_builder/AssistantBuilder.tsx @@ -535,7 +535,6 @@ export default function AssistantBuilder({ size="sm" variant="outline" tooltip="Inspect feedback and performance" - disabled={!agentConfigurationId} /> )} {/* Template Button */} diff --git a/front/components/assistant_builder/AssistantBuilderPreviewDrawer.tsx b/front/components/assistant_builder/AssistantBuilderPreviewDrawer.tsx index 5257b538921a..6a142d92b9b7 100644 --- a/front/components/assistant_builder/AssistantBuilderPreviewDrawer.tsx +++ b/front/components/assistant_builder/AssistantBuilderPreviewDrawer.tsx @@ -55,10 +55,10 @@ import { useAgentConfigurationHistory, } from "@app/lib/swr/assistants"; import { useUser } from "@app/lib/swr/user"; -import { timeAgoFrom } from "@app/lib/utils"; +import { formatTimestampToFriendlyDate, timeAgoFrom } from "@app/lib/utils"; import type { FetchAssistantTemplateResponse } from "@app/pages/api/w/[wId]/assistant/builder/templates/[tId]"; -const FEEDBACKS_BATCH_SIZE = 50; +const FEEDBACKS_PAGE_SIZE = 50; interface AssistantBuilderRightPanelProps { screen: BuilderScreen; @@ -122,40 +122,35 @@ export default function AssistantBuilderRightPanel({ return (
- {/* The agentConfigurationId is truthy iff not a new assistant */} - {(template || agentConfigurationId) && ( -
- - openRightPanelTab(t as AssistantBuilderRightPanelTab) - } - className="hidden lg:flex" - > - - {template && ( - - )} - {agentConfigurationId && ( - - )} +
+ + openRightPanelTab(t as AssistantBuilderRightPanelTab) + } + className="hidden lg:flex" + > + + {template && ( + + )} + {/* The agentConfigurationId is truthy iff not a new assistant */} + {agentConfigurationId && ( - - -
- )} + )} + +
+
+
+
)} @@ -418,42 +413,44 @@ const TemplateDropDownMenu = ({ const FeedbacksSection = ({ owner, - assistantId, + agentConfigurationId, }: { owner: LightWorkspaceType; - assistantId: string; + agentConfigurationId: string; }) => { - // Used for pagination's lastValue: BatchId -> LastFeedbackId - const [lastIdForBatches, setLastIdForBatches] = useState< - Record - >({}); + // Used for pagination's lastValue: page index -> last feedback id in page + const [lastIdForPage, setLastIdForPage] = useState>( + {} + ); const [paginationState, setPaginationState] = useState({ pageIndex: 0, - pageSize: FEEDBACKS_BATCH_SIZE, + pageSize: FEEDBACKS_PAGE_SIZE, }); // Decreasing version, paginated decreasing id. const { agentConfigurationFeedbacks, isAgentConfigurationFeedbacksLoading } = useAgentConfigurationFeedbacksByDescVersion({ workspaceId: owner.sId, - agentConfigurationId: assistantId ?? "", + agentConfigurationId: agentConfigurationId ?? "", withMetadata: true, paginationParams: { - limit: FEEDBACKS_BATCH_SIZE, + limit: FEEDBACKS_PAGE_SIZE, lastValue: paginationState.pageIndex === 0 ? undefined - : lastIdForBatches[paginationState.pageIndex - 1], + : lastIdForPage[paginationState.pageIndex - 1], orderColumn: "id", orderDirection: "desc", }, + disabled: !agentConfigurationId, }); const { agentConfigurationHistory, isAgentConfigurationHistoryLoading } = useAgentConfigurationHistory({ workspaceId: owner.sId, - agentConfigurationId: assistantId, + agentConfigurationId: agentConfigurationId, + disabled: !agentConfigurationId, }); const handleSetPagination = useCallback( @@ -465,7 +462,7 @@ const FeedbacksSection = ({ ) { return; } - setLastIdForBatches((prev) => ({ + setLastIdForPage((prev) => ({ ...prev, ...{ [paginationState.pageIndex]: @@ -479,7 +476,7 @@ const FeedbacksSection = ({ [agentConfigurationFeedbacks, paginationState.pageIndex] ); - const firstAgentConfigurationInBatch = useMemo( + const firstAgentConfigurationInPage = useMemo( () => agentConfigurationHistory?.find( (c) => @@ -504,7 +501,7 @@ const FeedbacksSection = ({ return
No feedbacks.
; } - if (!agentConfigurationHistory || !firstAgentConfigurationInBatch) { + if (!agentConfigurationHistory || !firstAgentConfigurationInPage) { return (
Error loading the previous agent versions. @@ -516,10 +513,10 @@ const FeedbacksSection = ({
@@ -591,13 +588,8 @@ function AgentConfigurationVersionHeader({ if (!config.versionCreatedAt) { return `v${config.version}`; } - return new Date(config.versionCreatedAt).toLocaleDateString("en-US", { - year: "numeric", - month: "long", - day: "numeric", - hour: "numeric", - minute: "numeric", - }); + const versionDate = new Date(config.versionCreatedAt); + return formatTimestampToFriendlyDate(versionDate.getTime(), "long"); }, [isLatestVersion] ); @@ -621,6 +613,8 @@ function FeedbackCard({ const conversationUrl = feedback.conversationId && feedback.messageId && + // IMPORTANT: We need to check if the conversation is shared before displaying it. + // This check is redundant: the conversationId is null if the conversation is not shared. feedback.isConversationShared ? `${process.env.NEXT_PUBLIC_DUST_CLIENT_FACING_URL}/w/${owner.sId}/assistant/${feedback.conversationId}#${feedback.messageId}` : null; diff --git a/front/lib/resources/agent_message_feedback_resource.ts b/front/lib/resources/agent_message_feedback_resource.ts index 5f68f0d1d38e..e11bd68ed1d5 100644 --- a/front/lib/resources/agent_message_feedback_resource.ts +++ b/front/lib/resources/agent_message_feedback_resource.ts @@ -156,6 +156,7 @@ export class AgentMessageFeedbackResource extends BaseResource