Skip to content

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

feat(annotation-queues): create queues from events table (#16427)

Ben Bachemdba62812b630
diff --git a/web/src/features/annotation-queues/components/AddTracesToAnnotationQueueDialogController.tsx b/web/src/features/annotation-queues/components/AddTracesToAnnotationQueueDialogController.tsx
index 74e27c5cc5..d3351e21bc 100644
--- a/web/src/features/annotation-queues/components/AddTracesToAnnotationQueueDialogController.tsx
+++ b/web/src/features/annotation-queues/components/AddTracesToAnnotationQueueDialogController.tsx
@@ -11,6 +11,10 @@ type AddTracesToAnnotationQueueDialogControllerProps = {
projectId: string;
onSuccess: () => void;
description: string;
+ actionId?: ActionId;
+ tableName?: BatchExportTableName;
+ alternateTableName?: BatchExportTableName;
+ objectLabel?: string;
onAddToQueue: (params: {
projectId: string;
targetId: string;
@@ -25,6 +29,10 @@ export function AddTracesToAnnotationQueueDialogController({
projectId,
onSuccess,
description,
+ actionId = ActionId.TraceAddToAnnotationQueue,
+ tableName = BatchExportTableName.Traces,
+ alternateTableName,
+ objectLabel = "traces",
onAddToQueue,
children,
}: AddTracesToAnnotationQueueDialogControllerProps) {
@@ -39,7 +47,7 @@ export function AddTracesToAnnotationQueueDialogController({
const disabled = hasQueueAccess
? undefined
: {
- reason: "You don't have permission to add traces to annotation queues.",
+ reason: `You don't have permission to add ${objectLabel} to annotation queues.`,
};
const openDialog = () => {
if (!hasQueueAccess) return;
@@ -60,14 +68,25 @@ export function AddTracesToAnnotationQueueDialogController({
const isInProgress = api.table.getIsBatchActionInProgress.useQuery(
{
projectId,
- tableName: BatchExportTableName.Traces,
- actionId: ActionId.TraceAddToAnnotationQueue,
+ tableName,
+ actionId,
},
{
enabled: open,
refetchInterval: 2 * 60 * 1000,
},
);
+ const isAlternateInProgress = api.table.getIsBatchActionInProgress.useQuery(
+ {
+ projectId,
+ tableName: alternateTableName ?? tableName,
+ actionId,
+ },
+ {
+ enabled: open && alternateTableName !== undefined,
+ refetchInterval: 2 * 60 * 1000,
+ },
+ );
const atQueueLimit =
typeof queueLimit === "number" &&
@@ -128,9 +147,9 @@ export function AddTracesToAnnotationQueueDialogController({
createQueueState={createQueueState}
hasAccess={hasQueueAccess}
batchActionState={
- isInProgress.isLoading
+ isInProgress.isLoading || isAlternateInProgress.isLoading
? { status: "checking" }
- : isInProgress.data
+ : isInProgress.data || isAlternateInProgress.data
? { status: "inProgress" }
: { status: "ready" }
}
diff --git a/web/src/features/events/components/EventsTable.tsx b/web/src/features/events/components/EventsTable.tsx
index 2568c04a12..183ce7c9b2 100644
--- a/web/src/features/events/components/EventsTable.tsx
+++ b/web/src/features/events/components/EventsTable.tsx
@@ -154,6 +154,7 @@ import {
useObservedMetadataPaths,
useObservedMetadataRecorder,
} from "@/src/hooks/useObservedMetadata";
+import { AddTracesToAnnotationQueueDialogController } from "@/src/features/annotation-queues/components/AddTracesToAnnotationQueueDialogController";
export type EventsTableRow = {
// Identity fields
@@ -1079,9 +1080,8 @@ export default function ObservationsEventsTable({
id: ActionId.ObservationAddToAnnotationQueue,
type: BatchActionType.Create,
label: "Add to Annotation Queue",
- description: "Add selected observations to an annotation queue.",
- targetLabel: "Annotation Queue",
- execute: handleAddToAnnotationQueue,
+ description: `Add ${itemCountDisplay} selected observations to an annotation queue.`,
+ customDialog: true,
accessCheck: {
scope: "annotationQueues:CUD",
},
@@ -2143,25 +2143,49 @@ export default function ObservationsEventsTable({
/>,
!chartActive &&
(selectedObservationIds.length > 0 || selectAll) ? (
- <TableActionMenu
+ <AddTracesToAnnotationQueueDialogController
key="observations-multi-select-actions"
projectId={projectId}
- actions={tableActions}
- tableName={BatchExportTableName.Observations}
- selectedCount={selectedObservationCount}
- onClearSelection={() => {
+ actionId={ActionId.ObservationAddToAnnotationQueue}
+ tableName={BatchExportTableName.Events}
+ alternateTableName={BatchExportTableName.Observations}
+ objectLabel="observations"
+ description={`Add ${itemCountDisplay} selected observations to an annotation queue.`}
+ onAddToQueue={handleAddToAnnotationQueue}
+ onSuccess={() => {
setSelectedRows({});
setSelectAll(false);
}}
- onCustomAction={(actionType) => {
- if (actionType === ActionId.ObservationBatchEvaluation) {
- setShowRunEvaluationDialog(true);
- }
- if (actionType === ActionId.ObservationAddToDataset) {
- setShowAddToDatasetDialog(true);
- }
- }}
- />
+ >
+ {({ openDialog }) => (
+ <TableActionMenu
+ projectId={projectId}
+ actions={tableActions}
+ tableName={BatchExportTableName.Observations}
+ selectedCount={selectedObservationCount}
+ onClearSelection={() => {
+ setSelectedRows({});
+ setSelectAll(false);
+ }}
+ onCustomAction={(actionType) => {
+ if (
+ actionType ===
+ ActionId.ObservationAddToAnnotationQueue
+ ) {
+ openDialog();
+ }
+ if (
+ actionType === ActionId.ObservationBatchEvaluation
+ ) {
+ setShowRunEvaluationDialog(true);
+ }
+ if (actionType === ActionId.ObservationAddToDataset) {
+ setShowAddToDatasetDialog(true);
+ }
+ }}
+ />
+ )}
+ </AddTracesToAnnotationQueueDialogController>
) : null,
]}
// No row selection in chart mode — the table (and its select-all