@mastra/playground-ui 2.0.5-alpha.0 → 3.0.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.
@@ -3,6 +3,7 @@ import * as React from 'react';
3
3
  interface ScrollAreaProps extends React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root> {
4
4
  viewPortClassName?: string;
5
5
  maxHeight?: string;
6
+ autoScroll?: boolean;
6
7
  }
7
8
  declare const ScrollArea: React.ForwardRefExoticComponent<ScrollAreaProps & React.RefAttributes<HTMLDivElement>>;
8
9
  declare const ScrollBar: React.ForwardRefExoticComponent<Omit<ScrollAreaPrimitive.ScrollAreaScrollbarProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,6 @@
1
+ import { default as React } from '../../node_modules/@types/react';
2
+
3
+ export interface UseAutoscrollOptions {
4
+ enabled?: boolean;
5
+ }
6
+ export declare const useAutoscroll: (ref: React.RefObject<HTMLElement | null>, { enabled }: UseAutoscrollOptions) => void;
@@ -2,7 +2,7 @@ import { Workflow } from '@mastra/core/workflows';
2
2
  import { WorkflowRunResult } from '@mastra/client-js';
3
3
 
4
4
  export declare const useWorkflow: (workflowId: string, baseUrl: string) => {
5
- workflow: Workflow<import('@mastra/core').Step<string, any, any, import('@mastra/core').StepExecutionContext<any, import('@mastra/core').WorkflowContext<any, import('@mastra/core').Step<string, any, any, any>[], Record<string, any>>>>[], any> | null;
5
+ workflow: Workflow<import('@mastra/core').Step<string, any, any, import('@mastra/core').StepExecutionContext<any, import('@mastra/core').WorkflowContext<any, import('@mastra/core').Step<string, any, any, any>[], Record<string, any>>>>[], string, any, any> | null;
6
6
  isLoading: boolean;
7
7
  };
8
8
  export declare const useExecuteWorkflow: (baseUrl: string) => {
package/dist/index.es.js CHANGED
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { MessagePrimitive, ActionBarPrimitive, BranchPickerPrimitive, ThreadPrimitive, ComposerPrimitive, useExternalStoreRuntime, AssistantRuntimeProvider } from '@assistant-ui/react';
3
3
  import { CheckIcon, CopyIcon, ChevronLeftIcon, ChevronRightIcon, ArrowUp, Copy, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, Braces, Clock1, ChevronDown, XIcon, Check, LoaderCircle, ChevronUpIcon, ChevronDownIcon, ExternalLinkIcon, X, Footprints, CircleCheck, CircleX, AlertCircleIcon, Plus, CalendarIcon, Loader2 } from 'lucide-react';
4
4
  import * as React from 'react';
5
- import React__default, { forwardRef, memo, useState, useEffect, createContext, useContext, useRef, useMemo, useCallback, Suspense, Fragment as Fragment$1 } from 'react';
5
+ import React__default, { forwardRef, memo, useState, useRef, useEffect, createContext, useContext, useMemo, useCallback, Suspense, Fragment as Fragment$1 } from 'react';
6
6
  import { Slot } from '@radix-ui/react-slot';
7
7
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
8
8
  import * as AvatarPrimitive from '@radix-ui/react-avatar';
@@ -3184,6 +3184,44 @@ const UserMessage = () => {
3184
3184
  );
3185
3185
  };
3186
3186
 
3187
+ const useAutoscroll = (ref, { enabled = true }) => {
3188
+ const shouldScrollRef = useRef(enabled);
3189
+ React__default.useEffect(() => {
3190
+ if (!enabled) return;
3191
+ if (!ref?.current) return;
3192
+ const area = ref.current;
3193
+ const observer = new MutationObserver(() => {
3194
+ if (shouldScrollRef.current) {
3195
+ area.scrollTo({ top: area.scrollHeight, behavior: "smooth" });
3196
+ }
3197
+ });
3198
+ observer.observe(area, {
3199
+ childList: true,
3200
+ // observe direct children changes
3201
+ subtree: true,
3202
+ // observe all descendants
3203
+ characterData: true
3204
+ // observe text content changes
3205
+ });
3206
+ const handleScroll = (e) => {
3207
+ const scrollElement = e.target;
3208
+ const currentPosition = scrollElement.scrollTop + scrollElement.clientHeight;
3209
+ const totalHeight = scrollElement.scrollHeight;
3210
+ const isAtEnd = currentPosition >= totalHeight - 1;
3211
+ if (isAtEnd) {
3212
+ shouldScrollRef.current = true;
3213
+ } else {
3214
+ shouldScrollRef.current = false;
3215
+ }
3216
+ };
3217
+ area.addEventListener("scroll", handleScroll);
3218
+ return () => {
3219
+ area.removeEventListener("scroll", handleScroll);
3220
+ observer.disconnect();
3221
+ };
3222
+ }, [enabled, ref]);
3223
+ };
3224
+
3187
3225
  const suggestions = ["What capabilities do you have?", "How can you help me?", "Tell me about yourself"];
3188
3226
  const Thread = ({
3189
3227
  memory,
@@ -3192,6 +3230,8 @@ const Thread = ({
3192
3230
  function WrappedAssistantMessage(props) {
3193
3231
  return /* @__PURE__ */ jsx(AssistantMessage, { ...props, ToolFallback });
3194
3232
  }
3233
+ const areaRef = useRef(null);
3234
+ useAutoscroll(areaRef, { enabled: true });
3195
3235
  return /* @__PURE__ */ jsxs(
3196
3236
  ThreadPrimitive.Root,
3197
3237
  {
@@ -3214,6 +3254,8 @@ const Thread = ({
3214
3254
  height: memory ? "calc(100vh - 65px)" : "calc(100vh - 90px)",
3215
3255
  paddingBottom: "108px"
3216
3256
  },
3257
+ ref: areaRef,
3258
+ autoScroll: false,
3217
3259
  children: [
3218
3260
  /* @__PURE__ */ jsxs("div", { style: { width: "100%", maxWidth: "48rem", paddingInline: "1.5rem" }, children: [
3219
3261
  /* @__PURE__ */ jsx(ThreadWelcome, {}),
@@ -4092,11 +4134,14 @@ const MastraResizablePanel = ({
4092
4134
  };
4093
4135
 
4094
4136
  const ScrollArea = React.forwardRef(
4095
- ({ className, children, viewPortClassName, maxHeight, ...props }, ref) => {
4137
+ ({ className, children, viewPortClassName, maxHeight, autoScroll = false, ...props }, ref) => {
4138
+ const areaRef = React.useRef(null);
4139
+ useAutoscroll(areaRef, { enabled: autoScroll });
4096
4140
  return /* @__PURE__ */ jsxs(ScrollAreaPrimitive.Root, { ref, className: cn("relative overflow-hidden", className), ...props, children: [
4097
4141
  /* @__PURE__ */ jsx(
4098
4142
  ScrollAreaPrimitive.Viewport,
4099
4143
  {
4144
+ ref: areaRef,
4100
4145
  className: cn("h-full w-full rounded-[inherit] [&>div]:!block", viewPortClassName),
4101
4146
  style: maxHeight ? { maxHeight } : void 0,
4102
4147
  children
@@ -4666,7 +4711,11 @@ function Attributes({ span }) {
4666
4711
  if (!span.attributes) return null;
4667
4712
  return /* @__PURE__ */ jsx(AttributesValues, { attributes: span.attributes });
4668
4713
  }
4669
- function AttributesValues({ attributes, depth = 0 }) {
4714
+ function AttributesValues({
4715
+ attributes,
4716
+ depth = 0,
4717
+ keyName
4718
+ }) {
4670
4719
  if (attributes === null) return null;
4671
4720
  if (attributes === void 0) return null;
4672
4721
  if (typeof attributes === "string") {
@@ -4676,6 +4725,10 @@ function AttributesValues({ attributes, depth = 0 }) {
4676
4725
  return /* @__PURE__ */ jsx(SyntaxHighlighter, { data: attr });
4677
4726
  }
4678
4727
  } catch {
4728
+ const val = attributes ? cleanString(attributes.toString()) : "N/A";
4729
+ if (keyName === "Input" && val === "[Not Serializable]") {
4730
+ return /* @__PURE__ */ jsx("span", { className: "text-sm overflow-x-scroll", children: "No input" });
4731
+ }
4679
4732
  return /* @__PURE__ */ jsx("span", { className: "text-sm overflow-x-scroll", children: attributes ? cleanString(attributes.toString()) : "N/A" });
4680
4733
  }
4681
4734
  }
@@ -4689,7 +4742,7 @@ function AttributesValues({ attributes, depth = 0 }) {
4689
4742
  if (entries.length === 0) return null;
4690
4743
  return /* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsx("div", { className: "mt-1", children: entries.map(([key, val]) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 p-2 pl-0", children: [
4691
4744
  /* @__PURE__ */ jsx("span", { className: "text-sm capitalize text-mastra-el-3", children: transformKey(key) }),
4692
- /* @__PURE__ */ jsx(AttributesValues, { attributes: val, depth: depth + 1 })
4745
+ /* @__PURE__ */ jsx(AttributesValues, { attributes: val, depth: depth + 1, keyName: transformKey(key) })
4693
4746
  ] }, key)) }) });
4694
4747
  }
4695
4748
  if (typeof processedValue === "boolean")
@@ -4839,8 +4892,8 @@ const useTraces = (componentName, baseUrl, isWorkflow = false) => {
4839
4892
  const onError = useCallback((error2) => {
4840
4893
  toast.error(error2.message);
4841
4894
  }, []);
4842
- const shouldContinue = useCallback((result) => {
4843
- return result.length > 0;
4895
+ const shouldContinue = useCallback(() => {
4896
+ return true;
4844
4897
  }, []);
4845
4898
  const { firstCallLoading, error } = usePolling({
4846
4899
  fetchFn,
@@ -6358,8 +6411,8 @@ function WorkflowLoopResultNode({ data }) {
6358
6411
 
6359
6412
  function WorkflowGraphInner({ workflow }) {
6360
6413
  const { nodes: initialNodes, edges: initialEdges } = contructNodesAndEdges({
6361
- stepGraph: workflow.serializedStepGraph,
6362
- stepSubscriberGraph: workflow.serializedStepSubscriberGraph
6414
+ stepGraph: workflow.serializedStepGraph || workflow.stepGraph,
6415
+ stepSubscriberGraph: workflow.serializedStepSubscriberGraph || workflow.stepSubscriberGraph
6363
6416
  });
6364
6417
  const [nodes, _, onNodesChange] = useNodesState(initialNodes);
6365
6418
  const [edges] = useEdgesState(initialEdges);
@@ -6369,7 +6422,6 @@ function WorkflowGraphInner({ workflow }) {
6369
6422
  "after-node": WorkflowAfterNode,
6370
6423
  "loop-result-node": WorkflowLoopResultNode
6371
6424
  };
6372
- console.log("nodes===>", nodes);
6373
6425
  return /* @__PURE__ */ jsx("div", { className: "w-full h-full", children: /* @__PURE__ */ jsxs(
6374
6426
  ReactFlow,
6375
6427
  {
@@ -7601,7 +7653,8 @@ function resolveSchemaComponent({
7601
7653
  formValues,
7602
7654
  errors,
7603
7655
  handleFieldChange,
7604
- isNullable: true
7656
+ isNullable: true,
7657
+ isOptional
7605
7658
  });
7606
7659
  }
7607
7660
  return /* @__PURE__ */ jsx(
@@ -7654,7 +7707,8 @@ function resolveSchemaComponent({
7654
7707
  values: formValues,
7655
7708
  errors,
7656
7709
  renderFieldMap: getDefaultFieldMap(),
7657
- onFieldChange: handleFieldChange
7710
+ onFieldChange: handleFieldChange,
7711
+ isOptional
7658
7712
  }) }, parentField);
7659
7713
  }
7660
7714
 
@@ -7808,10 +7862,10 @@ function WorkflowTrigger({
7808
7862
  }
7809
7863
  }, [watchResult]);
7810
7864
  if (isLoading) {
7811
- return /* @__PURE__ */ jsx(ScrollArea, { className: "h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs", children: /* @__PURE__ */ jsx("div", { className: "space-y-4", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[100px_1fr] gap-2", children: [
7812
- /* @__PURE__ */ jsx(Skeleton, { className: "h-3" }),
7813
- /* @__PURE__ */ jsx(Skeleton, { className: "h-3" })
7814
- ] }) }) });
7865
+ return /* @__PURE__ */ jsx(ScrollArea, { className: "h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
7866
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-10" }),
7867
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-10" })
7868
+ ] }) });
7815
7869
  }
7816
7870
  if (!workflow) return null;
7817
7871
  if (!triggerSchema) {