Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(trace): Simplify trace and observation actions (#17737)

Ben Bachem107fd6c06349
diff --git a/web/src/components/design-system/Checkbox/Checkbox.tsx b/web/src/components/design-system/Checkbox/Checkbox.tsx
index c9e2bd48bd..9fb36ed3a4 100644
--- a/web/src/components/design-system/Checkbox/Checkbox.tsx
+++ b/web/src/components/design-system/Checkbox/Checkbox.tsx
@@ -32,8 +32,8 @@ type CheckboxProps = Pick<
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>,
"className"
>,
- | "aria-label"
| "aria-hidden"
+ | "aria-label"
| "checked"
| "disabled"
| "id"
diff --git a/web/src/components/design-system/DropdownMenu/DropdownMenu.stories.tsx b/web/src/components/design-system/DropdownMenu/DropdownMenu.stories.tsx
index ac681a1722..5a8fe761c2 100644
--- a/web/src/components/design-system/DropdownMenu/DropdownMenu.stories.tsx
+++ b/web/src/components/design-system/DropdownMenu/DropdownMenu.stories.tsx
@@ -244,3 +244,104 @@ export const TestDisabledLink = meta.story({
await expect(link).toHaveAttribute("tabindex", "-1");
},
});
+
+const onCheckboxChange = fn();
+const onNestedAction = fn();
+
+export const TestCheckboxAndSubmenu = meta.story({
+ name: "(Test) Checkbox and submenu",
+ args: {
+ items: [
+ {
+ type: "checkbox",
+ id: "include-output",
+ title: "Include output",
+ checked: false,
+ onCheckedChange: onCheckboxChange,
+ },
+ {
+ type: "submenu",
+ id: "destinations",
+ title: "Destinations",
+ search: { placeholder: "Search destinations…" },
+ items: [
+ {
+ type: "item",
+ id: "dataset",
+ title: "Dataset",
+ onClick: onNestedAction,
+ },
+ {
+ type: "item",
+ id: "playground",
+ title: "Playground",
+ onClick: fn(),
+ },
+ ],
+ },
+ {
+ type: "submenu",
+ id: "unavailable",
+ title: "Unavailable",
+ disabled: { reason: "This submenu is unavailable." },
+ items: [
+ {
+ type: "item",
+ id: "hidden-item",
+ title: "Hidden item",
+ onClick: fn(),
+ },
+ ],
+ },
+ ],
+ },
+ play: async ({ canvasElement }) => {
+ onCheckboxChange.mockClear();
+ onNestedAction.mockClear();
+ const canvas = within(canvasElement);
+ const body = within(canvasElement.ownerDocument.body);
+
+ const trigger = canvas.getByRole("button", { name: "Open menu" });
+ trigger.focus();
+ await userEvent.keyboard("{ArrowDown}");
+ const menu = await body.findByRole("menu", { name: "Actions" });
+ const checkbox = body.getByRole("menuitemcheckbox", {
+ name: "Include output",
+ });
+ await expect(checkbox).toHaveFocus();
+ await userEvent.keyboard("{Enter}");
+ await expect(onCheckboxChange).toHaveBeenCalledWith(true);
+ await userEvent.keyboard("{ArrowDown}");
+ await expect(
+ body.getByRole("menuitem", { name: "Destinations" }),
+ ).toHaveFocus();
+ await expect(menu).toBeVisible();
+
+ await userEvent.hover(body.getByRole("menuitem", { name: "Destinations" }));
+ const submenu = await body.findByRole("menu", { name: "Destinations" });
+ await waitFor(() => expect(submenu).toBeVisible());
+ await userEvent.type(
+ body.getByRole("searchbox", { name: "Search destinations…" }),
+ "data",
+ );
+ await userEvent.keyboard("{ArrowUp}");
+ await expect(body.getByRole("menuitem", { name: "Dataset" })).toHaveFocus();
+ await userEvent.click(body.getByRole("button", { name: "Dataset" }));
+ await expect(onNestedAction).toHaveBeenCalledOnce();
+ await expect(body.queryByRole("menu", { name: "Actions" })).toBeNull();
+
+ await userEvent.click(trigger);
+ await userEvent.hover(body.getByRole("menuitem", { name: "Destinations" }));
+ await body.findByRole("menu", { name: "Destinations" });
+ await userEvent.click(
+ body.getByRole("searchbox", { name: "Search destinations…" }),
+ );
+ await userEvent.keyboard("{Escape}");
+ await waitFor(() =>
+ expect(body.queryByRole("menu", { name: "Destinations" })).toBeNull(),
+ );
+
+ await userEvent.hover(body.getByRole("menuitem", { name: "Unavailable" }));
+ await expect(body.queryByRole("menu", { name: "Unavailable" })).toBeNull();
+ },
+});
diff --git a/web/src/components/design-system/DropdownMenu/DropdownMenu.tsx b/web/src/components/design-system/DropdownMenu/DropdownMenu.tsx
index ad168393e6..13d9ab465f 100644
--- a/web/src/components/design-system/DropdownMenu/DropdownMenu.tsx
+++ b/web/src/components/design-system/DropdownMenu/DropdownMenu.tsx
@@ -4,12 +4,19 @@ import {
autoUpdate,
flip,
FloatingFocusManager,
+ FloatingNode,
FloatingPortal,
+ FloatingTree,
offset,
+ safePolygon,
shift,
useClick,
useDismiss,
useFloating,
+ useFloatingNodeId,
+ useFloatingParentNodeId,
+ useFloatingTree,
+ useHover,
useInteractions,
useListNavigation,
useRole,
@@ -17,12 +24,13 @@ import {
type Placement,
} from "@floating-ui/react";
import { cva } from "class-variance-authority";
-import { type LucideIcon } from "lucide-react";
+import { ChevronRight, type LucideIcon } from "lucide-react";
import Link from "next/link";
import * as React from "react";
import { useLayerContainer } from "@/src/context/LayerContext/LayerContext";
import { useScrollGradients } from "@/src/hooks/useScrollGradients";
+import { Checkbox } from "@/src/components/design-system/Checkbox/Checkbox";
const menuVariants = cva(
"bg-popover text-popover-foreground animate-in fade-in-0 zoom-in-95 min-w-32 overflow-y-auto rounded-md border shadow-md outline-hidden",
@@ -49,7 +57,7 @@ const menuBodyVariants = cva(
);
const menuItemVariants = cva(
- "focus:bg-accent data-[active]:bg-accent data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 relative flex h-8 min-w-0 cursor-pointer items-center rounded-sm text-sm outline-hidden transition-colors",
+ "focus:bg-accent data-[active]:bg-accent data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 relative flex h-8 w-full min-w-0 cursor-pointer items-center rounded-sm text-sm outline-hidden transition-colors",
{
variants: {
variant: {
@@ -72,6 +80,18 @@ const secondaryActionVariants = cva(
"hover:bg-border dark:hover:bg-white/10 mr-1 flex size-6 shrink-0 cursor-pointer items-center justify-center rounded",
);
+function mergeRefs<T>(...refs: Array<React.Ref<T> | undefined>) {
+ return (value: T | null) => {
+ refs.forEach((ref) => {
+ if (typeof ref === "function") {
+ ref(value);
+ } else if (ref) {
+ ref.current = value;
+ }
+ });
+ };
+}
+
type MenuAction =
| { href: string; onClick?: never }
| { href?: never; onClick: () => void };
@@ -89,52 +109,121 @@ type DropdownMenuItem = {
};
} & MenuAction;
-type DropdownMenuItemDefinition =
+type DropdownMenuCheckboxItem = {
+ checked: boolean;
+ closeOnCheckedChange?: boolean;
+ disabled?: { reason: string };
+ id: string;
+ title: string;
+ icon?: LucideIcon;
+ onCheckedChange: (checked: boolean) => void;
+ type: "checkbox";
+};
+
+type DropdownMenuSubmenu = {
+ disabled?: { reason: string };
+ id: string;
+ title: string;
+ icon?: LucideIcon;
+ items: DropdownMenuItemDefinition[];
+ search?: { placeholder: string };
+ type: "submenu";
+};
+
+export type DropdownMenuItemDefinition =
| DropdownMenuItem
+ | DropdownMenuCheckboxItem
+ | DropdownMenuSubmenu
| { id: string; type: "loading" }
| { id: string; type: "separator" };
type DropdownMenuProps = {
+ ariaLabel?: string;
children: (controls: {
- getTriggerProps: () => ReturnType<
- ReturnType<typeof useInteractions>["getReferenceProps"]
- >;
+ getTriggerProps: (
+ props?: React.HTMLProps<HTMLElement>,
+ ) => ReturnType<ReturnType<typeof useInteractions>["getReferenceProps"]>;
}) => React.ReactNode;
items: DropdownMenuItemDefinition[];
+ disabled?: boolean;
maxHeight?: React.CSSProperties["maxHeight"];
placement?: Placement;
+ search?: { placeholder: string };
title?: string;
};
-function DropdownMenu({
+function DropdownMenu(props: DropdownMenuProps) {
+ const parentId = useFloatingParentNodeId();
+ const stateKey = props.disabled ? "disabled" : "enabled";
+
+ if (parentId === null) {
+ return (
+ <FloatingTree>
+ <DropdownMenuNode key={stateKey} {...props} />
+ </FloatingTree>
+ );
+ }
+
+ return <DropdownMenuNode key={stateKey} {...props} />;
+}
+
+function DropdownMenuNode({
+ ariaLabel,
children,
+ disabled = false,
items,
maxHeight = "15rem",
placement = "bottom-start",
+ search,
title,
}: DropdownMenuProps) {
const [isOpen, setIsOpen] = React.useState(false);
const [activeIndex, setActiveIndex] = React.useState<number | null>(null);
+ const [searchQuery, setSearchQuery] = React.useState("");
+ const parentId = useFloatingParentNodeId();
+ const nodeId = useFloatingNodeId();
+ const tree = useFloatingTree();
+ const isNested = parentId !== null;
const layerContainer = useLayerContainer("popover");
const listRef = React.useRef<Array<HTMLElement | null>>([]);
const labelsRef = React.useRef<Array<string | null>>([]);
+ const closeMenu = React.useCallback(() => {
+ setIsOpen(false);
+ setSearchQuery("");
+ }, []);
const { register, recompute, top, bottom } =
useScrollGradients<HTMLDivElement>(true);
const { context, floatingStyles, refs } = useFloating({
+ nodeId,
open: isOpen,
- onOpenChange: setIsOpen,
+ onOpenChange: (open) => {
+ if (disabled) return;
+ if (!open) {
+ closeMenu();
+ return;
+ }
+
+ setIsOpen(true);
+ if (open) tree?.events.emit("menuopen", { nodeId, parentId });
+ },
placement,
middleware: [offset(4), flip(), shift({ padding: 8 })],
transform: false,
whileElementsMounted: autoUpdate,
});
- const click = useClick(context);
+ const click = useClick(context, { enabled: !disabled });
+ const hover = useHover(context, {
+ enabled: isNested && !disabled,
+ delay: { open: 75, close: 100 },
+ handleClose: safePolygon({ blockPointerEvents: true }),
+ });
const dismiss = useDismiss(context);
const role = useRole(context, { role: "menu" });
const listNavigation = useListNavigation(context, {
activeIndex,
listRef,
loop: true,
+ nested: isNested,
onNavigate: setActiveIndex,
});
const typeahead = useTypeahead(context, {
@@ -143,17 +232,49 @@ function DropdownMenu({
onMatch: setActiveIndex,
});
const { getFloatingProps, getItemProps, getReferenceProps } = useInteractions(
- [click, dismiss, role, listNavigation, typeahead],
+ [click, hover, dismiss, role, listNavigation, typeahead],
);
+ const visibleItems = React.useMemo(() => {
+ const normalizedQuery = searchQuery.trim().toLocaleLowerCase();
+ if (!search || !normalizedQuery) return items;
+
+ return items.filter((item) => {
+ if (item.type === "separator") return false;
+ if (item.type === "loading") return true;
+ return item.title.toLocaleLowerCase().includes(normalizedQuery);
+ });
+ }, [items, search, searchQuery]);
+
+ React.useEffect(() => {
+ const handleTreeClick = closeMenu;
+ const handleMenuOpen = (event: {
+ nodeId: string | number;
+ parentId: string | number | null;
+ }) => {
+ if (event.nodeId !== nodeId && event.parentId === parentId) {
+ closeMenu();
+ }
+ };
+
+ tree?.events.on("click", handleTreeClick);
+ tree?.events.on("menuopen", handleMenuOpen);
+ return () => {
+ tree?.events.off("click", handleTreeClick);
+ tree?.events.off("menuopen", handleMenuOpen);
+ };
+ }, [closeMenu, nodeId, parentId, tree]);
return (
- <>
+ <FloatingNode id={nodeId}>
{children({
- getTriggerProps: () =>
- getReferenceProps({
+ getTriggerProps: (props = {}) => {
+ const { ref, ...triggerProps } = props;
+ return getReferenceProps({
+ ...triggerProps,
"aria-expanded": isOpen,
- ref: refs.setReference,
- }),
+ ref: mergeRefs(ref, refs.setReference),
+ });
+ },
})}
{isOpen ? (
<FloatingPortal root={layerContainer}>
@@ -166,8 +287,11 @@ function DropdownMenu({
className={menuVariants()}
style={{ ...floatingStyles, maxHeight }}
{...getFloatingProps({ onScroll: recompute })}
- {...(title
- ? { "aria-label": title, "aria-labelledby": undefined }
+ {...(ariaLabel || title
+ ? {
+ "aria-label": ariaLabel ?? title,
+ "aria-labelledby": undefined,
+ }
: {})}
>
{title ? (
@@ -175,14 +299,51 @@ function DropdownMenu({
{title}
</div>
) : null}
+ {search ? (
+ <div className="border-border bg-popover sticky top-0 z-1 border-b p-1.5">
+ <input
+ type="search"
+ value={searchQuery}
+ placeholder={search.placeholder}
+ aria-label={search.placeholder}
+ className="border-input bg-background focus:ring-ring h-8 w-full rounded-md border px-2 text-sm outline-hidden focus:ring-1"
+ onChange={(event) => {
+ setSearchQuery(event.target.value);
+ setActiveIndex(null);
+ }}
+ onKeyDown={(event) => {
+ if (event.key === "Escape") {
+ closeMenu();
+ event.preventDefault();
+ } else if (event.key === "ArrowDown") {
+ const firstIndex = listRef.current
+ .slice(0, visibleItems.length)
+ .findIndex((element) => element !== null);
+ setActiveIndex(firstIndex === -1 ? null : firstIndex);
+ listRef.current[firstIndex]?.focus();
+ event.preventDefault();
+ } else if (event.key === "ArrowUp") {
+ const lastIndex = listRef.current
+ .slice(0, visibleItems.length)
+ .findLastIndex((element) => element !== null);
+ setActiveIndex(lastIndex === -1 ? null : lastIndex);
+ listRef.current[lastIndex]?.focus();
+ event.preventDefault();
+ }
+
+ event.stopPropagation();
+ }}
+ />
+ </div>
+ ) : null}
<div
className={menuBodyVariants({
- hasTitle: Boolean(title),
+ hasTitle: Boolean(title || search),
showBottomGradient: bottom,
showTopGradient: top,
})}
>
- {items.map((item, index) => {
+ {visibleItems.map((item, index) => {
if (item.type === "separator") {
labelsRef.current[index] = null;
listRef.current[index] = null;
@@ -211,6 +372,124 @@ function DropdownMenu({
);
}
+ if (item.type === "submenu") {
+ const ItemIcon = item.icon;
+ labelsRef.current[index] = item.title;
+
+ return (
+ <DropdownMenu
+ key={item.id}
+ items={item.items}
+ disabled={Boolean(item.disabled)}
+ maxHeight={maxHeight}
+ placement="right-start"
+ ariaLabel={item.title}
+ search={item.search}
+ >
+ {({ getTriggerProps }) => (
+ <button
+ type="button"
+ role="menuitem"
+ disabled={Boolean(item.disabled)}
+ aria-disabled={item.disabled ? "true" : undefined}
+ title={item.disabled?.reason}
+ tabIndex={activeIndex === index ? 0 : -1}
+ data-active={activeIndex === index ? "" : undefined}
+ data-disabled={item.disabled ? "" : undefined}
+ className={menuItemVariants()}
+ {...getItemProps(
+ getTriggerProps({
+ ref: (element) => {
+ listRef.current[index] = element;
+ },
+ }),
+ )}
+ >
+ <span className={primaryActionVariants()}>
+ {ItemIcon ? (
+ <ItemIcon
+ className="mr-1.5 size-4"
+ aria-hidden="true"
+ />
+ ) : null}
+ <span className="min-w-0 flex-1 overflow-hidden text-left text-ellipsis whitespace-nowrap">
+ {item.title}
+ </span>
+ <ChevronRight
+ className="ml-2 size-4"
+ aria-hidden="true"
+ />
+ </span>
+ </button>
+ )}
+ </DropdownMenu>
+ );
+ }
+
+ if (item.type === "checkbox") {
+ const ItemIcon = item.icon;
+ labelsRef.current[index] = item.title;
+ const handleCheckedChange = (checked: boolean) => {
+ if (item.disabled) return;
+ if (item.closeOnCheckedChange) {
+ tree?.events.emit("click");
+ }
+ item.onCheckedChange(checked);
+ };
+
+ return (
+ <div
+ key={item.id}
+ role="menuitemcheckbox"
+ aria-checked={item.checked}
+ aria-disabled={item.disabled ? "true" : undefined}
+ title={item.disabled?.reason}
+ tabIndex={activeIndex === index ? 0 : -1}
+ ref={(element) => {
+ listRef.current[index] = element;
+ }}
+ data-active={activeIndex === index ? "" : undefined}
+ data-disabled={item.disabled ? "" : undefined}
+ className={menuItemVariants()}
+ {...getItemProps({
+ onClick: () => {
+ handleCheckedChange(!item.checked);
+ },
+ onKeyDown: (event) => {
+ if (item.disabled) return;
+ if (event.key !== "Enter" && event.key !== " ")
+ return;
+ event.preventDefault();
+ handleCheckedChange(!item.checked);
+ },
+ })}
+ >
+ <span className={primaryActionVariants()}>
+ {ItemIcon ? (
+ <ItemIcon
+ className="mr-1.5 size-4"
+ aria-hidden="true"
+ />
+ ) : null}
+ <span className="min-w-0 flex-1 overflow-hidden text-left text-ellipsis whitespace-nowrap">
+ {item.title}
+ </span>
+ <span className="ml-2 flex shrink-0 items-center">
+ <Checkbox
+ aria-hidden="true"
+ checked={item.checked}
+ disabled={Boolean(item.disabled)}
+ size="sm"
+ tabIndex={-1}
+ onClick={(event) => event.stopPropagation()}
+ onCheckedChange={handleCheckedChange}
+ />
+ </span>
+ </span>
+ </div>
+ );
+ }
+
const ItemIcon = item.icon;
const SecondaryIcon = item.secondaryAction?.icon;
labelsRef.current[index] = item.title;
@@ -240,7 +519,7 @@ function DropdownMenu({
event.preventDefault();
return;
}
- setIsOpen(false);
+ tree?.events.emit("click");
}}
{...interactionProps}
>
@@ -258,7 +537,7 @@ function DropdownMenu({
className={secondaryActionVariants()}
onClick={(event) => {
event.stopPropagation();
- setIsOpen(false);
+ tree?.events.emit("click");
secondaryAction.onClick?.();
}}
{...interactionProps}
@@ -315,7 +594,7 @@ function DropdownMenu({
event.preventDefault();
return;
}
- setIsOpen(false);
+ tree?.events.emit("click");
}}
>
{ItemIcon ? (
@@ -338,7 +617,7 @@ function DropdownMenu({
data-primary-action=""
className={primaryActionVariants()}
onClick={() => {
- setIsOpen(false);
+ tree?.events.emit("click");
item.onClick?.();
}}
>
@@ -365,7 +644,7 @@ function DropdownMenu({
</FloatingFocusManager>
</FloatingPortal>
) : null}
- </>
+ </FloatingNode>
);
}
diff --git a/web/src/components/ui/MarkdownViewer.stories.tsx b/web/src/components/ui/MarkdownViewer.stories.tsx
index 9a780348c5..a768e093da 100644
--- a/web/src/components/ui/MarkdownViewer.stories.tsx
+++ b/web/src/components/ui/MarkdownViewer.stories.tsx
@@ -1,5 +1,5 @@
import preview from "../../../.storybook/preview";
-import { expect, userEvent, waitFor, within } from "storybook/test";
+import { expect, waitFor, within } from "storybook/test";
import { MarkdownView } from "./MarkdownViewer";
const meta = preview.meta({
@@ -154,8 +154,8 @@ trace.generation({ name: "answer" });
},
});
-export const HeaderControlsOnHover = meta.story({
- name: "(Test) Reveals Header Controls On Hover",
+export const HeaderControlsOnFocus = meta.story({
+ name: "(Test) Reveals Header Controls On Focus",
args: {
markdown: "Hover this message to reveal its header controls.",
title: "assistant",
@@ -163,14 +163,9 @@ export const HeaderControlsOnHover = meta.story({
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const copyButton = canvas.getByTitle("Copy to clipboard");
- const message = copyButton.closest<HTMLElement>(".group\\/iosection");
-
- if (!message) throw new Error("no markdown message");
-
- await userEvent.unhover(message);
await waitFor(() => expect(copyButton).not.toBeVisible());
- await userEvent.hover(message);
+ copyButton.focus();
await waitFor(() => expect(copyButton).toBeVisible());
},
});
diff --git a/web/src/features/annotation-queues/components/AnnotationQueueItemDropdownMenuController.tsx b/web/src/features/annotation-queues/components/AnnotationQueueItemDropdownMenuController.tsx
index 6480f71132..480d132546 100644
--- a/web/src/features/annotation-queues/components/AnnotationQueueItemDropdownMenuController.tsx
+++ b/web/src/features/annotation-queues/components/AnnotationQueueItemDropdownMenuController.tsx
@@ -19,6 +19,7 @@ type AnnotationQueueItemDropdownMenuControllerProps = {
children: (control: {
disabled: { reason: string } | undefined;
totalCount: number;
+ Trigger: typeof DropdownMenuTrigger;
}) => ReactNode;
};
@@ -106,9 +107,11 @@ export function AnnotationQueueItemDropdownMenuController({
if (hasAccess) setIsDropdownOpen(open);
}}
>
- <DropdownMenuTrigger asChild>
- {children({ disabled, totalCount })}
- </DropdownMenuTrigger>
+ {children({
+ disabled,
+ totalCount,
+ Trigger: DropdownMenuTrigger,
+ })}
{!isLoading ? (
<AnnotationQueueItemMenuContent
projectId={projectId}
diff --git a/web/src/features/datasets/components/NewDatasetItemFromExistingObjectDialogController.tsx b/web/src/features/datasets/components/NewDatasetItemFromExistingObjectDialogController.tsx
index eae78e2a77..1158135db0 100644
--- a/web/src/features/datasets/components/NewDatasetItemFromExistingObjectDialogController.tsx
+++ b/web/src/features/datasets/components/NewDatasetItemFromExistingObjectDialogController.tsx
@@ -14,6 +14,7 @@ type DatasetItemDialogState = {
traceId?: string;
observationId?: string;
fromDatasetId?: string;
+ datasetId?: string;
input: Prisma.JsonValue | null;
output: Prisma.JsonValue | null;
metadata: MetadataDomainClient;
@@ -53,6 +54,7 @@ export function NewDatasetItemFromExistingObjectDialogController(props: {
traceId={state.traceId}
observationId={state.observationId}
projectId={props.projectId}
+ datasetId={state.datasetId}
input={normalizePrefillValue(state.input)}
output={normalizePrefillValue(state.output)}
metadata={state.metadata}
diff --git a/web/src/features/playground/page/components/JumpToPlaygroundDropdownMenuController.tsx b/web/src/features/playground/page/components/JumpToPlaygroundDropdownMenuController.tsx
index fc63e53db0..687a332f38 100644
--- a/web/src/features/playground/page/components/JumpToPlaygroundDropdownMenuController.tsx
+++ b/web/src/features/playground/page/components/JumpToPlaygroundDropdownMenuController.tsx
@@ -1,8 +1,14 @@
-import { useMemo, useState } from "react";
+import { useCallback, useMemo, useState } from "react";
import { useRouter } from "next/router";
import { createEmptyMessage } from "@/src/components/ChatMessages/utils/createEmptyMessage";
-import { DropdownMenuController } from "@/src/components/ui/dropdown-menu";
+import {
+ DropdownMenuController,
+ DropdownMenuSub,
+ DropdownMenuSubContent,
+ DropdownMenuSubTrigger,
+ type DropdownMenuTrigger,
+} from "@/src/components/ui/dropdown-menu";
import { usePersistedWindowIds } from "@/src/features/playground/page/hooks/usePersistedWindowIds";
import {
type PlaygroundCache,
@@ -46,7 +52,7 @@ import {
type JumpToPlaygroundAction,
} from "./JumpToPlaygroundMenu";
-type JumpToPlaygroundDropdownMenuControllerProps = (
+export type JumpToPlaygroundSourceProps =
| {
source: "prompt";
prompt: Prompt & { resolvedPrompt?: Prisma.JsonValue };
@@ -62,22 +68,33 @@ type JumpToPlaygroundDropdownMenuControllerProps = (
output: string | null;
};
analyticsEventName: "trace_detail:test_in_playground_button_click";
- }
-) & {
- children: (control: {
- disabled: boolean;
- title: string;
- Trigger: Parameters<
- NonNullable<
- React.ComponentProps<typeof DropdownMenuController>["children"]
- >
- >[0]["Trigger"];
- }) => React.ReactNode;
-};
+ };
-export const JumpToPlaygroundDropdownMenuController = (
- props: JumpToPlaygroundDropdownMenuControllerProps,
-) => {
+type JumpToPlaygroundDropdownMenuControllerProps =
+ JumpToPlaygroundSourceProps & {
+ variant?: "dropdown" | "submenu";
+ children: (control: {
+ disabled: boolean;
+ title: string;
+ Trigger: typeof DropdownMenuTrigger | typeof DropdownMenuSubTrigger;
+ }) => React.ReactNode;
+ };
+
+export function useJumpToPlayground(
+ props:
+ | Extract<JumpToPlaygroundSourceProps, { source: "prompt" }>
+ | (Omit<
+ Extract<JumpToPlaygroundSourceProps, { source: "generation" }>,
+ "generation"
+ > & {
+ generation:
+ | Extract<
+ JumpToPlaygroundSourceProps,
+ { source: "generation" }
+ >["generation"]
+ | null;
+ }),
+) {
const router = useRouter();
const capture = usePostHogClientCapture();
const projectId = useProjectIdFromURL();
@@ -86,7 +103,7 @@ export const JumpToPlaygroundDropdownMenuController = (
// Generate a stable window ID based on the source data
const sourceId =
- props.source === "prompt" ? props.prompt.id : props.generation.id;
+ props.source === "prompt" ? props.prompt.id : props.generation?.id;
const stableWindowId = useMemo(() => {
return `playground-${props.source}-${sourceId}`;
}, [props.source, sourceId]);
@@ -120,7 +137,7 @@ export const JumpToPlaygroundDropdownMenuController = (
const prompt = props.source === "prompt" ? props.prompt : undefined;
const generation =
- props.source === "generation" ? props.generation : undefined;
+ props.source === "generation" ? (props.generation ?? undefined) : undefined;
const capturedState = useMemo(() => {
if (prompt) return parsePrompt(prompt);
if (generation) {
@@ -130,89 +147,117 @@ export const JumpToPlaygroundDropdownMenuController = (
}, [prompt, generation, modelToProviderMap, includeOutput]);
const isAvailable = capturedState !== null;
- const handlePlaygroundAction = (action: JumpToPlaygroundAction) => {
- const useFreshPlayground = action === "fresh";
- capture(props.analyticsEventName, {
- playgroundMode: useFreshPlayground ? "fresh" : "add_to_existing",
- });
-
- // First, ensure we have state to save
- if (!capturedState) {
- console.warn("No captured state available for playground");
- return;
- }
-
- let targetWindowId = stableWindowId;
-
- if (useFreshPlayground) {
- // Clear all existing playground data and reset to single window
- clearAllCache(stableWindowId);
- } else {
- targetWindowId = resolveJumpTargetWindowId({
- stableWindowId,
- openWindowIds: windowIds,
- incomingMessages: capturedState.messages,
- getCachedMessages: (windowId) => getWindowState(windowId)?.messages,
+ const handlePlaygroundAction = useCallback(
+ (action: JumpToPlaygroundAction) => {
+ const useFreshPlayground = action === "fresh";
+ capture(props.analyticsEventName, {
+ playgroundMode: useFreshPlayground ? "fresh" : "add_to_existing",
});
- const addedWindowId = addWindowWithId(targetWindowId);
-
- if (!addedWindowId) {
- console.warn(
- "Failed to add window to existing playground, maximum windows reached",
- );
+ // First, ensure we have state to save
+ if (!capturedState) {
+ console.warn("No captured state available for playground");
return;
}
- }
- // Use requestAnimationFrame to ensure the state update has been processed
- requestAnimationFrame(() => {
- try {
- setWindowState(targetWindowId, capturedState);
- console.log(
- `Cache saved for existing playground window ${targetWindowId}`,
- );
-
- // Navigate after cache is successfully saved
- router.push(`/project/${projectId}/playground`);
- } catch (error) {
- console.error("Failed to save playground cache:", error);
- // Navigate anyway, but user might not see their data
- router.push(`/project/${projectId}/playground`);
+ let targetWindowId = stableWindowId;
+
+ if (useFreshPlayground) {
+ // Clear all existing playground data and reset to single window
+ clearAllCache(stableWindowId);
+ } else {
+ targetWindowId = resolveJumpTargetWindowId({
+ stableWindowId,
+ openWindowIds: windowIds,
+ incomingMessages: capturedState.messages,
+ getCachedMessages: (windowId) => getWindowState(windowId)?.messages,
+ });
+
+ const addedWindowId = addWindowWithId(targetWindowId);
+
+ if (!addedWindowId) {
+ console.warn(
+ "Failed to add window to existing playground, maximum windows reached",
+ );
+ return;
+ }
}
- });
- };
+
+ // Use requestAnimationFrame to ensure the state update has been processed
+ requestAnimationFrame(() => {
+ try {
+ setWindowState(targetWindowId, capturedState);
+ console.log(
+ `Cache saved for existing playground window ${targetWindowId}`,
+ );
+
+ // Navigate after cache is successfully saved
+ router.push(`/project/${projectId}/playground`);
+ } catch (error) {
+ console.error("Failed to save playground cache:", error);
+ // Navigate anyway, but user might not see their data
+ router.push(`/project/${projectId}/playground`);
+ }
+ });
+ },
+ [
+ addWindowWithId,
+ capture,
+ capturedState,
+ clearAllCache,
+ projectId,
+ props.analyticsEventName,
+ router,
+ stableWindowId,
+ windowIds,
+ ],
+ );
const tooltipMessage = isAvailable
? "Test in LLM playground"
: "Test in LLM playground is not available since messages are not in valid ChatML format or tool calls have been used. If you think this is not correct, please open a GitHub issue.";
+ const menu =
+ props.source === "prompt" ? (
+ <JumpToPlaygroundMenu
+ source="prompt"
+ onPlaygroundAction={handlePlaygroundAction}
+ />
+ ) : (
+ <JumpToPlaygroundMenu
+ source="generation"
+ includeOutput={includeOutput}
+ onIncludeOutputChange={setIncludeOutput}
+ onPlaygroundAction={handlePlaygroundAction}
+ />
+ );
+ return {
+ disabled: !isAvailable,
+ title: tooltipMessage,
+ menu,
+ includeOutput,
+ setIncludeOutput,
+ handlePlaygroundAction,
+ };
+}
+
+export const JumpToPlaygroundDropdownMenuController = (
+ props: JumpToPlaygroundDropdownMenuControllerProps,
+) => {
+ const control = useJumpToPlayground(props);
+
+ if (props.variant === "submenu") {
+ return (
+ <DropdownMenuSub>
+ {props.children({ ...control, Trigger: DropdownMenuSubTrigger })}
+ <DropdownMenuSubContent>{control.menu}</DropdownMenuSubContent>
+ </DropdownMenuSub>
+ );
+ }
+
return (
- <DropdownMenuController
- align="end"
- renderMenu={() =>
- props.source === "prompt" ? (
- <JumpToPlaygroundMenu
- source="prompt"
- onPlaygroundAction={handlePlaygroundAction}
- />
- ) : (
- <JumpToPlaygroundMenu
- source="generation"
- includeOutput={includeOutput}
- onIncludeOutputChange={setIncludeOutput}
- onPlaygroundAction={handlePlaygroundAction}
- />
- )
- }
- >
- {({ Trigger }) =>
- props.children({
- Trigger,
- disabled: !isAvailable,
- title: tooltipMessage,
- })
- }
+ <DropdownMenuController align="end" renderMenu={() => control.menu}>
+ {({ Trigger }) => props.children({ ...control, Trigger })}
</DropdownMenuController>
);
};
diff --git a/web/src/features/sessions/SessionPages.tsx b/web/src/features/sessions/SessionPages.tsx
index f5ee6fc421..6f79619e3d 100644
--- a/web/src/features/sessions/SessionPages.tsx
+++ b/web/src/features/sessions/SessionPages.tsx
@@ -656,22 +656,24 @@ export const SessionPage: React.FC<{
objectId={sessionId}
objectType="SESSION"
>
- {({ disabled, totalCount }) => (
- <Button
- variant="outline"
- disabled={disabled !== undefined}
- className="rounded-l-none rounded-r-md border-l-2"
- >
- <span className="relative mr-1 text-xs">
- <ChevronDown className="h-3 w-3" />
- {totalCount > 0 && (
- <AnnotationQueueItemCountBadge
- totalCount={totalCount}
- layout="toolbar"
- />
- )}
- </span>
- </Button>
+ {({ disabled, totalCount, Trigger }) => (
+ <Trigger asChild>
+ <Button
+ variant="outline"
+ disabled={disabled !== undefined}
+ className="rounded-l-none rounded-r-md border-l-2"
+ >
+ <span className="relative mr-1 text-xs">
+ <ChevronDown className="h-3 w-3" />
+ {totalCount > 0 && (
+ <AnnotationQueueItemCountBadge
+ totalCount={totalCount}
+ layout="toolbar"
+ />
+ )}
+ </span>
+ </Button>
+ </Trigger>
)}
</AnnotationQueueItemDropdownMenuController>
</div>
@@ -776,22 +778,24 @@ export const SessionPage: React.FC<{
objectId={sessionId}
objectType="SESSION"
>
- {({ disabled, totalCount }) => (
- <Button
- variant="ghost"
- size="sm"
- disabled={disabled !== undefined}
- className="w-full justify-start gap-2 font-normal"
- >
- <ListPlus className="h-4 w-4" />
- <span className="text-sm">Add to queue</span>
- {totalCount > 0 && (
- <AnnotationQueueItemCountBadge
- totalCount={totalCount}
- layout="menu"
- />
- )}
- </Button>
+ {({ disabled, totalCount, Trigger }) => (
+ <Trigger asChild>
+ <Button
+ variant="ghost"
+ size="sm"
+ disabled={disabled !== undefined}
+ className="w-full justify-start gap-2 font-normal"
+ >
+ <ListPlus className="h-4 w-4" />
+ <span className="text-sm">Add to queue</span>
+ {totalCount > 0 && (
+ <AnnotationQueueItemCountBadge
+ totalCount={totalCount}
+ layout="menu"
+ />
+ )}
+ </Button>
+ </Trigger>
)}
</AnnotationQueueItemDropdownMenuController>
{webCalloutAction && (
@@ -1702,22 +1706,24 @@ const LoadedSessionEventsPage: React.FC<{
objectId={sessionId}
objectType="SESSION"
>
- {({ disabled, totalCount }) => (
- <Button
- variant="outline"
- disabled={disabled !== undefined}
- className="rounded-l-none rounded-r-md border-l-2"
- >
- <span className="relative mr-1 text-xs">
- <ChevronDown className="h-3 w-3" />
- {totalCount > 0 && (
- <AnnotationQueueItemCountBadge
- totalCount={totalCount}
- layout="toolbar"
- />
- )}
- </span>
- </Button>
+ {({ disabled, totalCount, Trigger }) => (
+ <Trigger asChild>
+ <Button
+ variant="outline"
+ disabled={disabled !== undefined}
+ className="rounded-l-none rounded-r-md border-l-2"
+ >
+ <span className="relative mr-1 text-xs">
+ <ChevronDown className="h-3 w-3" />
+ {totalCount > 0 && (
+ <AnnotationQueueItemCountBadge
+ totalCount={totalCount}
+ layout="toolbar"
+ />
+ )}
+ </span>
+ </Button>
+ </Trigger>
)}
</AnnotationQueueItemDropdownMenuController>
</div>
@@ -1854,22 +1860,24 @@ const LoadedSessionEventsPage: React.FC<{
objectId={sessionId}
objectType="SESSION"
>
- {({ disabled, totalCount }) => (
- <Button
- variant="ghost"
- size="sm"
- disabled={disabled !== undefined}
- className="w-full justify-start gap-2 font-normal"
- >
- <ListPlus className="h-4 w-4" />
- <span className="text-sm">Add to queue</span>
- {totalCount > 0 && (
- <AnnotationQueueItemCountBadge
- totalCount={totalCount}
- layout="menu"
- />
- )}
- </Button>
+ {({ disabled, totalCount, Trigger }) => (
+ <Trigger asChild>
+ <Button
+ variant="ghost"
+ size="sm"
+ disabled={disabled !== undefined}
+ className="w-full justify-start gap-2 font-normal"
+ >
+ <ListPlus className="h-4 w-4" />
+ <span className="text-sm">Add to queue</span>
+ {totalCount > 0 && (
+ <AnnotationQueueItemCountBadge
+ totalCount={totalCount}
+ layout="menu"
+ />
+ )}
+ </Button>
+ </Trigger>
)}
</AnnotationQueueItemDropdownMenuController>
{webCalloutAction && (
diff --git a/web/src/features/sessions/SessionTraceActionButtons.tsx b/web/src/features/sessions/SessionTraceActionButtons.tsx
index 80a4b8d916..8f9cb425ca 100644
--- a/web/src/features/sessions/SessionTraceActionButtons.tsx
+++ b/web/src/features/sessions/SessionTraceActionButtons.tsx
@@ -175,23 +175,25 @@ export function SessionTraceActionButtons({
objectId={traceId}
objectType="TRACE"
>
- {({ disabled, totalCount }) => (
- <Button
- variant="outline"
- size={size}
- disabled={disabled !== undefined}
- className="rounded-l-none rounded-r-md border-l-2"
- >
- <span className="relative mr-1 text-xs">
- <ChevronDown className="h-3 w-3" />
- {totalCount > 0 && (
- <AnnotationQueueItemCountBadge
- totalCount={totalCount}
- layout="toolbar"
- />
- )}
- </span>
- </Button>
+ {({ disabled, totalCount, Trigger }) => (
+ <Trigger asChild>
+ <Button
+ variant="outline"
+ size={size}
+ disabled={disabled !== undefined}
+ className="rounded-l-none rounded-r-md border-l-2"
+ >
+ <span className="relative mr-1 text-xs">
+ <ChevronDown className="h-3 w-3" />
+ {totalCount > 0 && (
+ <AnnotationQueueItemCountBadge
+ totalCount={totalCount}
+ layout="toolbar"
+ />
+ )}
+ </span>
+ </Button>
+ </Trigger>
)}
</AnnotationQueueItemDropdownMenuController>
</div>
diff --git a/web/src/features/traces/components/ConnectedTraceObservationAddToDropdownMenuController.tsx b/web/src/features/traces/components/ConnectedTraceObservationAddToDropdownMenuController.tsx
new file mode 100644
index 0000000000..01b00410d1
--- /dev/null
+++ b/web/src/features/traces/components/ConnectedTraceObservationAddToDropdownMenuController.tsx
@@ -0,0 +1,423 @@
+import { AnnotationQueueObjectType, type Prisma } from "@langfuse/shared";
+import { Database, ListPlus, PlusIcon, Terminal } from "lucide-react";
+import { useSession } from "next-auth/react";
+import { type ComponentProps, useCallback, useMemo } from "react";
+
+import {
+ DropdownMenu,
+ type DropdownMenuItemDefinition,
+} from "@/src/components/design-system/DropdownMenu/DropdownMenu";
+import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";
+import { AnnotationQueueFormDialogController } from "@/src/features/annotation-queues/components/AnnotationQueueFormDialogController";
+import { CreateDatasetDialogController } from "@/src/features/datasets/components/CreateDatasetDialogController";
+import { NewDatasetItemFromExistingObjectDialogController } from "@/src/features/datasets";
+import {
+ type JumpToPlaygroundSourceProps,
+ useJumpToPlayground,
+} from "@/src/features/playground/page/components/JumpToPlaygroundDropdownMenuController";
+import { useHasProjectAccess } from "@/src/features/rbac";
+import { api, reportNonTrpcError } from "@/src/utils/api";
+import type { MetadataDomainClient } from "@/src/utils/clientSideDomainTypes";
+
+type PlaygroundGeneration = Extract<
+ JumpToPlaygroundSourceProps,
+ { source: "generation" }
+>["generation"];
+
+type QueueRemoval = {
+ itemId: string;
+ queueName: string;
+};
+
+type ConnectedTraceObservationAddToDropdownMenuControllerProps = {
+ projectId: string;
+ input: Prisma.JsonValue | null;
+ output: Prisma.JsonValue | null;
+ metadata: MetadataDomainClient;
+ children: ComponentProps<typeof DropdownMenu>["children"];
+} & (
+ | {
+ variant: "trace";
+ traceId: string;
+ observationId?: never;
+ generation?: never;
+ }
+ | {
+ variant: "observation";
+ traceId: string;
+ observationId: string;
+ generation?: PlaygroundGeneration;
+ }
+);
+
+export function ConnectedTraceObservationAddToDropdownMenuController(
+ props: ConnectedTraceObservationAddToDropdownMenuControllerProps,
+) {
+ const objectId =
+ props.variant === "observation" ? props.observationId : props.traceId;
+ const objectType =
+ props.variant === "observation"
+ ? AnnotationQueueObjectType.OBSERVATION
+ : AnnotationQueueObjectType.TRACE;
+ const utils = api.useUtils();
+ const removeFromQueueMutation =
+ api.annotationQueueItems.deleteMany.useMutation();
+
+ return (
+ <NewDatasetItemFromExistingObjectDialogController
+ projectId={props.projectId}
+ >
+ {({ openDialog: openDatasetItemDialog }) => (
+ <AnnotationQueueFormDialogController
+ projectId={props.projectId}
+ mode="create"
+ onSuccess={() => undefined}
+ >
+ {({ disabled: createQueueDisabled, openDialog: openQueueDialog }) => (
+ <CreateDatasetDialogController
+ projectId={props.projectId}
+ target={{ type: "root" }}
+ >
+ {({
+ disabled: createDatasetDisabled,
+ openDialog: openDatasetDialog,
+ }) => (
+ <ConfirmationDialogController<QueueRemoval>
+ title="Remove from annotation queue"
+ text={({ queueName }) =>
+ `Are you sure you want to remove this item from the queue "${queueName}"?`
+ }
+ confirmLabel="Remove"
+ variant="destructive"
+ loading={removeFromQueueMutation.isPending}
+ error={removeFromQueueMutation.error?.message}
+ onConfirm={async ({ itemId }) => {
+ await removeFromQueueMutation.mutateAsync({
+ projectId: props.projectId,
+ itemIds: [itemId],
+ });
+ await utils.annotationQueues.byObjectId.invalidate({
+ projectId: props.projectId,
+ objectId,
+ objectType,
+ });
+ }}
+ >
+ {({ openDialog: openRemoveQueueDialog }) => (
+ <ConnectedTraceObservationAddToDropdownMenuControllerContent
+ {...props}
+ createDatasetDisabled={createDatasetDisabled}
+ createQueueDisabled={createQueueDisabled}
+ openDatasetDialog={openDatasetDialog}
+ openDatasetItemDialog={openDatasetItemDialog}
+ openQueueDialog={openQueueDialog}
+ openRemoveQueueDialog={openRemoveQueueDialog}
+ />
+ )}
+ </ConfirmationDialogController>
+ )}
+ </CreateDatasetDialogController>
+ )}
+ </AnnotationQueueFormDialogController>
+ )}
+ </NewDatasetItemFromExistingObjectDialogController>
+ );
+}
+
+function ConnectedTraceObservationAddToDropdownMenuControllerContent({
+ projectId,
+ variant,
+ traceId,
+ observationId,
+ input,
+ output,
+ metadata,
+ generation,
+ children,
+ createDatasetDisabled,
+ createQueueDisabled,
+ openDatasetDialog,
+ openDatasetItemDialog,
+ openQueueDialog,
+ openRemoveQueueDialog,
+}: ConnectedTraceObservationAddToDropdownMenuControllerProps & {
+ createDatasetDisabled: { reason: string } | undefined;
+ createQueueDisabled: { reason: string } | undefined;
+ openDatasetDialog: () => void;
+ openDatasetItemDialog: Parameters<
+ ComponentProps<
+ typeof NewDatasetItemFromExistingObjectDialogController
+ >["children"]
+ >[0]["openDialog"];
+ openQueueDialog: () => void;
+ openRemoveQueueDialog: (queueRemoval: QueueRemoval) => void;
+}) {
+ const session = useSession();
+ const objectId = variant === "observation" ? observationId : traceId;
+ const objectType =
+ variant === "observation"
+ ? AnnotationQueueObjectType.OBSERVATION
+ : AnnotationQueueObjectType.TRACE;
+ const queues = api.annotationQueues.byObjectId.useQuery(
+ { projectId, objectId, objectType },
+ {
+ enabled:
+ session.status === "authenticated" &&
+ Boolean(projectId) &&
+ Boolean(objectId),
+ },
+ );
+ const datasets = api.datasets.allDatasetMeta.useQuery({ projectId });
+ const utils = api.useUtils();
+ const addToQueueMutation = api.annotationQueueItems.createMany.useMutation();
+ const hasAnnotationQueueAccess = useHasProjectAccess({
+ projectId,
+ scope: "annotationQueues:CUD",
+ });
+ const hasDatasetAccess = useHasProjectAccess({
+ projectId,
+ scope: "datasets:CUD",
+ });
+ const playground = useJumpToPlayground({
+ source: "generation",
+ generation: generation ?? null,
+ analyticsEventName: "trace_detail:test_in_playground_button_click",
+ });
+ const {
+ disabled: playgroundDisabled,
+ handlePlaygroundAction,
+ includeOutput,
+ setIncludeOutput,
+ title: playgroundTitle,
+ } = playground;
+
+ const handleQueueItemToggle = useCallback(
+ async (queueId: string, queueName: string, itemId?: string) => {
+ try {
+ if (!itemId) {
+ await addToQueueMutation.mutateAsync({
+ projectId,
+ objectIds: [objectId],
+ objectType,
+ queueId,
+ });
+ } else {
+ openRemoveQueueDialog({ itemId, queueName });
+ return;
+ }
+
+ await utils.annotationQueues.byObjectId.invalidate({
+ projectId,
+ objectId,
+ objectType,
+ });
+ } catch (error) {
+ reportNonTrpcError(error, "annotation-queues");
+ }
+ },
+ [
+ addToQueueMutation,
+ objectId,
+ objectType,
+ openRemoveQueueDialog,
+ projectId,
+ utils.annotationQueues,
+ ],
+ );
+
+ const queuesAreLoading =
+ session.status !== "authenticated" || queues.isLoading;
+
+ const items = useMemo(() => {
+ const [annotationQueueItem, datasetItem]: [
+ DropdownMenuItemDefinition,
+ DropdownMenuItemDefinition,
+ ] = [
+ {
+ type: "submenu",
+ id: "annotation-queue",
+ title: "Annotation queue",
+ icon: ListPlus,
+ search: { placeholder: "Search annotation queues…" },
+ disabled:
+ !hasAnnotationQueueAccess || queuesAreLoading
+ ? {
+ reason: !hasAnnotationQueueAccess
+ ? "You don't have permission to add items to annotation queues."
+ : "Annotation queues are loading.",
+ }
+ : undefined,
+ items: queuesAreLoading
+ ? [{ id: "queues-loading", type: "loading" }]
+ : [
+ ...(queues.data?.queues ?? []).map((queue) => ({
+ type: "checkbox" as const,
+ id: queue.id,
+ title: queue.name,
+ checked: Boolean(queue.itemId),
+ closeOnCheckedChange: Boolean(queue.itemId),
+ onCheckedChange: () => {
+ handleQueueItemToggle(
+ queue.id,
+ queue.name,
+ queue.itemId,
+ ).catch(() => undefined);
+ },
+ })),
+ ...((queues.data?.queues.length ?? 0) === 0
+ ? [
+ {
+ id: "no-queues",
+ type: "item" as const,
+ title: "No queues defined",
+ disabled: {
+ reason: "No annotation queues are defined.",
+ },
+ onClick: () => undefined,
+ },
+ ]
+ : []),
+ ...(createQueueDisabled === undefined
+ ? [
+ {
+ id: "queues-separator",
+ type: "separator" as const,
+ },
+ {
+ id: "create-queue",
+ type: "item" as const,
+ title: "Create new queue",
+ icon: PlusIcon,
+ onClick: openQueueDialog,
+ },
+ ]
+ : []),
+ ],
+ },
+ {
+ type: "submenu",
+ id: "dataset",
+ title: "Dataset",
+ icon: Database,
+ search: { placeholder: "Search datasets…" },
+ disabled: !hasDatasetAccess
+ ? {
+ reason: "You don't have permission to add items to datasets.",
+ }
+ : undefined,
+ items: datasets.isLoading
+ ? [{ id: "datasets-loading", type: "loading" }]
+ : [
+ ...(datasets.data ?? []).map((dataset) => ({
+ type: "item" as const,
+ id: dataset.id,
+ title: dataset.name,
+ onClick: () =>
+ openDatasetItemDialog({
+ traceId,
+ observationId,
+ input,
+ output,
+ metadata,
+ datasetId: dataset.id,
+ }),
+ })),
+ ...((datasets.data?.length ?? 0) === 0
+ ? [
+ {
+ id: "no-datasets",
+ type: "item" as const,
+ title: "No datasets defined",
+ disabled: {
+ reason: "No datasets are defined.",
+ },
+ onClick: () => undefined,
+ },
+ ]
+ : []),
+ {
+ id: "datasets-separator",
+ type: "separator" as const,
+ },
+ {
+ type: "item" as const,
+ id: "create-dataset",
+ title: "Create new dataset",
+ icon: PlusIcon,
+ disabled: createDatasetDisabled,
+ onClick: openDatasetDialog,
+ },
+ ],
+ },
+ ];
+
+ const items = [datasetItem, annotationQueueItem];
+
+ if (generation) {
+ items.push({
+ type: "submenu",
+ id: "playground",
+ title: "Playground",
+ icon: Terminal,
+ disabled: playgroundDisabled ? { reason: playgroundTitle } : undefined,
+ items: [
+ {
+ type: "item",
+ id: "fresh-playground",
+ title: "Fresh playground",
+ onClick: () => handlePlaygroundAction("fresh"),
+ },
+ {
+ type: "item",
+ id: "existing-playground",
+ title: "Add to existing",
+ onClick: () => handlePlaygroundAction("existing"),
+ },
+ {
+ type: "separator",
+ id: "playground-separator",
+ },
+ {
+ type: "checkbox",
+ id: "include-output",
+ title: "Include output",
+ checked: includeOutput,
+ onCheckedChange: setIncludeOutput,
+ },
+ ],
+ });
+ }
+
+ return items;
+ }, [
+ createDatasetDisabled,
+ createQueueDisabled,
+ datasets.data,
+ datasets.isLoading,
+ generation,
+ handleQueueItemToggle,
+ hasAnnotationQueueAccess,
+ hasDatasetAccess,
+ input,
+ includeOutput,
+ metadata,
+ observationId,
+ openDatasetDialog,
+ openDatasetItemDialog,
+ openQueueDialog,
+ output,
+ handlePlaygroundAction,
+ playgroundDisabled,
+ playgroundTitle,
+ queues.data?.queues,
+ queuesAreLoading,
+ setIncludeOutput,
+ traceId,
+ ]);
+
+ return (
+ <DropdownMenu items={items} maxHeight="24rem" placement="bottom-start">
+ {children}
+ </DropdownMenu>
+ );
+}
diff --git a/web/src/features/traces/components/DetailHeaderActionsMenuController.stories.tsx b/web/src/features/traces/components/DetailHeaderActionsMenuController.stories.tsx
index c0a7ce652b..1b95e17ea3 100644
--- a/web/src/features/traces/components/DetailHeaderActionsMenuController.stories.tsx
+++ b/web/src/features/traces/components/DetailHeaderActionsMenuController.stories.tsx
@@ -8,19 +8,19 @@ function DetailHeaderActionsMenuStory() {
return (
<DetailHeaderActionsMenuController
idItems={[{ id: "storybook-trace", name: "Trace ID" }]}
+ isAdmin={false}
projectId="storybook-project"
>
- {({ Trigger }) => (
- <Trigger asChild>
- <Button
- aria-label="Options"
- size="icon-xs"
- title="Options"
- variant="ghost"
- >
- <EllipsisVertical className="h-4 w-4" />
- </Button>
- </Trigger>
+ {({ getTriggerProps }) => (
+ <Button
+ aria-label="Options"
+ size="icon-xs"
+ title="Options"
+ variant="ghost"
+ {...getTriggerProps()}
+ >
+ <EllipsisVertical className="h-4 w-4" />
+ </Button>
)}
</DetailHeaderActionsMenuController>
);
diff --git a/web/src/features/traces/components/DetailHeaderActionsMenuController.tsx b/web/src/features/traces/components/DetailHeaderActionsMenuController.tsx
index 3768c02f21..fc0abc8e84 100644
--- a/web/src/features/traces/components/DetailHeaderActionsMenuController.tsx
+++ b/web/src/features/traces/components/DetailHeaderActionsMenuController.tsx
@@ -1,22 +1,18 @@
import { useRouter } from "next/router";
import { useSession } from "next-auth/react";
-import { CheckIcon, CopyIcon } from "lucide-react";
+import { CheckIcon, CopyIcon, Webhook } from "lucide-react";
import { useState, type ComponentProps, type ReactNode } from "react";
import {
- DropdownMenuItem,
- DropdownMenuSeparator,
- DropdownMenuController,
-} from "@/src/components/ui/dropdown-menu";
+ DropdownMenu,
+ type DropdownMenuItemDefinition,
+} from "@/src/components/design-system/DropdownMenu/DropdownMenu";
import {
buildEventsTablePathForObservationType,
buildEventsTablePathForSpanName,
} from "@/src/features/events";
import { copyTextToClipboard } from "@/src/utils/clipboard";
import { type ObservationType } from "@langfuse/shared";
-import {
- useWebCalloutAction,
- WebCalloutMenuItem,
-} from "@/src/features/web-callouts";
+import { useWebCalloutAction } from "@/src/features/web-callouts";
type IdItem = {
name: string;
@@ -25,6 +21,7 @@ type IdItem = {
type DetailHeaderActionsMenuControllerProps = {
idItems: IdItem[];
+ isAdmin: boolean;
observationType?: ObservationType;
projectId: string;
observation?: {
@@ -33,12 +30,19 @@ type DetailHeaderActionsMenuControllerProps = {
startTime: Date;
};
spanName?: string;
+ webCalloutAction?: ReturnType<typeof useWebCalloutAction>;
+ children: ComponentProps<typeof DropdownMenu>["children"];
+};
+
+type ConnectedDetailHeaderActionsMenuControllerProps = Omit<
+ DetailHeaderActionsMenuControllerProps,
+ "isAdmin" | "webCalloutAction"
+> & {
webCallout?: {
traceId: string | null;
observationId?: string | null;
sessionId?: string | null;
};
- children: ComponentProps<typeof DropdownMenuController>["children"];
};
function buildObservationClickHouseQuery(
@@ -68,16 +72,45 @@ ORDER BY event_ts DESC
LIMIT 1;`;
}
+export function ConnectedDetailHeaderActionsMenuController({
+ webCallout,
+ ...props
+}: ConnectedDetailHeaderActionsMenuControllerProps) {
+ const session = useSession();
+ const isAdmin = session.data?.user?.admin === true;
+
+ if (!webCallout) {
+ return <DetailHeaderActionsMenuController {...props} isAdmin={isAdmin} />;
+ }
+
+ return (
+ <WebCalloutActionController
+ projectId={props.projectId}
+ webCallout={webCallout}
+ >
+ {(webCalloutAction) => (
+ <DetailHeaderActionsMenuController
+ {...props}
+ isAdmin={isAdmin}
+ webCalloutAction={webCalloutAction}
+ />
+ )}
+ </WebCalloutActionController>
+ );
+}
+
function WebCalloutActionController({
projectId,
webCallout,
children,
}: {
projectId: string;
- webCallout: NonNullable<DetailHeaderActionsMenuControllerProps["webCallout"]>;
+ webCallout: NonNullable<
+ ConnectedDetailHeaderActionsMenuControllerProps["webCallout"]
+ >;
children: (action: ReturnType<typeof useWebCalloutAction>) => ReactNode;
}) {
- const webCalloutAction = useWebCalloutAction(
+ const action = useWebCalloutAction(
{
projectId,
traceId: webCallout.traceId,
@@ -87,24 +120,24 @@ function WebCalloutActionController({
true,
);
- return children(webCalloutAction);
+ return children(action);
}
export function DetailHeaderActionsMenuController({
idItems,
+ isAdmin,
observationType,
projectId,
observation,
spanName,
- webCallout,
children,
+ webCalloutAction,
}: DetailHeaderActionsMenuControllerProps) {
const router = useRouter();
- const session = useSession();
const [copiedId, setCopiedId] = useState<string | null>(null);
const clickHouseQuery =
- session.data?.user?.admin === true && observation
+ isAdmin && observation
? buildObservationClickHouseQuery(projectId, observation)
: null;
@@ -134,85 +167,74 @@ export function DetailHeaderActionsMenuController({
const filterTypeLabel = observationType ? `type:${observationType}` : null;
+ const items: DropdownMenuItemDefinition[] = [
+ ...(webCalloutAction
+ ? [
+ {
+ type: "item" as const,
+ id: "web-callout",
+ title: `Call ${webCalloutAction.endpointName}`,
+ icon: Webhook,
+ disabled: webCalloutAction.isLoading
+ ? { reason: "Web callout is running" }
+ : undefined,
+ onClick: () => {
+ webCalloutAction.invokeCallout().catch(() => undefined);
+ },
+ },
+ { id: "web-callout-separator", type: "separator" as const },
+ ]
+ : []),
+ ...(href
+ ? [
+ {
+ type: "item" as const,
+ id: "filter-by-name",
+ title: `Filter by name:${spanName}`,
+ onClick: () => {
+ router.push(href).catch(() => undefined);
+ },
+ },
+ ]
+ : []),
+ ...(typeHref && filterTypeLabel
+ ? [
+ {
+ type: "item" as const,
+ id: "filter-by-type",
+ title: `Filter by ${filterTypeLabel}`,
+ onClick: () => {
+ router.push(typeHref).catch(() => undefined);
+ },
+ },
+ ]
+ : []),
+ ...(href || typeHref
+ ? [{ id: "filter-separator", type: "separator" as const }]
+ : []),
+ ...idItems.map((item) => ({
+ type: "item" as const,
+ id: `copy-${item.name}`,
+ title: `Copy ${item.name}`,
+ icon: copiedId === item.id ? CheckIcon : CopyIcon,
+ onClick: () => handleCopy(item.id),
+ })),
+ ...(clickHouseQuery
+ ? [
+ {
+ type: "item" as const,
+ id: "copy-clickhouse-query",
+ title: "Copy ClickHouse query",
+ icon: copiedId === clickHouseQuery ? CheckIcon : CopyIcon,
+ onClick: () => handleCopy(clickHouseQuery),
+ },
+ ]
+ : []),
+ ];
+
return (
- <DropdownMenuController
- align="start"
- renderMenu={() => (
- <>
- {webCallout && (
- <WebCalloutActionController
- projectId={projectId}
- webCallout={webCallout}
- >
- {(webCalloutAction) =>
- webCalloutAction ? (
- <WebCalloutMenuItem action={webCalloutAction} withSeparator />
- ) : null
- }
- </WebCalloutActionController>
- )}
- {(href || typeHref) && (
- <>
- {href && (
- <DropdownMenuItem
- className="text-xs"
- onSelect={() => router.push(href)}
- >
- <span className="max-w-[260px] truncate" title={spanName}>
- filter by <span className="font-bold">name:{spanName}</span>
- </span>
- </DropdownMenuItem>
- )}
- {typeHref && filterTypeLabel && (
- <DropdownMenuItem
- className="text-xs"
- onSelect={() => router.push(typeHref)}
- >
- <span
- className="max-w-[260px] truncate"
- title={filterTypeLabel}
- >
- filter by{" "}
- <span className="font-bold">{filterTypeLabel}</span>
- </span>
- </DropdownMenuItem>
- )}
- <DropdownMenuSeparator />
- </>
- )}
- {idItems.map((item) => (
- <DropdownMenuItem
- key={item.id}
- className="text-xs"
- onSelect={() => handleCopy(item.id)}
- >
- {copiedId === item.id ? (
- <CheckIcon className="text-muted-green mr-2 h-4 w-4" />
- ) : (
- <CopyIcon className="mr-2 h-4 w-4" />
- )}
- <span className="max-w-[260px] truncate" title={item.id}>
- Copy {item.name}
- </span>
- </DropdownMenuItem>
- ))}
- {clickHouseQuery && (
- <DropdownMenuItem
- className="text-xs"
- onSelect={() => handleCopy(clickHouseQuery)}
- >
- {copiedId === clickHouseQuery ? (
- <CheckIcon className="text-muted-green mr-2 h-4 w-4" />
- ) : (
- <CopyIcon className="mr-2 h-4 w-4" />
- )}
- Copy ClickHouse query
- </DropdownMenuItem>
- )}
- </>
- )}
- >
+ <DropdownMenu items={items} placement="bottom-end">
{children}
- </DropdownMenuController>
+ </DropdownMenu>
);
}
diff --git a/web/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader/ObservationDetailViewHeader.tsx b/web/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader/ObservationDetailViewHeader.tsx
index e1ad1a71ee..ada16bfdcd 100644
--- a/web/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader/ObservationDetailViewHeader.tsx
+++ b/web/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader/ObservationDetailViewHeader.tsx
@@ -1,10 +1,9 @@
-/* eslint-disable no-nested-ternary */
/**
* ObservationDetailViewHeader - Extracted header component for ObservationDetailView
*
* Contains:
* - Title row with ItemBadge, observation name, options menu
- * - Action buttons (Dataset, Annotate, Queue, Playground, Comments)
+ * - Action buttons (Add to, Score, Comment)
* - Metadata badges (timestamp, latency, environment, cost, usage, model, etc.)
*
* Memoized to prevent unnecessary re-renders when tab state changes.
@@ -13,27 +12,17 @@
import { memo, useMemo } from "react";
import {
type ObservationType,
- AnnotationQueueObjectType,
isGenerationLike,
LangfuseInternalTraceEnvironment,
type ScoreDomain,
} from "@langfuse/shared";
import { type ObservationReturnTypeWithMetadata } from "@/src/server/api/routers/traces";
import { ItemBadge } from "@/src/components/ItemBadge";
-import {
- ExistingDatasetItemsDropdownMenuController,
- NewDatasetItemFromExistingObjectDialogController,
- useDatasetItemFromTraceOrObservation,
-} from "@/src/features/datasets";
import {
AnnotateDrawerController,
DualAnnotationContent,
} from "@/src/features/scores";
-import {
- AnnotationQueueItemDropdownMenuController,
- AnnotationQueueItemCountBadge,
-} from "@/src/features/annotation-queues";
-import { JumpToPlaygroundDropdownMenuController } from "@/src/features/playground";
+import { ConnectedTraceObservationAddToDropdownMenuController } from "@/src/features/traces/components/ConnectedTraceObservationAddToDropdownMenuController";
import { PromptBadge } from "@/src/features/traces/components/PromptBadge";
import {
LatencyBadge,
@@ -53,7 +42,7 @@ import {
} from "@/src/utils/clientSideDomainTypes";
import { type AggregatedTraceMetrics } from "@/src/features/traces/fns/traceAggregation";
import type Decimal from "decimal.js";
-import { DetailHeaderActionsMenuController } from "@/src/features/traces/components/DetailHeaderActionsMenuController";
+import { ConnectedDetailHeaderActionsMenuController } from "@/src/features/traces/components/DetailHeaderActionsMenuController";
import { useViewPreferences } from "@/src/features/traces/contexts/ViewPreferencesContext";
import { useReadPath } from "@/src/features/events";
import { useTraceData } from "@/src/features/traces/contexts/TraceDataContext";
@@ -62,14 +51,12 @@ import { ActionButtonCountBadge } from "@/src/components/ui/action-button-count-
import {
ChevronDown,
EllipsisVertical,
- ListPlus,
LockIcon,
MessageSquare,
MessageSquareOff,
MoreHorizontal,
PlusIcon,
SquarePen,
- Terminal,
} from "lucide-react";
import {
Drawer,
@@ -141,19 +128,6 @@ export const ObservationDetailViewHeader = memo(
projectId,
scope: "scores:CUD",
});
- const {
- existingDatasetItems,
- hasAccess: hasDatasetAccess,
- captureNewDatasetItemFormOpen,
- } = useDatasetItemFromTraceOrObservation({
- projectId,
- traceId,
- observationId: observation.id,
- enabled: Boolean(observationWithIO),
- });
- const datasetCount = existingDatasetItems.length;
- const hasExistingDatasetItems = datasetCount > 0;
-
// Format cost and usage values
const totalCost = observation.totalCost;
const totalUsage = observation.totalUsage;
@@ -212,7 +186,7 @@ export const ObservationDetailViewHeader = memo(
return (
<div className="@container shrink-0 space-y-2 border-b p-2">
{/* Title row with actions */}
- <div className="grid w-full grid-cols-1 items-start gap-2 @2xl:grid-cols-[auto_auto] @2xl:justify-between">
+ <div className="grid w-full grid-cols-1 items-start gap-2 @2xl:grid-cols-[minmax(0,1fr)_auto]">
<div className="flex w-full min-w-0 flex-row items-center gap-1">
<ItemBadge type={observation.type as ObservationType} isSmall />
<span
@@ -224,43 +198,6 @@ export const ObservationDetailViewHeader = memo(
>
{observation.name || observation.id}
</span>
- <DetailHeaderActionsMenuController
- idItems={[
- { id: traceId, name: "Trace ID" },
- { id: observation.id, name: "Observation ID" },
- ]}
- observationType={observation.type}
- projectId={projectId}
- observation={
- isV4Enabled
- ? {
- id: observation.id,
- traceId,
- startTime: observation.startTime,
- }
- : undefined
- }
- spanName={observation.name ?? ""}
- webCallout={{
- traceId,
- observationId: observation.id,
- sessionId: observation.sessionId ?? null,
- }}
- >
- {({ Trigger }) => (
- <Trigger asChild>
- <Button
- aria-label="Options"
- className="mt-0.5 shrink-0"
- size="icon-xs"
- title="Options"
- variant="ghost"
- >
- <EllipsisVertical className="h-4 w-4" />
- </Button>
- </Trigger>
- )}
- </DetailHeaderActionsMenuController>
{/* Mobile: collapse the action-button cluster into a `⋯` overflow of
full-width labeled rows, next to the `â‹®` utility menu. */}
{isMobile && (
@@ -286,72 +223,33 @@ export const ObservationDetailViewHeader = memo(
className="flex w-auto min-w-44 flex-col gap-0.5 p-1 data-[state=closed]:hidden"
>
{observationWithIO && (
- <NewDatasetItemFromExistingObjectDialogController
+ <ConnectedTraceObservationAddToDropdownMenuController
projectId={projectId}
+ traceId={traceId}
+ variant="observation"
+ observationId={observation.id}
+ input={observationWithIO.input}
+ output={observationWithIO.output}
+ metadata={observationWithIO.metadata}
+ generation={
+ isGenerationLike(observationWithIO.type)
+ ? observationWithIO
+ : undefined
+ }
>
- {({ openDialog }) => (
- <ExistingDatasetItemsDropdownMenuController
- projectId={projectId}
- datasetItems={existingDatasetItems}
- disabled={!hasDatasetAccess}
- onOpenDialog={() =>
- openDialog({
- traceId,
- observationId: observation.id,
- input: observationWithIO.input,
- output: observationWithIO.output,
- metadata: observationWithIO.metadata,
- })
- }
+ {({ getTriggerProps }) => (
+ <Button
+ variant="ghost"
+ size="sm"
+ className="w-full justify-start gap-2 font-normal"
+ {...getTriggerProps()}
>
- {({ Anchor, openDropdown }) => (
- <Anchor>
- <Button
- variant="ghost"
- size="sm"
- disabled={!hasDatasetAccess}
- className="w-full justify-start gap-2 font-normal"
- onClick={() => {
- if (hasExistingDatasetItems) {
- openDropdown();
- return;
- }
-
- captureNewDatasetItemFormOpen();
- openDialog({
- traceId,
- observationId: observation.id,
- input: observationWithIO.input,
- output: observationWithIO.output,
- metadata: observationWithIO.metadata,
- });
- }}
- >
- {hasExistingDatasetItems || hasDatasetAccess ? (
- <PlusIcon
- className="h-4 w-4"
- aria-hidden="true"
- />
- ) : null}
- <span className="text-sm">
- {hasExistingDatasetItems
- ? `In ${datasetCount} dataset(s)`
- : "Add to datasets"}
- </span>
- {hasExistingDatasetItems ? (
- <ChevronDown className="ml-auto h-3 w-3" />
- ) : !hasDatasetAccess ? (
- <LockIcon
- className="ml-auto h-3 w-3"
- aria-hidden="true"
- />
- ) : null}
- </Button>
- </Anchor>
- )}
- </ExistingDatasetItemsDropdownMenuController>
+ <PlusIcon className="h-4 w-4" />
+ <span>Add to</span>
+ <ChevronDown className="ml-auto h-3 w-3" />
+ </Button>
)}
- </NewDatasetItemFromExistingObjectDialogController>
+ </ConnectedTraceObservationAddToDropdownMenuController>
)}
{!isAnnotationMode && (
<>
@@ -371,7 +269,7 @@ export const ObservationDetailViewHeader = memo(
) : (
<SquarePen className="h-4 w-4" />
)}
- <span className="text-sm">Annotate</span>
+ <span className="text-sm">Score</span>
</Button>
</DrawerTrigger>
<DrawerContent className="p-3">
@@ -418,66 +316,13 @@ export const ObservationDetailViewHeader = memo(
) : (
<SquarePen className="h-4 w-4" />
)}
- <span className="text-sm">Annotate</span>
+ <span className="text-sm">Score</span>
</Button>
)}
</AnnotateDrawerController>
)}
- <AnnotationQueueItemDropdownMenuController
- projectId={projectId}
- objectId={observation.id}
- objectType={AnnotationQueueObjectType.OBSERVATION}
- >
- {({ disabled, totalCount }) => (
- <Button
- variant="ghost"
- size="sm"
- disabled={disabled !== undefined}
- className="w-full justify-start gap-2 font-normal"
- >
- <ListPlus className="h-4 w-4" />
- <span className="text-sm">Add to queue</span>
- {totalCount > 0 && (
- <AnnotationQueueItemCountBadge
- totalCount={totalCount}
- layout="menu"
- />
- )}
- </Button>
- )}
- </AnnotationQueueItemDropdownMenuController>
</>
)}
- {observationWithIO &&
- isGenerationLike(observationWithIO.type) && (
- <JumpToPlaygroundDropdownMenuController
- source="generation"
- generation={observationWithIO}
- analyticsEventName="trace_detail:test_in_playground_button_click"
- >
- {({ Trigger, disabled, title }) => (
- <Trigger asChild>
- <Button
- variant="ghost"
- size="sm"
- disabled={disabled}
- title={title}
- className={cn(
- "w-full justify-start gap-2 font-normal",
- disabled
- ? "cursor-not-allowed opacity-50"
- : "cursor-pointer",
- )}
- >
- <Terminal className="h-4 w-4" />
- <span className="text-sm">
- Test in playground
- </span>
- </Button>
- </Trigger>
- )}
- </JumpToPlaygroundDropdownMenuController>
- )}
<Button
type="button"
variant="ghost"
@@ -491,7 +336,7 @@ export const ObservationDetailViewHeader = memo(
) : (
<MessageSquare className="h-4 w-4" />
)}
- <span className="text-sm">Add comment</span>
+ <span className="text-sm">Comment</span>
{!commentDrawerControl.disabled && commentCount ? (
<ActionButtonCountBadge count={commentCount} />
) : null}
@@ -499,200 +344,144 @@ export const ObservationDetailViewHeader = memo(
</PopoverContent>
</Popover>
)}
+ {isMobile && (
+ <ConnectedDetailHeaderActionsMenuController
+ idItems={[
+ { id: traceId, name: "Trace ID" },
+ { id: observation.id, name: "Observation ID" },
+ ]}
+ observationType={observation.type}
+ projectId={projectId}
+ observation={
+ isV4Enabled
+ ? {
+ id: observation.id,
+ traceId,
+ startTime: observation.startTime,
+ }
+ : undefined
+ }
+ spanName={observation.name ?? ""}
+ webCallout={{
+ traceId,
+ observationId: observation.id,
+ sessionId: observation.sessionId ?? null,
+ }}
+ >
+ {({ getTriggerProps }) => (
+ <Button
+ aria-label="Options"
+ className="shrink-0"
+ size="icon"
+ title="Options"
+ variant="secondary"
+ {...getTriggerProps()}
+ >
+ <EllipsisVertical className="h-4 w-4" />
+ </Button>
+ )}
+ </ConnectedDetailHeaderActionsMenuController>
+ )}
</div>
{/* Action buttons (desktop inline cluster) */}
{!isMobile && (
<div className="flex h-full flex-wrap content-start items-start justify-start gap-0.5 @2xl:mr-1 @2xl:justify-end">
{observationWithIO && (
- <NewDatasetItemFromExistingObjectDialogController
+ <ConnectedTraceObservationAddToDropdownMenuController
projectId={projectId}
key={observation.id}
+ traceId={traceId}
+ variant="observation"
+ observationId={observation.id}
+ input={observationWithIO.input}
+ output={observationWithIO.output}
+ metadata={observationWithIO.metadata}
+ generation={
+ isGenerationLike(observationWithIO.type)
+ ? observationWithIO
+ : undefined
+ }
>
- {({ openDialog }) => (
- <ExistingDatasetItemsDropdownMenuController
- projectId={projectId}
- datasetItems={existingDatasetItems}
- disabled={!hasDatasetAccess}
- onOpenDialog={() =>
- openDialog({
- traceId,
- observationId: observation.id,
- input: observationWithIO.input,
- output: observationWithIO.output,
- metadata: observationWithIO.metadata,
- })
- }
+ {({ getTriggerProps }) => (
+ <Button
+ variant="secondary"
+ size="sm"
+ className="gap-1"
+ {...getTriggerProps()}
>
- {({ Anchor, openDropdown }) => (
- <Anchor>
- <Button
- variant="secondary"
- size="sm"
- disabled={!hasDatasetAccess}
- onClick={() => {
- if (hasExistingDatasetItems) {
- openDropdown();
- return;
- }
-
- captureNewDatasetItemFormOpen();
- openDialog({
- traceId,
- observationId: observation.id,
- input: observationWithIO.input,
- output: observationWithIO.output,
- metadata: observationWithIO.metadata,
- });
- }}
- >
- {!hasExistingDatasetItems && hasDatasetAccess ? (
- <PlusIcon
- className="mr-1.5 -ml-0.5 h-3.5 w-3.5"
- aria-hidden="true"
- />
- ) : null}
- {hasExistingDatasetItems
- ? `In ${datasetCount} dataset(s)`
- : "Add to datasets"}
- {hasExistingDatasetItems ? (
- <ChevronDown className="ml-2 h-3 w-3" />
- ) : !hasDatasetAccess ? (
- <LockIcon
- className="ml-1.5 h-3 w-3"
- aria-hidden="true"
- />
- ) : null}
- </Button>
- </Anchor>
- )}
- </ExistingDatasetItemsDropdownMenuController>
+ <PlusIcon className="h-3.5 w-3.5" />
+ <span>Add to</span>
+ <ChevronDown className="h-3 w-3" />
+ </Button>
)}
- </NewDatasetItemFromExistingObjectDialogController>
+ </ConnectedTraceObservationAddToDropdownMenuController>
)}
{/* Hide annotation buttons in annotation mode (panel shown separately) */}
- {!isAnnotationMode && (
- <div className="flex items-start">
- {isV4Enabled ? (
- <Drawer key={"annotation-drawer-" + observation.id}>
- <DrawerTrigger asChild>
- <Button
- variant="secondary"
- size="sm"
- disabled={!hasAnnotationAccess}
- className="rounded-r-none"
- >
- {!hasAnnotationAccess ? (
- <LockIcon className="mr-1.5 h-3 w-3" />
- ) : (
- <SquarePen className="mr-1.5 h-3.5 w-3.5" />
- )}
- <span>Annotate</span>
- </Button>
- </DrawerTrigger>
- <DrawerContent className="p-3">
- <DualAnnotationContent
- projectId={projectId}
- traceId={traceId}
- observationId={observation.id}
- traceEnvironment={trace.environment}
- observationEnvironment={observation.environment}
- observationScores={observationScores}
- traceScores={traceScores}
- />
- </DrawerContent>
- </Drawer>
- ) : (
- <AnnotateDrawerController projectId={projectId}>
- {({ disabled, openDrawer }) => (
- <Button
- variant="secondary"
- size="sm"
- disabled={disabled}
- className="rounded-r-none"
- onClick={() =>
- openDrawer({
- scoreTarget: {
- type: "trace",
- traceId,
- observationId: observation.id,
- },
- scores: observationScores,
- analyticsData: {
- type: "trace",
- source: "TraceDetail",
- },
- scoreMetadata: {
- projectId,
- environment: observation.environment,
- },
- })
- }
- >
- {disabled ? (
- <LockIcon className="mr-1.5 h-3 w-3" />
- ) : (
- <SquarePen className="mr-1.5 h-3.5 w-3.5" />
- )}
- <span>Annotate</span>
- </Button>
- )}
- </AnnotateDrawerController>
- )}
- <AnnotationQueueItemDropdownMenuController
- projectId={projectId}
- objectId={observation.id}
- objectType={AnnotationQueueObjectType.OBSERVATION}
- >
- {({ disabled, totalCount }) => (
+ {!isAnnotationMode &&
+ (isV4Enabled ? (
+ <Drawer key={"annotation-drawer-" + observation.id}>
+ <DrawerTrigger asChild>
<Button
variant="secondary"
size="sm"
- disabled={disabled !== undefined}
- className="rounded-l-none rounded-r-md border-l-2"
+ disabled={!hasAnnotationAccess}
>
- <span className="relative mr-1 text-xs">
- <ChevronDown className="h-3 w-3" />
- {totalCount > 0 && (
- <AnnotationQueueItemCountBadge
- totalCount={totalCount}
- layout="toolbar"
- />
- )}
- </span>
+ {!hasAnnotationAccess ? (
+ <LockIcon className="mr-1.5 h-3 w-3" />
+ ) : (
+ <SquarePen className="mr-1.5 h-3.5 w-3.5" />
+ )}
+ <span>Score</span>
+ </Button>
+ </DrawerTrigger>
+ <DrawerContent className="p-3">
+ <DualAnnotationContent
+ projectId={projectId}
+ traceId={traceId}
+ observationId={observation.id}
+ traceEnvironment={trace.environment}
+ observationEnvironment={observation.environment}
+ observationScores={observationScores}
+ traceScores={traceScores}
+ />
+ </DrawerContent>
+ </Drawer>
+ ) : (
+ <AnnotateDrawerController projectId={projectId}>
+ {({ disabled, openDrawer }) => (
+ <Button
+ variant="secondary"
+ size="sm"
+ disabled={disabled}
+ onClick={() =>
+ openDrawer({
+ scoreTarget: {
+ type: "trace",
+ traceId,
+ observationId: observation.id,
+ },
+ scores: observationScores,
+ analyticsData: {
+ type: "trace",
+ source: "TraceDetail",
+ },
+ scoreMetadata: {
+ projectId,
+ environment: observation.environment,
+ },
+ })
+ }
+ >
+ {disabled ? (
+ <LockIcon className="mr-1.5 h-3 w-3" />
+ ) : (
+ <SquarePen className="mr-1.5 h-3.5 w-3.5" />
+ )}
+ <span>Score</span>
</Button>
)}
- </AnnotationQueueItemDropdownMenuController>
- </div>
- )}
- {observationWithIO &&
- isGenerationLike(observationWithIO.type) && (
- <JumpToPlaygroundDropdownMenuController
- source="generation"
- generation={observationWithIO}
- analyticsEventName="trace_detail:test_in_playground_button_click"
- >
- {({ Trigger, disabled, title }) => (
- <Trigger asChild>
- <Button
- variant="secondary"
- size="sm"
- disabled={disabled}
- title={title}
- className={cn(
- "flex items-center gap-1",
- disabled
- ? "cursor-not-allowed opacity-50"
- : "cursor-pointer",
- )}
- >
- <Terminal className="h-3.5 w-3.5" />
- <span className="hidden md:inline">Playground</span>
- <ChevronDown className="h-3 w-3" />
- </Button>
- </Trigger>
- )}
- </JumpToPlaygroundDropdownMenuController>
- )}
+ </AnnotateDrawerController>
+ ))}
<Button
type="button"
variant="secondary"
@@ -706,13 +495,49 @@ export const ObservationDetailViewHeader = memo(
) : (
<>
<MessageSquare className="h-3.5 w-3.5" />
- <span>Add comment</span>
+ <span>Comment</span>
{!!commentCount ? (
<ActionButtonCountBadge count={commentCount} />
) : null}
</>
)}
</Button>
+ <ConnectedDetailHeaderActionsMenuController
+ idItems={[
+ { id: traceId, name: "Trace ID" },
+ { id: observation.id, name: "Observation ID" },
+ ]}
+ observationType={observation.type}
+ projectId={projectId}
+ observation={
+ isV4Enabled
+ ? {
+ id: observation.id,
+ traceId,
+ startTime: observation.startTime,
+ }
+ : undefined
+ }
+ spanName={observation.name ?? ""}
+ webCallout={{
+ traceId,
+ observationId: observation.id,
+ sessionId: observation.sessionId ?? null,
+ }}
+ >
+ {({ getTriggerProps }) => (
+ <Button
+ aria-label="Options"
+ className="shrink-0"
+ size="icon-sm"
+ title="Options"
+ variant="secondary"
+ {...getTriggerProps()}
+ >
+ <EllipsisVertical className="h-4 w-4" />
+ </Button>
+ )}
+ </ConnectedDetailHeaderActionsMenuController>
</div>
)}
</div>
diff --git a/web/src/features/traces/components/TraceDetailView/components/TraceDetailViewHeader.tsx b/web/src/features/traces/components/TraceDetailView/components/TraceDetailViewHeader.tsx
index d0aa7b682d..f4ae881ae9 100644
--- a/web/src/features/traces/components/TraceDetailView/components/TraceDetailViewHeader.tsx
+++ b/web/src/features/traces/components/TraceDetailView/components/TraceDetailViewHeader.tsx
@@ -1,10 +1,9 @@
-/* eslint-disable no-nested-ternary */
/**
* TraceDetailViewHeader - Extracted header component for TraceDetailView
*
* Contains:
* - Title row with ItemBadge, trace name, options menu
- * - Action buttons (Dataset, Annotate, Queue, Comments)
+ * - Action buttons (Add to, Score, Comment)
* - Metadata badges (timestamp, environment, release, version, target trace)
* - Trace-level score chips
*
@@ -15,23 +14,14 @@ import { memo } from "react";
import {
type TraceDomain,
type ScoreDomain,
- AnnotationQueueObjectType,
LangfuseInternalTraceEnvironment,
} from "@langfuse/shared";
import { type WithStringifiedMetadata } from "@/src/utils/clientSideDomainTypes";
import { ItemBadge } from "@/src/components/ItemBadge";
-import { DetailHeaderActionsMenuController } from "@/src/features/traces/components/DetailHeaderActionsMenuController";
-import {
- ExistingDatasetItemsDropdownMenuController,
- NewDatasetItemFromExistingObjectDialogController,
- useDatasetItemFromTraceOrObservation,
-} from "@/src/features/datasets";
+import { ConnectedDetailHeaderActionsMenuController } from "@/src/features/traces/components/DetailHeaderActionsMenuController";
import { AnnotateDrawerController } from "@/src/features/scores";
import { ActionButtonCountBadge } from "@/src/components/ui/action-button-count-badge";
-import {
- AnnotationQueueItemDropdownMenuController,
- AnnotationQueueItemCountBadge,
-} from "@/src/features/annotation-queues";
+import { ConnectedTraceObservationAddToDropdownMenuController } from "@/src/features/traces/components/ConnectedTraceObservationAddToDropdownMenuController";
import {
EnvironmentBadge,
ReleaseBadge,
@@ -46,7 +36,6 @@ import { Button } from "@/src/components/ui/button";
import {
ChevronDown,
EllipsisVertical,
- ListPlus,
LockIcon,
MessageSquare,
MessageSquareOff,
@@ -88,17 +77,6 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({
}: TraceDetailViewHeaderProps) {
const { isAnnotationMode } = useViewPreferences();
const isMobile = useIsMobile();
- const {
- existingDatasetItems,
- hasAccess: hasDatasetAccess,
- captureNewDatasetItemFormOpen,
- } = useDatasetItemFromTraceOrObservation({
- projectId,
- traceId: trace.id,
- });
- const datasetCount = existingDatasetItems.length;
- const hasExistingDatasetItems = datasetCount > 0;
-
const targetTraceId =
trace.environment === LangfuseInternalTraceEnvironment.LLMJudge
? resolveEvalExecutionMetadata(parsedMetadata)
@@ -121,7 +99,7 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({
>
{trace.name || trace.id}
</span>
- <DetailHeaderActionsMenuController
+ <ConnectedDetailHeaderActionsMenuController
idItems={[{ id: trace.id, name: "Trace ID" }]}
projectId={projectId}
webCallout={{
@@ -129,20 +107,19 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({
sessionId: trace.sessionId ?? null,
}}
>
- {({ Trigger }) => (
- <Trigger asChild>
- <Button
- aria-label="Options"
- className="mt-0.5 shrink-0"
- size="icon-xs"
- title="Options"
- variant="ghost"
- >
- <EllipsisVertical className="h-4 w-4" />
- </Button>
- </Trigger>
+ {({ getTriggerProps }) => (
+ <Button
+ aria-label="Options"
+ className="mt-0.5 shrink-0"
+ size="icon-xs"
+ title="Options"
+ variant="ghost"
+ {...getTriggerProps()}
+ >
+ <EllipsisVertical className="h-4 w-4" />
+ </Button>
)}
- </DetailHeaderActionsMenuController>
+ </ConnectedDetailHeaderActionsMenuController>
{/* Mobile: collapse the action-button cluster into a `⋯` overflow of
full-width labeled rows, next to the `â‹®` utility menu. */}
{isMobile && (
@@ -167,70 +144,27 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({
forceMount
className="flex w-auto min-w-44 flex-col gap-0.5 p-1 data-[state=closed]:hidden"
>
- <NewDatasetItemFromExistingObjectDialogController
+ <ConnectedTraceObservationAddToDropdownMenuController
projectId={projectId}
+ traceId={trace.id}
+ variant="trace"
+ input={trace.input}
+ output={trace.output}
+ metadata={trace.metadata}
>
- {({ openDialog }) => (
- <ExistingDatasetItemsDropdownMenuController
- projectId={projectId}
- datasetItems={existingDatasetItems}
- disabled={!hasDatasetAccess}
- onOpenDialog={() =>
- openDialog({
- traceId: trace.id,
- input: trace.input,
- output: trace.output,
- metadata: trace.metadata,
- })
- }
+ {({ getTriggerProps }) => (
+ <Button
+ variant="ghost"
+ size="sm"
+ className="w-full justify-start gap-2 font-normal"
+ {...getTriggerProps()}
>
- {({ Anchor, openDropdown }) => (
- <Anchor>
- <Button
- variant="ghost"
- size="sm"
- disabled={!hasDatasetAccess}
- className="w-full justify-start gap-2 font-normal"
- onClick={() => {
- if (hasExistingDatasetItems) {
- openDropdown();
- return;
- }
-
- captureNewDatasetItemFormOpen();
- openDialog({
- traceId: trace.id,
- input: trace.input,
- output: trace.output,
- metadata: trace.metadata,
- });
- }}
- >
- {hasExistingDatasetItems || hasDatasetAccess ? (
- <PlusIcon
- className="h-4 w-4"
- aria-hidden="true"
- />
- ) : null}
- <span className="text-sm">
- {hasExistingDatasetItems
- ? `In ${datasetCount} dataset(s)`
- : "Add to datasets"}
- </span>
- {hasExistingDatasetItems ? (
- <ChevronDown className="ml-auto h-3 w-3" />
- ) : !hasDatasetAccess ? (
- <LockIcon
- className="ml-auto h-3 w-3"
- aria-hidden="true"
- />
- ) : null}
- </Button>
- </Anchor>
- )}
- </ExistingDatasetItemsDropdownMenuController>
+ <PlusIcon className="h-4 w-4" />
+ <span>Add to</span>
+ <ChevronDown className="ml-auto h-3 w-3" />
+ </Button>
)}
- </NewDatasetItemFromExistingObjectDialogController>
+ </ConnectedTraceObservationAddToDropdownMenuController>
{!isAnnotationMode && (
<>
<AnnotateDrawerController projectId={projectId}>
@@ -263,33 +197,10 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({
) : (
<SquarePen className="h-4 w-4" />
)}
- <span className="text-sm">Annotate</span>
+ <span className="text-sm">Score</span>
</Button>
)}
</AnnotateDrawerController>
- <AnnotationQueueItemDropdownMenuController
- projectId={projectId}
- objectId={trace.id}
- objectType={AnnotationQueueObjectType.TRACE}
- >
- {({ disabled, totalCount }) => (
- <Button
- variant="ghost"
- size="sm"
- disabled={disabled !== undefined}
- className="w-full justify-start gap-2 font-normal"
- >
- <ListPlus className="h-4 w-4" />
- <span className="text-sm">Add to queue</span>
- {totalCount > 0 && (
- <AnnotationQueueItemCountBadge
- totalCount={totalCount}
- layout="menu"
- />
- )}
- </Button>
- )}
- </AnnotationQueueItemDropdownMenuController>
</>
)}
<Button
@@ -305,7 +216,7 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({
) : (
<MessageSquare className="h-4 w-4" />
)}
- <span className="text-sm">Add comment</span>
+ <span className="text-sm">Comment</span>
{!commentDrawerControl.disabled && commentCount ? (
<ActionButtonCountBadge count={commentCount} />
) : null}
@@ -317,130 +228,62 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({
{/* Action buttons (desktop inline cluster) */}
{!isMobile && (
<div className="flex h-full flex-wrap content-start items-start justify-start gap-0.5 @2xl:mr-1 @2xl:justify-end">
- <NewDatasetItemFromExistingObjectDialogController
+ <ConnectedTraceObservationAddToDropdownMenuController
projectId={projectId}
- key={trace.id}
+ traceId={trace.id}
+ variant="trace"
+ input={trace.input}
+ output={trace.output}
+ metadata={trace.metadata}
>
- {({ openDialog }) => (
- <ExistingDatasetItemsDropdownMenuController
- projectId={projectId}
- datasetItems={existingDatasetItems}
- disabled={!hasDatasetAccess}
- onOpenDialog={() =>
- openDialog({
- traceId: trace.id,
- input: trace.input,
- output: trace.output,
- metadata: trace.metadata,
- })
- }
+ {({ getTriggerProps }) => (
+ <Button
+ variant="secondary"
+ size="sm"
+ className="gap-1"
+ {...getTriggerProps()}
>
- {({ Anchor, openDropdown }) => (
- <Anchor>
- <Button
- variant="secondary"
- size="sm"
- disabled={!hasDatasetAccess}
- onClick={() => {
- if (hasExistingDatasetItems) {
- openDropdown();
- return;
- }
-
- captureNewDatasetItemFormOpen();
- openDialog({
- traceId: trace.id,
- input: trace.input,
- output: trace.output,
- metadata: trace.metadata,
- });
- }}
- >
- {!hasExistingDatasetItems && hasDatasetAccess ? (
- <PlusIcon
- className="mr-1.5 -ml-0.5 h-3.5 w-3.5"
- aria-hidden="true"
- />
- ) : null}
- {hasExistingDatasetItems
- ? `In ${datasetCount} dataset(s)`
- : "Add to datasets"}
- {hasExistingDatasetItems ? (
- <ChevronDown className="ml-2 h-3 w-3" />
- ) : !hasDatasetAccess ? (
- <LockIcon
- className="ml-1.5 h-3 w-3"
- aria-hidden="true"
- />
- ) : null}
- </Button>
- </Anchor>
- )}
- </ExistingDatasetItemsDropdownMenuController>
+ <PlusIcon className="h-3.5 w-3.5" />
+ <span>Add to</span>
+ <ChevronDown className="h-3 w-3" />
+ </Button>
)}
- </NewDatasetItemFromExistingObjectDialogController>
+ </ConnectedTraceObservationAddToDropdownMenuController>
{/* Hide annotation buttons in annotation mode (panel shown separately) */}
{!isAnnotationMode && (
- <div className="flex items-start">
- <AnnotateDrawerController projectId={projectId}>
- {({ disabled, openDrawer }) => (
- <Button
- variant="secondary"
- size="sm"
- disabled={disabled}
- className="rounded-r-none"
- onClick={() =>
- openDrawer({
- scoreTarget: {
- type: "trace",
- traceId: trace.id,
- },
- scores: traceScores,
- analyticsData: {
- type: "trace",
- source: "TraceDetail",
- },
- scoreMetadata: {
- projectId,
- environment: trace.environment,
- },
- })
- }
- >
- {disabled ? (
- <LockIcon className="mr-1.5 h-3 w-3" />
- ) : (
- <SquarePen className="mr-1.5 h-3.5 w-3.5" />
- )}
- <span>Annotate</span>
- </Button>
- )}
- </AnnotateDrawerController>
- <AnnotationQueueItemDropdownMenuController
- projectId={projectId}
- objectId={trace.id}
- objectType={AnnotationQueueObjectType.TRACE}
- >
- {({ disabled, totalCount }) => (
- <Button
- variant="secondary"
- size="sm"
- disabled={disabled !== undefined}
- className="rounded-l-none rounded-r-md border-l-2"
- >
- <span className="relative mr-1 text-xs">
- <ChevronDown className="h-3 w-3" />
- {totalCount > 0 && (
- <AnnotationQueueItemCountBadge
- totalCount={totalCount}
- layout="toolbar"
- />
- )}
- </span>
- </Button>
- )}
- </AnnotationQueueItemDropdownMenuController>
- </div>
+ <AnnotateDrawerController projectId={projectId}>
+ {({ disabled, openDrawer }) => (
+ <Button
+ variant="secondary"
+ size="sm"
+ disabled={disabled}
+ onClick={() =>
+ openDrawer({
+ scoreTarget: {
+ type: "trace",
+ traceId: trace.id,
+ },
+ scores: traceScores,
+ analyticsData: {
+ type: "trace",
+ source: "TraceDetail",
+ },
+ scoreMetadata: {
+ projectId,
+ environment: trace.environment,
+ },
+ })
+ }
+ >
+ {disabled ? (
+ <LockIcon className="mr-1.5 h-3 w-3" />
+ ) : (
+ <SquarePen className="mr-1.5 h-3.5 w-3.5" />
+ )}
+ <span>Score</span>
+ </Button>
+ )}
+ </AnnotateDrawerController>
)}
<Button
type="button"
@@ -455,7 +298,7 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({
) : (
<>
<MessageSquare className="h-3.5 w-3.5" />
- <span>Add comment</span>
+ <span>Comment</span>
{!!commentCount ? (
<ActionButtonCountBadge count={commentCount} />
) : null}
diff --git a/web/src/features/web-callouts/components/WebCalloutMenuItem.tsx b/web/src/features/web-callouts/components/WebCalloutMenuItem.tsx
index e9f59c2ed9..7991340983 100644
--- a/web/src/features/web-callouts/components/WebCalloutMenuItem.tsx
+++ b/web/src/features/web-callouts/components/WebCalloutMenuItem.tsx
@@ -1,10 +1,6 @@
import { Webhook } from "lucide-react";
import { Button } from "@/src/components/ui/button";
-import {
- DropdownMenuItem,
- DropdownMenuSeparator,
-} from "@/src/components/ui/dropdown-menu";
import {
Tooltip,
TooltipContent,
@@ -71,37 +67,6 @@ export function useWebCalloutAction(props: WebCalloutTarget, enabled: boolean) {
type WebCalloutAction = NonNullable<ReturnType<typeof useWebCalloutAction>>;
-export function WebCalloutMenuItem({
- action,
- withSeparator,
-}: {
- action: WebCalloutAction;
- withSeparator?: boolean;
-}) {
- return (
- <>
- <DropdownMenuItem
- className="text-xs"
- disabled={action.isLoading}
- onSelect={(event) => {
- event.preventDefault();
- action.invokeCallout().catch(() => undefined);
- }}
- >
- <Webhook className="mr-2 h-4 w-4" />
- <span
- className="max-w-[260px] min-w-0 truncate"
- title={action.endpointName}
- >
- <span>Call </span>
- <span className="font-bold">{action.endpointName}</span>
- </span>
- </DropdownMenuItem>
- {withSeparator && <DropdownMenuSeparator />}
- </>
- );
-}
-
export function WebCalloutButton({
action,
layout = "toolbar",
@@ -110,8 +75,6 @@ export function WebCalloutButton({
/**
* "toolbar" (default) is the inline icon button; "menu" renders the same
* action as a full-width labeled row for the mobile header overflow popover.
- * (WebCalloutMenuItem is a Radix DropdownMenuItem and only works inside a
- * DropdownMenu, so the plain-popover mobile menu uses this row instead.)
*/
layout?: "toolbar" | "menu";
}) {
diff --git a/web/src/features/web-callouts/index.ts b/web/src/features/web-callouts/index.ts
index 3481f831ad..25fb8b6831 100644
--- a/web/src/features/web-callouts/index.ts
+++ b/web/src/features/web-callouts/index.ts
@@ -3,6 +3,5 @@
export {
useWebCalloutAction,
WebCalloutButton,
- WebCalloutMenuItem,
} from "@/src/features/web-callouts/components/WebCalloutMenuItem";
export { WebCalloutIntegrationCard } from "@/src/features/web-callouts/components/WebCalloutSettingsPage";