@mastra/playground-ui 6.5.0-alpha.0 → 6.5.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/index.cjs.js +1266 -880
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.es.js +1249 -869
  5. package/dist/index.es.js.map +1 -1
  6. package/dist/src/components/assistant-ui/tools/badges/badge-wrapper.d.ts +2 -1
  7. package/dist/src/components/ui/containers/buttons-group.d.ts +6 -0
  8. package/dist/src/components/ui/containers/index.d.ts +2 -0
  9. package/dist/src/components/ui/containers/sections.d.ts +6 -0
  10. package/dist/src/components/ui/elements/index.d.ts +3 -0
  11. package/dist/src/components/ui/elements/main-sidebar/index.d.ts +1 -0
  12. package/dist/src/components/ui/elements/main-sidebar/main-sidebar-bottom.d.ts +6 -0
  13. package/dist/src/components/ui/elements/main-sidebar/main-sidebar-context.d.ts +12 -0
  14. package/dist/src/components/ui/elements/main-sidebar/main-sidebar-nav-header.d.ts +8 -0
  15. package/dist/src/components/ui/elements/main-sidebar/main-sidebar-nav-link.d.ts +17 -0
  16. package/dist/src/components/ui/elements/main-sidebar/main-sidebar-nav-list.d.ts +12 -0
  17. package/dist/src/components/ui/elements/main-sidebar/main-sidebar-nav-section.d.ts +13 -0
  18. package/dist/src/components/ui/elements/main-sidebar/main-sidebar-nav-separator.d.ts +5 -0
  19. package/dist/src/components/ui/elements/main-sidebar/main-sidebar-nav.d.ts +6 -0
  20. package/dist/src/components/ui/elements/main-sidebar/main-sidebar-root.d.ts +6 -0
  21. package/dist/src/components/ui/elements/main-sidebar/main-sidebar.d.ts +21 -0
  22. package/dist/src/components/ui/elements/notification/index.d.ts +1 -0
  23. package/dist/src/components/ui/elements/notification/notification.d.ts +9 -0
  24. package/dist/src/components/ui/elements/section/index.d.ts +1 -0
  25. package/dist/src/components/ui/elements/section/section-header.d.ts +7 -0
  26. package/dist/src/components/ui/elements/section/section-heading.d.ts +8 -0
  27. package/dist/src/components/ui/elements/section/section-root.d.ts +5 -0
  28. package/dist/src/components/ui/elements/section/section.d.ts +8 -0
  29. package/dist/src/components/ui/elements/side-dialog/index.d.ts +0 -6
  30. package/dist/src/components/ui/elements/side-dialog/side-dialog-code-section.d.ts +3 -1
  31. package/dist/src/components/ui/elements/side-dialog/side-dialog-content.d.ts +1 -14
  32. package/dist/src/components/ui/elements/side-dialog/side-dialog-nav.d.ts +6 -0
  33. package/dist/src/components/ui/elements/side-dialog/side-dialog-root.d.ts +11 -0
  34. package/dist/src/components/ui/elements/side-dialog/side-dialog-top.d.ts +2 -4
  35. package/dist/src/components/ui/elements/side-dialog/side-dialog.d.ts +16 -12
  36. package/dist/src/components/ui/elements/tabs/tabs-content.d.ts +7 -0
  37. package/dist/src/components/ui/elements/tabs/tabs-list.d.ts +7 -0
  38. package/dist/src/components/ui/elements/tabs/tabs-root.d.ts +9 -0
  39. package/dist/src/components/ui/elements/tabs/tabs-tab.d.ts +8 -0
  40. package/dist/src/components/ui/elements/tabs/tabs.d.ts +20 -36
  41. package/dist/src/domains/agents/utils/__tests__/extractPrompt.test.d.ts +1 -0
  42. package/dist/src/domains/observability/components/index.d.ts +3 -0
  43. package/dist/src/domains/observability/components/span-details.d.ts +1 -2
  44. package/dist/src/domains/observability/components/span-dialog.d.ts +8 -2
  45. package/dist/src/domains/observability/components/span-score-list.d.ts +17 -0
  46. package/dist/src/domains/observability/components/span-scoring.d.ts +6 -0
  47. package/dist/src/domains/observability/components/span-tabs.d.ts +16 -0
  48. package/dist/src/domains/observability/components/trace-dialog.d.ts +4 -2
  49. package/dist/src/domains/observability/components/trace-timeline.d.ts +1 -4
  50. package/dist/src/domains/observability/components/traces-list.d.ts +5 -1
  51. package/dist/src/domains/scores/components/score-dialog.d.ts +5 -3
  52. package/dist/src/domains/scores/hooks/use-trace-span-scores.d.ts +7 -0
  53. package/dist/src/domains/scores/hooks/use-trigger-scorer.d.ts +1 -1
  54. package/dist/src/domains/scores/index.d.ts +1 -0
  55. package/dist/src/index.d.ts +1 -0
  56. package/package.json +9 -7
  57. package/dist/src/domains/scores/components/scorers-dropdown.d.ts +0 -8
package/dist/index.es.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { useMessagePart, useMessage, MessagePrimitive, ActionBarPrimitive, useAttachment, AttachmentPrimitive, useComposerRuntime, ComposerPrimitive, useComposer, ThreadPrimitive, CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, WebSpeechSynthesisAdapter, useExternalStoreRuntime, AssistantRuntimeProvider } from '@assistant-ui/react';
3
- import { CheckIcon as CheckIcon$1, CopyIcon, AlertCircle, TriangleAlert, Check, Copy, ChevronUpIcon, X, Share2, Braces, Loader2, Network, ChevronDown, PauseIcon, HourglassIcon, CircleDashed, Footprints, CircleCheck, CircleX, Minus, Plus, Maximize, Workflow, AlertCircleIcon, ChevronDownIcon, CirclePause, CalendarIcon, Brackets, PlusIcon, TrashIcon, Circle, StopCircle, SearchIcon, BrainIcon, AudioLinesIcon, StopCircleIcon, FileText, CircleXIcon, Link, CloudUpload, Mic, ArrowUp, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, SaveIcon, RefreshCw, ExternalLink, InfoIcon as InfoIcon$1, TriangleAlertIcon, ChevronRightIcon, ArrowLeftIcon, ArrowRightIcon, XIcon, ChevronsRightIcon, ArrowUpIcon, ArrowDownIcon, AlignLeftIcon, AlignJustifyIcon, CircleAlertIcon, GaugeIcon, HashIcon, Info, RotateCcw, GripVertical, AlertTriangleIcon, NetworkIcon, WorkflowIcon as WorkflowIcon$1, PackageIcon, GitBranchIcon, PackageOpenIcon, OctagonXIcon, FrownIcon, ChevronUp, ChevronsLeftRight, TimerIcon, ChevronsLeftRightIcon, ChevronFirstIcon, ChevronLastIcon, ListTreeIcon, ArrowRightToLineIcon, CoinsIcon, EyeIcon, ChevronsLeftRightEllipsisIcon, PanelTopIcon, PanelLeftIcon, CircleSlash, Clock as Clock$1 } from 'lucide-react';
3
+ import { CheckIcon as CheckIcon$1, CopyIcon, AlertCircle, TriangleAlert, Check, Copy, ChevronUpIcon, X, Share2, Braces, Loader2, Network, ChevronDown, PauseIcon, HourglassIcon, CircleDashed, Footprints, CircleCheck, CircleX, Minus, Plus, Maximize, Workflow, AlertCircleIcon, ChevronDownIcon, CirclePause, CalendarIcon, Brackets, PlusIcon, TrashIcon, Circle, StopCircle, SearchIcon, BrainIcon, AudioLinesIcon, StopCircleIcon, FileText, CircleXIcon, Link, CloudUpload, Mic, ArrowUp, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, SaveIcon, RefreshCw, ExternalLink, InfoIcon as InfoIcon$1, TriangleAlertIcon, ChevronRightIcon, ArrowLeftIcon, ArrowRightIcon, ChevronsRightIcon, AlignLeftIcon, AlignJustifyIcon, ArrowUpIcon, ArrowDownIcon, CircleAlertIcon, XIcon, PanelRightIcon, GaugeIcon, EyeIcon, ChevronsLeftRightEllipsisIcon, CalculatorIcon, HashIcon, FileInputIcon, FileOutputIcon, ReceiptText, Info, RotateCcw, GripVertical, AlertTriangleIcon, NetworkIcon, WorkflowIcon as WorkflowIcon$1, PackageIcon, GitBranchIcon, PackageOpenIcon, OctagonXIcon, FrownIcon, ChevronUp, ChevronsLeftRight, TimerIcon, ChevronsLeftRightIcon, ChevronFirstIcon, ChevronLastIcon, ArrowRightToLineIcon, CoinsIcon, BracesIcon, CircleGaugeIcon, PanelTopIcon, ListTreeIcon, PanelLeftIcon, CircleSlash, Clock as Clock$1 } from 'lucide-react';
4
4
  import * as React from 'react';
5
5
  import React__default, { forwardRef, memo, useState, useEffect, useRef, useCallback, useMemo, createContext, useContext, Fragment as Fragment$1, useId } from 'react';
6
6
  import { Slot } from '@radix-ui/react-slot';
@@ -64,7 +64,6 @@ import { DragDropContext, Droppable, Draggable } from '@hello-pangea/dnd';
64
64
  import * as SwitchPrimitives from '@radix-ui/react-switch';
65
65
  import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
66
66
  import { format as format$1 } from 'date-fns/format';
67
- import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
68
67
 
69
68
  function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
70
69
 
@@ -4392,10 +4391,11 @@ const BadgeWrapper = ({
4392
4391
  icon,
4393
4392
  title,
4394
4393
  collapsible = true,
4395
- extraInfo
4394
+ extraInfo,
4395
+ "data-testid": dataTestId
4396
4396
  }) => {
4397
4397
  const [isCollapsed, setIsCollapsed] = useState(initialCollapsed);
4398
- return /* @__PURE__ */ jsxs("div", { className: "mb-4", children: [
4398
+ return /* @__PURE__ */ jsxs("div", { className: "mb-4", "data-testid": dataTestId, children: [
4399
4399
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row gap-2 items-center justify-between", children: [
4400
4400
  /* @__PURE__ */ jsxs(
4401
4401
  "button",
@@ -4525,6 +4525,7 @@ const ToolBadge = ({ toolName, args, result, metadata, toolOutput }) => {
4525
4525
  return /* @__PURE__ */ jsx(
4526
4526
  BadgeWrapper,
4527
4527
  {
4528
+ "data-testid": "tool-badge",
4528
4529
  icon: /* @__PURE__ */ jsx(ToolsIcon, { className: "text-[#ECB047]" }),
4529
4530
  title: toolName,
4530
4531
  extraInfo: metadata?.mode === "network" && /* @__PURE__ */ jsx(
@@ -6902,7 +6903,8 @@ function DynamicForm({
6902
6903
  },
6903
6904
  defaultValues: isNotZodObject ? defaultValues ? { "​": defaultValues } : void 0 : defaultValues,
6904
6905
  formProps: {
6905
- className
6906
+ className,
6907
+ noValidate: true
6906
6908
  },
6907
6909
  uiComponents: {
6908
6910
  SubmitButton: ({ children }) => onSubmit ? /* @__PURE__ */ jsx(Button$1, { variant: "light", className: "w-full", size: "lg", disabled: isSubmitLoading, children: isSubmitLoading ? /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(Loader2, { className: "animate-spin" }) }) : submitButtonLabel || children }) : null
@@ -7695,7 +7697,7 @@ function WorkflowTable({ workflows, isLoading }) {
7695
7697
  return /* @__PURE__ */ jsx(EmptyWorkflowsTable, {});
7696
7698
  }
7697
7699
  const filteredRows = rows.filter((row) => row.original.name.toLowerCase().includes(search.toLowerCase()));
7698
- return /* @__PURE__ */ jsxs(Fragment, { children: [
7700
+ return /* @__PURE__ */ jsxs("div", { children: [
7699
7701
  /* @__PURE__ */ jsx(SearchbarWrapper, { children: /* @__PURE__ */ jsx(Searchbar, { onSearch: setSearch, label: "Search workflows", placeholder: "Search workflows" }) }),
7700
7702
  isLoading ? /* @__PURE__ */ jsx(WorkflowTableSkeleton, {}) : /* @__PURE__ */ jsx(ScrollableContainer, { children: /* @__PURE__ */ jsxs(Table$1, { children: [
7701
7703
  /* @__PURE__ */ jsx(Thead, { className: "sticky top-0", children: ths.headers.map((header) => /* @__PURE__ */ jsx(Th, { style: { width: header.index === 0 ? "auto" : header.column.getSize() }, children: flexRender(header.column.columnDef.header, header.getContext()) }, header.id)) }),
@@ -7749,6 +7751,7 @@ const WorkflowBadge = ({ workflow, runId, workflowId, isStreaming, metadata }) =
7749
7751
  return /* @__PURE__ */ jsxs(
7750
7752
  BadgeWrapper,
7751
7753
  {
7754
+ "data-testid": "workflow-badge",
7752
7755
  icon: /* @__PURE__ */ jsx(WorkflowIcon, { className: "text-accent3" }),
7753
7756
  title: workflow.name,
7754
7757
  initialCollapsed: false,
@@ -7814,6 +7817,7 @@ const AgentBadge = ({ agentId, messages = [], metadata }) => {
7814
7817
  return /* @__PURE__ */ jsx(
7815
7818
  BadgeWrapper,
7816
7819
  {
7820
+ "data-testid": "agent-badge",
7817
7821
  icon: /* @__PURE__ */ jsx(AgentIcon, { className: "text-accent1" }),
7818
7822
  title: agentId,
7819
7823
  initialCollapsed: false,
@@ -9547,13 +9551,11 @@ function MastraRuntimeProvider({
9547
9551
  () => memory ? initializeMessageState(initialLegacyMessages || []) : []
9548
9552
  );
9549
9553
  const {
9550
- setMessages,
9551
9554
  messages,
9552
- generate,
9553
- stream,
9554
- network,
9555
+ sendMessage,
9555
9556
  cancelRun,
9556
- isRunning: isRunningStream
9557
+ isRunning: isRunningStream,
9558
+ setMessages
9557
9559
  } = useChat({
9558
9560
  agentId,
9559
9561
  initializeMessages: () => initialMessages || []
@@ -9598,9 +9600,7 @@ function MastraRuntimeProvider({
9598
9600
  if (message.content[0]?.type !== "text") throw new Error("Only text messages are supported");
9599
9601
  const attachments = await convertToAIAttachments(message.attachments);
9600
9602
  const input = message.content[0].text;
9601
- if (isVNext) {
9602
- setMessages((s) => [...s, { role: "user", parts: [{ type: "text", text: input }] }]);
9603
- } else {
9603
+ if (!isVNext) {
9604
9604
  setLegacyMessages((s) => [...s, { role: "user", content: input, attachments: message.attachments }]);
9605
9605
  }
9606
9606
  const controller = new AbortController();
@@ -9613,14 +9613,10 @@ function MastraRuntimeProvider({
9613
9613
  try {
9614
9614
  if (isVNext) {
9615
9615
  if (chatWithNetwork) {
9616
- await network({
9617
- coreUserMessages: [
9618
- {
9619
- role: "user",
9620
- content: input
9621
- },
9622
- ...attachments
9623
- ],
9616
+ await sendMessage({
9617
+ message: input,
9618
+ mode: "network",
9619
+ coreUserMessages: attachments,
9624
9620
  runtimeContext: runtimeContextInstance,
9625
9621
  threadId,
9626
9622
  modelSettings: modelSettingsArgs,
@@ -9633,14 +9629,10 @@ function MastraRuntimeProvider({
9633
9629
  });
9634
9630
  } else {
9635
9631
  if (chatWithGenerate) {
9636
- await generate({
9637
- coreUserMessages: [
9638
- {
9639
- role: "user",
9640
- content: input
9641
- },
9642
- ...attachments
9643
- ],
9632
+ await sendMessage({
9633
+ message: input,
9634
+ mode: "generate",
9635
+ coreUserMessages: attachments,
9644
9636
  runtimeContext: runtimeContextInstance,
9645
9637
  threadId,
9646
9638
  modelSettings: modelSettingsArgs,
@@ -9648,14 +9640,10 @@ function MastraRuntimeProvider({
9648
9640
  });
9649
9641
  return;
9650
9642
  } else {
9651
- await stream({
9652
- coreUserMessages: [
9653
- {
9654
- role: "user",
9655
- content: input
9656
- },
9657
- ...attachments
9658
- ],
9643
+ await sendMessage({
9644
+ message: input,
9645
+ mode: "stream",
9646
+ coreUserMessages: attachments,
9659
9647
  runtimeContext: runtimeContextInstance,
9660
9648
  threadId,
9661
9649
  modelSettings: modelSettingsArgs,
@@ -10193,7 +10181,7 @@ const TableCaption = React.forwardRef(
10193
10181
  );
10194
10182
  TableCaption.displayName = "TableCaption";
10195
10183
 
10196
- const Tabs = TabsPrimitive.Root;
10184
+ const Tabs$1 = TabsPrimitive.Root;
10197
10185
  const TabsList = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
10198
10186
  TabsPrimitive.List,
10199
10187
  {
@@ -10236,12 +10224,12 @@ const PlaygroundTabs = ({
10236
10224
  setInternalTab(typedValue);
10237
10225
  }
10238
10226
  };
10239
- return /* @__PURE__ */ jsx(Tabs, { value: currentTab, onValueChange: handleTabChange, className: cn("h-full", className), children });
10227
+ return /* @__PURE__ */ jsx(Tabs$1, { value: currentTab, onValueChange: handleTabChange, className: cn("h-full", className), children });
10240
10228
  };
10241
- const TabList = ({ children, className }) => {
10229
+ const TabList$1 = ({ children, className }) => {
10242
10230
  return /* @__PURE__ */ jsx("div", { className: cn("w-full overflow-x-auto", className), children: /* @__PURE__ */ jsx(TabsList, { className: "border-b border-border1 flex min-w-full shrink-0", children }) });
10243
10231
  };
10244
- const Tab = ({ children, value, onClick }) => {
10232
+ const Tab$1 = ({ children, value, onClick }) => {
10245
10233
  return /* @__PURE__ */ jsx(
10246
10234
  TabsTrigger,
10247
10235
  {
@@ -10252,7 +10240,7 @@ const Tab = ({ children, value, onClick }) => {
10252
10240
  }
10253
10241
  );
10254
10242
  };
10255
- const TabContent = ({ children, value }) => {
10243
+ const TabContent$1 = ({ children, value }) => {
10256
10244
  return /* @__PURE__ */ jsx(TabsContent, { value, className: "h-full overflow-hidden flex flex-col", children });
10257
10245
  };
10258
10246
 
@@ -10277,12 +10265,12 @@ function AgentEvals({ liveEvals, ciEvals, onRefetchLiveEvals, onRefetchCiEvals }
10277
10265
  return onRefetchCiEvals();
10278
10266
  }
10279
10267
  return /* @__PURE__ */ jsxs(PlaygroundTabs, { defaultTab: "live", children: [
10280
- /* @__PURE__ */ jsxs(TabList, { children: [
10281
- /* @__PURE__ */ jsx(Tab, { value: "live", children: "Live" }),
10282
- /* @__PURE__ */ jsx(Tab, { value: "ci", children: "CI" })
10268
+ /* @__PURE__ */ jsxs(TabList$1, { children: [
10269
+ /* @__PURE__ */ jsx(Tab$1, { value: "live", children: "Live" }),
10270
+ /* @__PURE__ */ jsx(Tab$1, { value: "ci", children: "CI" })
10283
10271
  ] }),
10284
- /* @__PURE__ */ jsx(TabContent, { value: "live", children: /* @__PURE__ */ jsx(EvalTable, { evals: liveEvals, isCIMode: false, onRefresh: handleRefresh }) }),
10285
- /* @__PURE__ */ jsx(TabContent, { value: "ci", children: /* @__PURE__ */ jsx(EvalTable, { evals: ciEvals, isCIMode: true, onRefresh: handleRefresh }) })
10272
+ /* @__PURE__ */ jsx(TabContent$1, { value: "live", children: /* @__PURE__ */ jsx(EvalTable, { evals: liveEvals, isCIMode: false, onRefresh: handleRefresh }) }),
10273
+ /* @__PURE__ */ jsx(TabContent$1, { value: "ci", children: /* @__PURE__ */ jsx(EvalTable, { evals: ciEvals, isCIMode: true, onRefresh: handleRefresh }) })
10286
10274
  ] });
10287
10275
  }
10288
10276
  function EvalTable({ evals, isCIMode = false, onRefresh }) {
@@ -10954,7 +10942,7 @@ function AgentsTable({ agents, isLoading }) {
10954
10942
  return /* @__PURE__ */ jsx(EmptyAgentsTable, {});
10955
10943
  }
10956
10944
  const filteredRows = rows.filter((row) => row.original.name.toLowerCase().includes(search.toLowerCase()));
10957
- return /* @__PURE__ */ jsxs(Fragment, { children: [
10945
+ return /* @__PURE__ */ jsxs("div", { children: [
10958
10946
  /* @__PURE__ */ jsx(SearchbarWrapper, { children: /* @__PURE__ */ jsx(Searchbar, { onSearch: setSearch, label: "Search agents", placeholder: "Search agents" }) }),
10959
10947
  isLoading ? /* @__PURE__ */ jsx(AgentsTableSkeleton, {}) : /* @__PURE__ */ jsx(ScrollableContainer, { children: /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Table$1, { children: [
10960
10948
  /* @__PURE__ */ jsx(Thead, { className: "sticky top-0", children: ths.headers.map((header) => /* @__PURE__ */ jsx(Th, { style: { width: header.column.getSize() ?? "auto" }, children: flexRender(header.column.columnDef.header, header.getContext()) }, header.id)) }),
@@ -11579,7 +11567,7 @@ function RelationWrapper({ description, children }) {
11579
11567
  }
11580
11568
 
11581
11569
  function EntryListRoot({ children }) {
11582
- return /* @__PURE__ */ jsx("div", { className: "grid mb-[3rem]", children });
11570
+ return /* @__PURE__ */ jsx("div", { className: "grid", children });
11583
11571
  }
11584
11572
 
11585
11573
  function getColumnTemplate(columns) {
@@ -11796,30 +11784,29 @@ function getToPreviousEntryFn({ entries, id, update }) {
11796
11784
  return void 0;
11797
11785
  }
11798
11786
 
11799
- function SideDialog({
11787
+ function SideDialogRoot({
11800
11788
  dialogTitle,
11801
11789
  dialogDescription,
11802
11790
  isOpen,
11803
11791
  onClose,
11804
11792
  children,
11805
11793
  variant = "default",
11806
- hasCloseButton = true,
11794
+ level = 1,
11807
11795
  className
11808
11796
  }) {
11809
11797
  const isConfirmation = variant === "confirmation";
11810
11798
  return /* @__PURE__ */ jsx(DialogPrimitive.Root, { open: isOpen, onOpenChange: onClose, children: /* @__PURE__ */ jsxs(DialogPrimitive.Portal, { children: [
11811
- !isConfirmation && /* @__PURE__ */ jsx(DialogPrimitive.Overlay, { className: cn("bg-black top-0 bottom-0 right-0 left-0 fixed z-50 opacity-[0.25]") }),
11799
+ !isConfirmation && /* @__PURE__ */ jsx(DialogPrimitive.Overlay, { className: cn("bg-black top-0 bottom-0 right-0 left-0 fixed z-50 opacity-40") }),
11812
11800
  /* @__PURE__ */ jsxs(
11813
11801
  DialogPrimitive.Content,
11814
11802
  {
11815
11803
  className: cn(
11816
- "fixed top-0 bottom-0 right-0 border-l border-border1 z-50 bg-surface4",
11817
- "w-[calc(100vw-20rem)] max-w-[50rem]",
11818
- "3xl:max-w-[60rem]",
11819
- "4xl:max-w-[50%]",
11820
- "data-[state=closed]:animate-out data-[state=closed]:fade-out-0",
11804
+ "fixed top-0 bottom-0 right-0 border-l border-border2 z-50 bg-surface2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 ",
11821
11805
  {
11822
- "data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:slide-in-from-right-1/4": !isConfirmation,
11806
+ "w-[75vw] 2xl:w-[65vw] 4xl:w-[55vw]": level === 1,
11807
+ "w-[70vw] 2xl:w-[59vw] 4xl:w-[48vw]": level === 2,
11808
+ "w-[65vw] 2xl:w-[53vw] 4xl:w-[41vw]": level === 3,
11809
+ "data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:slide-in-from-right-1/4 shadow-[-3rem_0_2rem_0_rgba(0,0,0,0.75)]": !isConfirmation,
11823
11810
  "bg-surface2/70": isConfirmation
11824
11811
  },
11825
11812
  className
@@ -11829,15 +11816,15 @@ function SideDialog({
11829
11816
  /* @__PURE__ */ jsx(DialogPrimitive.Title, { children: dialogTitle }),
11830
11817
  /* @__PURE__ */ jsx(DialogPrimitive.Description, { children: dialogDescription })
11831
11818
  ] }),
11832
- !isConfirmation && hasCloseButton && /* @__PURE__ */ jsx(DialogPrimitive.Close, { asChild: true, children: /* @__PURE__ */ jsx(
11819
+ !isConfirmation && /* @__PURE__ */ jsx(DialogPrimitive.Close, { asChild: true, children: /* @__PURE__ */ jsx(
11833
11820
  "button",
11834
11821
  {
11835
11822
  className: cn(
11836
- "flex appearance-none items-center justify-center rounded-bl-lg h-[3.5rem] w-[3.5rem] absolute too-0 left-[-3.5rem] bg-surface4 text-icon4 border-l border-b border-border1",
11823
+ "flex appearance-none items-center justify-center rounded-bl-lg h-[3.5rem] w-[3.5rem] absolute top-0 left-[-3.5rem] bg-surface2 text-icon4 border-l border-b border-border2",
11837
11824
  "hover:surface5 hover:text-icon5"
11838
11825
  ),
11839
11826
  "aria-label": "Close",
11840
- children: isConfirmation ? /* @__PURE__ */ jsx(XIcon, {}) : /* @__PURE__ */ jsx(ChevronsRightIcon, {})
11827
+ children: /* @__PURE__ */ jsx(ChevronsRightIcon, {})
11841
11828
  }
11842
11829
  ) }),
11843
11830
  /* @__PURE__ */ jsx(
@@ -11855,125 +11842,97 @@ function SideDialog({
11855
11842
  ] }) });
11856
11843
  }
11857
11844
 
11858
- function SideDialogHeader({ children, className }) {
11859
- return /* @__PURE__ */ jsx("div", { className: cn("flex justify-between items-center pb-[1rem]", className), children });
11845
+ function MainContentLayout({
11846
+ children,
11847
+ className,
11848
+ style
11849
+ }) {
11850
+ const devStyleRequested = devUIStyleRequested("MainContentLayout");
11851
+ return /* @__PURE__ */ jsx(
11852
+ "main",
11853
+ {
11854
+ className: cn(`grid grid-rows-[auto_1fr] h-full items-start content-start`, className),
11855
+ style: { ...style, ...devStyleRequested ? { border: "3px dotted red" } : {} },
11856
+ children
11857
+ }
11858
+ );
11860
11859
  }
11861
-
11862
- function SideDialogFooter({ children, onNext, onPrevious, showInnerNav }) {
11863
- const handleOnNext = () => {
11864
- onNext?.();
11865
- };
11866
- const handleOnPrevious = () => {
11867
- onPrevious?.();
11868
- };
11869
- return /* @__PURE__ */ jsxs(
11860
+ function MainContentContent({
11861
+ children,
11862
+ className,
11863
+ isCentered = false,
11864
+ isDivided = false,
11865
+ hasLeftServiceColumn = false,
11866
+ style
11867
+ }) {
11868
+ const devStyleRequested = devUIStyleRequested("MainContentContent");
11869
+ return /* @__PURE__ */ jsx(
11870
11870
  "div",
11871
11871
  {
11872
11872
  className: cn(
11873
- "flex items-center justify-end gap-[1rem] px-[1.5rem] py-[1rem] min-h-[4rem] border-t border-border1",
11873
+ `grid overflow-y-auto h-full `,
11874
+ `overflow-x-auto min-w-[min-content]`,
11874
11875
  {
11875
- "justify-between": showInnerNav
11876
- }
11876
+ "items-start content-start": !isCentered && !isDivided && !hasLeftServiceColumn,
11877
+ "grid place-items-center": isCentered,
11878
+ "grid-cols-[1fr_1fr]": isDivided && !hasLeftServiceColumn,
11879
+ "grid-cols-[12rem_1fr_1fr]": isDivided && hasLeftServiceColumn,
11880
+ "grid-cols-[auto_1fr]": !isDivided && hasLeftServiceColumn
11881
+ },
11882
+ className
11877
11883
  ),
11878
- children: [
11879
- (onNext || onPrevious) && showInnerNav && /* @__PURE__ */ jsxs("div", { className: cn("flex gap-[1rem]"), children: [
11880
- /* @__PURE__ */ jsx(DialogPrimitive.Close, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { onClick: handleOnNext, disabled: !onNext, variant: "ghost", children: [
11881
- /* @__PURE__ */ jsx(XIcon, {}),
11882
- "Close"
11883
- ] }) }),
11884
- /* @__PURE__ */ jsxs(Button, { onClick: handleOnNext, disabled: !onNext, variant: "ghost", children: [
11885
- "Next",
11886
- /* @__PURE__ */ jsx(ArrowUpIcon, {})
11887
- ] }),
11888
- /* @__PURE__ */ jsxs(Button, { onClick: handleOnPrevious, disabled: !onPrevious, variant: "ghost", children: [
11889
- /* @__PURE__ */ jsx(ArrowDownIcon, {}),
11890
- "Previous"
11891
- ] })
11892
- ] }),
11893
- /* @__PURE__ */ jsx("div", { children })
11894
- ]
11884
+ style: { ...style, ...devStyleRequested ? { border: "3px dotted orange" } : {} },
11885
+ children
11895
11886
  }
11896
11887
  );
11897
11888
  }
11898
- function SideDialogFooterGroup({ children }) {
11899
- return /* @__PURE__ */ jsx("div", { className: "flex items-baseline gap-[1rem]", children });
11889
+ function devUIStyleRequested(name) {
11890
+ try {
11891
+ const raw = localStorage.getItem("add-dev-style-to-components");
11892
+ if (!raw) return false;
11893
+ const components = raw.split(",").map((c) => c.trim()).filter(Boolean);
11894
+ return components.includes(name);
11895
+ } catch (error) {
11896
+ console.error("Error reading or parsing localStorage:", error);
11897
+ return false;
11898
+ }
11899
+ }
11900
+
11901
+ function ButtonsGroup({ children, className }) {
11902
+ return /* @__PURE__ */ jsx("div", { className: cn(`flex gap-2 items-center`, "[&>button]:flex-grow", className), children });
11900
11903
  }
11901
11904
 
11902
- function SideDialogContent({ children, className, isCentered, isFullHeight, variant }) {
11903
- return /* @__PURE__ */ jsx("div", { className: cn("p-[3rem] py-[2rem] overflow-y-scroll", className), children: /* @__PURE__ */ jsx(
11904
- "div",
11905
- {
11906
- className: cn("grid gap-[2rem] max-w-[50rem] w-full mx-auto pb-[1rem] ", {
11907
- "items-center justify-center h-full content-center": isCentered,
11908
- "min-h-full": isFullHeight,
11909
- "content-start": !isFullHeight && !isCentered
11910
- }),
11911
- children
11912
- }
11913
- ) });
11905
+ function Sections({ children, className }) {
11906
+ return /* @__PURE__ */ jsx("div", { className: cn("grid gap-[3rem]", className), children });
11907
+ }
11908
+
11909
+ function SectionRoot({ children, className }) {
11910
+ return /* @__PURE__ */ jsx("section", { className: cn(`grid gap-[1rem]`, className), children });
11911
+ }
11912
+
11913
+ function SectionHeader({ children, className }) {
11914
+ return /* @__PURE__ */ jsx("header", { className: cn("grid items-center grid-cols-[1fr_auto]", className), children });
11914
11915
  }
11915
- function SideDialogSection({ children }) {
11916
+
11917
+ function SectionHeading({ headingLevel = "h2", children, className }) {
11918
+ const HeadingTag = headingLevel;
11916
11919
  return /* @__PURE__ */ jsx(
11917
- "div",
11920
+ HeadingTag,
11918
11921
  {
11919
11922
  className: cn(
11920
- "grid text-[0.875rem] text-icon5 gap-[1rem] justify-items-start",
11921
- "[&>h3]:text-icon3 [&>h3]:text-[1rem] [&>h3]:font-semibold [&>h3]:border-b [&>h3]:border-border1 [&>h3]:pb-[1rem] [&>h3]:pr-[1rem] [&>h3]:inline-flex [&>h3]:gap-[.5rem] [&>h3]:items-center",
11922
- "[&>h3>svg]:w-[1em] [&>h3>svg]:h-[1em] [&>h3>svg]:text-icon3"
11923
+ "flex items-center gap-[0.5em] text-[0.9375rem] font-bold text-icon4",
11924
+ "[&>svg]:w-[1.2em] [&>svg]:h-[1.2em] [&>svg]:opacity-50",
11925
+ className
11923
11926
  ),
11924
11927
  children
11925
11928
  }
11926
11929
  );
11927
11930
  }
11928
- function SideDialogKeyValueList({ items, className }) {
11929
- return /* @__PURE__ */ jsx("dl", { className: cn("grid grid-cols-[auto_1fr] gap-x-[2rem] gap-y-[.5rem] text-[0.875rem] content-start", className), children: items.map((item, index) => /* @__PURE__ */ jsxs(Fragment, { children: [
11930
- /* @__PURE__ */ jsxs("dt", { className: "text-icon3", children: [
11931
- item.key,
11932
- ":"
11933
- ] }),
11934
- /* @__PURE__ */ jsx("dd", { className: "text-icon4", children: item.value })
11935
- ] })) });
11936
- }
11937
11931
 
11938
- function SideDialogTop({ children, onNext, onPrevious, showInnerNav, className }) {
11939
- const handleOnNext = () => {
11940
- onNext?.();
11941
- };
11942
- const handleOnPrevious = () => {
11943
- onPrevious?.();
11944
- };
11945
- return /* @__PURE__ */ jsx(
11946
- "div",
11947
- {
11948
- className: cn(`flex justify-between h-[3.5rem] items-center text-icon5 text-[.875rem] pl-[1.5rem]`, className),
11949
- children: /* @__PURE__ */ jsxs("div", { className: cn("flex items-center gap-[2rem]", "[&_svg]:w-[1.1em] [&_svg]:h-[1.1em] [&_svg]:text-icon3"), children: [
11950
- children,
11951
- (onNext || onPrevious) && showInnerNav && /* @__PURE__ */ jsxs(Fragment, { children: [
11952
- /* @__PURE__ */ jsx("span", { className: "text-icon3", children: "|" }),
11953
- /* @__PURE__ */ jsxs(
11954
- "div",
11955
- {
11956
- className: cn(
11957
- "flex gap-[1rem] items-baseline"
11958
- // '[&>button]:text-[0.875rem] [&>button]:flex [&>button]:items-center [&>button]:px-[0.5rem] [&>button]:py-[0.8rem] [&>button]:leading-[1]',
11959
- ),
11960
- children: [
11961
- /* @__PURE__ */ jsxs(Button, { onClick: handleOnPrevious, disabled: !onPrevious, variant: "ghost", children: [
11962
- "Previous",
11963
- /* @__PURE__ */ jsx(ArrowUpIcon, {})
11964
- ] }),
11965
- /* @__PURE__ */ jsxs(Button, { onClick: handleOnNext, disabled: !onNext, variant: "ghost", children: [
11966
- "Next",
11967
- /* @__PURE__ */ jsx(ArrowDownIcon, {})
11968
- ] })
11969
- ]
11970
- }
11971
- )
11972
- ] })
11973
- ] })
11974
- }
11975
- );
11976
- }
11932
+ const Section = Object.assign(SectionRoot, {
11933
+ Header: SectionHeader,
11934
+ Heading: SectionHeading
11935
+ });
11977
11936
 
11978
11937
  const useCodemirrorTheme = () => {
11979
11938
  return useMemo(
@@ -11991,7 +11950,7 @@ const useCodemirrorTheme = () => {
11991
11950
  []
11992
11951
  );
11993
11952
  };
11994
- function SideDialogCodeSection({ codeStr = "", title, simplified = false }) {
11953
+ function SideDialogCodeSection({ codeStr = "", title, icon, simplified = false }) {
11995
11954
  const theme = useCodemirrorTheme();
11996
11955
  const [showAsMultilineText, setShowAsMultilineText] = useState(false);
11997
11956
  const hasMultilineText = useMemo(() => {
@@ -12003,22 +11962,19 @@ function SideDialogCodeSection({ codeStr = "", title, simplified = false }) {
12003
11962
  }
12004
11963
  }, [codeStr]);
12005
11964
  const finalCodeStr = showAsMultilineText ? codeStr?.replace(/\\n/g, "\n") : codeStr;
12006
- return /* @__PURE__ */ jsx("section", { className: "border border-border1 rounded-lg", children: /* @__PURE__ */ jsxs("div", { className: "border-b border-border1 last:border-b-0 grid", children: [
12007
- /* @__PURE__ */ jsxs("div", { className: "p-[1rem] px-[1.5rem] border-b border-border1 grid grid-cols-[1fr_auto]", children: [
12008
- /* @__PURE__ */ jsx("h3", { children: title }),
12009
- /* @__PURE__ */ jsxs("div", { className: "flex gap-2 items-center justify-end", children: [
11965
+ return /* @__PURE__ */ jsxs(Section, { children: [
11966
+ /* @__PURE__ */ jsxs(Section.Header, { children: [
11967
+ /* @__PURE__ */ jsxs(Section.Heading, { children: [
11968
+ icon,
11969
+ title
11970
+ ] }),
11971
+ /* @__PURE__ */ jsxs(ButtonsGroup, { children: [
12010
11972
  /* @__PURE__ */ jsx(CopyButton, { content: codeStr || "No content" }),
12011
11973
  hasMultilineText && /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: () => setShowAsMultilineText(!showAsMultilineText), children: showAsMultilineText ? /* @__PURE__ */ jsx(AlignLeftIcon, {}) : /* @__PURE__ */ jsx(AlignJustifyIcon, {}) })
12012
11974
  ] })
12013
11975
  ] }),
12014
- /* @__PURE__ */ jsx(
12015
- "div",
12016
- {
12017
- className: cn("bg-surface3 p-[1rem] overflow-auto text-icon4 text-[0.875rem] [&>div]:border-none break-all"),
12018
- children: codeStr && /* @__PURE__ */ jsx(Fragment, { children: simplified ? /* @__PURE__ */ jsx("div", { className: "text-icon4 text-[0.875rem] py-[1rem] font-mono break-all mx-[1.5rem]", children: /* @__PURE__ */ jsx("pre", { className: "text-wrap", children: codeStr }) }) : /* @__PURE__ */ jsx(CodeMirror, { extensions: [json(), EditorView.lineWrapping], theme, value: finalCodeStr }) })
12019
- }
12020
- )
12021
- ] }) });
11976
+ codeStr && /* @__PURE__ */ jsx("div", { className: "bg-black/20 p-[1rem] overflow-hidden rounded-xl border border-white/10 text-icon4 text-[0.875rem] break-all", children: simplified ? /* @__PURE__ */ jsx("div", { className: "text-icon4 font-mono break-all px-[0.5rem]", children: /* @__PURE__ */ jsx("pre", { className: "text-wrap", children: codeStr }) }) : /* @__PURE__ */ jsx(CodeMirror, { extensions: [json(), EditorView.lineWrapping], theme, value: finalCodeStr }) })
11977
+ ] });
12022
11978
  }
12023
11979
  function containsInnerNewline(obj) {
12024
11980
  if (typeof obj === "string") {
@@ -12051,6 +12007,69 @@ function SideDialogHeading({ children, className, as = "h1" }) {
12051
12007
  );
12052
12008
  }
12053
12009
 
12010
+ function SideDialogContent({ children, className }) {
12011
+ return /* @__PURE__ */ jsx("div", { className: cn("p-[1.5rem] pl-[2.25rem] overflow-y-scroll grid gap-[1.5rem] content-start", className), children: /* @__PURE__ */ jsx("div", { className: cn("grid gap-[1.5rem] mb-[2rem] "), children }) });
12012
+ }
12013
+
12014
+ function SideDialogHeader({ children, className }) {
12015
+ return /* @__PURE__ */ jsx("div", { className: cn("flex justify-between items-center pb-[1rem]", className), children });
12016
+ }
12017
+
12018
+ function SideDialogTop({ children, withTopSeparator, className }) {
12019
+ return /* @__PURE__ */ jsx(
12020
+ "div",
12021
+ {
12022
+ className: cn(
12023
+ `flex h-[3.5rem] items-center text-icon5 text-[.875rem] pl-[1.5rem] relative gap-[1rem]`,
12024
+ '[&:after]:content-[""] [&:after]:absolute [&:after]:left-[1.5rem] [&:after]:right-[1.5rem] [&:after]:bottom-0 [&:after]:border-b [&:after]:border-border1',
12025
+ {
12026
+ '[&:before]:content-[""] [&:before]:absolute [&:before]:left-[1.5rem] [&:before]:right-[1.5rem] [&:before]:top-0 [&:before]:border-t [&:before]:border-border1': withTopSeparator
12027
+ },
12028
+ className
12029
+ ),
12030
+ children
12031
+ }
12032
+ );
12033
+ }
12034
+
12035
+ function SideDialogNav({ onNext, onPrevious, className }) {
12036
+ const handleOnNext = () => {
12037
+ onNext?.();
12038
+ };
12039
+ const handleOnPrevious = () => {
12040
+ onPrevious?.();
12041
+ };
12042
+ return /* @__PURE__ */ jsx(
12043
+ "div",
12044
+ {
12045
+ className: cn(
12046
+ "flex items-center gap-[1rem]",
12047
+ "[&_svg]:w-[1.1em] [&_svg]:h-[1.1em] [&_svg]:text-icon3",
12048
+ className
12049
+ ),
12050
+ children: (onNext || onPrevious) && /* @__PURE__ */ jsxs("div", { className: cn("flex gap-[1rem] items-baseline"), children: [
12051
+ /* @__PURE__ */ jsxs(Button, { onClick: handleOnPrevious, disabled: !onPrevious, variant: "ghost", children: [
12052
+ "Previous",
12053
+ /* @__PURE__ */ jsx(ArrowUpIcon, {})
12054
+ ] }),
12055
+ /* @__PURE__ */ jsxs(Button, { onClick: handleOnNext, disabled: !onNext, variant: "ghost", children: [
12056
+ "Next",
12057
+ /* @__PURE__ */ jsx(ArrowDownIcon, {})
12058
+ ] })
12059
+ ] })
12060
+ }
12061
+ );
12062
+ }
12063
+
12064
+ const SideDialog = Object.assign(SideDialogRoot, {
12065
+ Top: SideDialogTop,
12066
+ Header: SideDialogHeader,
12067
+ Heading: SideDialogHeading,
12068
+ Content: SideDialogContent,
12069
+ CodeSection: SideDialogCodeSection,
12070
+ Nav: SideDialogNav
12071
+ });
12072
+
12054
12073
  function EntityMainHeader({
12055
12074
  title,
12056
12075
  description,
@@ -12465,7 +12484,7 @@ function TextAndIcon({ children, className }) {
12465
12484
  {
12466
12485
  className: cn(
12467
12486
  "flex items-center gap-[0.5em] text-icon4 text-[0.875rem]",
12468
- "[&>svg]:w-[1.2em] [&>svg]:h-[1.2em] [&>svg]:opacity-50 [&_svg]:flex-shrink-0",
12487
+ "[&>svg]:w-[1.1em] [&>svg]:h-[1.1em] [&>svg]:opacity-50 [&_svg]:flex-shrink-0",
12469
12488
  className
12470
12489
  ),
12471
12490
  children
@@ -12478,85 +12497,304 @@ function getShortId(id) {
12478
12497
  return id.slice(0, 8);
12479
12498
  }
12480
12499
 
12481
- const scoresListColumns = [
12482
- { name: "date", label: "Date", size: "4.5rem" },
12483
- { name: "time", label: "Time", size: "6.5rem" },
12484
- { name: "input", label: "Input", size: "1fr" },
12485
- { name: "entityId", label: "Entity", size: "10rem" },
12486
- { name: "score", label: "Score", size: "3rem" }
12487
- ];
12488
- function ScoresList({
12489
- scores,
12490
- pagination,
12491
- onScoreClick,
12492
- onPageChange,
12493
- errorMsg,
12494
- selectedScoreId
12495
- }) {
12496
- if (!scores) {
12497
- return null;
12498
- }
12499
- const scoresHasMore = pagination?.hasMore;
12500
- const handleNextPage = () => {
12501
- if (scoresHasMore) {
12502
- onPageChange?.(pagination.page + 1);
12500
+ function Notification({ children, className, isVisible, autoDismiss = true, dismissTime = 5e3 }) {
12501
+ const [localIsVisible, setLocalIsVisible] = useState(isVisible);
12502
+ useEffect(() => {
12503
+ if (autoDismiss && isVisible) {
12504
+ const timer = setTimeout(() => {
12505
+ setLocalIsVisible(false);
12506
+ }, dismissTime);
12507
+ return () => clearTimeout(timer);
12503
12508
  }
12504
- };
12505
- const handlePrevPage = () => {
12506
- if (pagination?.page && pagination.page > 0) {
12507
- onPageChange?.(pagination.page - 1);
12509
+ }, [autoDismiss, isVisible, dismissTime]);
12510
+ useEffect(() => {
12511
+ setLocalIsVisible(isVisible);
12512
+ }, [isVisible]);
12513
+ if (!localIsVisible) return null;
12514
+ return /* @__PURE__ */ jsxs(
12515
+ "div",
12516
+ {
12517
+ className: cn(
12518
+ "grid grid-cols-[1fr_auto] gap-[0.5rem] rounded-l bg-white/5 p-[1.5rem] py-[1rem] text-[0.875rem] text-icon3 items-center",
12519
+ "[&>svg]:w-[1.1em] [&>svg]:h-[1.1em] [&>svg]:opacity-50",
12520
+ className
12521
+ ),
12522
+ children: [
12523
+ /* @__PURE__ */ jsx("div", { className: "flex gap-[0.5rem] items-center", children }),
12524
+ /* @__PURE__ */ jsxs(Button, { variant: "ghost", onClick: () => setLocalIsVisible(false), children: [
12525
+ /* @__PURE__ */ jsx(XIcon, {}),
12526
+ /* @__PURE__ */ jsx(VisuallyHidden$1, { children: "Dismiss" })
12527
+ ] })
12528
+ ]
12508
12529
  }
12509
- };
12510
- return /* @__PURE__ */ jsxs(EntryList, { children: [
12511
- /* @__PURE__ */ jsxs(EntryList.Trim, { children: [
12512
- /* @__PURE__ */ jsx(EntryList.Header, { columns: scoresListColumns }),
12513
- errorMsg ? /* @__PURE__ */ jsx(EntryList.Message, { message: errorMsg, type: "error" }) : /* @__PURE__ */ jsx(Fragment, { children: scores.length > 0 ? /* @__PURE__ */ jsx(EntryList.Entries, { children: scores.map((score) => {
12514
- const createdAtDate = new Date(score.createdAt);
12515
- const isTodayDate = isToday(createdAtDate);
12516
- const entry = {
12517
- id: score.id,
12518
- date: isTodayDate ? "Today" : format(createdAtDate, "MMM dd"),
12519
- time: format(createdAtDate, "h:mm:ss aaa"),
12520
- input: JSON.stringify(score?.input),
12521
- entityId: score.entityId,
12522
- score: score.score
12523
- };
12524
- return /* @__PURE__ */ jsx(
12525
- EntryList.Entry,
12526
- {
12527
- entry,
12528
- isSelected: selectedScoreId === score.id,
12529
- columns: scoresListColumns,
12530
- onClick: onScoreClick,
12531
- children: scoresListColumns.map((col, index) => {
12532
- const key = `${index}-${score.id}`;
12533
- return /* @__PURE__ */ jsx(EntryList.EntryText, { children: entry?.[col.name] }, key);
12534
- })
12535
- },
12536
- entry.id
12537
- );
12538
- }) }) : /* @__PURE__ */ jsx(EntryList.Message, { message: "No scores for this scorer yet" }) })
12539
- ] }),
12540
- /* @__PURE__ */ jsx(
12541
- EntryList.Pagination,
12542
- {
12543
- currentPage: pagination?.page || 0,
12544
- onNextPage: handleNextPage,
12545
- onPrevPage: handlePrevPage,
12546
- hasMore: scoresHasMore
12547
- }
12548
- )
12549
- ] });
12530
+ );
12550
12531
  }
12551
12532
 
12552
- function ScoreDialog({
12553
- scorer,
12554
- score,
12555
- isOpen,
12533
+ function MainSidebarNavSeparator({ className }) {
12534
+ return /* @__PURE__ */ jsx(
12535
+ "div",
12536
+ {
12537
+ className: cn(
12538
+ "min-h-[1.3rem] relative",
12539
+ '[&:after]:content-[""] [&:after]:block [&:after]:absolute [&:after]:h-[0px] [&:after]:border-border1 [&:after]:border-t [&:after]:top-[48%] [&:after]:left-[0.75rem] [&:after]:right-[0.75rem]',
12540
+ className
12541
+ )
12542
+ }
12543
+ );
12544
+ }
12545
+
12546
+ function MainSidebarRoot({ children, className }) {
12547
+ const { state, toggleSidebar } = useMainSidebar();
12548
+ const isCollapsed = state === "collapsed";
12549
+ return /* @__PURE__ */ jsxs(
12550
+ "div",
12551
+ {
12552
+ className: cn(
12553
+ "flex flex-col h-full px-[1rem] pb-[1rem] relative overflow-y-auto",
12554
+ {
12555
+ "lg:min-w-[13rem] xl:min-w-[14rem] 2xl:min-w-[15rem] 3xl:min-w-[16rem] 4xl:min-w-[17rem]": !isCollapsed
12556
+ },
12557
+ className
12558
+ ),
12559
+ children: [
12560
+ children,
12561
+ /* @__PURE__ */ jsx(MainSidebarNavSeparator, {}),
12562
+ /* @__PURE__ */ jsx(
12563
+ "button",
12564
+ {
12565
+ onClick: toggleSidebar,
12566
+ className: cn(
12567
+ "inline-flex w-auto items-center text-icon3 h-[2rem] px-[0.75rem] rounded-md",
12568
+ "hover:bg-surface4",
12569
+ "[&_svg]:w-[1rem] [&_svg]:h-[1rem] [&_svg]:text-icon3",
12570
+ {
12571
+ "ml-auto": !isCollapsed
12572
+ }
12573
+ ),
12574
+ "aria-label": "Toggle sidebar",
12575
+ children: /* @__PURE__ */ jsx(
12576
+ PanelRightIcon,
12577
+ {
12578
+ className: cn({
12579
+ "rotate-180": isCollapsed
12580
+ })
12581
+ }
12582
+ )
12583
+ }
12584
+ ),
12585
+ /* @__PURE__ */ jsx(
12586
+ "button",
12587
+ {
12588
+ onClick: toggleSidebar,
12589
+ className: cn("w-[.75rem] h-full right-0 top-0 absolute opacity-10", {
12590
+ "cursor-w-resize": !isCollapsed,
12591
+ "cursor-e-resize": isCollapsed
12592
+ }),
12593
+ "aria-label": "Toggle sidebar"
12594
+ }
12595
+ )
12596
+ ]
12597
+ }
12598
+ );
12599
+ }
12600
+
12601
+ function MainSidebarBottom({ children, className }) {
12602
+ return /* @__PURE__ */ jsx("div", { className: cn("mt-auto", className), children });
12603
+ }
12604
+
12605
+ function MainSidebarNav({ children, className }) {
12606
+ return /* @__PURE__ */ jsx("nav", { className: cn("", className), children });
12607
+ }
12608
+
12609
+ function MainSidebarNavSection({ children, className }) {
12610
+ return /* @__PURE__ */ jsx("section", { className: cn("grid items-start content-center relative", className), children });
12611
+ }
12612
+
12613
+ function MainSidebarNavLink({
12614
+ link,
12615
+ state = "default",
12616
+ children,
12617
+ isActive,
12618
+ className
12619
+ }) {
12620
+ const { Link } = useLinkComponent();
12621
+ const isDefaultState = state === "default";
12622
+ const isFeatured = link?.variant === "featured";
12623
+ const linkParams = link?.url?.startsWith("http") ? { target: "_blank", rel: "noreferrer" } : {};
12624
+ return /* @__PURE__ */ jsx(
12625
+ "li",
12626
+ {
12627
+ className: cn(
12628
+ "flex ",
12629
+ "[&>a]:flex [&>a]:items-center [&>a]:min-h-[2rem] [&>a]:gap-[10px] [&>a]:text-[0.8125rem] [&>a]:text-icon3 [&>a]:py-[6px] [&>a]:px-[0.75rem] [&>a]:w-full [&>a]:rounded-lg [&>a]:justify-center",
12630
+ "[&_svg]:w-[1rem] [&_svg]:h-[1rem] [&_svg]:text-icon3/60",
12631
+ "[&>a:hover]:bg-surface4 [&>a:hover]:text-icon5 [&>a:hover_svg]:text-icon3",
12632
+ {
12633
+ "[&>a]:text-icon5 [&>a]:bg-surface3": isActive,
12634
+ "[&_svg]:text-icon5": isActive,
12635
+ "[&>a]:justify-start ": isDefaultState,
12636
+ "[&_svg]:text-icon3": !isDefaultState,
12637
+ "[&>a]:rounded-md [&>a]:my-[0.5rem] [&>a]:bg-accent1/75 [&>a:hover]:bg-accent1/85 [&>a]:text-black [&>a:hover]:text-black": isFeatured,
12638
+ "[&_svg]:text-black/75": isFeatured
12639
+ },
12640
+ className
12641
+ ),
12642
+ children: link ? /* @__PURE__ */ jsxs(Link, { href: link.url, ...linkParams, children: [
12643
+ isDefaultState ? /* @__PURE__ */ jsx(Fragment, { children: link.icon && link.icon }) : /* @__PURE__ */ jsxs(Tooltip, { children: [
12644
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: link.icon && link.icon }),
12645
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", align: "center", className: "bg-border1 text-icon6 ml-[1rem]", children: link.name })
12646
+ ] }),
12647
+ isDefaultState ? link.name : /* @__PURE__ */ jsx(VisuallyHidden$1, { children: link.name }),
12648
+ " ",
12649
+ children
12650
+ ] }) : children
12651
+ }
12652
+ );
12653
+ }
12654
+
12655
+ function MainSidebarNavHeader({ children, className, state = "default" }) {
12656
+ const isDefaultState = state === "default";
12657
+ return /* @__PURE__ */ jsxs("div", { className: cn("grid grid-cols-[auto_1fr] items-center min-h-[2.8rem] ", className), children: [
12658
+ /* @__PURE__ */ jsx(
12659
+ "header",
12660
+ {
12661
+ className: cn("text-[0.6875rem] uppercase text-icon3/75 tracking-widest", {
12662
+ "pl-[0.75rem]": isDefaultState
12663
+ }),
12664
+ children: isDefaultState ? children : /* @__PURE__ */ jsx(VisuallyHidden$1, { children })
12665
+ }
12666
+ ),
12667
+ /* @__PURE__ */ jsx(MainSidebarNavSeparator, {})
12668
+ ] });
12669
+ }
12670
+
12671
+ function MainSidebarNavList({ children, className }) {
12672
+ return /* @__PURE__ */ jsx("ul", { className: cn("grid gap-[0.25rem] items-start content-center ", className), children });
12673
+ }
12674
+
12675
+ const SIDEBAR_COOKIE_NAME = "sidebar:state";
12676
+ const MainSidebarContext = React__default.createContext(null);
12677
+ function useMainSidebar() {
12678
+ const context = React__default.useContext(MainSidebarContext);
12679
+ if (!context) {
12680
+ throw new Error("useMainSidebar must be used within a MainSidebarProvider.");
12681
+ }
12682
+ return context;
12683
+ }
12684
+ function stateInitializer() {
12685
+ const storedState = window.localStorage.getItem(SIDEBAR_COOKIE_NAME);
12686
+ return storedState === "collapsed" ? "collapsed" : "default";
12687
+ }
12688
+ const setLocalStorage = (value) => {
12689
+ window.localStorage.setItem(SIDEBAR_COOKIE_NAME, value.toString());
12690
+ };
12691
+ function MainSidebarProvider({ children }) {
12692
+ const [state, setState] = React__default.useState(stateInitializer);
12693
+ const toggleSidebar = React__default.useCallback(() => {
12694
+ setLocalStorage(state === "default" ? "collapsed" : "default");
12695
+ setState(state === "default" ? "collapsed" : "default");
12696
+ }, [state]);
12697
+ const contextValue = React__default.useMemo(
12698
+ () => ({
12699
+ state,
12700
+ toggleSidebar
12701
+ }),
12702
+ [state, toggleSidebar]
12703
+ );
12704
+ return /* @__PURE__ */ jsx(MainSidebarContext.Provider, { value: contextValue, children });
12705
+ }
12706
+
12707
+ const MainSidebar = Object.assign(MainSidebarRoot, {
12708
+ Bottom: MainSidebarBottom,
12709
+ Nav: MainSidebarNav,
12710
+ NavSection: MainSidebarNavSection,
12711
+ NavLink: MainSidebarNavLink,
12712
+ NavHeader: MainSidebarNavHeader,
12713
+ NavList: MainSidebarNavList,
12714
+ NavSeparator: MainSidebarNavSeparator
12715
+ });
12716
+
12717
+ const scoresListColumns = [
12718
+ { name: "date", label: "Date", size: "4.5rem" },
12719
+ { name: "time", label: "Time", size: "6.5rem" },
12720
+ { name: "input", label: "Input", size: "1fr" },
12721
+ { name: "entityId", label: "Entity", size: "10rem" },
12722
+ { name: "score", label: "Score", size: "3rem" }
12723
+ ];
12724
+ function ScoresList({
12725
+ scores,
12726
+ pagination,
12727
+ onScoreClick,
12728
+ onPageChange,
12729
+ errorMsg,
12730
+ selectedScoreId
12731
+ }) {
12732
+ if (!scores) {
12733
+ return null;
12734
+ }
12735
+ const scoresHasMore = pagination?.hasMore;
12736
+ const handleNextPage = () => {
12737
+ if (scoresHasMore) {
12738
+ onPageChange?.(pagination.page + 1);
12739
+ }
12740
+ };
12741
+ const handlePrevPage = () => {
12742
+ if (pagination?.page && pagination.page > 0) {
12743
+ onPageChange?.(pagination.page - 1);
12744
+ }
12745
+ };
12746
+ return /* @__PURE__ */ jsxs(EntryList, { children: [
12747
+ /* @__PURE__ */ jsxs(EntryList.Trim, { children: [
12748
+ /* @__PURE__ */ jsx(EntryList.Header, { columns: scoresListColumns }),
12749
+ errorMsg ? /* @__PURE__ */ jsx(EntryList.Message, { message: errorMsg, type: "error" }) : /* @__PURE__ */ jsx(Fragment, { children: scores.length > 0 ? /* @__PURE__ */ jsx(EntryList.Entries, { children: scores.map((score) => {
12750
+ const createdAtDate = new Date(score.createdAt);
12751
+ const isTodayDate = isToday(createdAtDate);
12752
+ const entry = {
12753
+ id: score.id,
12754
+ date: isTodayDate ? "Today" : format(createdAtDate, "MMM dd"),
12755
+ time: format(createdAtDate, "h:mm:ss aaa"),
12756
+ input: JSON.stringify(score?.input),
12757
+ entityId: score.entityId,
12758
+ score: score.score
12759
+ };
12760
+ return /* @__PURE__ */ jsx(
12761
+ EntryList.Entry,
12762
+ {
12763
+ entry,
12764
+ isSelected: selectedScoreId === score.id,
12765
+ columns: scoresListColumns,
12766
+ onClick: onScoreClick,
12767
+ children: scoresListColumns.map((col, index) => {
12768
+ const key = `${index}-${score.id}`;
12769
+ return /* @__PURE__ */ jsx(EntryList.EntryText, { children: entry?.[col.name] }, key);
12770
+ })
12771
+ },
12772
+ entry.id
12773
+ );
12774
+ }) }) : /* @__PURE__ */ jsx(EntryList.Message, { message: "No scores for this scorer yet" }) })
12775
+ ] }),
12776
+ /* @__PURE__ */ jsx(
12777
+ EntryList.Pagination,
12778
+ {
12779
+ currentPage: pagination?.page || 0,
12780
+ onNextPage: handleNextPage,
12781
+ onPrevPage: handlePrevPage,
12782
+ hasMore: scoresHasMore
12783
+ }
12784
+ )
12785
+ ] });
12786
+ }
12787
+
12788
+ function ScoreDialog({
12789
+ score,
12790
+ scorerName,
12791
+ isOpen,
12556
12792
  onClose,
12557
12793
  onNext,
12558
12794
  onPrevious,
12559
- computeTraceLink
12795
+ computeTraceLink,
12796
+ dialogLevel = 1,
12797
+ usageContext = "scorerPage"
12560
12798
  }) {
12561
12799
  const { Link } = useLinkComponent();
12562
12800
  return /* @__PURE__ */ jsxs(
@@ -12566,77 +12804,144 @@ function ScoreDialog({
12566
12804
  dialogDescription: "View and analyze score details",
12567
12805
  isOpen,
12568
12806
  onClose,
12569
- className: cn("w-[calc(100vw-20rem)] max-w-[80%]", "3xl:max-w-[65%]", "4xl:max-w-[55%]"),
12807
+ level: dialogLevel,
12570
12808
  children: [
12571
- /* @__PURE__ */ jsx(SideDialogTop, { onNext, onPrevious, showInnerNav: true, children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-[1rem] text-icon4 text-[0.875rem]", children: [
12572
- /* @__PURE__ */ jsxs(TextAndIcon, { children: [
12809
+ /* @__PURE__ */ jsxs(SideDialog.Top, { children: [
12810
+ usageContext === "scorerPage" && /* @__PURE__ */ jsxs(TextAndIcon, { children: [
12573
12811
  /* @__PURE__ */ jsx(GaugeIcon, {}),
12574
12812
  " ",
12575
- scorer?.config?.name
12813
+ scorerName
12814
+ ] }),
12815
+ usageContext === "aiSpanDialog" && /* @__PURE__ */ jsxs(Fragment, { children: [
12816
+ /* @__PURE__ */ jsxs(TextAndIcon, { children: [
12817
+ /* @__PURE__ */ jsx(EyeIcon, {}),
12818
+ " ",
12819
+ getShortId(score?.traceId)
12820
+ ] }),
12821
+ score?.spanId && /* @__PURE__ */ jsxs(Fragment, { children: [
12822
+ "›",
12823
+ /* @__PURE__ */ jsxs(TextAndIcon, { children: [
12824
+ /* @__PURE__ */ jsx(ChevronsLeftRightEllipsisIcon, {}),
12825
+ getShortId(score?.spanId)
12826
+ ] })
12827
+ ] })
12576
12828
  ] }),
12577
12829
  "›",
12578
12830
  /* @__PURE__ */ jsxs(TextAndIcon, { children: [
12579
- /* @__PURE__ */ jsx(HashIcon, {}),
12580
- score?.id
12581
- ] })
12582
- ] }) }),
12583
- /* @__PURE__ */ jsx("div", { className: "p-[1.5rem] px-[2.5rem] overflow-y-auto grid gap-[1.5rem] content-start", children: /* @__PURE__ */ jsxs("div", { className: "grid gap-[1.5rem] mb-[2rem]", children: [
12584
- score?.traceId && /* @__PURE__ */ jsx(
12585
- KeyValueList,
12586
- {
12587
- data: [
12588
- {
12589
- label: "Trace ID",
12590
- value: /* @__PURE__ */ jsx(Link, { href: computeTraceLink(score?.traceId), children: score?.traceId }),
12591
- key: "traceId"
12592
- },
12593
- ...score?.spanId ? [
12831
+ /* @__PURE__ */ jsx(CalculatorIcon, {}),
12832
+ getShortId(score?.id)
12833
+ ] }),
12834
+ "|",
12835
+ /* @__PURE__ */ jsx(SideDialog.Nav, { onNext, onPrevious })
12836
+ ] }),
12837
+ /* @__PURE__ */ jsxs(SideDialog.Content, { children: [
12838
+ /* @__PURE__ */ jsxs(SideDialog.Header, { children: [
12839
+ /* @__PURE__ */ jsxs(SideDialog.Heading, { children: [
12840
+ /* @__PURE__ */ jsx(CalculatorIcon, {}),
12841
+ " Score"
12842
+ ] }),
12843
+ /* @__PURE__ */ jsxs(TextAndIcon, { children: [
12844
+ /* @__PURE__ */ jsx(HashIcon, {}),
12845
+ " ",
12846
+ score?.id
12847
+ ] })
12848
+ ] }),
12849
+ /* @__PURE__ */ jsxs(Sections, { children: [
12850
+ /* @__PURE__ */ jsx(
12851
+ KeyValueList,
12852
+ {
12853
+ data: [
12854
+ ...usageContext === "aiSpanDialog" ? [
12855
+ {
12856
+ label: "Scorer",
12857
+ value: score?.scorer?.name || "-",
12858
+ key: "scorer-name"
12859
+ }
12860
+ ] : [],
12594
12861
  {
12595
- label: "Span ID",
12596
- value: /* @__PURE__ */ jsx(Link, { href: computeTraceLink(score?.traceId, score?.spanId), children: score?.spanId }),
12597
- key: "spanId"
12598
- }
12599
- ] : []
12600
- ],
12601
- LinkComponent: Link
12602
- }
12603
- ),
12604
- /* @__PURE__ */ jsx(
12605
- SideDialogCodeSection,
12606
- {
12607
- title: `Score: ${Number.isNaN(score?.score) ? "n/a" : score?.score}`,
12608
- codeStr: score?.reason,
12609
- simplified: true
12610
- }
12611
- ),
12612
- /* @__PURE__ */ jsx(SideDialogCodeSection, { title: "Input", codeStr: JSON.stringify(score?.input || null, null, 2) }),
12613
- /* @__PURE__ */ jsx(SideDialogCodeSection, { title: "Output", codeStr: JSON.stringify(score?.output || null, null, 2) }),
12614
- /* @__PURE__ */ jsx(
12615
- SideDialogCodeSection,
12616
- {
12617
- title: "Preprocess Prompt",
12618
- codeStr: score?.preprocessPrompt || "null",
12619
- simplified: true
12620
- }
12621
- ),
12622
- /* @__PURE__ */ jsx(SideDialogCodeSection, { title: "Analyze Prompt", codeStr: score?.analyzePrompt || "null", simplified: true }),
12623
- /* @__PURE__ */ jsx(
12624
- SideDialogCodeSection,
12625
- {
12626
- title: "Generate Score Prompt",
12627
- codeStr: score?.generateScorePrompt || "null",
12628
- simplified: true
12629
- }
12630
- ),
12631
- /* @__PURE__ */ jsx(
12632
- SideDialogCodeSection,
12633
- {
12634
- title: "Generate Reason Prompt",
12635
- codeStr: score?.generateReasonPrompt || "null",
12636
- simplified: true
12637
- }
12638
- )
12639
- ] }) })
12862
+ label: "Created at",
12863
+ value: score?.createdAt ? format$1(new Date(score?.createdAt), "MMM d, h:mm:ss aaa") : "n/a",
12864
+ key: "date"
12865
+ },
12866
+ ...usageContext !== "aiSpanDialog" ? [
12867
+ {
12868
+ label: "Trace ID",
12869
+ value: score?.traceId ? /* @__PURE__ */ jsx(Link, { href: computeTraceLink(score?.traceId), children: score?.traceId }) : "n/a",
12870
+ key: "traceId"
12871
+ },
12872
+ {
12873
+ label: "Span ID",
12874
+ value: score?.traceId && score?.spanId ? /* @__PURE__ */ jsx(Link, { href: computeTraceLink(score?.traceId, score?.spanId), children: score?.spanId }) : "n/a",
12875
+ key: "spanId"
12876
+ }
12877
+ ] : []
12878
+ ],
12879
+ LinkComponent: Link
12880
+ }
12881
+ ),
12882
+ /* @__PURE__ */ jsx(
12883
+ SideDialog.CodeSection,
12884
+ {
12885
+ title: `Score: ${Number.isNaN(score?.score) ? "n/a" : score?.score}`,
12886
+ icon: /* @__PURE__ */ jsx(GaugeIcon, {}),
12887
+ codeStr: score?.reason || "null",
12888
+ simplified: true
12889
+ }
12890
+ ),
12891
+ /* @__PURE__ */ jsx(
12892
+ SideDialog.CodeSection,
12893
+ {
12894
+ title: "Input",
12895
+ icon: /* @__PURE__ */ jsx(FileInputIcon, {}),
12896
+ codeStr: JSON.stringify(score?.input || null, null, 2)
12897
+ }
12898
+ ),
12899
+ /* @__PURE__ */ jsx(
12900
+ SideDialog.CodeSection,
12901
+ {
12902
+ title: "Output",
12903
+ icon: /* @__PURE__ */ jsx(FileOutputIcon, {}),
12904
+ codeStr: JSON.stringify(score?.output || null, null, 2)
12905
+ }
12906
+ ),
12907
+ /* @__PURE__ */ jsx(
12908
+ SideDialog.CodeSection,
12909
+ {
12910
+ title: "Preprocess Prompt",
12911
+ icon: /* @__PURE__ */ jsx(ReceiptText, {}),
12912
+ codeStr: score?.preprocessPrompt || "null",
12913
+ simplified: true
12914
+ }
12915
+ ),
12916
+ /* @__PURE__ */ jsx(
12917
+ SideDialog.CodeSection,
12918
+ {
12919
+ title: "Analyze Prompt",
12920
+ icon: /* @__PURE__ */ jsx(ReceiptText, {}),
12921
+ codeStr: score?.analyzePrompt || "null",
12922
+ simplified: true
12923
+ }
12924
+ ),
12925
+ /* @__PURE__ */ jsx(
12926
+ SideDialog.CodeSection,
12927
+ {
12928
+ title: "Generate Score Prompt",
12929
+ icon: /* @__PURE__ */ jsx(ReceiptText, {}),
12930
+ codeStr: score?.generateScorePrompt || "null",
12931
+ simplified: true
12932
+ }
12933
+ ),
12934
+ /* @__PURE__ */ jsx(
12935
+ SideDialog.CodeSection,
12936
+ {
12937
+ title: "Generate Reason Prompt",
12938
+ icon: /* @__PURE__ */ jsx(ReceiptText, {}),
12939
+ codeStr: score?.generateReasonPrompt || "null",
12940
+ simplified: true
12941
+ }
12942
+ )
12943
+ ] })
12944
+ ] })
12640
12945
  ]
12641
12946
  }
12642
12947
  );
@@ -12777,7 +13082,7 @@ function ScorersTable({ scorers, isLoading }) {
12777
13082
  return /* @__PURE__ */ jsx(EmptyScorersTable, {});
12778
13083
  }
12779
13084
  const filteredRows = rows.filter((row) => row.original.scorer.config.name.toLowerCase().includes(search.toLowerCase()));
12780
- return /* @__PURE__ */ jsxs(Fragment, { children: [
13085
+ return /* @__PURE__ */ jsxs("div", { children: [
12781
13086
  /* @__PURE__ */ jsx(SearchbarWrapper, { children: /* @__PURE__ */ jsx(Searchbar, { onSearch: setSearch, label: "Search scorers", placeholder: "Search scorers" }) }),
12782
13087
  isLoading ? /* @__PURE__ */ jsx(ScorersTableSkeleton, {}) : /* @__PURE__ */ jsx(ScrollableContainer, { children: /* @__PURE__ */ jsxs(Table$1, { children: [
12783
13088
  /* @__PURE__ */ jsx(Thead, { className: "sticky top-0", children: ths.headers.map((header) => /* @__PURE__ */ jsx(Th, { style: { width: header.index === 0 ? "auto" : header.column.getSize() }, children: flexRender(header.column.columnDef.header, header.getContext()) }, header.id)) }),
@@ -12813,6 +13118,18 @@ const EmptyScorersTable = () => /* @__PURE__ */ jsx("div", { className: "flex h-
12813
13118
  }
12814
13119
  ) });
12815
13120
 
13121
+ const useTraceSpanScores = ({ traceId = "", spanId = "", page }) => {
13122
+ const client = useMastraClient();
13123
+ return useQuery({
13124
+ queryKey: ["trace-span-scores", traceId, spanId, page],
13125
+ queryFn: () => client.getScoresBySpan({ traceId, spanId, page: page || 0, perPage: 10 }),
13126
+ enabled: !!traceId && !!spanId,
13127
+ refetchInterval: 3e3,
13128
+ gcTime: 0,
13129
+ staleTime: 0
13130
+ });
13131
+ };
13132
+
12816
13133
  const AgentMetadataModelSwitcher = ({
12817
13134
  defaultProvider,
12818
13135
  defaultModel,
@@ -13059,6 +13376,7 @@ const AgentMetadataModelSwitcher = ({
13059
13376
  /* @__PURE__ */ jsx(
13060
13377
  Input,
13061
13378
  {
13379
+ "aria-label": "Search providers",
13062
13380
  spellCheck: "false",
13063
13381
  ref: providerInputRef,
13064
13382
  className: `w-full ${!isSearchingProvider && currentModelProvider ? "pl-8 pr-8" : ""}`,
@@ -13097,20 +13415,6 @@ const AgentMetadataModelSwitcher = ({
13097
13415
  handleProviderSelect(provider);
13098
13416
  }
13099
13417
  break;
13100
- case "Tab":
13101
- if (!e.shiftKey) {
13102
- e.preventDefault();
13103
- if (highlightedProviderIndex >= 0 && highlightedProviderIndex < filteredProviders2.length) {
13104
- const provider = filteredProviders2[highlightedProviderIndex];
13105
- handleProviderSelect(provider);
13106
- } else {
13107
- setShowProviderSuggestions(false);
13108
- setIsSearchingProvider(false);
13109
- setProviderSearch("");
13110
- setHighlightedProviderIndex(-1);
13111
- }
13112
- }
13113
- break;
13114
13418
  case "Escape":
13115
13419
  e.preventDefault();
13116
13420
  setIsSearchingProvider(false);
@@ -13119,8 +13423,6 @@ const AgentMetadataModelSwitcher = ({
13119
13423
  setShowProviderSuggestions(false);
13120
13424
  break;
13121
13425
  }
13122
- } else if (e.key === "Tab") {
13123
- return;
13124
13426
  }
13125
13427
  },
13126
13428
  onFocus: () => {
@@ -13212,6 +13514,7 @@ const AgentMetadataModelSwitcher = ({
13212
13514
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
13213
13515
  Input,
13214
13516
  {
13517
+ "aria-label": "Search models",
13215
13518
  spellCheck: "false",
13216
13519
  ref: modelInputRef,
13217
13520
  className: "w-full xl:w-3/5",
@@ -13264,7 +13567,6 @@ const AgentMetadataModelSwitcher = ({
13264
13567
  }, 0);
13265
13568
  break;
13266
13569
  case "Enter":
13267
- case "Tab":
13268
13570
  e.preventDefault();
13269
13571
  if (highlightedModelIndex >= 0 && highlightedModelIndex < filteredModels.length) {
13270
13572
  const model = filteredModels[highlightedModelIndex];
@@ -13509,7 +13811,7 @@ const AgentMetadataNetworkList = ({ agents }) => {
13509
13811
  if (agents.length === 0) {
13510
13812
  return /* @__PURE__ */ jsx(AgentMetadataListEmpty, { children: "No agents" });
13511
13813
  }
13512
- return /* @__PURE__ */ jsx(AgentMetadataList, { children: agents.map((agent) => /* @__PURE__ */ jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsx(Link, { href: paths.agentLink(agent.id), children: /* @__PURE__ */ jsx(Badge$1, { variant: "success", icon: /* @__PURE__ */ jsx(AgentIcon, {}), children: agent.name }) }) }, agent.id)) });
13814
+ return /* @__PURE__ */ jsx(AgentMetadataList, { children: agents.map((agent) => /* @__PURE__ */ jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsx(Link, { href: paths.agentLink(agent.id), "data-testid": "agent-badge", children: /* @__PURE__ */ jsx(Badge$1, { variant: "success", icon: /* @__PURE__ */ jsx(AgentIcon, {}), children: agent.name }) }) }, agent.id)) });
13513
13815
  };
13514
13816
  const AgentMetadata = ({
13515
13817
  agentId,
@@ -13565,7 +13867,10 @@ const AgentMetadata = ({
13565
13867
  link: "https://mastra.ai/en/docs/agents/agent-memory",
13566
13868
  title: "Agent Memory documentation"
13567
13869
  },
13568
- children: hasMemoryEnabled ? /* @__PURE__ */ jsx(Badge$1, { icon: /* @__PURE__ */ jsx(MemoryIcon, {}), variant: "success", className: "font-medium", children: "On" }) : /* @__PURE__ */ jsxs(Alert$1, { variant: "warning", children: [
13870
+ children: hasMemoryEnabled ? /* @__PURE__ */ jsxs(Badge$1, { icon: /* @__PURE__ */ jsx(MemoryIcon, {}), variant: "success", className: "font-medium", children: [
13871
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Memory is enabled" }),
13872
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "On" })
13873
+ ] }) : /* @__PURE__ */ jsxs(Alert$1, { variant: "warning", children: [
13569
13874
  /* @__PURE__ */ jsx(AlertTitle$1, { as: "h5", children: "Memory not enabled" }),
13570
13875
  /* @__PURE__ */ jsxs(AlertDescription$1, { as: "p", children: [
13571
13876
  "Thread messages will not be stored. To activate memory, see the",
@@ -13627,14 +13932,14 @@ const AgentMetadataToolList = ({ tools, agentId }) => {
13627
13932
  if (tools.length === 0) {
13628
13933
  return /* @__PURE__ */ jsx(AgentMetadataListEmpty, { children: "No tools" });
13629
13934
  }
13630
- return /* @__PURE__ */ jsx(AgentMetadataList, { children: tools.map((tool) => /* @__PURE__ */ jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsx(Link, { href: paths.agentToolLink(agentId, tool.id), children: /* @__PURE__ */ jsx(Badge$1, { icon: /* @__PURE__ */ jsx(ToolsIcon, { className: "text-[#ECB047]" }), children: tool.id }) }) }, tool.id)) });
13935
+ return /* @__PURE__ */ jsx(AgentMetadataList, { children: tools.map((tool) => /* @__PURE__ */ jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsx(Link, { href: paths.agentToolLink(agentId, tool.id), "data-testid": "tool-badge", children: /* @__PURE__ */ jsx(Badge$1, { icon: /* @__PURE__ */ jsx(ToolsIcon, { className: "text-[#ECB047]" }), children: tool.id }) }) }, tool.id)) });
13631
13936
  };
13632
13937
  const AgentMetadataWorkflowList = ({ workflows }) => {
13633
13938
  const { Link, paths } = useLinkComponent();
13634
13939
  if (workflows.length === 0) {
13635
13940
  return /* @__PURE__ */ jsx(AgentMetadataListEmpty, { children: "No workflows" });
13636
13941
  }
13637
- return /* @__PURE__ */ jsx(AgentMetadataList, { children: workflows.map((workflow) => /* @__PURE__ */ jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsx(Link, { href: paths.workflowLink(workflow.id), children: /* @__PURE__ */ jsx(Badge$1, { icon: /* @__PURE__ */ jsx(WorkflowIcon, { className: "text-accent3" }), children: workflow.name }) }) }, workflow.id)) });
13942
+ return /* @__PURE__ */ jsx(AgentMetadataList, { children: workflows.map((workflow) => /* @__PURE__ */ jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsx(Link, { href: paths.workflowLink(workflow.id), "data-testid": "workflow-badge", children: /* @__PURE__ */ jsx(Badge$1, { icon: /* @__PURE__ */ jsx(WorkflowIcon, { className: "text-accent3" }), children: workflow.name }) }) }, workflow.id)) });
13638
13943
  };
13639
13944
  const AgentMetadataScorerList = ({ entityId, entityType }) => {
13640
13945
  const { Link, paths } = useLinkComponent();
@@ -13652,7 +13957,7 @@ const AgentMetadataScorerList = ({ entityId, entityType }) => {
13652
13957
  if (scorerList.length === 0) {
13653
13958
  return /* @__PURE__ */ jsx(AgentMetadataListEmpty, { children: "No Scorers" });
13654
13959
  }
13655
- return /* @__PURE__ */ jsx(AgentMetadataList, { children: scorerList.map((scorer) => /* @__PURE__ */ jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsx(Link, { href: paths.scorerLink(scorer.id), children: /* @__PURE__ */ jsx(Badge$1, { icon: /* @__PURE__ */ jsx(GaugeIcon, { className: "text-icon3" }), children: scorer.scorer.config.name }) }) }, scorer.id)) });
13960
+ return /* @__PURE__ */ jsx(AgentMetadataList, { children: scorerList.map((scorer) => /* @__PURE__ */ jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsx(Link, { href: paths.scorerLink(scorer.id), "data-testid": "scorer-badge", children: /* @__PURE__ */ jsx(Badge$1, { icon: /* @__PURE__ */ jsx(GaugeIcon, { className: "text-icon3" }), children: scorer.scorer.config.name }) }) }, scorer.id)) });
13656
13961
  };
13657
13962
 
13658
13963
  const AgentMetadataPrompt = ({ prompt }) => {
@@ -13947,7 +14252,7 @@ function ToolTable({ tools, agents, isLoading }) {
13947
14252
  return /* @__PURE__ */ jsx(EmptyToolsTable, {});
13948
14253
  }
13949
14254
  const filteredRows = rows.filter((row) => row.original.id.toLowerCase().includes(search.toLowerCase()));
13950
- return /* @__PURE__ */ jsxs(Fragment, { children: [
14255
+ return /* @__PURE__ */ jsxs("div", { children: [
13951
14256
  /* @__PURE__ */ jsx(SearchbarWrapper, { children: /* @__PURE__ */ jsx(Searchbar, { onSearch: setSearch, label: "Search tools", placeholder: "Search tools" }) }),
13952
14257
  isLoading ? /* @__PURE__ */ jsx(ToolTableSkeleton, {}) : /* @__PURE__ */ jsx(ScrollableContainer, { children: /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Table$1, { children: [
13953
14258
  /* @__PURE__ */ jsx(Thead, { className: "sticky top-0", children: ths.headers.map((header) => /* @__PURE__ */ jsx(Th, { style: { width: header.column.getSize() ?? "auto" }, children: flexRender(header.column.columnDef.header, header.getContext()) }, header.id)) }),
@@ -15658,6 +15963,45 @@ function TreePositionMark({ isLastChild, hasChildren = false }) {
15658
15963
  );
15659
15964
  }
15660
15965
 
15966
+ function TraceTimeline({ hierarchicalSpans = [], onSpanClick, selectedSpanId, isLoading }) {
15967
+ const overallLatency = hierarchicalSpans?.[0]?.latency || 0;
15968
+ const overallStartTime = hierarchicalSpans?.[0]?.startTime || "";
15969
+ const overallEndTime = hierarchicalSpans?.[0]?.endTime || "";
15970
+ return /* @__PURE__ */ jsx(Fragment, { children: isLoading ? /* @__PURE__ */ jsxs(
15971
+ "div",
15972
+ {
15973
+ className: cn(
15974
+ "flex items-center text-[0.875rem] gap-[1rem] bg-surface3/50 rounded-md p-[1.5rem] justify-center text-icon3",
15975
+ "[&_svg]:w-[1.25em] [&_svg]:h-[1.25em] [&_svg]:opacity-50"
15976
+ ),
15977
+ children: [
15978
+ /* @__PURE__ */ jsx(Spinner, {}),
15979
+ " Loading Trace Timeline ..."
15980
+ ]
15981
+ }
15982
+ ) : /* @__PURE__ */ jsx(
15983
+ "div",
15984
+ {
15985
+ className: cn("grid items-start content-start gap-y-[2px] overflow-hidden", "xl:gap-x-[1rem] xl:py-[1rem]", {
15986
+ "xl:grid-cols-[3fr_auto]": !overallEndTime,
15987
+ "xl:grid-cols-[3fr_2fr]": overallEndTime
15988
+ }),
15989
+ children: hierarchicalSpans?.map((span) => /* @__PURE__ */ jsx(
15990
+ TraceTimelineSpan,
15991
+ {
15992
+ span,
15993
+ onSpanClick,
15994
+ selectedSpanId,
15995
+ overallLatency,
15996
+ overallStartTime,
15997
+ overallEndTime
15998
+ },
15999
+ span.id
16000
+ ))
16001
+ }
16002
+ ) });
16003
+ }
16004
+
15661
16005
  function TraceTimelineLegend({ spans = [] }) {
15662
16006
  const activeSpanTypes = spanTypePrefixes.filter(
15663
16007
  (typePrefix) => spans.some((span) => span?.spanType?.startsWith(typePrefix))
@@ -15671,65 +16015,6 @@ function TraceTimelineLegend({ spans = [] }) {
15671
16015
  }) });
15672
16016
  }
15673
16017
 
15674
- function TraceTimeline({
15675
- spans = [],
15676
- hierarchicalSpans = [],
15677
- onSpanClick,
15678
- selectedSpanId,
15679
- isLoading,
15680
- className
15681
- }) {
15682
- const overallLatency = hierarchicalSpans?.[0]?.latency || 0;
15683
- const overallStartTime = hierarchicalSpans?.[0]?.startTime || "";
15684
- const overallEndTime = hierarchicalSpans?.[0]?.endTime || "";
15685
- return /* @__PURE__ */ jsxs("div", { className: cn("grid gap-[1rem]", className), children: [
15686
- /* @__PURE__ */ jsxs("div", { className: "flex w-full justify-between pr-[2.5rem]", children: [
15687
- /* @__PURE__ */ jsxs(SideDialogHeading, { as: "h2", children: [
15688
- /* @__PURE__ */ jsx(ListTreeIcon, {}),
15689
- " Timeline"
15690
- ] }),
15691
- /* @__PURE__ */ jsx(TraceTimelineLegend, { spans })
15692
- ] }),
15693
- isLoading ? /* @__PURE__ */ jsxs(
15694
- "div",
15695
- {
15696
- className: cn(
15697
- "flex items-center text-[0.875rem] gap-[1rem] bg-surface3/50 rounded-md p-[1.5rem] mr-[1.5rem] justify-center text-icon3 mt-[.5rem]",
15698
- "[&_svg]:w-[1.25em] [&_svg]:h-[1.25em] [&_svg]:opacity-50"
15699
- ),
15700
- children: [
15701
- /* @__PURE__ */ jsx(Spinner, {}),
15702
- " Loading Trace Timeline ..."
15703
- ]
15704
- }
15705
- ) : /* @__PURE__ */ jsx(
15706
- "div",
15707
- {
15708
- className: cn(
15709
- "grid items-start content-start gap-y-[2px] bg-surface2 rounded-lg overflow-hidden pl-[1.5rem] py-[1.5rem]",
15710
- "xl:gap-x-[1rem] xl:py-[1rem]",
15711
- {
15712
- "xl:grid-cols-[3fr_auto]": !overallEndTime,
15713
- "xl:grid-cols-[3fr_2fr]": overallEndTime
15714
- }
15715
- ),
15716
- children: hierarchicalSpans?.map((span) => /* @__PURE__ */ jsx(
15717
- TraceTimelineSpan,
15718
- {
15719
- span,
15720
- onSpanClick,
15721
- selectedSpanId,
15722
- overallLatency,
15723
- overallStartTime,
15724
- overallEndTime
15725
- },
15726
- span.id
15727
- ))
15728
- }
15729
- )
15730
- ] });
15731
- }
15732
-
15733
16018
  function TraceSpanUsage({ traceUsage, traceSpans = [], spanUsage, className }) {
15734
16019
  if (!traceUsage && !spanUsage) {
15735
16020
  console.warn("No usage data available");
@@ -15842,12 +16127,11 @@ function TraceSpanUsage({ traceUsage, traceSpans = [], spanUsage, className }) {
15842
16127
  icon: /* @__PURE__ */ jsx(CoinsIcon, {})
15843
16128
  }
15844
16129
  };
15845
- let tokenPresentations = {};
15846
- if (hasV5Format) {
15847
- tokenPresentations = { ...commonTokenPresentations, ...v5TokenPresentations };
15848
- } else {
15849
- tokenPresentations = { ...commonTokenPresentations, ...legacyTokenPresentations };
15850
- }
16130
+ let tokenPresentations = {
16131
+ ...commonTokenPresentations,
16132
+ ...v5TokenPresentations,
16133
+ ...legacyTokenPresentations
16134
+ };
15851
16135
  let usageKeyOrder = [];
15852
16136
  if (hasV5Format) {
15853
16137
  usageKeyOrder = ["totalTokens", "inputTokens", "outputTokens", "reasoningTokens", "cachedInputTokens"];
@@ -15855,55 +16139,42 @@ function TraceSpanUsage({ traceUsage, traceSpans = [], spanUsage, className }) {
15855
16139
  usageKeyOrder = ["totalTokens", "promptTokens", "completionTokens"];
15856
16140
  }
15857
16141
  const usageAsArray = Object.entries(traceUsage || spanUsage || {}).map(([key, value]) => ({ key, value })).sort((a, b) => usageKeyOrder.indexOf(a.key) - usageKeyOrder.indexOf(b.key));
15858
- return /* @__PURE__ */ jsx(
16142
+ return /* @__PURE__ */ jsx("div", { className: cn("flex gap-[1.5rem] flex-wrap", className), children: usageAsArray.map(({ key, value }) => /* @__PURE__ */ jsxs(
15859
16143
  "div",
15860
16144
  {
15861
- className: cn(
15862
- "grid gap-[1.5rem]",
15863
- {
15864
- "xl:grid-cols-3": usageAsArray.length === 3,
15865
- "xl:grid-cols-2": usageAsArray.length === 2
15866
- },
15867
- className
15868
- ),
15869
- children: usageAsArray.map(({ key, value }) => /* @__PURE__ */ jsxs(
15870
- "div",
15871
- {
15872
- className: cn("bg-white/5 p-[1rem] px-[1.25rem] rounded-lg text-[0.875rem]", {
15873
- "min-h-[5.5rem]": traceUsage
15874
- }),
15875
- children: [
15876
- /* @__PURE__ */ jsxs(
15877
- "div",
15878
- {
15879
- className: cn(
15880
- "grid grid-cols-[1.5rem_1fr_auto] gap-[.5rem] items-center",
15881
- "[&>svg]:w-[1.5em] [&>svg]:h-[1.5em] [&>svg]:opacity-70"
15882
- ),
15883
- children: [
15884
- tokenPresentations?.[key]?.icon,
15885
- /* @__PURE__ */ jsx("span", { className: "text-[0.875rem]", children: tokenPresentations?.[key]?.label }),
15886
- /* @__PURE__ */ jsx("b", { className: "text-[1rem]", children: value })
15887
- ]
15888
- }
16145
+ className: cn("bg-white/5 p-[.75rem] px-[1rem] rounded-lg text-[0.875rem] flex-grow", {
16146
+ "min-h-[5.5rem]": traceUsage
16147
+ }),
16148
+ children: [
16149
+ /* @__PURE__ */ jsxs(
16150
+ "div",
16151
+ {
16152
+ className: cn(
16153
+ "grid grid-cols-[1.5rem_1fr_auto] gap-[.5rem] items-center",
16154
+ "[&>svg]:w-[1.5em] [&>svg]:h-[1.5em] [&>svg]:opacity-70"
15889
16155
  ),
15890
- tokensByProviderValid && /* @__PURE__ */ jsx("div", { className: "text-[0.875rem] mt-[0.5rem] pl-[2rem] ", children: Object.entries(tokensByProvider).map(([provider, providerTokens]) => /* @__PURE__ */ jsxs(
15891
- "dl",
15892
- {
15893
- className: "grid grid-cols-[1fr_auto] gap-x-[1rem] gap-y-[.25rem] justify-between text-icon3",
15894
- children: [
15895
- /* @__PURE__ */ jsx("dt", { children: provider }),
15896
- /* @__PURE__ */ jsx("dd", { children: providerTokens?.[key] })
15897
- ]
15898
- },
15899
- provider
15900
- )) })
15901
- ]
15902
- },
15903
- key
15904
- ))
15905
- }
15906
- );
16156
+ children: [
16157
+ tokenPresentations?.[key]?.icon,
16158
+ /* @__PURE__ */ jsx("span", { className: "text-[0.875rem]", children: tokenPresentations?.[key]?.label }),
16159
+ /* @__PURE__ */ jsx("b", { className: "text-[1rem]", children: value })
16160
+ ]
16161
+ }
16162
+ ),
16163
+ tokensByProviderValid && /* @__PURE__ */ jsx("div", { className: "text-[0.875rem] mt-[0.5rem] pl-[2rem]", children: Object.entries(tokensByProvider).map(([provider, providerTokens]) => /* @__PURE__ */ jsxs(
16164
+ "dl",
16165
+ {
16166
+ className: "grid grid-cols-[1fr_auto] gap-x-[1rem] gap-y-[.25rem] justify-between text-icon3",
16167
+ children: [
16168
+ /* @__PURE__ */ jsx("dt", { children: provider }),
16169
+ /* @__PURE__ */ jsx("dd", { children: providerTokens?.[key] })
16170
+ ]
16171
+ },
16172
+ provider
16173
+ )) })
16174
+ ]
16175
+ },
16176
+ key
16177
+ )) });
15907
16178
  }
15908
16179
 
15909
16180
  function useTraceInfo(trace) {
@@ -15986,253 +16257,199 @@ function getSpanInfo({ span, withTraceId = true, withSpanId = true }) {
15986
16257
  return baseInfo;
15987
16258
  }
15988
16259
 
15989
- const ScoreTable = ({ scores, onItemClick }) => {
15990
- return /* @__PURE__ */ jsxs(Table$1, { children: [
15991
- /* @__PURE__ */ jsxs(Thead, { children: [
15992
- /* @__PURE__ */ jsx(Th, { children: "Type" }),
15993
- /* @__PURE__ */ jsx(Th, { children: "Scorer" }),
15994
- /* @__PURE__ */ jsx(Th, { children: "Score" }),
15995
- /* @__PURE__ */ jsx(Th, { children: "Created At" })
15996
- ] }),
15997
- /* @__PURE__ */ jsx(Tbody, { children: scores.map((score) => /* @__PURE__ */ jsxs(Row, { onClick: () => onItemClick(score.scorerName), children: [
15998
- /* @__PURE__ */ jsx(TxtCell, { children: /* @__PURE__ */ jsx(Badge$1, { children: score.type }) }),
15999
- /* @__PURE__ */ jsx(TxtCell, { children: score.scorerName }),
16000
- /* @__PURE__ */ jsx(TxtCell, { children: score.score }),
16001
- /* @__PURE__ */ jsx(DateTimeCell, { dateTime: new Date(score.createdAt) })
16002
- ] }, score.scoreId)) })
16003
- ] });
16260
+ const TabsRoot = ({
16261
+ children,
16262
+ defaultTab,
16263
+ value,
16264
+ onValueChange,
16265
+ className
16266
+ }) => {
16267
+ const [internalTab, setInternalTab] = useState(defaultTab);
16268
+ const isControlled = value !== void 0 && onValueChange !== void 0;
16269
+ const currentTab = isControlled ? value : internalTab;
16270
+ const handleTabChange = (newValue) => {
16271
+ const typedValue = newValue;
16272
+ if (isControlled) {
16273
+ onValueChange(typedValue);
16274
+ } else {
16275
+ setInternalTab(typedValue);
16276
+ }
16277
+ };
16278
+ return /* @__PURE__ */ jsx(
16279
+ TabsPrimitive.Root,
16280
+ {
16281
+ value: currentTab,
16282
+ onValueChange: handleTabChange,
16283
+ className: cn("grid gap-[3rem] overflow-y-auto", className),
16284
+ children
16285
+ }
16286
+ );
16004
16287
  };
16005
16288
 
16006
- function SpanDetails({ span, onScorerTriggered }) {
16007
- if (!span) {
16008
- return null;
16009
- }
16010
- return /* @__PURE__ */ jsxs("div", { className: "grid gap-[1.5rem] mb-[2rem]", children: [
16011
- /* @__PURE__ */ jsx(SideDialogCodeSection, { title: "Input", codeStr: JSON.stringify(span.input || null, null, 2) }),
16012
- /* @__PURE__ */ jsx(SideDialogCodeSection, { title: "Output", codeStr: JSON.stringify(span.output || null, null, 2) }),
16013
- /* @__PURE__ */ jsx(SideDialogCodeSection, { title: "Metadata", codeStr: JSON.stringify(span.metadata || null, null, 2) }),
16014
- /* @__PURE__ */ jsx(SideDialogCodeSection, { title: "Attributes", codeStr: JSON.stringify(span.attributes || null, null, 2) }),
16015
- span?.links?.length > 0 && /* @__PURE__ */ jsxs("div", { className: "pt-[2.5rem] pr-[2.5rem]", children: [
16016
- /* @__PURE__ */ jsxs(SideDialogHeading, { as: "h2", className: "pb-[1rem]", children: [
16017
- /* @__PURE__ */ jsx(GaugeIcon, {}),
16018
- " Scores"
16019
- ] }),
16020
- /* @__PURE__ */ jsx("div", { className: "bg-surface2 rounded-lg overflow-hidden border-sm border-border1", children: /* @__PURE__ */ jsx(
16021
- ScoreTable,
16289
+ const TabList = ({ children, variant = "default", className }) => {
16290
+ return /* @__PURE__ */ jsx("div", { className: cn("w-full overflow-x-auto", className), children: /* @__PURE__ */ jsx(
16291
+ TabsPrimitive.List,
16292
+ {
16293
+ className: cn(
16294
+ "flex items-center",
16022
16295
  {
16023
- scores: span?.links,
16024
- onItemClick: (scorerName) => onScorerTriggered(scorerName, span.traceId, span.spanId)
16025
- }
16026
- ) })
16027
- ] })
16028
- ] });
16029
- }
16296
+ // variant: default
16297
+ "text-[0.9375rem]": variant === "default",
16298
+ "[&>button]:py-[0.5rem] [&>button]:px-[1.5rem] [&>button]:font-normal [&>button]:text-icon3 [&>button]:flex-1 [&>button]:border-b [&>button]:border-border1": variant === "default",
16299
+ "[&>button[data-state=active]]:text-icon5 [&>button[data-state=active]]:transition-colors [&>button[data-state=active]]:duration-200 [&>button[data-state=active]]:border-icon3": variant === "default",
16300
+ // variant: buttons
16301
+ "border border-border1 flex justify-stretch rounded-md overflow-hidden text-[0.875rem] min-h-[2.5rem]": variant === "buttons",
16302
+ "[&>button]:flex-1 [&>button]:py-[0.5rem] [&>button]:px-[1rem] [&>button]:text-icon3": variant === "buttons",
16303
+ "[&>button[data-state=active]]:text-icon5 [&>button[data-state=active]]:bg-[#222]": variant === "buttons"
16304
+ },
16305
+ className
16306
+ ),
16307
+ children
16308
+ }
16309
+ ) });
16310
+ };
16030
16311
 
16031
- const DropdownMenu = DropdownMenuPrimitive.Root;
16032
- const DropdownMenuGroup = DropdownMenuPrimitive.Group;
16033
- const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
16034
- const DropdownMenuSub = DropdownMenuPrimitive.Sub;
16035
- const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
16036
- const DropdownMenuTrigger = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx(DropdownMenuPrimitive.Trigger, { ref, className: cn("cursor-pointer focus-visible:rounded", className), ...props, children }));
16037
- DropdownMenuTrigger.displayName = DropdownMenuPrimitive.Trigger.displayName;
16038
- const DropdownMenuSubTrigger = React.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxs(
16039
- DropdownMenuPrimitive.SubTrigger,
16040
- {
16041
- ref,
16042
- className: cn(
16043
- "focus:bg-accent data-[state=open]:bg-accent flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm",
16044
- inset && "pl-8",
16045
- className
16046
- ),
16047
- ...props,
16048
- children: [
16049
- children,
16050
- /* @__PURE__ */ jsx(ChevronDown, { className: "ml-auto -rotate-90" })
16051
- ]
16052
- }
16053
- ));
16054
- DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
16055
- const DropdownMenuSubContent = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
16056
- DropdownMenuPrimitive.SubContent,
16057
- {
16058
- ref,
16059
- className: cn(
16060
- "popover-background data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 z-50 min-w-[8rem] overflow-auto overflow-x-hidden rounded-none p-1",
16061
- className
16062
- ),
16063
- ...props
16064
- }
16065
- ));
16066
- DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
16067
- const DropdownMenuContent = React.forwardRef(({ className, container, sideOffset = 4, ...props }, ref) => {
16068
- return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { container, children: /* @__PURE__ */ jsx(
16069
- DropdownMenuPrimitive.Content,
16312
+ const Tab = ({ children, value, onClick, className }) => {
16313
+ return /* @__PURE__ */ jsx(TabsPrimitive.Trigger, { value, className: cn("hover:text-icon5", className), onClick, children });
16314
+ };
16315
+
16316
+ const TabContent = ({ children, value, className }) => {
16317
+ return /* @__PURE__ */ jsx(
16318
+ TabsPrimitive.Content,
16070
16319
  {
16071
- ref,
16072
- sideOffset,
16073
- className: clsx(
16074
- "data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 bg-surface2 text-icon3 border-sm border-border1 z-50 min-w-[8rem] overflow-auto rounded-md p-1 shadow-md",
16320
+ value,
16321
+ className: cn(
16322
+ "grid overflow-y-auto ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:none",
16075
16323
  className
16076
16324
  ),
16077
- ...props
16325
+ children
16078
16326
  }
16079
- ) });
16327
+ );
16328
+ };
16329
+
16330
+ const Tabs = Object.assign(TabsRoot, {
16331
+ List: TabList,
16332
+ Tab,
16333
+ Content: TabContent
16080
16334
  });
16081
- DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
16082
- const DropdownMenuItem = React.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
16083
- DropdownMenuPrimitive.Item,
16084
- {
16085
- ref,
16086
- className: cn(
16087
- "focus:text-accent-foreground relative flex cursor-default cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 font-sans text-[0.8125rem] transition-colors focus:bg-[#66686A]/20 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>span]:truncate",
16088
- inset && "pl-8",
16089
- className
16090
- ),
16091
- ...props
16335
+
16336
+ function SpanDetails({ span }) {
16337
+ if (!span) {
16338
+ return null;
16092
16339
  }
16093
- ));
16094
- DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
16095
- const DropdownMenuCheckboxItem = React.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxs(
16096
- DropdownMenuPrimitive.CheckboxItem,
16097
- {
16098
- ref,
16099
- className: cn(
16100
- "focus:bg-accent focus:text-accent-foreground relative flex w-full cursor-default cursor-pointer select-none items-center gap-4 rounded-sm px-2 py-1.5 text-sm transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
16101
- className
16340
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
16341
+ /* @__PURE__ */ jsx(
16342
+ SideDialog.CodeSection,
16343
+ {
16344
+ title: "Input",
16345
+ icon: /* @__PURE__ */ jsx(FileInputIcon, {}),
16346
+ codeStr: JSON.stringify(span.input || null, null, 2)
16347
+ }
16102
16348
  ),
16103
- checked,
16104
- ...props,
16105
- children: [
16106
- /* @__PURE__ */ jsx("div", { className: "border-sm border-border1 flex h-4 w-4 items-center justify-center rounded-sm", children: checked && /* @__PURE__ */ jsx(Icon, { size: "sm", children: /* @__PURE__ */ jsx(Check, {}) }) }),
16107
- children
16108
- ]
16109
- }
16110
- ));
16111
- DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
16112
- const DropdownMenuRadioItem = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
16113
- DropdownMenuPrimitive.RadioItem,
16114
- {
16115
- ref,
16116
- className: cn(
16117
- "focus:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm transition-colors focus:bg-[#66686A]/20 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
16118
- className
16349
+ /* @__PURE__ */ jsx(
16350
+ SideDialog.CodeSection,
16351
+ {
16352
+ title: "Output",
16353
+ icon: /* @__PURE__ */ jsx(FileOutputIcon, {}),
16354
+ codeStr: JSON.stringify(span.output || null, null, 2)
16355
+ }
16119
16356
  ),
16120
- ...props,
16121
- children: [
16122
- /* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Circle, { className: "h-2 w-2 fill-current" }) }) }),
16123
- children
16124
- ]
16125
- }
16126
- ));
16127
- DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
16128
- const DropdownMenuLabel = React.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
16129
- DropdownMenuPrimitive.Label,
16130
- {
16131
- ref,
16132
- className: cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className),
16133
- ...props
16134
- }
16135
- ));
16136
- DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
16137
- const DropdownMenuSeparator = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
16138
- DropdownMenuPrimitive.Separator,
16139
- {
16140
- ref,
16141
- className: cn("popover-dividers-bg -mx-1 my-1 h-px", className),
16142
- ...props
16143
- }
16144
- ));
16145
- DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
16146
- const DropdownMenuShortcut = ({ className, ...props }) => {
16147
- return /* @__PURE__ */ jsx("span", { className: cn("ml-auto text-xs tracking-widest opacity-60", className), ...props });
16148
- };
16149
- DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
16150
- function Dropdown({
16151
- open,
16152
- onOpenChange,
16153
- children,
16154
- modal
16155
- }) {
16156
- return /* @__PURE__ */ jsx(DropdownMenu, { modal, open, onOpenChange, children });
16157
- }
16158
- Dropdown.Trigger = DropdownMenuTrigger;
16159
- Dropdown.Content = DropdownMenuContent;
16160
- Dropdown.Group = DropdownMenuGroup;
16161
- Dropdown.Portal = DropdownMenuPortal;
16162
- Dropdown.Item = DropdownMenuItem;
16163
- Dropdown.CheckboxItem = DropdownMenuCheckboxItem;
16164
- Dropdown.RadioItem = DropdownMenuRadioItem;
16165
- Dropdown.Label = DropdownMenuLabel;
16166
- Dropdown.Separator = DropdownMenuSeparator;
16167
- Dropdown.Shortcut = DropdownMenuShortcut;
16168
- Dropdown.Sub = DropdownMenuSub;
16169
- Dropdown.SubContent = DropdownMenuSubContent;
16170
- Dropdown.SubTrigger = DropdownMenuSubTrigger;
16171
- Dropdown.RadioGroup = DropdownMenuRadioGroup;
16172
-
16173
- const useTriggerScorer = (onScorerTriggered) => {
16174
- const client = useMastraClient();
16175
- return useMutation({
16176
- mutationFn: async ({ scorerName, traceId, spanId }) => {
16177
- const response = await client.score({
16178
- scorerName,
16179
- targets: [{ traceId, spanId }]
16180
- });
16181
- return response;
16182
- },
16183
- onSuccess: (_, variables) => {
16184
- toast.success("Scorer triggered successfully");
16185
- onScorerTriggered(variables.scorerName, variables.traceId, variables.spanId);
16186
- },
16187
- onError: () => {
16188
- toast.error("Error triggering scorer");
16189
- }
16190
- });
16191
- };
16357
+ /* @__PURE__ */ jsx(
16358
+ SideDialog.CodeSection,
16359
+ {
16360
+ title: "Metadata",
16361
+ icon: /* @__PURE__ */ jsx(BracesIcon, {}),
16362
+ codeStr: JSON.stringify(span.metadata || null, null, 2)
16363
+ }
16364
+ ),
16365
+ /* @__PURE__ */ jsx(
16366
+ SideDialog.CodeSection,
16367
+ {
16368
+ title: "Attributes",
16369
+ icon: /* @__PURE__ */ jsx(BracesIcon, {}),
16370
+ codeStr: JSON.stringify(span.attributes || null, null, 2)
16371
+ }
16372
+ )
16373
+ ] });
16374
+ }
16192
16375
 
16193
- const ScorersDropdown = ({ trace, spanId, onScorerTriggered, entityType }) => {
16194
- const { data: scorers = {}, isLoading } = useScorers();
16195
- const { mutate: triggerScorer, isPending } = useTriggerScorer(onScorerTriggered);
16196
- let scorerList = Object.entries(scorers).map(([key, scorer]) => ({
16197
- id: key,
16198
- name: scorer.scorer.config.name,
16199
- description: scorer.scorer.config.description,
16200
- isRegistered: scorer.isRegistered,
16201
- type: scorer.scorer.config.type
16202
- })).filter((scorer) => scorer.isRegistered);
16203
- if (entityType !== "Agent" || spanId) {
16204
- scorerList = scorerList.filter((scorer) => scorer.type !== "agent");
16376
+ function SpanTabs({
16377
+ trace,
16378
+ span,
16379
+ spanScoresData,
16380
+ onSpanScoresPageChange,
16381
+ isLoadingSpanScoresData,
16382
+ spanInfo = [],
16383
+ defaultActiveTab = "details",
16384
+ initialScoreId,
16385
+ computeTraceLink
16386
+ }) {
16387
+ const { Link } = useLinkComponent();
16388
+ let entityType;
16389
+ if (span?.attributes?.agentId) {
16390
+ entityType = "Agent";
16391
+ } else if (span?.attributes?.workflowId) {
16392
+ entityType = "Workflow";
16205
16393
  }
16206
- const isWaiting = isPending || isLoading;
16207
- return /* @__PURE__ */ jsxs(Dropdown, { children: [
16208
- /* @__PURE__ */ jsx(Dropdown.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button$1, { variant: "light", disabled: isWaiting, children: [
16209
- isWaiting ? /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(Spinner, {}) }) : /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(GaugeIcon, {}) }),
16210
- "Run scorer",
16211
- /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(ChevronDown, {}) })
16394
+ return /* @__PURE__ */ jsxs(Tabs, { defaultTab: defaultActiveTab, children: [
16395
+ /* @__PURE__ */ jsxs(Tabs.List, { children: [
16396
+ /* @__PURE__ */ jsx(Tabs.Tab, { value: "details", children: "Details" }),
16397
+ /* @__PURE__ */ jsxs(Tabs.Tab, { value: "scores", children: [
16398
+ "Scoring ",
16399
+ spanScoresData?.pagination && `(${spanScoresData.pagination.total || 0})`
16400
+ ] })
16401
+ ] }),
16402
+ /* @__PURE__ */ jsx(Tabs.Content, { value: "details", children: /* @__PURE__ */ jsxs(Sections, { children: [
16403
+ span?.attributes?.usage && /* @__PURE__ */ jsx(TraceSpanUsage, { spanUsage: span.attributes.usage }),
16404
+ /* @__PURE__ */ jsx(KeyValueList, { data: spanInfo, LinkComponent: Link }),
16405
+ /* @__PURE__ */ jsx(SpanDetails, { span })
16212
16406
  ] }) }),
16213
- /* @__PURE__ */ jsx(Dropdown.Content, { children: scorerList.map((scorer) => /* @__PURE__ */ jsx(
16214
- Dropdown.Item,
16215
- {
16216
- onClick: () => triggerScorer({ scorerName: scorer.name, traceId: trace.traceId, spanId }),
16217
- children: /* @__PURE__ */ jsx("span", { children: scorer.name })
16218
- },
16219
- scorer.id
16220
- )) })
16407
+ /* @__PURE__ */ jsx(Tabs.Content, { value: "scores", children: /* @__PURE__ */ jsxs(Sections, { children: [
16408
+ /* @__PURE__ */ jsxs(Section, { children: [
16409
+ /* @__PURE__ */ jsx(Section.Header, { children: /* @__PURE__ */ jsxs(Section.Heading, { children: [
16410
+ /* @__PURE__ */ jsx(CircleGaugeIcon, {}),
16411
+ " Scoring"
16412
+ ] }) }),
16413
+ /* @__PURE__ */ jsx(SpanScoring, { traceId: trace?.traceId, spanId: span?.spanId, entityType })
16414
+ ] }),
16415
+ /* @__PURE__ */ jsxs(Section, { children: [
16416
+ /* @__PURE__ */ jsx(Section.Header, { children: /* @__PURE__ */ jsxs(Section.Heading, { children: [
16417
+ /* @__PURE__ */ jsx(CircleGaugeIcon, {}),
16418
+ " Scores"
16419
+ ] }) }),
16420
+ /* @__PURE__ */ jsx(
16421
+ SpanScoreList,
16422
+ {
16423
+ scoresData: spanScoresData,
16424
+ onPageChange: onSpanScoresPageChange,
16425
+ isLoadingScoresData: isLoadingSpanScoresData,
16426
+ initialScoreId,
16427
+ traceId: trace?.traceId,
16428
+ spanId: span?.spanId,
16429
+ computeTraceLink
16430
+ }
16431
+ )
16432
+ ] })
16433
+ ] }) })
16221
16434
  ] });
16222
- };
16435
+ }
16223
16436
 
16224
16437
  function SpanDialog({
16225
16438
  trace,
16226
16439
  span,
16440
+ spanScoresData,
16441
+ onSpanScoresPageChange,
16442
+ isLoadingSpanScoresData,
16227
16443
  isOpen,
16228
16444
  onClose,
16229
16445
  onNext,
16230
16446
  onPrevious,
16231
16447
  onViewToggle,
16232
16448
  spanInfo = [],
16233
- onScorerTriggered
16449
+ defaultActiveTab = "details",
16450
+ initialScoreId,
16451
+ computeTraceLink
16234
16452
  }) {
16235
- const { Link } = useLinkComponent();
16236
16453
  return /* @__PURE__ */ jsxs(
16237
16454
  SideDialog,
16238
16455
  {
@@ -16240,43 +16457,53 @@ function SpanDialog({
16240
16457
  dialogDescription: "View and analyze span details",
16241
16458
  isOpen,
16242
16459
  onClose,
16243
- hasCloseButton: true,
16244
- className: cn("w-[calc(100vw-25rem)] max-w-[65%]", "3xl:max-w-[50%]", "4xl:max-w-[40%]"),
16460
+ level: 2,
16245
16461
  children: [
16246
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pr-[1.5rem]", children: [
16247
- /* @__PURE__ */ jsx(SideDialogTop, { onNext, onPrevious, showInnerNav: true, children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-[1rem] text-icon4 text-[0.875rem]", children: [
16248
- /* @__PURE__ */ jsxs(TextAndIcon, { children: [
16249
- /* @__PURE__ */ jsx(EyeIcon, {}),
16462
+ /* @__PURE__ */ jsxs(SideDialog.Top, { children: [
16463
+ /* @__PURE__ */ jsxs(TextAndIcon, { children: [
16464
+ /* @__PURE__ */ jsx(EyeIcon, {}),
16465
+ " ",
16466
+ getShortId(span?.traceId)
16467
+ ] }),
16468
+ "›",
16469
+ /* @__PURE__ */ jsxs(TextAndIcon, { children: [
16470
+ /* @__PURE__ */ jsx(ChevronsLeftRightEllipsisIcon, {}),
16471
+ getShortId(span?.spanId)
16472
+ ] }),
16473
+ "|",
16474
+ /* @__PURE__ */ jsx(SideDialog.Nav, { onNext, onPrevious }),
16475
+ /* @__PURE__ */ jsxs("button", { className: "ml-auto mr-[2rem]", onClick: onViewToggle, children: [
16476
+ /* @__PURE__ */ jsx(PanelTopIcon, {}),
16477
+ /* @__PURE__ */ jsx(VisuallyHidden$1, { children: "Switch to dialog view" })
16478
+ ] })
16479
+ ] }),
16480
+ /* @__PURE__ */ jsxs(SideDialog.Content, { children: [
16481
+ /* @__PURE__ */ jsxs(SideDialog.Header, { children: [
16482
+ /* @__PURE__ */ jsxs(SideDialog.Heading, { children: [
16483
+ /* @__PURE__ */ jsx(ChevronsLeftRightEllipsisIcon, {}),
16250
16484
  " ",
16251
- getShortId(span?.traceId)
16485
+ span?.name
16252
16486
  ] }),
16253
- "›",
16254
16487
  /* @__PURE__ */ jsxs(TextAndIcon, { children: [
16255
- /* @__PURE__ */ jsx(ChevronsLeftRightEllipsisIcon, {}),
16256
- getShortId(span?.spanId)
16488
+ /* @__PURE__ */ jsx(HashIcon, {}),
16489
+ " ",
16490
+ span?.spanId
16257
16491
  ] })
16258
- ] }) }),
16259
- /* @__PURE__ */ jsx("button", { className: "flex items-center gap-1", onClick: onViewToggle, children: /* @__PURE__ */ jsx(PanelTopIcon, {}) })
16260
- ] }),
16261
- /* @__PURE__ */ jsxs("div", { className: "p-[1.5rem] px-[2.5rem] overflow-y-auto grid gap-[1.5rem] content-start", children: [
16262
- /* @__PURE__ */ jsxs("div", { children: [
16263
- /* @__PURE__ */ jsxs(SideDialogHeader, { className: "flex gap-[1rem] items-baseline pr-[2.5rem]", children: [
16264
- /* @__PURE__ */ jsxs(SideDialogHeading, { children: [
16265
- /* @__PURE__ */ jsx(ChevronsLeftRightEllipsisIcon, {}),
16266
- " ",
16267
- span?.name
16268
- ] }),
16269
- /* @__PURE__ */ jsxs(TextAndIcon, { children: [
16270
- /* @__PURE__ */ jsx(HashIcon, {}),
16271
- " ",
16272
- span?.spanId
16273
- ] })
16274
- ] }),
16275
- span?.traceId && span?.spanId && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(ScorersDropdown, { trace, spanId: span?.spanId, onScorerTriggered }) })
16276
16492
  ] }),
16277
- span?.attributes?.usage && /* @__PURE__ */ jsx(TraceSpanUsage, { spanUsage: span.attributes.usage, className: "mt-[1.5rem]" }),
16278
- /* @__PURE__ */ jsx(KeyValueList, { data: spanInfo, LinkComponent: Link, className: "mt-[1.5rem]" }),
16279
- /* @__PURE__ */ jsx(SpanDetails, { span, onScorerTriggered })
16493
+ /* @__PURE__ */ jsx(
16494
+ SpanTabs,
16495
+ {
16496
+ trace,
16497
+ span,
16498
+ spanScoresData,
16499
+ onSpanScoresPageChange,
16500
+ isLoadingSpanScoresData,
16501
+ spanInfo,
16502
+ defaultActiveTab,
16503
+ initialScoreId,
16504
+ computeTraceLink
16505
+ }
16506
+ )
16280
16507
  ] })
16281
16508
  ]
16282
16509
  }
@@ -16294,15 +16521,30 @@ function TraceDialog({
16294
16521
  isLoadingSpans,
16295
16522
  computeAgentsLink,
16296
16523
  computeWorkflowsLink,
16297
- onScorerTriggered,
16298
- initialSpanId
16524
+ computeTraceLink,
16525
+ initialSpanId,
16526
+ initialSpanTab,
16527
+ initialScoreId
16299
16528
  }) {
16300
- const { Link } = useLinkComponent();
16529
+ const { Link, navigate } = useLinkComponent();
16301
16530
  const [dialogIsOpen, setDialogIsOpen] = useState(Boolean(initialSpanId));
16302
16531
  const [selectedSpanId, setSelectedSpanId] = useState(initialSpanId);
16303
16532
  const [combinedView, setCombinedView] = useState(false);
16533
+ const [spanDialogDefaultTab, setSpanDialogDefaultTab] = useState(initialSpanTab || "details");
16304
16534
  const selectedSpan = traceSpans.find((span) => span.spanId === selectedSpanId);
16305
16535
  const traceInfo = useTraceInfo(traceDetails);
16536
+ const [spanScoresPage, setSpanScoresPage] = useState(0);
16537
+ useEffect(() => {
16538
+ if (initialSpanId) {
16539
+ setSelectedSpanId(initialSpanId);
16540
+ setDialogIsOpen(true);
16541
+ }
16542
+ }, [initialSpanId]);
16543
+ useEffect(() => {
16544
+ if (spanScoresPage > 0) {
16545
+ setSpanScoresPage(0);
16546
+ }
16547
+ }, [selectedSpanId]);
16306
16548
  const hierarchicalSpans = useMemo(() => {
16307
16549
  return formatHierarchicalSpans(traceSpans);
16308
16550
  }, [traceSpans]);
@@ -16320,39 +16562,38 @@ function TraceDialog({
16320
16562
  };
16321
16563
  return flattenSpans(hierarchicalSpans);
16322
16564
  }, [hierarchicalSpans]);
16565
+ const { data: spanScoresData, isLoading: isLoadingSpanScoresData } = useTraceSpanScores({
16566
+ traceId,
16567
+ spanId: selectedSpanId || flatSpans?.[0]?.id,
16568
+ page: spanScoresPage
16569
+ });
16323
16570
  const handleSpanClick = (id) => {
16324
16571
  setSelectedSpanId(id);
16572
+ setSpanDialogDefaultTab("details");
16325
16573
  setDialogIsOpen(true);
16326
16574
  };
16327
- const toNextSpan = () => {
16328
- const currentIndex = flatSpans.findIndex((span) => span.id === selectedSpanId);
16329
- const nextItem = flatSpans[currentIndex + 1];
16330
- if (nextItem) {
16331
- setSelectedSpanId(nextItem.id);
16575
+ const handleToScoring = () => {
16576
+ setSelectedSpanId(hierarchicalSpans[0]?.id);
16577
+ setSpanDialogDefaultTab("scores");
16578
+ if (traceId) {
16579
+ navigate(`${computeTraceLink(traceId, hierarchicalSpans?.[0]?.id)}&tab=scores`);
16332
16580
  }
16333
16581
  };
16334
- const toPreviousSpan = () => {
16335
- const currentIndex = flatSpans.findIndex((span) => span.id === selectedSpanId);
16336
- const previousItem = flatSpans[currentIndex - 1];
16337
- if (previousItem) {
16338
- setSelectedSpanId(previousItem.id);
16582
+ const handleToLastScore = () => {
16583
+ setSelectedSpanId(hierarchicalSpans[0]?.id);
16584
+ setSpanDialogDefaultTab("scores");
16585
+ if (traceId) {
16586
+ navigate(
16587
+ `${computeTraceLink(
16588
+ traceId,
16589
+ hierarchicalSpans?.[0]?.id
16590
+ )}&tab=scores&scoreId=${spanScoresData?.scores?.[0]?.id}`
16591
+ );
16339
16592
  }
16340
16593
  };
16341
- const thereIsNextSpan = () => {
16342
- const currentIndex = flatSpans.findIndex((span) => span.id === selectedSpanId);
16343
- return currentIndex < flatSpans.length - 1;
16344
- };
16345
- const thereIsPreviousSpan = () => {
16346
- const currentIndex = flatSpans.findIndex((span) => span.id === selectedSpanId);
16347
- return currentIndex > 0;
16348
- };
16349
16594
  const selectedSpanInfo = getSpanInfo({ span: selectedSpan, withTraceId: !combinedView, withSpanId: combinedView });
16350
- let entityType;
16351
- if (traceDetails?.attributes?.agentId) {
16352
- entityType = "Agent";
16353
- } else if (traceDetails?.attributes?.workflowId) {
16354
- entityType = "Workflow";
16355
- }
16595
+ const toNextSpan = getToNextEntryFn({ entries: flatSpans, id: selectedSpanId, update: setSelectedSpanId });
16596
+ const toPreviousSpan = getToPreviousEntryFn({ entries: flatSpans, id: selectedSpanId, update: setSelectedSpanId });
16356
16597
  return /* @__PURE__ */ jsxs(Fragment, { children: [
16357
16598
  /* @__PURE__ */ jsxs(
16358
16599
  SideDialog,
@@ -16361,111 +16602,100 @@ function TraceDialog({
16361
16602
  dialogDescription: "View and analyze trace details",
16362
16603
  isOpen,
16363
16604
  onClose,
16364
- hasCloseButton: !dialogIsOpen || combinedView,
16365
- className: cn("w-[calc(100vw-20rem)] max-w-[80%]", "3xl:max-w-[65%]", "4xl:max-w-[55%]"),
16605
+ level: 1,
16366
16606
  children: [
16367
- /* @__PURE__ */ jsx(SideDialogTop, { onNext, onPrevious, showInnerNav: true, children: /* @__PURE__ */ jsxs(TextAndIcon, { children: [
16368
- /* @__PURE__ */ jsx(EyeIcon, {}),
16369
- " ",
16370
- getShortId(traceId)
16371
- ] }) }),
16607
+ /* @__PURE__ */ jsxs(SideDialog.Top, { children: [
16608
+ /* @__PURE__ */ jsxs(TextAndIcon, { children: [
16609
+ /* @__PURE__ */ jsx(EyeIcon, {}),
16610
+ " ",
16611
+ getShortId(traceId)
16612
+ ] }),
16613
+ "|",
16614
+ /* @__PURE__ */ jsx(SideDialog.Nav, { onNext, onPrevious })
16615
+ ] }),
16372
16616
  /* @__PURE__ */ jsxs(
16373
16617
  "div",
16374
16618
  {
16375
- className: cn("pt-[1.5rem] pl-[2.5rem] grid-rows-[auto_1fr] grid h-full overflow-y-auto", {
16376
- "grid-rows-[auto_1fr_1fr]": selectedSpan && combinedView
16619
+ className: cn("overflow-y-auto", {
16620
+ "grid grid-rows-[2fr_3fr]": Boolean(selectedSpan && combinedView)
16377
16621
  }),
16378
16622
  children: [
16379
- /* @__PURE__ */ jsxs(SideDialogHeader, { className: "pr-[2.5rem]", children: [
16380
- /* @__PURE__ */ jsxs(SideDialogHeading, { children: [
16381
- /* @__PURE__ */ jsx(EyeIcon, {}),
16382
- " ",
16383
- traceDetails?.name
16384
- ] }),
16385
- /* @__PURE__ */ jsxs(TextAndIcon, { children: [
16386
- /* @__PURE__ */ jsx(HashIcon, {}),
16387
- " ",
16388
- traceId
16389
- ] })
16390
- ] }),
16391
- /* @__PURE__ */ jsxs("div", { className: cn("overflow-y-auto pb-[2.5rem]"), children: [
16392
- traceDetails && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
16393
- ScorersDropdown,
16394
- {
16395
- trace: traceDetails,
16396
- spanId: selectedSpanId,
16397
- onScorerTriggered,
16398
- entityType
16399
- }
16400
- ) }),
16401
- traceDetails?.metadata?.usage && /* @__PURE__ */ jsx(
16402
- TraceSpanUsage,
16403
- {
16404
- traceUsage: traceDetails?.metadata?.usage,
16405
- traceSpans,
16406
- className: "mt-[2rem] pr-[1.5rem]"
16407
- }
16408
- ),
16409
- /* @__PURE__ */ jsx(KeyValueList, { data: traceInfo, LinkComponent: Link, className: "mt-[2rem]" }),
16410
- /* @__PURE__ */ jsx(
16411
- TraceTimeline,
16412
- {
16413
- hierarchicalSpans,
16414
- spans: traceSpans,
16415
- onSpanClick: handleSpanClick,
16416
- selectedSpanId,
16417
- isLoading: isLoadingSpans,
16418
- className: "pr-[2.5rem] pt-[2.5rem]"
16419
- }
16420
- ),
16421
- traceDetails?.links?.length > 0 && /* @__PURE__ */ jsxs("div", { className: "pt-[2.5rem] pr-[2.5rem]", children: [
16422
- /* @__PURE__ */ jsxs(SideDialogHeading, { as: "h2", className: "pb-[1rem]", children: [
16423
- /* @__PURE__ */ jsx(GaugeIcon, {}),
16424
- " Scores"
16623
+ /* @__PURE__ */ jsxs(SideDialog.Content, { children: [
16624
+ /* @__PURE__ */ jsxs(SideDialog.Header, { children: [
16625
+ /* @__PURE__ */ jsxs(SideDialog.Heading, { children: [
16626
+ /* @__PURE__ */ jsx(EyeIcon, {}),
16627
+ " ",
16628
+ traceDetails?.name
16425
16629
  ] }),
16426
- /* @__PURE__ */ jsx("div", { className: "bg-surface2 rounded-lg overflow-hidden border-sm border-border1", children: /* @__PURE__ */ jsx(
16427
- ScoreTable,
16428
- {
16429
- scores: traceDetails?.links,
16430
- onItemClick: (scorerName) => onScorerTriggered(scorerName, traceDetails.traceId, selectedSpanId)
16431
- }
16432
- ) })
16433
- ] })
16434
- ] }),
16435
- selectedSpan && combinedView && /* @__PURE__ */ jsxs("div", { className: "overflow-y-auto grid grid-rows-[auto_1fr] relative", children: [
16436
- /* @__PURE__ */ jsx("div", { className: "absolute left-0 right-[2.5rem] h-[.5rem] bg-surface1 rounded-full top-0" }),
16437
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pb-[.5rem] pt-[1rem] border-b border-border1 pr-[2.5rem]", children: [
16438
- /* @__PURE__ */ jsx(
16439
- SideDialogTop,
16440
- {
16441
- onNext: thereIsNextSpan() ? toNextSpan : void 0,
16442
- onPrevious: thereIsPreviousSpan() ? toPreviousSpan : void 0,
16443
- showInnerNav: true,
16444
- className: "pl-0",
16445
- children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-[1rem] text-icon4 text-[0.875rem]", children: [
16446
- /* @__PURE__ */ jsxs(TextAndIcon, { children: [
16447
- /* @__PURE__ */ jsx(EyeIcon, {}),
16448
- " ",
16449
- getShortId(traceId)
16630
+ /* @__PURE__ */ jsxs(TextAndIcon, { children: [
16631
+ /* @__PURE__ */ jsx(HashIcon, {}),
16632
+ " ",
16633
+ traceId
16634
+ ] })
16635
+ ] }),
16636
+ traceDetails && /* @__PURE__ */ jsxs(Sections, { children: [
16637
+ /* @__PURE__ */ jsxs("div", { className: "grid xl:grid-cols-[3fr_2fr] gap-[1rem] items-start", children: [
16638
+ /* @__PURE__ */ jsx(KeyValueList, { data: traceInfo, LinkComponent: Link }),
16639
+ /* @__PURE__ */ jsxs("div", { className: "bg-surface3 p-[1.5rem] rounded-lg grid gap-[1rem]", children: [
16640
+ /* @__PURE__ */ jsx("h4", { className: "text-[1rem]", children: /* @__PURE__ */ jsxs(TextAndIcon, { children: [
16641
+ /* @__PURE__ */ jsx(GaugeIcon, {}),
16642
+ " Evaluate trace"
16643
+ ] }) }),
16644
+ /* @__PURE__ */ jsxs(ButtonsGroup, { className: "w-full", children: [
16645
+ /* @__PURE__ */ jsxs(Button, { onClick: handleToScoring, children: [
16646
+ "Scoring ",
16647
+ /* @__PURE__ */ jsx(CircleGaugeIcon, {}),
16648
+ " "
16450
16649
  ] }),
16451
- "›",
16452
- /* @__PURE__ */ jsxs(TextAndIcon, { children: [
16453
- /* @__PURE__ */ jsx(ChevronsLeftRightEllipsisIcon, {}),
16454
- " ",
16455
- getShortId(selectedSpanId)
16650
+ spanScoresData?.scores?.[0] && /* @__PURE__ */ jsxs(Button, { onClick: handleToLastScore, children: [
16651
+ "Last score: ",
16652
+ /* @__PURE__ */ jsx("b", { children: spanScoresData?.scores?.[0]?.score })
16456
16653
  ] })
16457
16654
  ] })
16458
- }
16459
- ),
16460
- /* @__PURE__ */ jsx("div", { className: "flex items-center gap-[1rem]", children: /* @__PURE__ */ jsx("button", { className: "flex items-center gap-1", onClick: () => setCombinedView(false), children: /* @__PURE__ */ jsx(PanelLeftIcon, {}) }) })
16655
+ ] })
16656
+ ] }),
16657
+ /* @__PURE__ */ jsxs(Section, { children: [
16658
+ /* @__PURE__ */ jsxs(Section.Header, { children: [
16659
+ /* @__PURE__ */ jsxs(Section.Heading, { children: [
16660
+ /* @__PURE__ */ jsx(ListTreeIcon, {}),
16661
+ " Timeline"
16662
+ ] }),
16663
+ /* @__PURE__ */ jsx(TraceTimelineLegend, { spans: traceSpans })
16664
+ ] }),
16665
+ /* @__PURE__ */ jsx(
16666
+ TraceTimeline,
16667
+ {
16668
+ hierarchicalSpans,
16669
+ onSpanClick: handleSpanClick,
16670
+ selectedSpanId,
16671
+ isLoading: isLoadingSpans
16672
+ }
16673
+ )
16674
+ ] })
16675
+ ] })
16676
+ ] }),
16677
+ selectedSpan && combinedView && /* @__PURE__ */ jsxs("div", { className: "grid grid-rows-[auto_1fr] relative overflow-y-auto", children: [
16678
+ /* @__PURE__ */ jsxs(SideDialog.Top, { withTopSeparator: true, children: [
16679
+ /* @__PURE__ */ jsxs(TextAndIcon, { children: [
16680
+ /* @__PURE__ */ jsx(ChevronsLeftRightEllipsisIcon, {}),
16681
+ " ",
16682
+ getShortId(selectedSpanId)
16683
+ ] }),
16684
+ "|",
16685
+ /* @__PURE__ */ jsx(SideDialog.Nav, { onNext: toNextSpan, onPrevious: toPreviousSpan }),
16686
+ /* @__PURE__ */ jsxs("button", { className: "ml-auto mr-[2rem]", onClick: () => setCombinedView(false), children: [
16687
+ /* @__PURE__ */ jsx(PanelLeftIcon, {}),
16688
+ " ",
16689
+ /* @__PURE__ */ jsx(VisuallyHidden$1, { children: "Switch to dialog view" })
16690
+ ] })
16461
16691
  ] }),
16462
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[20rem_1fr] gap-[1rem] overflow-y-auto", children: [
16463
- /* @__PURE__ */ jsxs("div", { className: "overflow-y-auto grid content-start p-[1.5rem] pl-0 gap-[2rem]", children: [
16464
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(SideDialogHeading, { as: "h2", children: [
16692
+ /* @__PURE__ */ jsxs("div", { className: cn("h-full overflow-y-auto grid gap-[2rem] grid-cols-[20rem_1fr]"), children: [
16693
+ /* @__PURE__ */ jsxs("div", { className: "overflow-y-auto grid content-start p-[2rem] gap-[2rem]", children: [
16694
+ /* @__PURE__ */ jsxs(SideDialog.Heading, { as: "h2", children: [
16465
16695
  /* @__PURE__ */ jsx(ChevronsLeftRightEllipsisIcon, {}),
16466
16696
  " ",
16467
16697
  selectedSpan?.name
16468
- ] }) }),
16698
+ ] }),
16469
16699
  selectedSpan?.attributes?.usage && /* @__PURE__ */ jsx(
16470
16700
  TraceSpanUsage,
16471
16701
  {
@@ -16475,7 +16705,20 @@ function TraceDialog({
16475
16705
  ),
16476
16706
  /* @__PURE__ */ jsx(KeyValueList, { data: selectedSpanInfo, LinkComponent: Link })
16477
16707
  ] }),
16478
- /* @__PURE__ */ jsx("div", { className: "overflow-y-auto pr-[2.5rem] pt-[2rem]", children: /* @__PURE__ */ jsx(SpanDetails, { span: selectedSpan, onScorerTriggered }) })
16708
+ /* @__PURE__ */ jsx("div", { className: "overflow-y-auto pr-[2rem] pt-[2rem] h-full", children: /* @__PURE__ */ jsx(
16709
+ SpanTabs,
16710
+ {
16711
+ trace: traceDetails,
16712
+ span: selectedSpan,
16713
+ spanScoresData,
16714
+ onSpanScoresPageChange: setSpanScoresPage,
16715
+ isLoadingSpanScoresData,
16716
+ spanInfo: selectedSpanInfo,
16717
+ defaultActiveTab: spanDialogDefaultTab,
16718
+ initialScoreId,
16719
+ computeTraceLink
16720
+ }
16721
+ ) })
16479
16722
  ] })
16480
16723
  ] })
16481
16724
  ]
@@ -16489,16 +16732,22 @@ function TraceDialog({
16489
16732
  {
16490
16733
  trace: traceDetails,
16491
16734
  span: selectedSpan,
16735
+ spanScoresData,
16736
+ onSpanScoresPageChange: setSpanScoresPage,
16737
+ isLoadingSpanScoresData,
16492
16738
  isOpen: Boolean(dialogIsOpen && selectedSpanId && !combinedView),
16493
16739
  onClose: () => {
16740
+ navigate(computeTraceLink(traceId || ""));
16494
16741
  setDialogIsOpen(false);
16495
16742
  setSelectedSpanId(void 0);
16496
16743
  },
16497
- onNext: thereIsNextSpan() ? toNextSpan : void 0,
16498
- onPrevious: thereIsPreviousSpan() ? toPreviousSpan : void 0,
16744
+ onNext: toNextSpan,
16745
+ onPrevious: toPreviousSpan,
16499
16746
  onViewToggle: () => setCombinedView(!combinedView),
16500
16747
  spanInfo: selectedSpanInfo,
16501
- onScorerTriggered
16748
+ defaultActiveTab: spanDialogDefaultTab,
16749
+ initialScoreId,
16750
+ computeTraceLink
16502
16751
  }
16503
16752
  )
16504
16753
  ] });
@@ -16637,61 +16886,192 @@ function TracesList({
16637
16886
  ] });
16638
16887
  }
16639
16888
 
16640
- function MainContentLayout({
16641
- children,
16642
- className,
16643
- style
16889
+ const traceScoresListColumns = [
16890
+ { name: "shortId", label: "ID", size: "1fr" },
16891
+ { name: "date", label: "Date", size: "1fr" },
16892
+ { name: "time", label: "Time", size: "1fr" },
16893
+ { name: "score", label: "Score", size: "1fr" },
16894
+ { name: "scorer", label: "Scorer", size: "1fr" }
16895
+ ];
16896
+ function SpanScoreList({
16897
+ scoresData,
16898
+ isLoadingScoresData,
16899
+ traceId,
16900
+ spanId,
16901
+ initialScoreId,
16902
+ onPageChange,
16903
+ computeTraceLink
16644
16904
  }) {
16645
- const devStyleRequested = devUIStyleRequested("MainContentLayout");
16646
- return /* @__PURE__ */ jsx(
16647
- "main",
16648
- {
16649
- className: cn(`grid grid-rows-[auto_1fr] h-full items-start content-start`, className),
16650
- style: { ...style, ...devStyleRequested ? { border: "3px dotted red" } : {} },
16651
- children
16905
+ const { navigate } = useLinkComponent();
16906
+ const [dialogIsOpen, setDialogIsOpen] = useState(false);
16907
+ const [selectedScore, setSelectedScore] = useState();
16908
+ useEffect(() => {
16909
+ if (initialScoreId) {
16910
+ handleOnScore(initialScoreId);
16652
16911
  }
16653
- );
16654
- }
16655
- function MainContentContent({
16656
- children,
16657
- className,
16658
- isCentered = false,
16659
- isDivided = false,
16660
- hasLeftServiceColumn = false,
16661
- style
16662
- }) {
16663
- const devStyleRequested = devUIStyleRequested("MainContentContent");
16664
- return /* @__PURE__ */ jsx(
16665
- "div",
16666
- {
16667
- className: cn(
16668
- `grid overflow-y-auto h-full `,
16669
- `overflow-x-auto min-w-[min-content]`,
16912
+ }, [initialScoreId]);
16913
+ const handleOnScore = (scoreId) => {
16914
+ const score = scoresData?.scores?.find((s) => s?.id === scoreId);
16915
+ setSelectedScore(score);
16916
+ setDialogIsOpen(true);
16917
+ };
16918
+ if (isLoadingScoresData) {
16919
+ return /* @__PURE__ */ jsx(EntryListSkeleton, { columns: traceScoresListColumns });
16920
+ }
16921
+ const updateSelectedScore = (scoreId) => {
16922
+ const score = scoresData?.scores?.find((s) => s?.id === scoreId);
16923
+ setSelectedScore(score);
16924
+ };
16925
+ const toNextScore = getToNextEntryFn({
16926
+ entries: scoresData?.scores || [],
16927
+ id: selectedScore?.id,
16928
+ update: updateSelectedScore
16929
+ });
16930
+ const toPreviousScore = getToPreviousEntryFn({
16931
+ entries: scoresData?.scores || [],
16932
+ id: selectedScore?.id,
16933
+ update: updateSelectedScore
16934
+ });
16935
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
16936
+ /* @__PURE__ */ jsxs(EntryList, { children: [
16937
+ /* @__PURE__ */ jsxs(EntryList.Trim, { children: [
16938
+ /* @__PURE__ */ jsx(EntryList.Header, { columns: traceScoresListColumns }),
16939
+ scoresData?.scores && scoresData.scores.length > 0 ? /* @__PURE__ */ jsx(EntryList.Entries, { children: scoresData?.scores?.map((score) => {
16940
+ const createdAtDate = new Date(score.createdAt);
16941
+ const isTodayDate = isToday(createdAtDate);
16942
+ const entry = {
16943
+ id: score?.id,
16944
+ shortId: getShortId(score?.id) || "n/a",
16945
+ date: isTodayDate ? "Today" : format(createdAtDate, "MMM dd"),
16946
+ time: format(createdAtDate, "h:mm:ss aaa"),
16947
+ score: score?.score,
16948
+ scorer: score?.scorer?.name
16949
+ };
16950
+ return /* @__PURE__ */ jsx(
16951
+ EntryList.Entry,
16952
+ {
16953
+ columns: traceScoresListColumns,
16954
+ onClick: () => handleOnScore(score.id),
16955
+ entry,
16956
+ children: traceScoresListColumns.map((col) => {
16957
+ const key = `col-${col.name}`;
16958
+ return /* @__PURE__ */ jsx(EntryList.EntryText, { children: entry?.[col.name] }, key);
16959
+ })
16960
+ },
16961
+ score.id
16962
+ );
16963
+ }) }) : /* @__PURE__ */ jsx(EntryList.Message, { message: "No scores found", type: "info" })
16964
+ ] }),
16965
+ /* @__PURE__ */ jsx(
16966
+ EntryList.Pagination,
16670
16967
  {
16671
- "items-start content-start": !isCentered && !isDivided && !hasLeftServiceColumn,
16672
- "grid place-items-center": isCentered,
16673
- "grid-cols-[1fr_1fr]": isDivided && !hasLeftServiceColumn,
16674
- "grid-cols-[12rem_1fr_1fr]": isDivided && hasLeftServiceColumn,
16675
- "grid-cols-[auto_1fr]": !isDivided && hasLeftServiceColumn
16968
+ currentPage: scoresData?.pagination?.page || 0,
16969
+ hasMore: scoresData?.pagination?.hasMore,
16970
+ onNextPage: () => onPageChange && onPageChange((scoresData?.pagination?.page || 0) + 1),
16971
+ onPrevPage: () => onPageChange && onPageChange((scoresData?.pagination?.page || 0) - 1)
16972
+ }
16973
+ )
16974
+ ] }),
16975
+ /* @__PURE__ */ jsx(
16976
+ ScoreDialog,
16977
+ {
16978
+ scorerName: selectedScore?.scorer?.name || "",
16979
+ score: selectedScore,
16980
+ isOpen: dialogIsOpen,
16981
+ onClose: () => {
16982
+ if (traceId) {
16983
+ navigate(`${computeTraceLink(traceId, spanId)}&tab=scores`);
16984
+ }
16985
+ setDialogIsOpen(false);
16676
16986
  },
16677
- className
16678
- ),
16679
- style: { ...style, ...devStyleRequested ? { border: "3px dotted orange" } : {} },
16680
- children
16681
- }
16682
- );
16987
+ dialogLevel: 3,
16988
+ onNext: toNextScore,
16989
+ onPrevious: toPreviousScore,
16990
+ computeTraceLink: (traceId2, spanId2) => `/observability?traceId=${traceId2}${spanId2 ? `&spanId=${spanId2}` : ""}`,
16991
+ usageContext: "aiSpanDialog"
16992
+ }
16993
+ )
16994
+ ] });
16683
16995
  }
16684
- function devUIStyleRequested(name) {
16685
- try {
16686
- const raw = localStorage.getItem("add-dev-style-to-components");
16687
- if (!raw) return false;
16688
- const components = raw.split(",").map((c) => c.trim()).filter(Boolean);
16689
- return components.includes(name);
16690
- } catch (error) {
16691
- console.error("Error reading or parsing localStorage:", error);
16692
- return false;
16996
+
16997
+ const useTriggerScorer = () => {
16998
+ const client = useMastraClient();
16999
+ return useMutation({
17000
+ mutationFn: async ({ scorerName, traceId, spanId }) => {
17001
+ const response = await client.score({
17002
+ scorerName,
17003
+ targets: [{ traceId, spanId }]
17004
+ });
17005
+ return response;
17006
+ }
17007
+ });
17008
+ };
17009
+
17010
+ const SpanScoring = ({ traceId, spanId, entityType }) => {
17011
+ const { data: scorers = {}, isLoading } = useScorers();
17012
+ const [selectedScorer, setSelectedScorer] = useState(null);
17013
+ const { mutate: triggerScorer, isPending, isSuccess } = useTriggerScorer();
17014
+ const [notificationIsVisible, setNotificationIsVisible] = useState(false);
17015
+ useEffect(() => {
17016
+ if (isSuccess) {
17017
+ setNotificationIsVisible(true);
17018
+ }
17019
+ }, [isSuccess]);
17020
+ let scorerList = Object.entries(scorers).map(([key, scorer]) => ({
17021
+ id: key,
17022
+ name: scorer.scorer.config.name,
17023
+ description: scorer.scorer.config.description,
17024
+ isRegistered: scorer.isRegistered,
17025
+ type: scorer.scorer.config.type
17026
+ })).filter((scorer) => scorer.isRegistered);
17027
+ if (entityType !== "Agent" || spanId) {
17028
+ scorerList = scorerList.filter((scorer) => scorer.type !== "agent");
16693
17029
  }
16694
- }
17030
+ const isWaiting = isPending || isLoading;
17031
+ const handleStartScoring = () => {
17032
+ if (selectedScorer) {
17033
+ setNotificationIsVisible(false);
17034
+ triggerScorer({
17035
+ scorerName: selectedScorer,
17036
+ traceId: traceId || "",
17037
+ spanId
17038
+ });
17039
+ }
17040
+ };
17041
+ const handleScorerChange = (val) => {
17042
+ setSelectedScorer(val);
17043
+ setNotificationIsVisible(false);
17044
+ };
17045
+ const selectedScorerDescription = scorerList.find((s) => s.name === selectedScorer)?.description || "";
17046
+ return /* @__PURE__ */ jsxs("div", { children: [
17047
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[3fr_1fr] gap-[1rem] items-start", children: [
17048
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-[0.5rem]", children: [
17049
+ /* @__PURE__ */ jsx(
17050
+ SelectField,
17051
+ {
17052
+ name: "select-scorer",
17053
+ placeholder: "Select a scorer...",
17054
+ options: scorerList.map((scorer) => ({ label: scorer.name, value: scorer.name })),
17055
+ onValueChange: handleScorerChange,
17056
+ value: selectedScorer || "",
17057
+ className: "min-w-[20rem]",
17058
+ disabled: isWaiting
17059
+ }
17060
+ ),
17061
+ selectedScorerDescription && /* @__PURE__ */ jsxs(TextAndIcon, { className: "text-icon3", children: [
17062
+ /* @__PURE__ */ jsx(InfoIcon$1, {}),
17063
+ " ",
17064
+ selectedScorerDescription
17065
+ ] })
17066
+ ] }),
17067
+ /* @__PURE__ */ jsx(Button, { disabled: !selectedScorer || isWaiting, onClick: handleStartScoring, children: isPending ? "Starting..." : "Start Scoring" })
17068
+ ] }),
17069
+ /* @__PURE__ */ jsxs(Notification, { isVisible: notificationIsVisible, className: "mt-[1rem]", children: [
17070
+ /* @__PURE__ */ jsx(InfoIcon$1, {}),
17071
+ " Scorer triggered! When finished successfully, it will appear in the list below. It could take a moment."
17072
+ ] })
17073
+ ] });
17074
+ };
16695
17075
 
16696
17076
  const Breadcrumb = ({ children, label }) => {
16697
17077
  return /* @__PURE__ */ jsx("nav", { "aria-label": label, children: /* @__PURE__ */ jsx("ol", { className: "gap-sm flex items-center", children }) });
@@ -17298,7 +17678,7 @@ function MCPTable({ mcpServers, isLoading }) {
17298
17678
  return /* @__PURE__ */ jsx(EmptyMCPTable, {});
17299
17679
  }
17300
17680
  const filteredRows = rows.filter((row) => row.original.name.toLowerCase().includes(search.toLowerCase()));
17301
- return /* @__PURE__ */ jsxs(Fragment, { children: [
17681
+ return /* @__PURE__ */ jsxs("div", { children: [
17302
17682
  /* @__PURE__ */ jsx(SearchbarWrapper, { children: /* @__PURE__ */ jsx(Searchbar, { onSearch: setSearch, label: "Search MCP servers", placeholder: "Search MCP servers" }) }),
17303
17683
  isLoading ? /* @__PURE__ */ jsx(MCPTableSkeleton, {}) : /* @__PURE__ */ jsx(ScrollableContainer, { children: /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Table$1, { children: [
17304
17684
  /* @__PURE__ */ jsx(Thead, { className: "sticky top-0", children: ths.headers.map((header) => /* @__PURE__ */ jsx(Th, { style: { width: header.column.getSize() ?? "auto" }, children: flexRender(header.column.columnDef.header, header.getContext()) }, header.id)) }),
@@ -17384,5 +17764,5 @@ const WorkflowRunStatusBadge = ({ status }) => {
17384
17764
  return /* @__PURE__ */ jsx(Badge$1, { variant: "default", children: status });
17385
17765
  };
17386
17766
 
17387
- export { AgentChat, AgentCoinIcon, AgentEntityHeader, AgentEvals, AgentIcon, AgentMetadata, AgentMetadataList, AgentMetadataListEmpty, AgentMetadataListItem, AgentMetadataNetworkList, AgentMetadataPrompt, AgentMetadataScorerList, AgentMetadataSection, AgentMetadataToolList, AgentMetadataWorkflowList, AgentMetadataWrapper, AgentNetworkCoinIcon, AgentSettings, AgentSettingsContext, AgentSettingsProvider, AgentsTable, AiIcon, Alert$1 as Alert, AlertDescription$1 as AlertDescription, AlertDialog, AlertTitle$1 as AlertTitle, ApiIcon, Badge$1 as Badge, BranchIcon, Breadcrumb, Button$1 as Button, Cell, ChatThreads, CheckIcon, ChevronIcon, Collapsible, CollapsibleContent, CollapsibleTrigger, CommitIcon, CrossIcon, Crumb, DarkLogo, DateTimeCell, DateTimePicker, DateTimePickerContent, DbIcon, DebugIcon, DefaultTrigger, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, EmptyState, Entity, EntityContent, EntityDescription, EntityHeader, EntityIcon, EntityMainHeader, EntityName, Entry, EntryCell, EntryList, EntryListSkeleton, EnvIcon, EvaluatorCoinIcon, FiltersIcon, FolderIcon, FormActions, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, InputField, JudgeIcon, Kbd, KeyValueList, LatencyIcon, LinkComponentProvider, LogsIcon, MCPTable, MainContentContent, MainContentLayout, MastraResizablePanel, McpCoinIcon, McpServerIcon, MemoryIcon, MemorySearch, ModelResetProvider, OpenAIIcon, PageHeader, PlaygroundQueryClient, PlaygroundTabs, PromptIcon, RadioGroup, RadioGroupField, RadioGroupItem, RepoIcon, Row, RuntimeContext, RuntimeContextWrapper, ScoreDialog, ScoreIcon, ScorersTable, ScoresList, ScoresTools, SearchField, Searchbar, SearchbarWrapper, SelectField, SettingsIcon, SideDialog, SideDialogCodeSection, SideDialogContent, SideDialogFooter, SideDialogFooterGroup, SideDialogHeader, SideDialogHeading, SideDialogKeyValueList, SideDialogSection, SideDialogTop, SlashIcon, SliderField, Tab, TabContent, TabList, Table$1 as Table, Tbody, TemplateFailure, TemplateForm, TemplateInfo, TemplateInstallation, TemplateSuccess, TemplatesList, TemplatesTools, TextAndIcon, TextareaField, Th, Thead, ThreadDeleteButton, ThreadInputProvider, ThreadItem, ThreadLink, ThreadList, Threads, ToolCoinIcon, ToolFallback, ToolTable, ToolsIcon, TraceDialog, TraceIcon, TraceTimeline, TraceTimelineLegend, TraceTimelineSpan, TracesList, TracesTools, TracesView, TracesViewSkeleton, TsIcon, Txt, TxtCell, UnitCell, VariablesIcon, WorkflowCoinIcon, WorkflowGraph, WorkflowIcon, WorkflowRunContext, WorkflowRunDetail, WorkflowRunList, WorkflowRunProvider, WorkflowTable, WorkflowTrigger, WorkingMemoryContext, WorkingMemoryProvider, allowedAiSpanAttributes, cleanString, convertWorkflowRunStateToStreamResult, extractPrompt, formatDuration, formatHierarchicalSpans, formatOtelTimestamp, formatOtelTimestamp2, getColumnTemplate, getShortId, getSpanTypeUi, getToNextEntryFn, getToPreviousEntryFn, parseError, providerMapToIcon, scoresListColumns, spanTypePrefixes, tracesListColumns, transformKey, useAgentSettings, useCurrentRun, useInView, useLinkComponent, useMCPServerTools, useModelReset, usePlaygroundStore, usePolling, useScorer, useScorers, useScoresByEntityId, useScoresByScorerId, useSpeechRecognition, useThreadInput, useWorkflow, useWorkflowRuns, useWorkingMemory };
17767
+ export { AgentChat, AgentCoinIcon, AgentEntityHeader, AgentEvals, AgentIcon, AgentMetadata, AgentMetadataList, AgentMetadataListEmpty, AgentMetadataListItem, AgentMetadataNetworkList, AgentMetadataPrompt, AgentMetadataScorerList, AgentMetadataSection, AgentMetadataToolList, AgentMetadataWorkflowList, AgentMetadataWrapper, AgentNetworkCoinIcon, AgentSettings, AgentSettingsContext, AgentSettingsProvider, AgentsTable, AiIcon, Alert$1 as Alert, AlertDescription$1 as AlertDescription, AlertDialog, AlertTitle$1 as AlertTitle, ApiIcon, Badge$1 as Badge, BranchIcon, Breadcrumb, Button$1 as Button, ButtonsGroup, Cell, ChatThreads, CheckIcon, ChevronIcon, Collapsible, CollapsibleContent, CollapsibleTrigger, CommitIcon, CrossIcon, Crumb, DarkLogo, DateTimeCell, DateTimePicker, DateTimePickerContent, DbIcon, DebugIcon, DefaultTrigger, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, EmptyState, Entity, EntityContent, EntityDescription, EntityHeader, EntityIcon, EntityMainHeader, EntityName, Entry, EntryCell, EntryList, EntryListSkeleton, EnvIcon, EvaluatorCoinIcon, FiltersIcon, FolderIcon, FormActions, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, InputField, JudgeIcon, Kbd, KeyValueList, LatencyIcon, LinkComponentProvider, LogsIcon, MCPTable, MainContentContent, MainContentLayout, MainSidebar, MainSidebarProvider, MastraResizablePanel, McpCoinIcon, McpServerIcon, MemoryIcon, MemorySearch, ModelResetProvider, Notification, OpenAIIcon, PageHeader, PlaygroundQueryClient, PlaygroundTabs, PromptIcon, RadioGroup, RadioGroupField, RadioGroupItem, RepoIcon, Row, RuntimeContext, RuntimeContextWrapper, ScoreDialog, ScoreIcon, ScorersTable, ScoresList, ScoresTools, SearchField, Searchbar, SearchbarWrapper, Section, Sections, SelectField, SettingsIcon, SideDialog, SlashIcon, SliderField, SpanScoreList, SpanScoring, SpanTabs, Tab$1 as Tab, TabContent$1 as TabContent, TabList$1 as TabList, Table$1 as Table, Tbody, TemplateFailure, TemplateForm, TemplateInfo, TemplateInstallation, TemplateSuccess, TemplatesList, TemplatesTools, TextAndIcon, TextareaField, Th, Thead, ThreadDeleteButton, ThreadInputProvider, ThreadItem, ThreadLink, ThreadList, Threads, ToolCoinIcon, ToolFallback, ToolTable, ToolsIcon, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TraceDialog, TraceIcon, TraceTimeline, TraceTimelineLegend, TraceTimelineSpan, TracesList, TracesTools, TracesView, TracesViewSkeleton, TsIcon, Txt, TxtCell, UnitCell, VariablesIcon, WorkflowCoinIcon, WorkflowGraph, WorkflowIcon, WorkflowRunContext, WorkflowRunDetail, WorkflowRunList, WorkflowRunProvider, WorkflowTable, WorkflowTrigger, WorkingMemoryContext, WorkingMemoryProvider, allowedAiSpanAttributes, cleanString, convertWorkflowRunStateToStreamResult, extractPrompt, formatDuration, formatHierarchicalSpans, formatOtelTimestamp, formatOtelTimestamp2, getColumnTemplate, getShortId, getSpanTypeUi, getToNextEntryFn, getToPreviousEntryFn, parseError, providerMapToIcon, scoresListColumns, spanTypePrefixes, traceScoresListColumns, tracesListColumns, transformKey, useAgentSettings, useCurrentRun, useInView, useLinkComponent, useMCPServerTools, useMainSidebar, useModelReset, usePlaygroundStore, usePolling, useScorer, useScorers, useScoresByEntityId, useScoresByScorerId, useSpeechRecognition, useThreadInput, useTraceSpanScores, useWorkflow, useWorkflowRuns, useWorkingMemory };
17388
17768
  //# sourceMappingURL=index.es.js.map