@smartspace/chat-ui 1.14.4-pr.627.fd22da1 → 1.14.4-pr.636.eab7f82

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.
package/dist/index.js CHANGED
@@ -47,15 +47,15 @@ import vertexaiIcon from '@lobehub/icons-static-svg/icons/vertexai-color.svg';
47
47
  import xaiIcon from '@lobehub/icons-static-svg/icons/xai.svg';
48
48
  import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
49
49
  import ReactMarkdown, { defaultUrlTransform } from 'react-markdown';
50
- import MuiSkeleton from '@mui/material/Skeleton';
50
+ import { Slot } from '@radix-ui/react-slot';
51
+ import { cva } from 'class-variance-authority';
51
52
  import { clsx } from 'clsx';
52
53
  import { twMerge } from 'tailwind-merge';
54
+ import MuiSkeleton from '@mui/material/Skeleton';
53
55
  import dayjs from 'dayjs';
54
56
  import advancedFormat from 'dayjs/plugin/advancedFormat';
55
57
  import relativeTime from 'dayjs/plugin/relativeTime';
56
58
  import utc from 'dayjs/plugin/utc';
57
- import { Slot } from '@radix-ui/react-slot';
58
- import { cva } from 'class-variance-authority';
59
59
  import { useTheme, Box, Skeleton as Skeleton$1 } from '@mui/material';
60
60
 
61
61
  var __defProp = Object.defineProperty;
@@ -540,7 +540,10 @@ var threadDetailOptions = ({
540
540
  queryKey: threadsKeys.detail(workspaceId, threadId),
541
541
  queryFn: () => service.fetchThread(workspaceId, threadId),
542
542
  refetchOnWindowFocus: false,
543
- staleTime: 6e4
543
+ staleTime: 6e4,
544
+ // The route loader has just tried and failed. Retrying on mount delays
545
+ // the inline error by several seconds; the user has Try again.
546
+ retryOnMount: false
544
547
  });
545
548
  function getThreadPlaceholderFromListCache(queryClient, workspaceId, threadId) {
546
549
  const entries = queryClient.getQueriesData({
@@ -4236,7 +4239,10 @@ var workspaceDetailOptions = ({
4236
4239
  }) => queryOptions({
4237
4240
  queryKey: workspaceKeys.byId(workspaceId),
4238
4241
  queryFn: () => service.fetchWorkspace(workspaceId),
4239
- staleTime: 3e4
4242
+ staleTime: 3e4,
4243
+ // The route loader has just tried and failed. Retrying on mount delays
4244
+ // the header's error by several seconds.
4245
+ retryOnMount: false
4240
4246
  });
4241
4247
  function useWorkspace(workspaceId) {
4242
4248
  const service = useChatService();
@@ -19583,6 +19589,45 @@ function MessageMarkdown({ value, className }) {
19583
19589
  function cn(...inputs) {
19584
19590
  return twMerge(clsx(inputs));
19585
19591
  }
19592
+ var buttonVariants = cva(
19593
+ "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
19594
+ {
19595
+ variants: {
19596
+ variant: {
19597
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
19598
+ destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
19599
+ outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
19600
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
19601
+ ghost: "hover:bg-accent hover:text-accent-foreground",
19602
+ link: "text-primary underline-offset-4 hover:underline"
19603
+ },
19604
+ size: {
19605
+ default: "h-10 px-4 py-2",
19606
+ sm: "h-9 rounded-md px-3",
19607
+ lg: "h-11 rounded-md px-8",
19608
+ icon: "h-10 w-10"
19609
+ }
19610
+ },
19611
+ defaultVariants: {
19612
+ variant: "default",
19613
+ size: "default"
19614
+ }
19615
+ }
19616
+ );
19617
+ var Button = React9.forwardRef(
19618
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
19619
+ const Comp = asChild ? Slot : "button";
19620
+ return /* @__PURE__ */ jsx(
19621
+ Comp,
19622
+ {
19623
+ className: cn(buttonVariants({ variant, size, className })),
19624
+ ref,
19625
+ ...props
19626
+ }
19627
+ );
19628
+ }
19629
+ );
19630
+ Button.displayName = "Button";
19586
19631
  function Skeleton({ className, ...props }) {
19587
19632
  return /* @__PURE__ */ jsx(
19588
19633
  MuiSkeleton,
@@ -19872,45 +19917,6 @@ function parseDateTime(date, customFormat) {
19872
19917
  function parseDateTimeHuman(date) {
19873
19918
  return dayjs.utc(date).local().fromNow();
19874
19919
  }
19875
- var buttonVariants = cva(
19876
- "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
19877
- {
19878
- variants: {
19879
- variant: {
19880
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
19881
- destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
19882
- outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
19883
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
19884
- ghost: "hover:bg-accent hover:text-accent-foreground",
19885
- link: "text-primary underline-offset-4 hover:underline"
19886
- },
19887
- size: {
19888
- default: "h-10 px-4 py-2",
19889
- sm: "h-9 rounded-md px-3",
19890
- lg: "h-11 rounded-md px-8",
19891
- icon: "h-10 w-10"
19892
- }
19893
- },
19894
- defaultVariants: {
19895
- variant: "default",
19896
- size: "default"
19897
- }
19898
- }
19899
- );
19900
- var Button = React9.forwardRef(
19901
- ({ className, variant, size, asChild = false, ...props }, ref) => {
19902
- const Comp = asChild ? Slot : "button";
19903
- return /* @__PURE__ */ jsx(
19904
- Comp,
19905
- {
19906
- className: cn(buttonVariants({ variant, size, className })),
19907
- ref,
19908
- ...props
19909
- }
19910
- );
19911
- }
19912
- );
19913
- Button.displayName = "Button";
19914
19920
 
19915
19921
  // src/messages/smartCopy.ts
19916
19922
  async function copyMessageRich(container, markdown) {
@@ -20932,14 +20938,16 @@ function MessageList({
20932
20938
  data: thread,
20933
20939
  isPending: threadPending,
20934
20940
  isFetching: threadFetching,
20935
- error: threadError
20941
+ error: threadError,
20942
+ refetch: refetchThread
20936
20943
  } = useThread({ workspaceId, threadId });
20937
20944
  const isRunning = useThreadIsRunning(workspaceId, threadId);
20938
20945
  const {
20939
20946
  data: messages,
20940
20947
  isPending: messagesPending,
20941
20948
  isFetching: messagesFetching,
20942
- error: messagesError
20949
+ error: messagesError,
20950
+ refetch: refetchMessages
20943
20951
  } = useMessages(threadId);
20944
20952
  const hostBg = applyHostBackgroundOverride ? "chat-main" : "";
20945
20953
  const scrollToBottom = useCallback((behavior = "auto") => {
@@ -21018,7 +21026,19 @@ function MessageList({
21018
21026
  messagesError && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-destructive", children: [
21019
21027
  /* @__PURE__ */ jsx(AlertTriangle, { className: "h-4 w-4" }),
21020
21028
  /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Failed to load messages" })
21021
- ] })
21029
+ ] }),
21030
+ /* @__PURE__ */ jsx(
21031
+ Button,
21032
+ {
21033
+ size: "sm",
21034
+ variant: "outline",
21035
+ onClick: () => {
21036
+ if (threadError) void refetchThread();
21037
+ if (messagesError) void refetchMessages();
21038
+ },
21039
+ children: "Try again"
21040
+ }
21041
+ )
21022
21042
  ] }) });
21023
21043
  }
21024
21044
  if (safeMessages.length === 0 && !hadMessagesBefore) {