diff --git a/apps/opik-frontend/src/components/pages/CompareExperimentsPage/AddExperimentToCompareDialog.tsx b/apps/opik-frontend/src/components/pages/CompareExperimentsPage/AddExperimentToCompareDialog.tsx index 123f1bef80..51b667e85c 100644 --- a/apps/opik-frontend/src/components/pages/CompareExperimentsPage/AddExperimentToCompareDialog.tsx +++ b/apps/opik-frontend/src/components/pages/CompareExperimentsPage/AddExperimentToCompareDialog.tsx @@ -122,43 +122,41 @@ const AddExperimentToCompareDialog: React.FunctionComponent< }; return ( - <> - - - - Add to compare - -
- - - - - Only experiments using the same dataset as the baseline can be - added to compare. - - -
- {renderListItems()} -
- {total > DEFAULT_SIZE && ( -
- -
- )} + + + + Add to compare + +
+ + + + + Only experiments using the same dataset as the baseline can be + added to compare. + + +
+ {renderListItems()}
- -
- + {total > DEFAULT_SIZE && ( +
+ +
+ )} +
+
+
); }; diff --git a/apps/opik-frontend/src/components/pages/ExperimentsPage/ExperimentsActionsButton.tsx b/apps/opik-frontend/src/components/pages/ExperimentsPage/ExperimentsActionsButton.tsx index 77fd0711f2..4c4ba43e21 100644 --- a/apps/opik-frontend/src/components/pages/ExperimentsPage/ExperimentsActionsButton.tsx +++ b/apps/opik-frontend/src/components/pages/ExperimentsPage/ExperimentsActionsButton.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useRef, useState } from "react"; import { Split } from "lucide-react"; import { @@ -11,6 +11,7 @@ import { Button } from "@/components/ui/button"; import { Experiment } from "@/types/datasets"; import { useNavigate } from "@tanstack/react-router"; import useAppStore from "@/store/AppStore"; +import FilterExperimentsToCompareDialog from "@/components/pages/ExperimentsPage/FilterExperimentsToCompareDialog"; type ExperimentsActionsButtonProps = { experiments: Experiment[]; @@ -19,26 +20,43 @@ type ExperimentsActionsButtonProps = { const ExperimentsActionsButton: React.FunctionComponent< ExperimentsActionsButtonProps > = ({ experiments }) => { + const resetKeyRef = useRef(0); + const [open, setOpen] = useState(false); const navigate = useNavigate(); const workspaceName = useAppStore((state) => state.activeWorkspaceName); const handleCompareClick = () => { if (experiments.length === 0) return; - navigate({ - to: "/$workspaceName/experiments/$datasetId/compare", - params: { - datasetId: experiments[0].dataset_id, - workspaceName, - }, - search: { - experiments: experiments.map((e) => e.id), - }, - }); + const hasTheSameDataset = experiments.every( + (e) => e.dataset_id === experiments[0].dataset_id, + ); + + if (hasTheSameDataset) { + navigate({ + to: "/$workspaceName/experiments/$datasetId/compare", + params: { + datasetId: experiments[0].dataset_id, + workspaceName, + }, + search: { + experiments: experiments.map((e) => e.id), + }, + }); + } else { + setOpen(true); + resetKeyRef.current = resetKeyRef.current + 1; + } }; return ( <> + + + + + + + + + ); +}; + +export default FilterExperimentsToCompareDialog;