[] = [
{
id: "select",
accessorKey: "select",
size: 30,
isPinnedLeft: true,
isFixedPosition: true,
header: ({ table }) => {
return (
{
table.toggleAllPageRowsSelected(!!value);
if (!value) {
setSelectedRows({});
}
}}
aria-label="Select all"
className="opacity-60"
/>
);
},
cell: ({ row }) => {
return (
row.toggleSelected(!!value)}
aria-label="Select row"
className="mt-1 opacity-60 data-[state=checked]:mt-[5px]"
/>
);
},
},
{
accessorKey: "id",
header: "Id",
id: "id",
size: 70,
isFixedPosition: true,
cell: ({ row }) => {
const id: QueueItemRowData["id"] = row.getValue("id");
return (
);
},
},
{
accessorKey: "objectType",
header: "Type",
id: "objectType",
size: 50,
cell: ({ row }) => {
const objectType: QueueItemRowData["objectType"] =
row.getValue("objectType");
return {objectType.toLowerCase()};
},
},
{
accessorKey: "source",
header: "Source",
headerTooltip: {
description:
"Link to the source trace, observation or session based on which this item was added",
},
id: "source",
size: 50,
cell: ({ row }) => {
const rowData = row.original;
if (!rowData.source) return null;
switch (rowData.objectType) {
case "OBSERVATION":
return (
}
/>
);
case "TRACE":
return (
}
/>
);
case "SESSION":
return (
}
/>
);
default:
throw new Error(`Unknown object type`);
}
},
},
{
accessorKey: "sourceId",
header: "Source ID",
id: "sourceId",
size: 50,
cell: ({ row }) => {
const sourceId: QueueItemRowData["sourceId"] = row.getValue("sourceId");
return ;
},
enableHiding: true,
defaultHidden: true,
},
{
accessorKey: "status",
header: "Status",
id: "status",
size: 60,
cell: ({ row }) => {
const status: QueueItemRowData["status"] = row.getValue("status");
return (
);
},
},
{
accessorKey: "completedAt",
header: "Completed At",
id: "completedAt",
defaultHidden: true,
enableHiding: true,
size: 60,
},
{
accessorKey: "annotatorUser",
header: "Completed by",
id: "annotatorUser",
enableHiding: true,
size: 80,
cell: ({ row }) => {
const annotatorUser: QueueItemRowData["annotatorUser"] =
row.getValue("annotatorUser");
if (!annotatorUser || !annotatorUser.userId) return null;
const { userId, userName, image } = annotatorUser;
return (
{userName
? userName
.split(" ")
.map((word) => word[0])
.slice(0, 2)
.concat("")
: null}
{userName ?? userId}
);
},
},
];
const convertToTableRow = (
item: RouterOutput["annotationQueueItems"]["itemsByQueueId"]["queueItems"][number],
): QueueItemRowData => {
const baseData = {
id: item.id,
completedAt: item.completedAt?.toLocaleString() ?? "",
status: item.status,
annotatorUser: {
userId: item.annotatorUserId ?? undefined,
userName: item.annotatorUserName ?? undefined,
image: item.annotatorUserImage ?? undefined,
},
sourceId: item.objectId,
};
switch (item.objectType) {
case "OBSERVATION":
return {
...baseData,
objectType: "OBSERVATION" as const,
source: {
traceId: item.parentTraceId ?? "",
observationId: item.objectId,
},
};
case "TRACE":
return {
...baseData,
objectType: "TRACE" as const,
source: {
traceId: item.objectId,
},
};
case "SESSION":
return {
...baseData,
objectType: "SESSION" as const,
source: {
sessionId: item.objectId,
},
};
default:
throw new Error(`Unknown object type: ${item.objectType}`);
}
};
const [columnVisibility, setColumnVisibility] =
useColumnVisibility(
`queueItemsColumnVisibility-${projectId}`,
columns,
);
const [columnOrder, setColumnOrder] = useColumnOrder(
"queueItemsColumnOrder",
columns,
);
return (
<>
items.data?.queueItems.map((item) => item.id).includes(itemId),
).length > 0 ? (
items.data?.queueItems.map((item) => item.id).includes(itemId),
)}
projectId={projectId}
onDeleteSuccess={() => {
setSelectedRows({});
}}
/>
) : null,
]}
/>
convertToTableRow(item),
),
}
}
help={{
description:
"Add traces and/or observations to your annotation queue to have them annotated by your team across predefined dimensions.",
href: "https://langfuse.com/docs/evaluation/evaluation-methods/llm-as-a-judge",
}}
pagination={{
totalCount: items.data?.totalItems ?? null,
onChange: setPaginationState,
state: paginationState,
}}
rowSelection={selectedRows}
setRowSelection={setSelectedRows}
columnVisibility={columnVisibility}
onColumnVisibilityChange={setColumnVisibility}
columnOrder={columnOrder}
onColumnOrderChange={setColumnOrder}
rowHeight={rowHeight}
/>
>
);
}