Skip to content

Commit

Permalink
feat(experiments): add the ability to copy experiment IDs to the clip…
Browse files Browse the repository at this point in the history
…board (#4317)
  • Loading branch information
mikeldking authored Aug 21, 2024
1 parent 58685b7 commit 589ac03
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions app/src/pages/experiments/ExperimentsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
getCoreRowModel,
useReactTable,
} from "@tanstack/react-table";
import copy from "copy-to-clipboard";
import { css } from "@emotion/react";

import {
Expand Down Expand Up @@ -42,6 +43,7 @@ import { selectableTableCSS } from "@phoenix/components/table/styles";
import { TextCell } from "@phoenix/components/table/TextCell";
import { TimestampCell } from "@phoenix/components/table/TimestampCell";
import { LatencyText } from "@phoenix/components/trace/LatencyText";
import { useNotifySuccess } from "@phoenix/contexts";
import { useWordColor } from "@phoenix/hooks/useWordColor";
import { assertUnreachable } from "@phoenix/typeUtils";
import {
Expand Down Expand Up @@ -177,7 +179,6 @@ export function ExperimentsTable({
/>
),
},

{
header: "name",
accessorKey: "name",
Expand Down Expand Up @@ -299,6 +300,7 @@ export function ExperimentsTable({
return (
<ExperimentActionMenu
projectId={project?.id || null}
experimentId={row.original.id}
metadata={metadata}
/>
);
Expand Down Expand Up @@ -496,16 +498,19 @@ function AnnotationAggregationCell({

export enum ExperimentAction {
GO_TO_EXPERIMENT_RUN_TRACES = "GO_TO_EXPERIMENT_RUN_TRACES",
COPY_EXPERIMENT_ID = "COPY_EXPERIMENT_ID",
VIEW_METADATA = "VIEW_METADATA",
}

function ExperimentActionMenu(props: {
projectId: string | null;
experimentId: string;
metadata: unknown;
}) {
const { projectId } = props;
const navigate = useNavigate();
const [dialog, setDialog] = useState<ReactNode>(null);
const notifySuccess = useNotifySuccess();
return (
<div
// TODO: add this logic to the ActionMenu component
Expand Down Expand Up @@ -535,6 +540,14 @@ function ExperimentActionMenu(props: {
);
break;
}
case ExperimentAction.COPY_EXPERIMENT_ID: {
copy(props.experimentId);
notifySuccess({
title: "Copied",
message: "The experiment ID has been copied to your clipboard",
});
break;
}
default: {
assertUnreachable(action);
}
Expand All @@ -560,7 +573,18 @@ function ExperimentActionMenu(props: {
alignItems="center"
>
<Icon svg={<Icons.InfoOutline />} />
<Text>View Metadata</Text>
<Text>View metadata</Text>
</Flex>
</Item>
<Item key={ExperimentAction.COPY_EXPERIMENT_ID}>
<Flex
direction="row"
gap="size-75"
justifyContent="start"
alignItems="center"
>
<Icon svg={<Icons.ClipboardCopy />} />
<Text>Copy experiment ID</Text>
</Flex>
</Item>
</ActionMenu>
Expand Down

0 comments on commit 589ac03

Please sign in to comment.