@smartspace/chat-ui 1.14.4-dev.b35149c → 1.14.4-dev.cbcaafb

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
@@ -1,8 +1,8 @@
1
1
  import MuiButton from '@mui/material/Button';
2
2
  import IconButton2 from '@mui/material/IconButton';
3
- import { Loader2, ChevronDown, Check, Cpu, SlidersHorizontal, X, Globe, Zap, Square, Mic, Paperclip, Send, Minimize2, AlertTriangle, FileImage, FileVideo, FileAudio, FileArchive, FileCode, FileSpreadsheet, Presentation, FileText, ChevronUp, ExternalLink, Download, ShieldAlert, Copy } from 'lucide-react';
3
+ import { Loader2, ChevronDown, Check, Cpu, SlidersHorizontal, X, Globe, Zap, Square, Mic, Paperclip, Send, Minimize2, AlertTriangle, FileImage, FileVideo, FileAudio, FileArchive, FileCode, FileSpreadsheet, Presentation, FileText, ChevronRight, ChevronUp, ExternalLink, Download, ShieldAlert, Copy } from 'lucide-react';
4
4
  import * as React9 from 'react';
5
- import React9__default, { createContext, forwardRef, useImperativeHandle, useRef, useState, useEffect, useMemo, useCallback, useContext, useSyncExternalStore } from 'react';
5
+ import React9__default, { createContext, forwardRef, useImperativeHandle, useRef, useState, useEffect, useMemo, useCallback, useContext, useSyncExternalStore, Fragment as Fragment$1 } from 'react';
6
6
  import { createPortal } from 'react-dom';
7
7
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
8
  import { useQuery, queryOptions, useQueryClient, useMutation } from '@tanstack/react-query';
@@ -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;
@@ -115,8 +115,7 @@ var filesKeys = {
115
115
  mutation: {
116
116
  upload: (scope) => [...filesKeys.mutations(), "upload", { scope }],
117
117
  download: (fileId) => [...filesKeys.mutations(), "download", { fileId }],
118
- downloadBlob: (fileId) => [...filesKeys.mutations(), "downloadBlob", { fileId }],
119
- downloadByUri: (uri) => [...filesKeys.mutations(), "downloadByUri", { uri }]
118
+ downloadBlob: (fileId) => [...filesKeys.mutations(), "downloadBlob", { fileId }]
120
119
  }
121
120
  };
122
121
 
@@ -163,20 +162,6 @@ var useFileMutations = (scope) => {
163
162
  },
164
163
  onError: () => toast.error("Failed to download file")
165
164
  });
166
- const downloadFileByUriMutation = useMutation({
167
- mutationFn: async ({
168
- name,
169
- sourceUri
170
- }) => {
171
- const uri = await service.getFileDownloadUrl(sourceUri);
172
- if (!uri) throw new Error("No download URL");
173
- const response = await fetch(uri);
174
- const blob = await response.blob();
175
- saveFile(blob, name);
176
- return blob;
177
- },
178
- onError: () => toast.error("Failed to download file")
179
- });
180
165
  const fileStates = (files) => files.map((file) => ({
181
166
  name: file.name,
182
167
  progress: fileProgress[file.name] ?? 0,
@@ -200,7 +185,6 @@ var useFileMutations = (scope) => {
200
185
  return {
201
186
  uploadFilesMutation,
202
187
  downloadFileMutation,
203
- downloadFileByUriMutation,
204
188
  getFileBlobUrl,
205
189
  fileProgress,
206
190
  uploadedFiles,
@@ -556,7 +540,10 @@ var threadDetailOptions = ({
556
540
  queryKey: threadsKeys.detail(workspaceId, threadId),
557
541
  queryFn: () => service.fetchThread(workspaceId, threadId),
558
542
  refetchOnWindowFocus: false,
559
- 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
560
547
  });
561
548
  function getThreadPlaceholderFromListCache(queryClient, workspaceId, threadId) {
562
549
  const entries = queryClient.getQueriesData({
@@ -2620,7 +2607,8 @@ function kickOff(fn) {
2620
2607
  var isSupported = () => typeof window !== "undefined" && window.isSecureContext && !!navigator.mediaDevices?.getUserMedia;
2621
2608
  function classifyTokenFailure(error) {
2622
2609
  const code3 = error?.code;
2623
- if (code3 === "SP500") return "unavailable";
2610
+ if (code3 === "speech.identity_misconfigured" || code3 === "SP500")
2611
+ return "unavailable";
2624
2612
  if (error?.type === "NotFound") {
2625
2613
  return "unavailable";
2626
2614
  }
@@ -4251,7 +4239,10 @@ var workspaceDetailOptions = ({
4251
4239
  }) => queryOptions({
4252
4240
  queryKey: workspaceKeys.byId(workspaceId),
4253
4241
  queryFn: () => service.fetchWorkspace(workspaceId),
4254
- 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
4255
4246
  });
4256
4247
  function useWorkspace(workspaceId) {
4257
4248
  const service = useChatService();
@@ -4299,6 +4290,8 @@ function useMessageComposerVm(props = {}) {
4299
4290
  const isRunning = useThreadIsRunning(workspaceId, threadId);
4300
4291
  const isUploadingFiles = props.isUploadingFiles ?? false;
4301
4292
  const sendMessage = useSendMessage();
4293
+ const currentThreadId = useRef(threadId);
4294
+ currentThreadId.current = threadId;
4302
4295
  const sendDisabled = useMemo(() => {
4303
4296
  const nothingToSend = !newMessage.trim() && !props.hasAttachments;
4304
4297
  const flowBlocked = isRunning || sendMessage.isPending;
@@ -4310,18 +4303,27 @@ function useMessageComposerVm(props = {}) {
4310
4303
  newMessage,
4311
4304
  props.hasAttachments
4312
4305
  ]);
4313
- const internalSend = (text6, files) => {
4306
+ const internalSend = (text6, files, onFailed) => {
4314
4307
  if (!workspaceId || !threadId) return;
4315
4308
  const trimmed = text6.trim();
4316
4309
  const contentList = trimmed ? [{ text: trimmed, image: void 0 }] : void 0;
4317
4310
  const vars = variables && Object.keys(variables).length > 0 ? variables : void 0;
4318
- sendMessage.mutate({
4319
- workspaceId,
4320
- threadId,
4321
- contentList,
4322
- files,
4323
- variables: vars
4324
- });
4311
+ sendMessage.mutate(
4312
+ {
4313
+ workspaceId,
4314
+ threadId,
4315
+ contentList,
4316
+ files,
4317
+ variables: vars
4318
+ },
4319
+ // The composer stays mounted across threads: a send that fails after
4320
+ // the user moved to another thread must not put its text in that one.
4321
+ {
4322
+ onError: () => {
4323
+ if (currentThreadId.current === threadId) onFailed?.();
4324
+ }
4325
+ }
4326
+ );
4325
4327
  setNewMessage("");
4326
4328
  };
4327
4329
  const canSend = (text6, files) => {
@@ -4330,9 +4332,9 @@ function useMessageComposerVm(props = {}) {
4330
4332
  const flowBlocked = isRunning || sendMessage.isPending;
4331
4333
  return !(isUploadingFiles || flowBlocked || nothingToSend);
4332
4334
  };
4333
- const handleSendMessage = (text6, files) => {
4335
+ const handleSendMessage = (text6, files, onFailed) => {
4334
4336
  if (!canSend(text6, files)) return false;
4335
- internalSend(text6, files);
4337
+ internalSend(text6, files, onFailed);
4336
4338
  return true;
4337
4339
  };
4338
4340
  return {
@@ -4616,7 +4618,16 @@ function MessageComposer(_props = {}) {
4616
4618
  }, [editorKey]);
4617
4619
  const handleSendMessageAndClear = () => {
4618
4620
  const latestText = editorRef.current?.getMarkdown() ?? newMessage;
4619
- const sent = handleSendMessage(latestText, uploadedAttachments);
4621
+ const restoreText = () => {
4622
+ if ((editorRef.current?.getMarkdown() ?? "").trim()) return;
4623
+ setNewMessage(latestText);
4624
+ setEditorKey((k) => k + 1);
4625
+ };
4626
+ const sent = handleSendMessage(
4627
+ latestText,
4628
+ uploadedAttachments,
4629
+ restoreText
4630
+ );
4620
4631
  if (!sent) return;
4621
4632
  stopDictation();
4622
4633
  handleClearAttachments();
@@ -19598,6 +19609,45 @@ function MessageMarkdown({ value, className }) {
19598
19609
  function cn(...inputs) {
19599
19610
  return twMerge(clsx(inputs));
19600
19611
  }
19612
+ var buttonVariants = cva(
19613
+ "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",
19614
+ {
19615
+ variants: {
19616
+ variant: {
19617
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
19618
+ destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
19619
+ outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
19620
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
19621
+ ghost: "hover:bg-accent hover:text-accent-foreground",
19622
+ link: "text-primary underline-offset-4 hover:underline"
19623
+ },
19624
+ size: {
19625
+ default: "h-10 px-4 py-2",
19626
+ sm: "h-9 rounded-md px-3",
19627
+ lg: "h-11 rounded-md px-8",
19628
+ icon: "h-10 w-10"
19629
+ }
19630
+ },
19631
+ defaultVariants: {
19632
+ variant: "default",
19633
+ size: "default"
19634
+ }
19635
+ }
19636
+ );
19637
+ var Button = React9.forwardRef(
19638
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
19639
+ const Comp = asChild ? Slot : "button";
19640
+ return /* @__PURE__ */ jsx(
19641
+ Comp,
19642
+ {
19643
+ className: cn(buttonVariants({ variant, size, className })),
19644
+ ref,
19645
+ ...props
19646
+ }
19647
+ );
19648
+ }
19649
+ );
19650
+ Button.displayName = "Button";
19601
19651
  function Skeleton({ className, ...props }) {
19602
19652
  return /* @__PURE__ */ jsx(
19603
19653
  MuiSkeleton,
@@ -19626,7 +19676,23 @@ var ERROR_CODE_TEXT = {
19626
19676
  "llm.content_policy": "\u26A0\uFE0F **The response was blocked by a content filter**\n\nPlease rephrase your request.",
19627
19677
  "llm.schema_validation": "\u26A0\uFE0F **The model returned an invalid response**\n\nPlease try again.",
19628
19678
  "llm.unsupported_modality": "\u26A0\uFE0F **This model can't read images**\n\nSwitch to a vision-capable model, or remove the attachment and describe it instead.",
19629
- "llm.unknown": GENERIC_ERROR_TEXT
19679
+ "llm.unknown": GENERIC_ERROR_TEXT,
19680
+ // The AI API's current name for llm.auth; older messages stored that one.
19681
+ "llm.auth_failed": "\u26A0\uFE0F **The model connection isn't authorised**\n\nAn administrator needs to check the model configuration.",
19682
+ "llm.unsupported_tools": "\u26A0\uFE0F **This model can't use tools**\n\nAn administrator needs to choose a model that supports tools for this step.",
19683
+ "embeddings.model_not_found": "\u26A0\uFE0F **The model or deployment could not be found**\n\nAn administrator needs to check the model configuration.",
19684
+ // The app API's names for losing the AI API before or part-way through a reply.
19685
+ "ai_api.unavailable": "\u26A0\uFE0F **The connection to the model was interrupted**\n\nThis is usually temporary. Please try again.",
19686
+ "ai_api.stream_broken": "\u26A0\uFE0F **The connection to the model was interrupted**\n\nThis is usually temporary. Please try again.",
19687
+ // Managed secrets. A secret's failure arrives as a 404 or 400, which the
19688
+ // status table below would read as a missing model or a generic error.
19689
+ "secret.user_value_not_set": "\u26A0\uFE0F **Your own key for this isn't set**\n\nThis step uses a credential each person sets for themselves, and none is set for you yet. Ask an administrator to add it.",
19690
+ "secret.run_has_no_user": "\u26A0\uFE0F **This step needs a signed-in user**\n\nIt uses a person's own credential, so it can't run when no one started the run.",
19691
+ "secret.user_mismatch": "\u26A0\uFE0F **A credential couldn't be loaded**\n\nAn administrator needs to check this flow's secrets.",
19692
+ "secret.run_required": "\u26A0\uFE0F **A credential couldn't be loaded**\n\nAn administrator needs to check this flow's secrets.",
19693
+ "secret.not_found": "\u26A0\uFE0F **A secret this flow uses doesn't exist**\n\nAn administrator needs to add it, or point the flow at another one.",
19694
+ // The API's name for secret.not_found before it was renamed; older messages stored it.
19695
+ MS404: "\u26A0\uFE0F **A secret this flow uses doesn't exist**\n\nAn administrator needs to add it, or point the flow at another one."
19630
19696
  };
19631
19697
  var STATUS_CODE_TEXT = {
19632
19698
  408: ERROR_CODE_TEXT["llm.timeout"],
@@ -19646,8 +19712,39 @@ var getMessageErrorText = (error) => {
19646
19712
  if (error.errorCode && ERROR_CODE_TEXT[error.errorCode]) {
19647
19713
  return ERROR_CODE_TEXT[error.errorCode];
19648
19714
  }
19715
+ if (error.errorCode && !error.errorCode.startsWith("llm.")) {
19716
+ return GENERIC_ERROR_TEXT;
19717
+ }
19649
19718
  return STATUS_CODE_TEXT[error.code] ?? GENERIC_ERROR_TEXT;
19650
19719
  };
19720
+ function extractProviderErrorDetail(raw2) {
19721
+ const start = raw2.indexOf("{");
19722
+ if (start === -1) return null;
19723
+ let parsed;
19724
+ try {
19725
+ parsed = JSON.parse(raw2.slice(start));
19726
+ } catch {
19727
+ return null;
19728
+ }
19729
+ if (typeof parsed !== "object" || parsed === null) return null;
19730
+ const record = parsed;
19731
+ const inner = typeof record.error === "object" && record.error !== null ? record.error : record;
19732
+ if (typeof inner.message !== "string") return null;
19733
+ return {
19734
+ message: inner.message,
19735
+ param: typeof inner.param === "string" ? inner.param : void 0
19736
+ };
19737
+ }
19738
+ var getMessageErrorDetail = (error) => {
19739
+ if (typeof error === "number" || !error.message) {
19740
+ return null;
19741
+ }
19742
+ const detail = extractProviderErrorDetail(error.message);
19743
+ if (!detail) {
19744
+ return error.message;
19745
+ }
19746
+ return detail.param ? `${detail.message} (param: ${detail.param})` : detail.message;
19747
+ };
19651
19748
  var FileInfoSchema = z.object({
19652
19749
  id: z.string(),
19653
19750
  name: z.string()
@@ -19691,7 +19788,8 @@ var MessageErrorMessageSchema = z.object({
19691
19788
  error_code: z.string().nullish(),
19692
19789
  message: z.string().nullish(),
19693
19790
  data: z.string().nullish(),
19694
- blockId: z.string().nullish()
19791
+ blockId: z.string().nullish(),
19792
+ traceId: z.string().nullish()
19695
19793
  });
19696
19794
  var MessageSchema = z.object({
19697
19795
  id: z.string().nullish(),
@@ -19839,45 +19937,6 @@ function parseDateTime(date, customFormat) {
19839
19937
  function parseDateTimeHuman(date) {
19840
19938
  return dayjs.utc(date).local().fromNow();
19841
19939
  }
19842
- var buttonVariants = cva(
19843
- "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",
19844
- {
19845
- variants: {
19846
- variant: {
19847
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
19848
- destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
19849
- outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
19850
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
19851
- ghost: "hover:bg-accent hover:text-accent-foreground",
19852
- link: "text-primary underline-offset-4 hover:underline"
19853
- },
19854
- size: {
19855
- default: "h-10 px-4 py-2",
19856
- sm: "h-9 rounded-md px-3",
19857
- lg: "h-11 rounded-md px-8",
19858
- icon: "h-10 w-10"
19859
- }
19860
- },
19861
- defaultVariants: {
19862
- variant: "default",
19863
- size: "default"
19864
- }
19865
- }
19866
- );
19867
- var Button = React9.forwardRef(
19868
- ({ className, variant, size, asChild = false, ...props }, ref) => {
19869
- const Comp = asChild ? Slot : "button";
19870
- return /* @__PURE__ */ jsx(
19871
- Comp,
19872
- {
19873
- className: cn(buttonVariants({ variant, size, className })),
19874
- ref,
19875
- ...props
19876
- }
19877
- );
19878
- }
19879
- );
19880
- Button.displayName = "Button";
19881
19940
 
19882
19941
  // src/messages/smartCopy.ts
19883
19942
  async function copyMessageRich(container, markdown) {
@@ -20539,6 +20598,34 @@ var MessageBubble = (props) => {
20539
20598
  /* @__PURE__ */ jsx("div", { className: "mt-1.5", children: metaRow })
20540
20599
  ] });
20541
20600
  };
20601
+ function MessageErrorDetails({
20602
+ detail,
20603
+ traceId
20604
+ }) {
20605
+ const [expanded, setExpanded] = useState(false);
20606
+ return /* @__PURE__ */ jsxs("div", { className: "mt-1", children: [
20607
+ /* @__PURE__ */ jsxs(
20608
+ "button",
20609
+ {
20610
+ type: "button",
20611
+ onClick: () => setExpanded((prev) => !prev),
20612
+ "aria-expanded": expanded,
20613
+ className: "m-0 inline-flex w-auto cursor-pointer appearance-none items-center gap-1 border-0 bg-transparent p-0 text-[11px] font-medium leading-none text-muted-foreground hover:text-foreground",
20614
+ children: [
20615
+ expanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3 shrink-0" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 shrink-0" }),
20616
+ expanded ? "Hide details" : "Show details"
20617
+ ]
20618
+ }
20619
+ ),
20620
+ expanded && /* @__PURE__ */ jsxs("div", { className: "mt-1.5 whitespace-pre-wrap break-words rounded-md bg-secondary/60 p-2 font-mono text-[11px] leading-relaxed text-muted-foreground", children: [
20621
+ detail,
20622
+ traceId && /* @__PURE__ */ jsxs("div", { className: detail ? "mt-1.5" : void 0, children: [
20623
+ "Reference: ",
20624
+ traceId
20625
+ ] })
20626
+ ] })
20627
+ ] });
20628
+ }
20542
20629
  var ThinkingSection = ({ status }) => /* @__PURE__ */ jsxs(
20543
20630
  "div",
20544
20631
  {
@@ -20826,22 +20913,26 @@ var MessageItem = ({
20826
20913
  );
20827
20914
  }
20828
20915
  (message.errors ?? []).forEach((error, errorIndex) => {
20916
+ const key = `error-${message.id ?? "msg"}-${errorIndex}-${error.errorCode ?? error.code}`;
20917
+ const detail = getMessageErrorDetail(error);
20829
20918
  bubbles.push(
20830
- /* @__PURE__ */ jsx(
20831
- MessageBubble,
20832
- {
20833
- createdBy: chatbotName,
20834
- createdAt: message.createdAt,
20835
- type: "Output" /* OUTPUT */,
20836
- content: [{ text: getMessageErrorText(error) }],
20837
- files: [],
20838
- sources: [],
20839
- chatbotName,
20840
- userOutput: null,
20841
- userInput: null
20842
- },
20843
- `error-${message.id ?? "msg"}-${errorIndex}-${error.errorCode ?? error.code}`
20844
- )
20919
+ /* @__PURE__ */ jsxs(Fragment$1, { children: [
20920
+ /* @__PURE__ */ jsx(
20921
+ MessageBubble,
20922
+ {
20923
+ createdBy: chatbotName,
20924
+ createdAt: message.createdAt,
20925
+ type: "Output" /* OUTPUT */,
20926
+ content: [{ text: getMessageErrorText(error) }],
20927
+ files: [],
20928
+ sources: [],
20929
+ chatbotName,
20930
+ userOutput: null,
20931
+ userInput: null
20932
+ }
20933
+ ),
20934
+ (detail || error.traceId) && /* @__PURE__ */ jsx(MessageErrorDetails, { detail, traceId: error.traceId })
20935
+ ] }, key)
20845
20936
  );
20846
20937
  });
20847
20938
  return bubbles;
@@ -20867,14 +20958,16 @@ function MessageList({
20867
20958
  data: thread,
20868
20959
  isPending: threadPending,
20869
20960
  isFetching: threadFetching,
20870
- error: threadError
20961
+ error: threadError,
20962
+ refetch: refetchThread
20871
20963
  } = useThread({ workspaceId, threadId });
20872
20964
  const isRunning = useThreadIsRunning(workspaceId, threadId);
20873
20965
  const {
20874
20966
  data: messages,
20875
20967
  isPending: messagesPending,
20876
20968
  isFetching: messagesFetching,
20877
- error: messagesError
20969
+ error: messagesError,
20970
+ refetch: refetchMessages
20878
20971
  } = useMessages(threadId);
20879
20972
  const hostBg = applyHostBackgroundOverride ? "chat-main" : "";
20880
20973
  const scrollToBottom = useCallback((behavior = "auto") => {
@@ -20953,7 +21046,19 @@ function MessageList({
20953
21046
  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: [
20954
21047
  /* @__PURE__ */ jsx(AlertTriangle, { className: "h-4 w-4" }),
20955
21048
  /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Failed to load messages" })
20956
- ] })
21049
+ ] }),
21050
+ /* @__PURE__ */ jsx(
21051
+ Button,
21052
+ {
21053
+ size: "sm",
21054
+ variant: "outline",
21055
+ onClick: () => {
21056
+ if (threadError) void refetchThread();
21057
+ if (messagesError) void refetchMessages();
21058
+ },
21059
+ children: "Try again"
21060
+ }
21061
+ )
20957
21062
  ] }) });
20958
21063
  }
20959
21064
  if (safeMessages.length === 0 && !hadMessagesBefore) {
@@ -21096,6 +21201,11 @@ function MessageListSkeleton() {
21096
21201
  i
21097
21202
  )) });
21098
21203
  }
21204
+
21205
+ // src/shared/utils/enums.ts
21206
+ var isMember = (e, value) => Object.values(e).includes(value);
21207
+
21208
+ // src/domains/messages/mapper.ts
21099
21209
  var {
21100
21210
  messageThreadsThreadMessagesIdMessagesResponse: messagesResponseSchema
21101
21211
  } = ChatZod;
@@ -21122,6 +21232,7 @@ function mapMessageValueDtoToModel(dto) {
21122
21232
  createdByUserId: dto.createdByUserId ?? void 0
21123
21233
  };
21124
21234
  }
21235
+ var mapMessageValuesDtoToModels = (dtos) => dtos.filter((dto) => isMember(MessageValueType, dto.type)).map(mapMessageValueDtoToModel);
21125
21236
  function mapMessageErrorDtoToModel(dto) {
21126
21237
  const { error_code, ...rest } = dto;
21127
21238
  return {
@@ -21139,7 +21250,7 @@ function mapMessageDtoToModel(dto) {
21139
21250
  createdByUserId: dto.createdByUserId ?? void 0,
21140
21251
  messageThreadId: dto.messageThreadId ?? void 0,
21141
21252
  errors: dto.errors?.map(mapMessageErrorDtoToModel) ?? void 0,
21142
- values: dto.values?.map(mapMessageValueDtoToModel)
21253
+ values: dto.values && mapMessageValuesDtoToModels(dto.values)
21143
21254
  };
21144
21255
  }
21145
21256
  function mapMessagesDtoToModels(dto) {
@@ -21255,8 +21366,7 @@ var mapWorkspacesDtoToModels = (arr) => arr.map(mapWorkspaceDtoToModel);
21255
21366
  function getChatApiBaseUrl() {
21256
21367
  try {
21257
21368
  const w = window;
21258
- const env2 = import.meta.env;
21259
- const cfg = w?.ssconfig?.Chat_Api_Uri ?? env2?.VITE_CHAT_API_URI;
21369
+ const cfg = w?.ssconfig?.Chat_Api_Uri;
21260
21370
  return typeof cfg === "string" && cfg.trim() ? cfg.trim() : "";
21261
21371
  } catch {
21262
21372
  return "";
@@ -21269,6 +21379,6 @@ function getUserPhotoUrl(userId) {
21269
21379
  return `${base2}/users/${userId}/photo`;
21270
21380
  }
21271
21381
 
21272
- export { ChatProvider, ChatVariablesForm, DRAFT_THREAD_PREFIX, DateFromApi, DictationButton, MarkdownEditor, MessageComposer, MessageList, MessageListSkeleton, MessageMarkdown, MessageValueType, NEW_THREAD_ID, THREAD_LIST_PAGE_SIZE, applyDeltaToMessage, applyThreadToCache, createDraftThreadId, createThreadId, downloadFileBlobOptions, filesKeys, flowRunsKeys, getMessageErrorText, getModelIcon, getRetryStatusText, getThreadPlaceholderFromListCache, getUserPhotoUrl, invalidateWorkspaceThreadLists, isDraftThreadId, mapFileInfoDtoToModel, mapMentionUserDtoToModel, mapMessageDtoToModel, mapMessageErrorDtoToModel, mapMessageValueDtoToModel, mapMessagesDtoToModels, mapSignalRThreadSummaryToModel, mapThreadDtoToModel, mapThreadsResponseDtoToModel, mapWorkspaceDtoToModel, mapWorkspacesDtoToModels, markDraftThreadId, messagesKeys, messagesListOptions, messagesMutationsKeys, modelsKeys, parseDateTime, parseDateTimeHuman, parseRetryStatus, randomUUID, setThreadOptimisticRunning, setThreadRunningInLists, speechKeys, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDictation, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useIsDraftThreadId, useMessages, useModels, useSendMessage, useSpeechConfig, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, utcDate, workspaceDetailOptions, workspaceKeys };
21382
+ export { ChatProvider, ChatVariablesForm, DRAFT_THREAD_PREFIX, DateFromApi, DictationButton, MarkdownEditor, MessageComposer, MessageList, MessageListSkeleton, MessageMarkdown, MessageValueType, NEW_THREAD_ID, THREAD_LIST_PAGE_SIZE, applyDeltaToMessage, applyThreadToCache, createDraftThreadId, createThreadId, downloadFileBlobOptions, filesKeys, flowRunsKeys, getMessageErrorDetail, getMessageErrorText, getModelIcon, getRetryStatusText, getThreadPlaceholderFromListCache, getUserPhotoUrl, invalidateWorkspaceThreadLists, isDraftThreadId, mapFileInfoDtoToModel, mapMentionUserDtoToModel, mapMessageDtoToModel, mapMessageErrorDtoToModel, mapMessageValueDtoToModel, mapMessageValuesDtoToModels, mapMessagesDtoToModels, mapSignalRThreadSummaryToModel, mapThreadDtoToModel, mapThreadsResponseDtoToModel, mapWorkspaceDtoToModel, mapWorkspacesDtoToModels, markDraftThreadId, messagesKeys, messagesListOptions, messagesMutationsKeys, modelsKeys, parseDateTime, parseDateTimeHuman, parseRetryStatus, randomUUID, setThreadOptimisticRunning, setThreadRunningInLists, speechKeys, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDictation, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useIsDraftThreadId, useMessages, useModels, useSendMessage, useSpeechConfig, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, utcDate, workspaceDetailOptions, workspaceKeys };
21273
21383
  //# sourceMappingURL=index.js.map
21274
21384
  //# sourceMappingURL=index.js.map