@mastra/playground-ui 2.0.1-alpha.0 → 2.0.1-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.
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from '../../node_modules/@types/react';
2
+
3
+ export declare const MastraResizablePanel: ({ children, defaultWidth, minimumWidth, maximumWidth, className, disabled, setCurrentWidth, dividerPosition, }: {
4
+ children: ReactNode;
5
+ defaultWidth: number;
6
+ minimumWidth: number;
7
+ maximumWidth: number;
8
+ className?: string;
9
+ disabled?: boolean;
10
+ setCurrentWidth?: (width: number) => void;
11
+ dividerPosition?: "left" | "right";
12
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,10 @@
1
1
  import { MouseEvent as ReactMouseEvent } from '../../node_modules/@types/react';
2
2
 
3
- export declare const useResizeColumn: ({ defaultWidth, minimumWidth, maximumWidth, }: {
3
+ export declare const useResizeColumn: ({ defaultWidth, minimumWidth, maximumWidth, setCurrentWidth, }: {
4
4
  defaultWidth: number;
5
5
  minimumWidth: number;
6
6
  maximumWidth: number;
7
+ setCurrentWidth?: (width: number) => void;
7
8
  }) => {
8
9
  sidebarWidth: number;
9
10
  isDragging: boolean;
package/dist/index.css CHANGED
@@ -9,3 +9,7 @@
9
9
  [hidden]:where(:not([hidden=until-found])) {
10
10
  display: none !important;
11
11
  }
12
+
13
+ .unset-position {
14
+ position: unset;
15
+ }
package/dist/index.d.ts CHANGED
@@ -2,3 +2,4 @@
2
2
  export * from './chat-ui/chat';
3
3
  export * from './domains/agents/index';
4
4
  export * from './domains/workflows/index';
5
+ export * from './domains/resizable-panel';
package/dist/index.es.js CHANGED
@@ -4616,7 +4616,7 @@ const useEvalsByAgentId = (agentId, type, baseUrl) => {
4616
4616
  };
4617
4617
 
4618
4618
  const AgentEvalsContext = createContext({ handleRefresh: () => {
4619
- }, isLoading: false });
4619
+ }, isLoading: true });
4620
4620
  const scrollableContentClass = cn(
4621
4621
  "relative overflow-y-auto overflow-x-hidden invisible hover:visible focus:visible",
4622
4622
  "[&::-webkit-scrollbar]:w-1",
@@ -4648,6 +4648,13 @@ function AgentEvals({ agentId, baseUrl }) {
4648
4648
  handleRefresh,
4649
4649
  isLoading: activeTab === "live" ? isLiveLoading : isCiLoading
4650
4650
  };
4651
+ function handleRefresh() {
4652
+ if (activeTab === "live") {
4653
+ refetchLiveEvals();
4654
+ } else {
4655
+ refetchCiEvals();
4656
+ }
4657
+ }
4651
4658
  return /* @__PURE__ */ jsx(AgentEvalsContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs(
4652
4659
  Tabs,
4653
4660
  {
@@ -4655,7 +4662,7 @@ function AgentEvals({ agentId, baseUrl }) {
4655
4662
  onValueChange: (value) => setActiveTab(value),
4656
4663
  className: "grid grid-rows-[auto_1fr] h-full min-h-0 pb-2",
4657
4664
  children: [
4658
- /* @__PURE__ */ jsx("div", { className: "bg-mastra-bg-2 border-b border-mastra-border/10", children: /* @__PURE__ */ jsxs(TabsList, { className: "bg-transparent border-0 h-auto mx-4 pt-5", children: [
4665
+ /* @__PURE__ */ jsx("div", { className: "border-b border-mastra-border/10", children: /* @__PURE__ */ jsxs(TabsList, { className: "bg-transparent border-0 h-auto mx-4", children: [
4659
4666
  /* @__PURE__ */ jsx(TabsTrigger, { value: "live", className: tabIndicatorClass, children: "Live" }),
4660
4667
  /* @__PURE__ */ jsx(TabsTrigger, { value: "ci", className: tabIndicatorClass, children: "CI" })
4661
4668
  ] }) }),
@@ -4664,32 +4671,14 @@ function AgentEvals({ agentId, baseUrl }) {
4664
4671
  ]
4665
4672
  }
4666
4673
  ) });
4667
- function handleRefresh() {
4668
- if (activeTab === "live") {
4669
- refetchLiveEvals();
4670
- } else {
4671
- refetchCiEvals();
4672
- }
4673
- }
4674
4674
  }
4675
4675
  function EvalTable({ evals, isCIMode = false }) {
4676
4676
  const { handleRefresh, isLoading: isTableLoading } = useContext(AgentEvalsContext);
4677
4677
  const [expandedMetrics, setExpandedMetrics] = useState(/* @__PURE__ */ new Set());
4678
4678
  const [searchTerm, setSearchTerm] = useState("");
4679
4679
  const [sortConfig, setSortConfig] = useState({ field: "metricName", direction: "asc" });
4680
- const [showLoading, setShowLoading] = useState(false);
4681
- useEffect(() => {
4682
- if (isTableLoading) {
4683
- const timer = setTimeout(() => {
4684
- setShowLoading(true);
4685
- }, 200);
4686
- return () => clearTimeout(timer);
4687
- } else {
4688
- setShowLoading(false);
4689
- }
4690
- }, [isTableLoading]);
4691
4680
  return /* @__PURE__ */ jsxs("div", { className: "min-h-0 grid grid-rows-[auto_1fr]", children: [
4692
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 p-4 bg-mastra-bg-2 rounded-lg", children: [
4681
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 p-4 rounded-lg", children: [
4693
4682
  /* @__PURE__ */ jsxs("div", { className: "relative flex-1", children: [
4694
4683
  /* @__PURE__ */ jsx(Search, { className: "absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-mastra-el-3" }),
4695
4684
  /* @__PURE__ */ jsx(
@@ -4707,11 +4696,11 @@ function EvalTable({ evals, isCIMode = false }) {
4707
4696
  evals.length,
4708
4697
  " Total Evaluations"
4709
4698
  ] }),
4710
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", onClick: handleRefresh, disabled: showLoading, className: "h-9 w-9", children: showLoading ? /* @__PURE__ */ jsx(RefreshCcwIcon, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(RefreshCcwIcon, { className: "h-4 w-4" }) })
4699
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", onClick: handleRefresh, disabled: isTableLoading, className: "h-9 w-9", children: isTableLoading ? /* @__PURE__ */ jsx(RefreshCcwIcon, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(RefreshCcwIcon, { className: "h-4 w-4" }) })
4711
4700
  ] }),
4712
4701
  /* @__PURE__ */ jsx("div", { className: "overflow-auto", children: /* @__PURE__ */ jsxs(Table, { className: "w-full", children: [
4713
- /* @__PURE__ */ jsx(TableHeader, { className: "bg-mastra-bg-2 sticky top-0 z-10", children: /* @__PURE__ */ jsxs(TableRow, { className: "border-gray-6 border-b-[0.1px] text-[0.8125rem]", children: [
4714
- /* @__PURE__ */ jsx(TableHead, { className: "w-12" }),
4702
+ /* @__PURE__ */ jsx(TableHeader, { className: "bg-mastra-bg-2 h-[var(--table-header-height)] sticky top-0 z-10", children: /* @__PURE__ */ jsxs(TableRow, { className: "border-gray-6 border-b-[0.1px] text-[0.8125rem]", children: [
4703
+ /* @__PURE__ */ jsx(TableHead, { className: "w-12 h-12" }),
4715
4704
  /* @__PURE__ */ jsx(
4716
4705
  TableHead,
4717
4706
  {
@@ -4730,17 +4719,20 @@ function EvalTable({ evals, isCIMode = false }) {
4730
4719
  ] }) }),
4731
4720
  /* @__PURE__ */ jsx(TableHead, { className: "w-48 text-mastra-el-3", children: "Evaluations" })
4732
4721
  ] }) }),
4733
- /* @__PURE__ */ jsx(TableBody, { className: "border-b border-gray-6 relative", children: /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", presenceAffectsLayout: false, children: showLoading ? Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ jsxs(TableRow, { className: "border-b-gray-6 border-b-[0.1px] text-[0.8125rem]", children: [
4734
- /* @__PURE__ */ jsx(TableCell, { className: "w-12", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-8 rounded-full" }) }),
4735
- /* @__PURE__ */ jsx(TableCell, { className: "min-w-[200px]", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-3/4" }) }),
4722
+ /* @__PURE__ */ jsx(TableBody, { className: "border-b border-gray-6 relative", children: /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", presenceAffectsLayout: false, children: isTableLoading ? Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ jsxs(TableRow, { className: "border-b-gray-6 border-b-[0.1px] text-[0.8125rem]", children: [
4723
+ /* @__PURE__ */ jsx(TableCell, { className: "w-12 h-12", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-8 rounded-full" }) }),
4724
+ /* @__PURE__ */ jsx(TableCell, { className: "min-w-[200px] max-w-[30%]", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-3/4" }) }),
4736
4725
  /* @__PURE__ */ jsx(TableCell, { className: "flex-1", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full" }) }),
4737
4726
  /* @__PURE__ */ jsx(TableCell, { className: "w-48", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-20" }) }),
4738
- /* @__PURE__ */ jsx(TableCell, { className: "w-48", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-16" }) })
4739
- ] }, i)) : groupEvals(evals).length === 0 ? /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, { colSpan: 5, className: "h-32 text-center text-mastra-el-3", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-2", children: [
4740
- /* @__PURE__ */ jsx(Search, { className: "h-8 w-8" }),
4741
- /* @__PURE__ */ jsx("p", { children: "No evaluations found" }),
4742
- searchTerm && /* @__PURE__ */ jsx("p", { className: "text-sm", children: "Try adjusting your search terms" })
4743
- ] }) }) }) : groupEvals(evals).map((group) => /* @__PURE__ */ jsxs(React__default.Fragment, { children: [
4727
+ /* @__PURE__ */ jsx(TableCell, { className: "w-48", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-20" }) })
4728
+ ] }, i)) : groupEvals(evals).length === 0 ? /* @__PURE__ */ jsxs(TableRow, { children: [
4729
+ /* @__PURE__ */ jsx(TableCell, { className: "h-12 w-16" }),
4730
+ /* @__PURE__ */ jsx(TableCell, { colSpan: 4, className: "h-32 px-4 text-center text-mastra-el-3", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-2", children: [
4731
+ /* @__PURE__ */ jsx(Search, { className: "size-5" }),
4732
+ /* @__PURE__ */ jsx("p", { children: "No evaluations found" }),
4733
+ searchTerm && /* @__PURE__ */ jsx("p", { className: "text-sm", children: "Try adjusting your search terms" })
4734
+ ] }) })
4735
+ ] }) : groupEvals(evals).map((group) => /* @__PURE__ */ jsxs(React__default.Fragment, { children: [
4744
4736
  /* @__PURE__ */ jsxs(
4745
4737
  TableRow,
4746
4738
  {
@@ -5461,52 +5453,6 @@ function AttributesValues({ attributes, depth = 0 }) {
5461
5453
  return /* @__PURE__ */ jsx("span", { className: "text-gray-400", children: String(processedValue) });
5462
5454
  }
5463
5455
 
5464
- const useResizeColumn = ({
5465
- defaultWidth,
5466
- minimumWidth,
5467
- maximumWidth
5468
- }) => {
5469
- const [isDragging, setIsDragging] = useState(false);
5470
- const [sidebarWidth, setSidebarWidth] = useState(defaultWidth);
5471
- const { isOpen } = useContext(TraceContext);
5472
- const containerRef = useRef(null);
5473
- const dragStartXRef = useRef(0);
5474
- const initialWidthRef = useRef(0);
5475
- const handleMouseDown = (e) => {
5476
- e.preventDefault();
5477
- setIsDragging(true);
5478
- dragStartXRef.current = e.clientX;
5479
- initialWidthRef.current = sidebarWidth;
5480
- };
5481
- useEffect(() => {
5482
- if (!isOpen) {
5483
- setSidebarWidth(defaultWidth);
5484
- }
5485
- }, [isOpen]);
5486
- useEffect(() => {
5487
- const handleMouseMove = (e) => {
5488
- if (!isDragging || !containerRef.current) return;
5489
- const containerWidth = containerRef.current.offsetWidth;
5490
- const deltaX = dragStartXRef.current - e.clientX;
5491
- const deltaPercentage = deltaX / containerWidth * 100;
5492
- const newWidth = Math.min(Math.max(initialWidthRef.current + deltaPercentage, minimumWidth), maximumWidth);
5493
- setSidebarWidth(newWidth);
5494
- };
5495
- const handleMouseUp = () => {
5496
- setIsDragging(false);
5497
- };
5498
- if (isDragging) {
5499
- window.addEventListener("mousemove", handleMouseMove);
5500
- window.addEventListener("mouseup", handleMouseUp);
5501
- }
5502
- return () => {
5503
- window.removeEventListener("mousemove", handleMouseMove);
5504
- window.removeEventListener("mouseup", handleMouseUp);
5505
- };
5506
- }, [isDragging]);
5507
- return { sidebarWidth, isDragging, handleMouseDown, containerRef };
5508
- };
5509
-
5510
5456
  function usePolling({
5511
5457
  fetchFn,
5512
5458
  interval = 3e3,
@@ -5634,6 +5580,89 @@ const useTraces = (componentName, baseUrl, isWorkflow = false) => {
5634
5580
  return { traces, firstCallLoading, error };
5635
5581
  };
5636
5582
 
5583
+ const useResizeColumn = ({
5584
+ defaultWidth,
5585
+ minimumWidth,
5586
+ maximumWidth,
5587
+ setCurrentWidth
5588
+ }) => {
5589
+ const [isDragging, setIsDragging] = useState(false);
5590
+ const [sidebarWidth, setSidebarWidth] = useState(defaultWidth);
5591
+ const containerRef = useRef(null);
5592
+ const dragStartXRef = useRef(0);
5593
+ const initialWidthRef = useRef(0);
5594
+ const handleMouseDown = (e) => {
5595
+ e.preventDefault();
5596
+ setIsDragging(true);
5597
+ dragStartXRef.current = e.clientX;
5598
+ initialWidthRef.current = sidebarWidth;
5599
+ };
5600
+ useEffect(() => {
5601
+ setSidebarWidth(defaultWidth);
5602
+ setCurrentWidth?.(defaultWidth);
5603
+ }, [defaultWidth]);
5604
+ useEffect(() => {
5605
+ const handleMouseMove = (e) => {
5606
+ if (!isDragging || !containerRef.current) return;
5607
+ const containerWidth = containerRef.current.offsetWidth;
5608
+ const deltaX = dragStartXRef.current - e.clientX;
5609
+ const deltaPercentage = deltaX / containerWidth * 100;
5610
+ const newWidth = Math.min(Math.max(initialWidthRef.current + deltaPercentage, minimumWidth), maximumWidth);
5611
+ setSidebarWidth(newWidth);
5612
+ setCurrentWidth?.(newWidth);
5613
+ };
5614
+ const handleMouseUp = () => {
5615
+ setIsDragging(false);
5616
+ };
5617
+ if (isDragging) {
5618
+ window.addEventListener("mousemove", handleMouseMove);
5619
+ window.addEventListener("mouseup", handleMouseUp);
5620
+ }
5621
+ return () => {
5622
+ window.removeEventListener("mousemove", handleMouseMove);
5623
+ window.removeEventListener("mouseup", handleMouseUp);
5624
+ };
5625
+ }, [isDragging]);
5626
+ return { sidebarWidth, isDragging, handleMouseDown, containerRef };
5627
+ };
5628
+
5629
+ const MastraResizablePanel = ({
5630
+ children,
5631
+ defaultWidth,
5632
+ minimumWidth,
5633
+ maximumWidth,
5634
+ className,
5635
+ disabled = false,
5636
+ setCurrentWidth,
5637
+ dividerPosition = "left"
5638
+ }) => {
5639
+ const { sidebarWidth, isDragging, handleMouseDown, containerRef } = useResizeColumn({
5640
+ defaultWidth: disabled ? 100 : defaultWidth,
5641
+ minimumWidth,
5642
+ maximumWidth,
5643
+ setCurrentWidth
5644
+ });
5645
+ return /* @__PURE__ */ jsxs("div", { className: cn("w-full h-full relative", className), ref: containerRef, style: { width: `${sidebarWidth}%` }, children: [
5646
+ !disabled && dividerPosition === "left" ? /* @__PURE__ */ jsx(
5647
+ "div",
5648
+ {
5649
+ className: `w-1 bg-mastra-bg-1 bg-[#121212] h-full cursor-col-resize hover:w-1.5 hover:bg-mastra-border-2 hover:bg-[#424242] active:bg-mastra-border-3 active:bg-[#3e3e3e] transition-colors absolute inset-y-0 -left-1 -right-1 z-10
5650
+ ${isDragging ? "bg-mastra-border-2 bg-[#424242] w-1.5 cursor- col-resize" : ""}`,
5651
+ onMouseDown: handleMouseDown
5652
+ }
5653
+ ) : null,
5654
+ children,
5655
+ !disabled && dividerPosition === "right" ? /* @__PURE__ */ jsx(
5656
+ "div",
5657
+ {
5658
+ className: `w-1 bg-mastra-bg-1 bg-[#121212] h-full cursor-col-resize hover:w-1.5 hover:bg-mastra-border-2 hover:bg-[#424242] active:bg-mastra-border-3 active:bg-[#3e3e3e] transition-colors absolute inset-y-0 -left-1 -right-1 z-10
5659
+ ${isDragging ? "bg-mastra-border-2 bg-[#424242] w-1.5 cursor- col-resize" : ""}`,
5660
+ onMouseDown: handleMouseDown
5661
+ }
5662
+ ) : null
5663
+ ] });
5664
+ };
5665
+
5637
5666
  function AgentTraces({
5638
5667
  agentName,
5639
5668
  baseUrl,
@@ -5648,11 +5677,6 @@ function AgentTracesInner({
5648
5677
  }) {
5649
5678
  const { traces, error, firstCallLoading } = useTraces(agentName, baseUrl);
5650
5679
  const { isOpen: open } = useContext(TraceContext);
5651
- const { sidebarWidth, isDragging, handleMouseDown, containerRef } = useResizeColumn({
5652
- defaultWidth: 60,
5653
- minimumWidth: 50,
5654
- maximumWidth: 90
5655
- });
5656
5680
  if (firstCallLoading) {
5657
5681
  return /* @__PURE__ */ jsxs("main", { className: "flex-1 relative overflow-hidden h-full", children: [
5658
5682
  /* @__PURE__ */ jsx("div", { className: "h-full w-[calc(100%_-_400px)]", children: /* @__PURE__ */ jsxs(Table, { children: [
@@ -5672,7 +5696,7 @@ function AgentTracesInner({
5672
5696
  /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-full" }) })
5673
5697
  ] }) })
5674
5698
  ] }) }),
5675
- /* @__PURE__ */ jsx(SidebarItems$1, { sidebarChild })
5699
+ /* @__PURE__ */ jsx(SidebarItems$1, { sidebarChild, className: "min-w-[400px]" })
5676
5700
  ] });
5677
5701
  }
5678
5702
  if (!traces || traces.length === 0) {
@@ -5689,59 +5713,28 @@ function AgentTracesInner({
5689
5713
  ] }) }),
5690
5714
  /* @__PURE__ */ jsx(TableBody, { className: "border-b border-gray-6", children: /* @__PURE__ */ jsx(TableRow, { className: "border-b-gray-6 border-b-[0.1px] text-[0.8125rem]", children: /* @__PURE__ */ jsx(TableCell, { colSpan: 4, className: "h-24 text-center", children: error?.message || "No traces found" }) }) })
5691
5715
  ] }) }),
5692
- /* @__PURE__ */ jsx(SidebarItems$1, { sidebarChild })
5716
+ /* @__PURE__ */ jsx(SidebarItems$1, { sidebarChild, className: "min-w-[400px]" })
5693
5717
  ] });
5694
5718
  }
5695
- return /* @__PURE__ */ jsxs("main", { className: "flex-1 h-full relative overflow-hidden", ref: containerRef, children: [
5719
+ return /* @__PURE__ */ jsxs("main", { className: "flex-1 h-full relative overflow-hidden", children: [
5696
5720
  /* @__PURE__ */ jsx(Traces, { traces }),
5697
- /* @__PURE__ */ jsx(
5698
- SidebarItems$1,
5699
- {
5700
- sidebarWidth,
5701
- className: cn(open ? "grid grid-cols-2 w-[60%]" : ""),
5702
- isDragging,
5703
- handleMouseDown,
5704
- sidebarChild
5705
- }
5706
- )
5721
+ /* @__PURE__ */ jsx(SidebarItems$1, { sidebarChild, className: cn(open ? "grid grid-cols-2 w-[60%]" : "min-w-[400px]") })
5707
5722
  ] });
5708
5723
  }
5709
- function SidebarItems$1({
5710
- sidebarChild,
5711
- className,
5712
- sidebarWidth,
5713
- isDragging,
5714
- handleMouseDown
5715
- }) {
5724
+ function SidebarItems$1({ sidebarChild, className }) {
5716
5725
  const { openDetail, isOpen: open } = useContext(TraceContext);
5717
- const {
5718
- sidebarWidth: rightSidebarWidth,
5719
- isDragging: innerIsDragging,
5720
- handleMouseDown: handleInnerMouseDown,
5721
- containerRef: innerContainerRef
5722
- } = useResizeColumn({
5723
- defaultWidth: 50,
5724
- minimumWidth: 30,
5725
- maximumWidth: 80
5726
- });
5726
+ const [rightSidebarWidth, setRightSidebarWidth] = useState(40);
5727
5727
  return /* @__PURE__ */ jsxs(
5728
- "aside",
5728
+ MastraResizablePanel,
5729
5729
  {
5730
5730
  className: cn(
5731
- "absolute right-0 top-0 h-full w-[400px] z-20 overflow-x-scroll border-l-[0.5px] bg-mastra-bg-1 bg-[#121212]",
5731
+ "absolute right-0 top-0 h-full z-20 overflow-x-scroll border-l-[0.5px] bg-mastra-bg-1 bg-[#121212]",
5732
5732
  className
5733
5733
  ),
5734
- style: { width: open ? `${sidebarWidth}%` : void 0 },
5735
- ref: innerContainerRef,
5734
+ defaultWidth: open ? 60 : 30,
5735
+ minimumWidth: open ? 50 : 30,
5736
+ maximumWidth: open ? 90 : 50,
5736
5737
  children: [
5737
- open ? /* @__PURE__ */ jsx(
5738
- "div",
5739
- {
5740
- className: `w-1 bg-mastra-bg-1 bg-[#121212] h-full cursor-col-resize hover:w-2 hover:bg-mastra-border-2 hover:bg-[#424242] active:bg-mastra-border-3 active:bg-[#3e3e3e] transition-colors absolute inset-y-0 -left-1 -right-1 z-10
5741
- ${isDragging ? "bg-mastra-border-2 bg-[#424242] w-2 cursor-col-resize" : ""}`,
5742
- onMouseDown: handleMouseDown
5743
- }
5744
- ) : null,
5745
5738
  open && /* @__PURE__ */ jsx(
5746
5739
  "div",
5747
5740
  {
@@ -5750,22 +5743,19 @@ function SidebarItems$1({
5750
5743
  children: /* @__PURE__ */ jsx(TraceDetails, {})
5751
5744
  }
5752
5745
  ),
5753
- /* @__PURE__ */ jsxs(
5754
- "div",
5746
+ /* @__PURE__ */ jsx(
5747
+ MastraResizablePanel,
5755
5748
  {
5756
- className: "h-full overflow-y-hidden border-l-[0.5px] absolute right-0 top-0 z-20 bg-mastra-bg-1 bg-[#121212]",
5757
- style: { width: `${openDetail ? rightSidebarWidth : 100}%` },
5758
- children: [
5759
- openDetail ? /* @__PURE__ */ jsx(
5760
- "div",
5761
- {
5762
- className: `w-1 h-full bg-mastra-bg-1 bg-[#121212] cursor-col-resize hover:w-2 hover:bg-mastra-border-2 hover:bg-[#424242] active:bg-mastra-border-3 active:bg-[#3e3e3e] transition-colors absolute inset-y-0 -left-1 -right-1 z-10
5763
- ${innerIsDragging ? "bg-mastra-border-2 bg-[#424242] w-2 cursor-col-resize" : ""}`,
5764
- onMouseDown: handleInnerMouseDown
5765
- }
5766
- ) : null,
5767
- /* @__PURE__ */ jsx("div", { className: "h-full overflow-y-scroll", children: !openDetail ? sidebarChild : /* @__PURE__ */ jsx(SpanDetail, {}) })
5768
- ]
5749
+ defaultWidth: 50,
5750
+ minimumWidth: 30,
5751
+ maximumWidth: 80,
5752
+ className: cn("h-full overflow-y-hidden border-l-[0.5px] right-0 top-0 z-20 bg-mastra-bg-1 bg-[#121212]", {
5753
+ absolute: open,
5754
+ "unset-position": !open
5755
+ }),
5756
+ disabled: !open,
5757
+ setCurrentWidth: setRightSidebarWidth,
5758
+ children: /* @__PURE__ */ jsx("div", { className: "h-full overflow-y-scroll", children: !openDetail ? sidebarChild : /* @__PURE__ */ jsx(SpanDetail, {}) })
5769
5759
  }
5770
5760
  )
5771
5761
  ]
@@ -5954,11 +5944,6 @@ function WorkflowTracesInner({
5954
5944
  }) {
5955
5945
  const { traces, error, firstCallLoading } = useTraces(workflowName, baseUrl, true);
5956
5946
  const { isOpen: open } = useContext(TraceContext);
5957
- const { sidebarWidth, isDragging, handleMouseDown, containerRef } = useResizeColumn({
5958
- defaultWidth: 60,
5959
- minimumWidth: 50,
5960
- maximumWidth: 90
5961
- });
5962
5947
  if (firstCallLoading) {
5963
5948
  return /* @__PURE__ */ jsxs("main", { className: "flex-1 h-full relative overflow-hidden", children: [
5964
5949
  /* @__PURE__ */ jsx("div", { className: "h-full w-[calc(100%_-_400px)]", children: /* @__PURE__ */ jsxs(Table, { children: [
@@ -5978,7 +5963,7 @@ function WorkflowTracesInner({
5978
5963
  /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-full" }) })
5979
5964
  ] }) })
5980
5965
  ] }) }),
5981
- /* @__PURE__ */ jsx(SidebarItems, { sidebarChild })
5966
+ /* @__PURE__ */ jsx(SidebarItems, { sidebarChild, className: "min-w-[400px]" })
5982
5967
  ] });
5983
5968
  }
5984
5969
  if (!traces || traces.length === 0) {
@@ -5995,59 +5980,28 @@ function WorkflowTracesInner({
5995
5980
  ] }) }),
5996
5981
  /* @__PURE__ */ jsx(TableBody, { className: "border-b border-gray-6", children: /* @__PURE__ */ jsx(TableRow, { className: "border-b-gray-6 border-b-[0.1px] text-[0.8125rem]", children: /* @__PURE__ */ jsx(TableCell, { colSpan: 4, className: "h-24 text-center", children: error?.message || "No traces found" }) }) })
5997
5982
  ] }) }),
5998
- /* @__PURE__ */ jsx(SidebarItems, { sidebarChild })
5983
+ /* @__PURE__ */ jsx(SidebarItems, { sidebarChild, className: "min-w-[400px]" })
5999
5984
  ] });
6000
5985
  }
6001
- return /* @__PURE__ */ jsxs("main", { className: "flex-1 h-full relative overflow-hidden", ref: containerRef, children: [
5986
+ return /* @__PURE__ */ jsxs("main", { className: "flex-1 h-full relative overflow-hidden", children: [
6002
5987
  /* @__PURE__ */ jsx(Traces, { traces }),
6003
- /* @__PURE__ */ jsx(
6004
- SidebarItems,
6005
- {
6006
- sidebarWidth,
6007
- className: cn(open ? "grid grid-cols-2 w-[60%]" : ""),
6008
- isDragging,
6009
- handleMouseDown,
6010
- sidebarChild
6011
- }
6012
- )
5988
+ /* @__PURE__ */ jsx(SidebarItems, { className: cn(open ? "grid grid-cols-2 w-[60%]" : "min-w-[400px]"), sidebarChild })
6013
5989
  ] });
6014
5990
  }
6015
- function SidebarItems({
6016
- sidebarChild,
6017
- className,
6018
- sidebarWidth,
6019
- isDragging,
6020
- handleMouseDown
6021
- }) {
5991
+ function SidebarItems({ sidebarChild, className }) {
6022
5992
  const { openDetail, isOpen: open } = useContext(TraceContext);
6023
- const {
6024
- sidebarWidth: rightSidebarWidth,
6025
- isDragging: innerIsDragging,
6026
- handleMouseDown: handleInnerMouseDown,
6027
- containerRef: innerContainerRef
6028
- } = useResizeColumn({
6029
- defaultWidth: 50,
6030
- minimumWidth: 30,
6031
- maximumWidth: 80
6032
- });
5993
+ const [rightSidebarWidth, setRightSidebarWidth] = useState(40);
6033
5994
  return /* @__PURE__ */ jsxs(
6034
- "aside",
5995
+ MastraResizablePanel,
6035
5996
  {
6036
5997
  className: cn(
6037
- "absolute right-0 top-0 h-full w-[400px] z-20 overflow-x-scroll border-l-[0.5px] bg-mastra-bg-1 bg-[#121212]",
5998
+ "absolute right-0 top-0 h-full z-20 overflow-x-scroll border-l-[0.5px] bg-mastra-bg-1 bg-[#121212]",
6038
5999
  className
6039
6000
  ),
6040
- style: { width: open ? `${sidebarWidth}%` : void 0 },
6041
- ref: innerContainerRef,
6001
+ defaultWidth: open ? 60 : 30,
6002
+ minimumWidth: open ? 50 : 30,
6003
+ maximumWidth: open ? 90 : 50,
6042
6004
  children: [
6043
- open ? /* @__PURE__ */ jsx(
6044
- "div",
6045
- {
6046
- className: `w-1 bg-mastra-bg-1 bg-[#121212] h-full cursor-col-resize hover:w-2 hover:bg-mastra-border-2 hover:bg-[#424242] active:bg-mastra-border-3 active:bg-[#3e3e3e] transition-colors absolute inset-y-0 -left-1 -right-1 z-10
6047
- ${isDragging ? "bg-mastra-border-2 bg-[#424242] w-2 cursor-col-resize" : ""}`,
6048
- onMouseDown: handleMouseDown
6049
- }
6050
- ) : null,
6051
6005
  open && /* @__PURE__ */ jsx(
6052
6006
  "div",
6053
6007
  {
@@ -6056,22 +6010,19 @@ function SidebarItems({
6056
6010
  children: /* @__PURE__ */ jsx(TraceDetails, {})
6057
6011
  }
6058
6012
  ),
6059
- /* @__PURE__ */ jsxs(
6060
- "div",
6013
+ /* @__PURE__ */ jsx(
6014
+ MastraResizablePanel,
6061
6015
  {
6062
- className: "h-full overflow-y-hidden border-l-[0.5px] absolute right-0 top-0 z-20 bg-mastra-bg-1 bg-[#121212]",
6063
- style: { width: `${openDetail ? rightSidebarWidth : 100}%` },
6064
- children: [
6065
- openDetail ? /* @__PURE__ */ jsx(
6066
- "div",
6067
- {
6068
- className: `w-1 h-full bg-mastra-bg-1 bg-[#121212] cursor-col-resize hover:w-2 hover:bg-mastra-border-2 hover:bg-[#424242] active:bg-mastra-border-3 active:bg-[#3e3e3e] transition-colors absolute inset-y-0 -left-1 -right-1 z-10
6069
- ${innerIsDragging ? "bg-mastra-border-2 bg-[#424242] w-2 cursor-col-resize" : ""}`,
6070
- onMouseDown: handleInnerMouseDown
6071
- }
6072
- ) : null,
6073
- /* @__PURE__ */ jsx("div", { className: "h-full overflow-y-scroll", children: !openDetail ? sidebarChild : /* @__PURE__ */ jsx(SpanDetail, {}) })
6074
- ]
6016
+ defaultWidth: 50,
6017
+ minimumWidth: 30,
6018
+ maximumWidth: 80,
6019
+ className: cn("h-full overflow-y-hidden border-l-[0.5px] right-0 top-0 z-20 bg-mastra-bg-1 bg-[#121212]", {
6020
+ absolute: open,
6021
+ "unset-position": !open
6022
+ }),
6023
+ disabled: !open,
6024
+ setCurrentWidth: setRightSidebarWidth,
6025
+ children: /* @__PURE__ */ jsx("div", { className: "h-full overflow-y-scroll", children: !openDetail ? sidebarChild : /* @__PURE__ */ jsx(SpanDetail, {}) })
6075
6026
  }
6076
6027
  )
6077
6028
  ]
@@ -7976,13 +7927,20 @@ function WorkflowTrigger({
7976
7927
  const { watchWorkflow, watchResult, isWatchingWorkflow } = useWatchWorkflow(baseUrl);
7977
7928
  const { resumeWorkflow, isResumingWorkflow } = useResumeWorkflow(baseUrl);
7978
7929
  const [suspendedSteps, setSuspendedSteps] = useState([]);
7930
+ const [isRunning, setIsRunning] = useState(false);
7979
7931
  const triggerSchema = workflow?.triggerSchema;
7980
7932
  const handleExecuteWorkflow = async (data) => {
7981
- if (!workflow) return;
7982
- setResult(null);
7983
- const { runId } = await createWorkflowRun({ workflowId, input: data });
7984
- setRunId?.(runId);
7985
- watchWorkflow({ workflowId, runId });
7933
+ try {
7934
+ if (!workflow) return;
7935
+ setIsRunning(true);
7936
+ setResult(null);
7937
+ const { runId } = await createWorkflowRun({ workflowId, input: data });
7938
+ setRunId?.(runId);
7939
+ watchWorkflow({ workflowId, runId });
7940
+ } catch (err) {
7941
+ setIsRunning(false);
7942
+ toast.error("Error executing workflow");
7943
+ }
7986
7944
  };
7987
7945
  const handleResumeWorkflow = async (step) => {
7988
7946
  if (!workflow) return;
@@ -7997,6 +7955,9 @@ function WorkflowTrigger({
7997
7955
  };
7998
7956
  const watchResultToUse = result ?? watchResult;
7999
7957
  const workflowActivePaths = watchResultToUse?.activePaths ?? [];
7958
+ useEffect(() => {
7959
+ setIsRunning(isWatchingWorkflow);
7960
+ }, [isWatchingWorkflow]);
8000
7961
  useEffect(() => {
8001
7962
  if (!watchResultToUse?.activePaths || !result?.runId) return;
8002
7963
  const suspended = watchResultToUse.activePaths.filter((path) => watchResultToUse.context?.steps?.[path.stepId]?.status === "suspended").map((path) => ({
@@ -8018,8 +7979,8 @@ function WorkflowTrigger({
8018
7979
  }
8019
7980
  if (!workflow) return null;
8020
7981
  if (!triggerSchema) {
8021
- return /* @__PURE__ */ jsx(ScrollArea, { className: "h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs w-[400px]", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
8022
- /* @__PURE__ */ jsx("div", { className: "space-y-4 px-4", children: /* @__PURE__ */ jsx(Button, { className: "w-full", disabled: isWatchingWorkflow, onClick: () => handleExecuteWorkflow(null), children: isWatchingWorkflow ? /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) : "Trigger" }) }),
7982
+ return /* @__PURE__ */ jsx(ScrollArea, { className: "h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs w-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
7983
+ /* @__PURE__ */ jsx("div", { className: "space-y-4 px-4", children: /* @__PURE__ */ jsx(Button, { className: "w-full", disabled: isRunning, onClick: () => handleExecuteWorkflow(null), children: isRunning ? /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) : "Trigger" }) }),
8023
7984
  /* @__PURE__ */ jsxs("div", { children: [
8024
7985
  /* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3 px-4", size: "xs", children: "Output" }),
8025
7986
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ jsx(
@@ -8041,7 +8002,7 @@ function WorkflowTrigger({
8041
8002
  ] }) });
8042
8003
  }
8043
8004
  const zodInputSchema = resolveSerializedZodOutput(jsonSchemaToZod(parse(triggerSchema)));
8044
- return /* @__PURE__ */ jsx(ScrollArea, { className: "h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs w-[400px]", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
8005
+ return /* @__PURE__ */ jsx(ScrollArea, { className: "h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs w-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
8045
8006
  /* @__PURE__ */ jsxs("div", { children: [
8046
8007
  suspendedSteps.length > 0 ? suspendedSteps?.map((step) => /* @__PURE__ */ jsxs("div", { className: "px-4", children: [
8047
8008
  /* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: step.stepId }),
@@ -8073,7 +8034,7 @@ function WorkflowTrigger({
8073
8034
  {
8074
8035
  schema: zodInputSchema,
8075
8036
  defaultValues: payload,
8076
- isSubmitLoading: isWatchingWorkflow,
8037
+ isSubmitLoading: isRunning,
8077
8038
  onSubmit: (data) => {
8078
8039
  setPayload(data);
8079
8040
  handleExecuteWorkflow(data);
@@ -8129,5 +8090,5 @@ function WorkflowTrigger({
8129
8090
  ] }) });
8130
8091
  }
8131
8092
 
8132
- export { AgentChat, AgentEvals, AgentTraces, AgentsTable, Chat, WorkflowGraph, WorkflowRunContext, WorkflowRunProvider, WorkflowTraces, WorkflowTrigger, WorkflowsTable };
8093
+ export { AgentChat, AgentEvals, AgentTraces, AgentsTable, Chat, MastraResizablePanel, WorkflowGraph, WorkflowRunContext, WorkflowRunProvider, WorkflowTraces, WorkflowTrigger, WorkflowsTable };
8133
8094
  //# sourceMappingURL=index.es.js.map