Skip to content

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

refactor(web): Clean up `AnnotateDrawer` (#16765)

Ben Bachem2cde6a788410
diff --git a/web/src/components/session/SessionTraceActionButtons.tsx b/web/src/components/session/SessionTraceActionButtons.tsx
index d272384d17..f6b003da44 100644
--- a/web/src/components/session/SessionTraceActionButtons.tsx
+++ b/web/src/components/session/SessionTraceActionButtons.tsx
@@ -3,13 +3,19 @@ import { type RouterOutputs } from "@/src/utils/api";
import { getNumberFromMap } from "@/src/utils/map-utils";
import { ActionButtonCountBadge } from "@/src/components/ui/action-button-count-badge";
import { Button } from "@/src/components/ui/button";
-import { AnnotateDrawer } from "@/src/features/scores/components/AnnotateDrawer";
+import { AnnotateDrawerController } from "@/src/features/scores/components/AnnotateDrawerController";
import { CommentDrawerController } from "@/src/features/comments/CommentDrawerController";
import { NewDatasetItemFromTraceId } from "@/src/components/session/NewDatasetItemFromTrace";
import { AnnotationQueueItemDropdownMenuController } from "@/src/features/annotation-queues/components/AnnotationQueueItemDropdownMenuController";
import { AnnotationQueueItemCountBadge } from "@/src/features/annotation-queues/components/AnnotationQueueItemCountBadge";
import { cn } from "@/src/utils/tailwind";
-import { ChevronDown, MessageSquare, MessageSquareOff } from "lucide-react";
+import {
+ ChevronDown,
+ LockIcon,
+ MessageSquare,
+ MessageSquareOff,
+ SquarePen,
+} from "lucide-react";
type TraceScores =
RouterOutputs["sessions"]["byIdWithScores"]["traces"][number]["scores"];
@@ -46,7 +52,7 @@ export function SessionTraceActionButtons({
size={size}
/>
<div className="flex items-start">
- <AnnotateDrawer
+ <AnnotateDrawerController
key={`annotation-drawer-${traceId}`}
projectId={projectId}
scoreTarget={{
@@ -54,8 +60,6 @@ export function SessionTraceActionButtons({
traceId,
}}
scores={scores}
- buttonVariant="outline"
- size={size}
analyticsData={{
type: "trace",
source: "SessionDetail",
@@ -64,7 +68,24 @@ export function SessionTraceActionButtons({
projectId,
environment: environment ?? undefined,
}}
- />
+ >
+ {({ disabled, openDrawer }) => (
+ <Button
+ variant="outline"
+ size={size}
+ disabled={disabled}
+ className="rounded-r-none"
+ onClick={openDrawer}
+ >
+ {disabled ? (
+ <LockIcon className="mr-1.5 h-3 w-3" />
+ ) : (
+ <SquarePen className="mr-1.5 h-4 w-4" />
+ )}
+ <span>Annotate</span>
+ </Button>
+ )}
+ </AnnotateDrawerController>
<AnnotationQueueItemDropdownMenuController
projectId={projectId}
objectId={traceId}
diff --git a/web/src/components/session/index.tsx b/web/src/components/session/index.tsx
index 3dc2a3fa38..35d5bc37d5 100644
--- a/web/src/components/session/index.tsx
+++ b/web/src/components/session/index.tsx
@@ -15,7 +15,7 @@ import Link from "next/link";
import { useRouter } from "next/router";
import React, { useEffect, useState, useCallback, useRef } from "react";
import { useVirtualizer } from "@tanstack/react-virtual";
-import { AnnotateDrawer } from "@/src/features/scores/components/AnnotateDrawer";
+import { AnnotateDrawerController } from "@/src/features/scores/components/AnnotateDrawerController";
import { ActionButtonCountBadge } from "@/src/components/ui/action-button-count-badge";
import { Button } from "@/src/components/ui/button";
import { CommentDrawerController } from "@/src/features/comments/CommentDrawerController";
@@ -27,10 +27,12 @@ import {
CopyIcon,
Download,
ExternalLinkIcon,
+ LockIcon,
MessageSquare,
MessageSquareOff,
ListPlus,
MoreVertical,
+ SquarePen,
} from "lucide-react";
import { useCopyToClipboard } from "@/src/hooks/useCopyToClipboard";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
@@ -594,7 +596,7 @@ export const SessionPage: React.FC<{
)}
</CommentDrawerController>
<div className="flex items-start">
- <AnnotateDrawer
+ <AnnotateDrawerController
projectId={projectId}
scoreTarget={{
type: "session",
@@ -605,8 +607,24 @@ export const SessionPage: React.FC<{
projectId: projectId,
environment: session.data?.environment,
}}
- buttonVariant="outline"
- />
+ >
+ {({ disabled, openDrawer }) => (
+ <Button
+ variant="outline"
+ size="default"
+ disabled={disabled}
+ className="rounded-r-none"
+ onClick={openDrawer}
+ >
+ {disabled ? (
+ <LockIcon className="mr-1.5 h-3 w-3" />
+ ) : (
+ <SquarePen className="mr-1.5 h-4 w-4" />
+ )}
+ <span>Annotate</span>
+ </Button>
+ )}
+ </AnnotateDrawerController>
<AnnotationQueueItemDropdownMenuController
projectId={projectId}
objectId={sessionId}
@@ -690,7 +708,7 @@ export const SessionPage: React.FC<{
</Button>
)}
</CommentDrawerController>
- <AnnotateDrawer
+ <AnnotateDrawerController
projectId={projectId}
scoreTarget={{
type: "session",
@@ -701,9 +719,24 @@ export const SessionPage: React.FC<{
projectId: projectId,
environment: session.data?.environment,
}}
- buttonVariant="outline"
- layout="menu"
- />
+ >
+ {({ disabled, openDrawer }) => (
+ <Button
+ variant="ghost"
+ size="sm"
+ disabled={disabled}
+ className="w-full justify-start gap-2 font-normal"
+ onClick={openDrawer}
+ >
+ {disabled ? (
+ <LockIcon className="h-3 w-3" />
+ ) : (
+ <SquarePen className="h-4 w-4" />
+ )}
+ <span className="text-sm">Annotate</span>
+ </Button>
+ )}
+ </AnnotateDrawerController>
<AnnotationQueueItemDropdownMenuController
projectId={projectId}
objectId={sessionId}
@@ -1568,7 +1601,7 @@ const LoadedSessionEventsPage: React.FC<{
)}
</CommentDrawerController>
<div className="flex items-start">
- <AnnotateDrawer
+ <AnnotateDrawerController
projectId={projectId}
scoreTarget={{
type: "session",
@@ -1579,9 +1612,29 @@ const LoadedSessionEventsPage: React.FC<{
projectId: projectId,
environment: session.environment,
}}
- buttonVariant="outline"
- showAnnotationCount={isModernSessionEnabled}
- />
+ >
+ {({ annotationCount, disabled, openDrawer }) => (
+ <Button
+ variant="outline"
+ size="default"
+ disabled={disabled}
+ className="rounded-r-none"
+ onClick={openDrawer}
+ >
+ {disabled ? (
+ <LockIcon className="mr-1.5 h-3 w-3" />
+ ) : (
+ <SquarePen className="mr-1.5 h-4 w-4" />
+ )}
+ <span>Annotate</span>
+ {isModernSessionEnabled && annotationCount > 0 ? (
+ <span className="ml-1">
+ <ActionButtonCountBadge count={annotationCount} />
+ </span>
+ ) : null}
+ </Button>
+ )}
+ </AnnotateDrawerController>
<AnnotationQueueItemDropdownMenuController
projectId={projectId}
objectId={sessionId}
@@ -1687,7 +1740,7 @@ const LoadedSessionEventsPage: React.FC<{
</Button>
)}
</CommentDrawerController>
- <AnnotateDrawer
+ <AnnotateDrawerController
projectId={projectId}
scoreTarget={{
type: "session",
@@ -1698,10 +1751,29 @@ const LoadedSessionEventsPage: React.FC<{
projectId: projectId,
environment: session.environment,
}}
- buttonVariant="outline"
- layout="menu"
- showAnnotationCount={isModernSessionEnabled}
- />
+ >
+ {({ annotationCount, disabled, openDrawer }) => (
+ <Button
+ variant="ghost"
+ size="sm"
+ disabled={disabled}
+ className="w-full justify-start gap-2 font-normal"
+ onClick={openDrawer}
+ >
+ {disabled ? (
+ <LockIcon className="h-3 w-3" />
+ ) : (
+ <SquarePen className="h-4 w-4" />
+ )}
+ <span className="text-sm">Annotate</span>
+ {isModernSessionEnabled && annotationCount > 0 ? (
+ <span className="ml-1">
+ <ActionButtonCountBadge count={annotationCount} />
+ </span>
+ ) : null}
+ </Button>
+ )}
+ </AnnotateDrawerController>
<AnnotationQueueItemDropdownMenuController
projectId={projectId}
objectId={sessionId}
diff --git a/web/src/features/scores/components/AnnotateDrawer.tsx b/web/src/features/scores/components/AnnotateDrawer.tsx
deleted file mode 100644
index 1baee58f5d..0000000000
--- a/web/src/features/scores/components/AnnotateDrawer.tsx
+++ /dev/null
@@ -1,110 +0,0 @@
-/* eslint-disable @repo/no-abstracted-overlay-trigger */
-import React from "react";
-import { ActionButtonCountBadge } from "@/src/components/ui/action-button-count-badge";
-import { Button } from "@/src/components/ui/button";
-import { LockIcon, SquarePen } from "lucide-react";
-import {
- Drawer,
- DrawerContent,
- DrawerTrigger,
-} from "@/src/components/ui/drawer";
-import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
-import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
-import {
- type AnnotateDrawerProps,
- type ScoreTarget,
-} from "@/src/features/scores/types";
-import { AnnotationForm } from "@/src/features/scores/components/AnnotationForm";
-
-export function AnnotateDrawer<Target extends ScoreTarget>({
- projectId,
- scoreTarget,
- scores,
- analyticsData = {
- type: "trace",
- source: "TraceDetail",
- },
- scoreMetadata,
- buttonVariant = "secondary",
- size = "default",
- layout = "toolbar",
- showAnnotationCount = false,
-}: AnnotateDrawerProps<Target> & {
- size?: "default" | "sm" | "xs" | "lg" | "icon" | "icon-xs" | "icon-sm";
- /**
- * "toolbar" (default) is the inline button; "menu" renders the same drawer
- * trigger as a full-width labeled row for the mobile header overflow popover.
- */
- layout?: "toolbar" | "menu";
- showAnnotationCount?: boolean;
-}) {
- const isMenu = layout === "menu";
- const capture = usePostHogClientCapture();
- const hasAccess = useHasProjectAccess({
- projectId,
- scope: "scores:CUD",
- });
-
- const hasNonAnnotationScores = scores.some(
- (score) => score.source !== "ANNOTATION",
- );
- const annotationCount = scores.filter(
- (score) => score.source === "ANNOTATION",
- ).length;
-
- return (
- <Drawer>
- <DrawerTrigger asChild>
- <Button
- variant={isMenu ? "ghost" : buttonVariant}
- size={isMenu ? "sm" : size}
- disabled={!hasAccess}
- className={
- isMenu ? "w-full justify-start gap-2 font-normal" : "rounded-r-none"
- }
- onClick={() => {
- capture(
- Boolean(scores.length)
- ? "score:update_form_open"
- : "score:create_form_open",
- analyticsData,
- );
- }}
- >
- {!hasAccess ? (
- <LockIcon className={isMenu ? "h-3 w-3" : "mr-1.5 h-3 w-3"} />
- ) : (
- <SquarePen
- className={
- isMenu
- ? "h-4 w-4"
- : size === "sm"
- ? "mr-1.5 h-3.5 w-3.5"
- : "mr-1.5 h-4 w-4"
- }
- />
- )}
- <span className={isMenu ? "text-sm" : undefined}>Annotate</span>
- {showAnnotationCount && annotationCount > 0 ? (
- <span className="ml-1">
- <ActionButtonCountBadge count={annotationCount} />
- </span>
- ) : null}
- </Button>
- </DrawerTrigger>
- <DrawerContent className="p-3">
- <AnnotationForm
- serverScores={scores}
- scoreTarget={scoreTarget}
- analyticsData={analyticsData}
- scoreMetadata={scoreMetadata}
- />
- {hasNonAnnotationScores && (
- <div className="text-muted-foreground mt-4 text-xs">
- API and eval scores visible on left. Add manual annotations above.
- </div>
- )}
- </DrawerContent>
- </Drawer>
- );
-}
diff --git a/web/src/features/scores/components/AnnotateDrawerContent.tsx b/web/src/features/scores/components/AnnotateDrawerContent.tsx
new file mode 100644
index 0000000000..c28b10677f
--- /dev/null
+++ b/web/src/features/scores/components/AnnotateDrawerContent.tsx
@@ -0,0 +1,46 @@
+import { DrawerContent } from "@/src/components/ui/drawer";
+import { AnnotationForm } from "@/src/features/scores/components/AnnotationForm";
+import {
+ type AnalyticsData,
+ type ScoreTarget,
+} from "@/src/features/scores/types";
+import { type ScoreDomain } from "@langfuse/shared";
+import { type WithStringifiedMetadata } from "@/src/utils/clientSideDomainTypes";
+
+type AnnotateDrawerContentProps<Target extends ScoreTarget> = {
+ analyticsData: AnalyticsData;
+ scoreMetadata: {
+ projectId: string;
+ queueId?: string;
+ environment?: string;
+ };
+ scoreTarget: Target;
+ scores: WithStringifiedMetadata<ScoreDomain>[];
+};
+
+export function AnnotateDrawerContent<Target extends ScoreTarget>({
+ analyticsData,
+ scoreMetadata,
+ scoreTarget,
+ scores,
+}: AnnotateDrawerContentProps<Target>) {
+ const hasNonAnnotationScores = scores.some(
+ (score) => score.source !== "ANNOTATION",
+ );
+
+ return (
+ <DrawerContent className="p-3">
+ <AnnotationForm
+ serverScores={scores}
+ scoreTarget={scoreTarget}
+ analyticsData={analyticsData}
+ scoreMetadata={scoreMetadata}
+ />
+ {hasNonAnnotationScores ? (
+ <div className="text-muted-foreground mt-4 text-xs">
+ API and eval scores visible on left. Add manual annotations above.
+ </div>
+ ) : null}
+ </DrawerContent>
+ );
+}
diff --git a/web/src/features/scores/components/AnnotateDrawerController.tsx b/web/src/features/scores/components/AnnotateDrawerController.tsx
new file mode 100644
index 0000000000..1151817153
--- /dev/null
+++ b/web/src/features/scores/components/AnnotateDrawerController.tsx
@@ -0,0 +1,73 @@
+import { Drawer } from "@/src/components/ui/drawer";
+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
+import {
+ type AnalyticsData,
+ type ScoreTarget,
+} from "@/src/features/scores/types";
+import { type ReactNode, useState } from "react";
+import { AnnotateDrawerContent } from "@/src/features/scores/components/AnnotateDrawerContent";
+import { type ScoreDomain } from "@langfuse/shared";
+import { type WithStringifiedMetadata } from "@/src/utils/clientSideDomainTypes";
+
+export type AnnotateDrawerControllerProps<Target extends ScoreTarget> = {
+ analyticsData?: AnalyticsData;
+ children: (control: {
+ annotationCount: number;
+ disabled: boolean;
+ openDrawer: () => void;
+ }) => ReactNode;
+ projectId: string;
+ scoreMetadata: {
+ projectId: string;
+ queueId?: string;
+ environment?: string;
+ };
+ scoreTarget: Target;
+ scores: WithStringifiedMetadata<ScoreDomain>[];
+};
+
+export function AnnotateDrawerController<Target extends ScoreTarget>({
+ analyticsData = {
+ type: "trace",
+ source: "TraceDetail",
+ },
+ children,
+ projectId,
+ scoreMetadata,
+ scoreTarget,
+ scores,
+}: AnnotateDrawerControllerProps<Target>) {
+ const [isOpen, setIsOpen] = useState(false);
+ const capture = usePostHogClientCapture();
+ const hasAccess = useHasProjectAccess({
+ projectId,
+ scope: "scores:CUD",
+ });
+ const annotationCount = scores.filter(
+ (score) => score.source === "ANNOTATION",
+ ).length;
+ const disabled = !hasAccess;
+
+ const openDrawer = () => {
+ if (disabled) return;
+
+ capture(
+ scores.length ? "score:update_form_open" : "score:create_form_open",
+ analyticsData,
+ );
+ setIsOpen(true);
+ };
+
+ return (
+ <Drawer open={isOpen} onOpenChange={setIsOpen}>
+ {children({ annotationCount, disabled, openDrawer })}
+ <AnnotateDrawerContent
+ analyticsData={analyticsData}
+ scoreMetadata={scoreMetadata}
+ scoreTarget={scoreTarget}
+ scores={scores}
+ />
+ </Drawer>
+ );
+}
diff --git a/web/src/features/scores/types.ts b/web/src/features/scores/types.ts
index a59aab9865..de7e7d0587 100644
--- a/web/src/features/scores/types.ts
+++ b/web/src/features/scores/types.ts
@@ -2,7 +2,6 @@ import {
type AnnotationScoreDataSchema,
type AnnotateFormSchema,
} from "@/src/features/scores/schema";
-import { type ButtonProps } from "@/src/components/ui/button";
import { type WithStringifiedMetadata } from "@/src/utils/clientSideDomainTypes";
import {
type ScoreSourceType,
@@ -71,19 +70,6 @@ export type AnalyticsData = {
| "DatasetCompare";
};
-export type AnnotateDrawerProps<Target extends ScoreTarget> = {
- projectId: string;
- scoreTarget: Target;
- scores: WithStringifiedMetadata<ScoreDomain>[];
- analyticsData?: AnalyticsData;
- scoreMetadata: {
- projectId: string;
- queueId?: string;
- environment?: string;
- };
- buttonVariant?: ButtonProps["variant"];
-};
-
export type AnnotateFormSchemaType = z.infer<typeof AnnotateFormSchema>;
export type AnnotationScoreSchemaType = z.infer<
typeof AnnotationScoreDataSchema
diff --git a/web/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader.tsx b/web/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader.tsx
index 80d89b090c..de587ece81 100644
--- a/web/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader.tsx
+++ b/web/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader.tsx
@@ -21,7 +21,7 @@ import { type ObservationReturnTypeWithMetadata } from "@/src/server/api/routers
import { ItemBadge } from "@/src/components/ItemBadge";
import { LocalIsoDate } from "@/src/components/LocalIsoDate";
import { NewDatasetItemFromExistingObject } from "@/src/features/datasets/components/NewDatasetItemFromExistingObject";
-import { AnnotateDrawer } from "@/src/features/scores/components/AnnotateDrawer";
+import { AnnotateDrawerController } from "@/src/features/scores/components/AnnotateDrawerController";
import { CommentDrawerController } from "@/src/features/comments/CommentDrawerController";
import { AnnotationQueueItemDropdownMenuController } from "@/src/features/annotation-queues/components/AnnotationQueueItemDropdownMenuController";
import { AnnotationQueueItemCountBadge } from "@/src/features/annotation-queues/components/AnnotationQueueItemCountBadge";
@@ -252,7 +252,7 @@ export const ObservationDetailViewHeader = memo(
</DrawerContent>
</Drawer>
) : (
- <AnnotateDrawer
+ <AnnotateDrawerController
key={"annotation-drawer-menu-" + observation.id}
projectId={projectId}
scoreTarget={{
@@ -265,8 +265,24 @@ export const ObservationDetailViewHeader = memo(
projectId: projectId,
environment: observation.environment,
}}
- layout="menu"
- />
+ >
+ {({ disabled, openDrawer }) => (
+ <Button
+ variant="ghost"
+ size="sm"
+ disabled={disabled}
+ className="w-full justify-start gap-2 font-normal"
+ onClick={openDrawer}
+ >
+ {disabled ? (
+ <LockIcon className="h-3 w-3" />
+ ) : (
+ <SquarePen className="h-4 w-4" />
+ )}
+ <span className="text-sm">Annotate</span>
+ </Button>
+ )}
+ </AnnotateDrawerController>
)}
<AnnotationQueueItemDropdownMenuController
projectId={projectId}
@@ -404,7 +420,7 @@ export const ObservationDetailViewHeader = memo(
</DrawerContent>
</Drawer>
) : (
- <AnnotateDrawer
+ <AnnotateDrawerController
key={"annotation-drawer-" + observation.id}
projectId={projectId}
scoreTarget={{
@@ -417,8 +433,24 @@ export const ObservationDetailViewHeader = memo(
projectId: projectId,
environment: observation.environment,
}}
- size="sm"
- />
+ >
+ {({ disabled, openDrawer }) => (
+ <Button
+ variant="secondary"
+ size="sm"
+ disabled={disabled}
+ className="rounded-r-none"
+ onClick={openDrawer}
+ >
+ {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}
diff --git a/web/src/features/traces/components/TraceDetailView/components/TraceDetailViewHeader.tsx b/web/src/features/traces/components/TraceDetailView/components/TraceDetailViewHeader.tsx
index a25fc024ce..fc9339a6d0 100644
--- a/web/src/features/traces/components/TraceDetailView/components/TraceDetailViewHeader.tsx
+++ b/web/src/features/traces/components/TraceDetailView/components/TraceDetailViewHeader.tsx
@@ -23,7 +23,7 @@ import { ItemBadge } from "@/src/components/ItemBadge";
import { LocalIsoDate } from "@/src/components/LocalIsoDate";
import { DetailHeaderActionsMenuController } from "@/src/features/traces/components/DetailHeaderActionsMenuController";
import { NewDatasetItemFromExistingObject } from "@/src/features/datasets/components/NewDatasetItemFromExistingObject";
-import { AnnotateDrawer } from "@/src/features/scores/components/AnnotateDrawer";
+import { AnnotateDrawerController } from "@/src/features/scores/components/AnnotateDrawerController";
import { CommentDrawerController } from "@/src/features/comments/CommentDrawerController";
import { ActionButtonCountBadge } from "@/src/components/ui/action-button-count-badge";
import { AnnotationQueueItemDropdownMenuController } from "@/src/features/annotation-queues/components/AnnotationQueueItemDropdownMenuController";
@@ -48,9 +48,11 @@ import {
ChevronDown,
EllipsisVertical,
ListPlus,
+ LockIcon,
MessageSquare,
MessageSquareOff,
MoreHorizontal,
+ SquarePen,
} from "lucide-react";
import {
Popover,
@@ -171,7 +173,7 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({
/>
{!isAnnotationMode && (
<>
- <AnnotateDrawer
+ <AnnotateDrawerController
projectId={projectId}
scoreTarget={{
type: "trace",
@@ -182,8 +184,24 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({
projectId: projectId,
environment: trace.environment,
}}
- layout="menu"
- />
+ >
+ {({ disabled, openDrawer }) => (
+ <Button
+ variant="ghost"
+ size="sm"
+ disabled={disabled}
+ className="w-full justify-start gap-2 font-normal"
+ onClick={openDrawer}
+ >
+ {disabled ? (
+ <LockIcon className="h-3 w-3" />
+ ) : (
+ <SquarePen className="h-4 w-4" />
+ )}
+ <span className="text-sm">Annotate</span>
+ </Button>
+ )}
+ </AnnotateDrawerController>
<AnnotationQueueItemDropdownMenuController
projectId={projectId}
objectId={trace.id}
@@ -257,7 +275,7 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({
{/* Hide annotation buttons in annotation mode (panel shown separately) */}
{!isAnnotationMode && (
<div className="flex items-start">
- <AnnotateDrawer
+ <AnnotateDrawerController
key={"annotation-drawer-" + trace.id}
projectId={projectId}
scoreTarget={{
@@ -269,8 +287,24 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({
projectId: projectId,
environment: trace.environment,
}}
- size="sm"
- />
+ >
+ {({ disabled, openDrawer }) => (
+ <Button
+ variant="secondary"
+ size="sm"
+ disabled={disabled}
+ className="rounded-r-none"
+ onClick={openDrawer}
+ >
+ {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}