Skip to content

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

fix(trace-table): auto select annotation queue if there is only one (#11569)

Nimardaba490c0088
diff --git a/web/src/features/table/components/TableActionDialog.tsx b/web/src/features/table/components/TableActionDialog.tsx
index 9fe9f317ba..596e523802 100644
--- a/web/src/features/table/components/TableActionDialog.tsx
+++ b/web/src/features/table/components/TableActionDialog.tsx
@@ -1,3 +1,4 @@
+import { useEffect } from "react";
import {
Dialog,
DialogBody,
@@ -30,6 +31,7 @@ import { useSelectAll } from "@/src/features/table/hooks/useSelectAll";
import { type BatchExportTableName } from "@langfuse/shared";
import { api } from "@/src/utils/api";
import { Loader2 } from "lucide-react";
+import { targetOptionsQueryMap } from "@/src/features/table/components/targetOptionsQueryMap";
type TableActionDialogProps = {
isOpen: boolean;
@@ -65,6 +67,24 @@ export function TableActionDialog({
},
);
+ const targetOptions = api.annotationQueues.allNamesAndIds.useQuery(
+ { projectId },
+ {
+ enabled:
+ action.type === "create" &&
+ action.id in targetOptionsQueryMap &&
+ hasEntitlement,
+ },
+ );
+
+ // Auto-select when there's only one option
+ useEffect(() => {
+ const options = targetOptions?.data;
+ if (options?.length === 1 && !form.getValues().targetId) {
+ form.setValue("targetId", options[0].id);
+ }
+ }, [targetOptions?.data, form]);
+
const handleConfirm = async () => {
if ("execute" in action) {
await action.execute({
@@ -100,7 +120,7 @@ export function TableActionDialog({
<FormItem>
<Select
onValueChange={field.onChange}
- defaultValue={field.value}
+ value={field.value}
>
<FormControl>
<SelectTrigger>