@smartspace/chat-ui 1.14.6-main.f1a461a → 1.14.10-main.c4a79a2

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.d.ts CHANGED
@@ -319,6 +319,8 @@ type Message = {
319
319
  message?: string | null;
320
320
  data?: string | null;
321
321
  blockId?: string | null;
322
+ /** Trace id of the request that recorded the error, for a support reference. */
323
+ traceId?: string | null;
322
324
  }[] | null;
323
325
  values?: MessageValue[] | null;
324
326
  optimistic?: boolean;
@@ -449,7 +451,6 @@ interface ChatService {
449
451
  uploadFiles(files: File[], scope: FileScope, onFileUploaded?: (file: File, fileInfo: FileInfo$1) => void, onChunkUploaded?: (chunkIndex: number, totalChunks: number, file: File) => void): Promise<FileInfo$1[]>;
450
452
  downloadFile(id: string, scope?: FileScope): Promise<Blob>;
451
453
  getFileInfo(id: string, scope: FileScope): Promise<FileInfo$1>;
452
- getFileDownloadUrl(sourceUri: string): Promise<string>;
453
454
  fetchThread(workspaceId: string, threadId: string): Promise<MessageThread>;
454
455
  fetchWorkspace(workspaceId: string): Promise<Workspace>;
455
456
  fetchTaggableUsers(workspaceId: string): Promise<MentionUser[]>;
@@ -1254,9 +1255,6 @@ declare const filesKeys: {
1254
1255
  downloadBlob: (fileId: string) => readonly ["files", "mutation", "downloadBlob", {
1255
1256
  readonly fileId: string;
1256
1257
  }];
1257
- downloadByUri: (uri: string) => readonly ["files", "mutation", "downloadByUri", {
1258
- readonly uri: string;
1259
- }];
1260
1258
  };
1261
1259
  };
1262
1260
 
@@ -1352,10 +1350,6 @@ declare function useMessages(threadId: string): _tanstack_react_query.UseQueryRe
1352
1350
  declare const useFileMutations: (scope: FileScope) => {
1353
1351
  uploadFilesMutation: _tanstack_react_query.UseMutationResult<FileInfo$1[], Error, File[], unknown>;
1354
1352
  downloadFileMutation: _tanstack_react_query.UseMutationResult<void, Error, FileInfo$1, unknown>;
1355
- downloadFileByUriMutation: _tanstack_react_query.UseMutationResult<Blob, Error, {
1356
- name: string;
1357
- sourceUri: string;
1358
- }, unknown>;
1359
1353
  getFileBlobUrl: (id: string) => Promise<string>;
1360
1354
  fileProgress: Record<string, number>;
1361
1355
  uploadedFiles: FileInfo$1[];
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;
@@ -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,
@@ -19619,27 +19669,40 @@ var ERROR_CODE_TEXT = {
19619
19669
  "llm.timeout": "\u26A0\uFE0F **The model took too long to respond**\n\nPlease try again. If this keeps happening, try a shorter question.",
19620
19670
  "llm.transient_connection": "\u26A0\uFE0F **The connection to the model was interrupted**\n\nThis is usually temporary. Please try again.",
19621
19671
  "llm.upstream_error": "\u26A0\uFE0F **The model provider had a problem**\n\nPlease try again in a moment.",
19622
- "llm.auth": "\u26A0\uFE0F **The model connection isn't authorised**\n\nAn administrator needs to check the model configuration.",
19623
19672
  "llm.not_found": "\u26A0\uFE0F **The model or deployment could not be found**\n\nAn administrator needs to check the model configuration.",
19624
19673
  "llm.invalid_request": "\u26A0\uFE0F **The request was rejected by the model provider**\n\nPlease try rephrasing your message.",
19625
19674
  "llm.context_window": "\u26A0\uFE0F **This conversation is too long for the model**\n\nPlease start a new thread, or ask a shorter question.",
19626
19675
  "llm.content_policy": "\u26A0\uFE0F **The response was blocked by a content filter**\n\nPlease rephrase your request.",
19627
19676
  "llm.schema_validation": "\u26A0\uFE0F **The model returned an invalid response**\n\nPlease try again.",
19628
19677
  "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,
19678
+ "llm.auth_failed": "\u26A0\uFE0F **The model connection isn't authorised**\n\nAn administrator needs to check the model configuration.",
19679
+ "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.",
19680
+ "embeddings.model_not_found": "\u26A0\uFE0F **The model or deployment could not be found**\n\nAn administrator needs to check the model configuration.",
19681
+ // The app API's names for losing the AI API before or part-way through a reply.
19682
+ "ai_api.unavailable": "\u26A0\uFE0F **The connection to the model was interrupted**\n\nThis is usually temporary. Please try again.",
19683
+ "ai_api.stream_broken": "\u26A0\uFE0F **The connection to the model was interrupted**\n\nThis is usually temporary. Please try again.",
19630
19684
  // Managed secrets. A secret's failure arrives as a 404 or 400, which the
19631
19685
  // status table below would read as a missing model or a generic error.
19632
- "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.",
19686
+ "secret.user_value_not_set": "\u26A0\uFE0F **Your own key for this isn't set**\n\nThis step uses a credential that is set separately for each person, and none is set for you yet. Ask an administrator to add yours.",
19633
19687
  "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.",
19634
19688
  "secret.user_mismatch": "\u26A0\uFE0F **A credential couldn't be loaded**\n\nAn administrator needs to check this flow's secrets.",
19635
19689
  "secret.run_required": "\u26A0\uFE0F **A credential couldn't be loaded**\n\nAn administrator needs to check this flow's secrets.",
19636
- 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."
19690
+ "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."
19691
+ };
19692
+ var LEGACY_CODE_TEXT = {
19693
+ "llm.auth": ERROR_CODE_TEXT["llm.auth_failed"],
19694
+ "llm.unknown": GENERIC_ERROR_TEXT,
19695
+ MS404: ERROR_CODE_TEXT["secret.not_found"]
19696
+ };
19697
+ var CODE_TEXT = {
19698
+ ...LEGACY_CODE_TEXT,
19699
+ ...ERROR_CODE_TEXT
19637
19700
  };
19638
19701
  var STATUS_CODE_TEXT = {
19639
19702
  408: ERROR_CODE_TEXT["llm.timeout"],
19640
19703
  429: ERROR_CODE_TEXT["llm.rate_limit"],
19641
- 401: ERROR_CODE_TEXT["llm.auth"],
19642
- 403: ERROR_CODE_TEXT["llm.auth"],
19704
+ 401: ERROR_CODE_TEXT["llm.auth_failed"],
19705
+ 403: ERROR_CODE_TEXT["llm.auth_failed"],
19643
19706
  404: ERROR_CODE_TEXT["llm.not_found"],
19644
19707
  500: ERROR_CODE_TEXT["llm.upstream_error"],
19645
19708
  502: ERROR_CODE_TEXT["llm.upstream_error"],
@@ -19650,8 +19713,12 @@ var getMessageErrorText = (error) => {
19650
19713
  if (typeof error === "number") {
19651
19714
  return STATUS_CODE_TEXT[error] ?? GENERIC_ERROR_TEXT;
19652
19715
  }
19653
- if (error.errorCode && ERROR_CODE_TEXT[error.errorCode]) {
19654
- return ERROR_CODE_TEXT[error.errorCode];
19716
+ const codeText = error.errorCode ? CODE_TEXT[error.errorCode] : void 0;
19717
+ if (codeText) {
19718
+ return codeText;
19719
+ }
19720
+ if (error.errorCode && !error.errorCode.startsWith("llm.")) {
19721
+ return GENERIC_ERROR_TEXT;
19655
19722
  }
19656
19723
  return STATUS_CODE_TEXT[error.code] ?? GENERIC_ERROR_TEXT;
19657
19724
  };
@@ -19726,7 +19793,8 @@ var MessageErrorMessageSchema = z.object({
19726
19793
  error_code: z.string().nullish(),
19727
19794
  message: z.string().nullish(),
19728
19795
  data: z.string().nullish(),
19729
- blockId: z.string().nullish()
19796
+ blockId: z.string().nullish(),
19797
+ traceId: z.string().nullish()
19730
19798
  });
19731
19799
  var MessageSchema = z.object({
19732
19800
  id: z.string().nullish(),
@@ -19793,7 +19861,7 @@ var RETRY_REASON_TEXT = {
19793
19861
  "llm.rate_limit": "the model is busy",
19794
19862
  "llm.timeout": "the model took too long",
19795
19863
  "llm.transient_connection": "the connection dropped",
19796
- "llm.server_error": "the model provider had a problem"
19864
+ "llm.upstream_error": "the model provider had a problem"
19797
19865
  };
19798
19866
  var getRetryStatusText = (status) => {
19799
19867
  const reason = status.errorCode ? RETRY_REASON_TEXT[status.errorCode] : void 0;
@@ -19874,45 +19942,6 @@ function parseDateTime(date, customFormat) {
19874
19942
  function parseDateTimeHuman(date) {
19875
19943
  return dayjs.utc(date).local().fromNow();
19876
19944
  }
19877
- var buttonVariants = cva(
19878
- "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",
19879
- {
19880
- variants: {
19881
- variant: {
19882
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
19883
- destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
19884
- outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
19885
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
19886
- ghost: "hover:bg-accent hover:text-accent-foreground",
19887
- link: "text-primary underline-offset-4 hover:underline"
19888
- },
19889
- size: {
19890
- default: "h-10 px-4 py-2",
19891
- sm: "h-9 rounded-md px-3",
19892
- lg: "h-11 rounded-md px-8",
19893
- icon: "h-10 w-10"
19894
- }
19895
- },
19896
- defaultVariants: {
19897
- variant: "default",
19898
- size: "default"
19899
- }
19900
- }
19901
- );
19902
- var Button = React9.forwardRef(
19903
- ({ className, variant, size, asChild = false, ...props }, ref) => {
19904
- const Comp = asChild ? Slot : "button";
19905
- return /* @__PURE__ */ jsx(
19906
- Comp,
19907
- {
19908
- className: cn(buttonVariants({ variant, size, className })),
19909
- ref,
19910
- ...props
19911
- }
19912
- );
19913
- }
19914
- );
19915
- Button.displayName = "Button";
19916
19945
 
19917
19946
  // src/messages/smartCopy.ts
19918
19947
  async function copyMessageRich(container, markdown) {
@@ -20574,7 +20603,10 @@ var MessageBubble = (props) => {
20574
20603
  /* @__PURE__ */ jsx("div", { className: "mt-1.5", children: metaRow })
20575
20604
  ] });
20576
20605
  };
20577
- function MessageErrorDetails({ detail }) {
20606
+ function MessageErrorDetails({
20607
+ detail,
20608
+ traceId
20609
+ }) {
20578
20610
  const [expanded, setExpanded] = useState(false);
20579
20611
  return /* @__PURE__ */ jsxs("div", { className: "mt-1", children: [
20580
20612
  /* @__PURE__ */ jsxs(
@@ -20590,7 +20622,32 @@ function MessageErrorDetails({ detail }) {
20590
20622
  ]
20591
20623
  }
20592
20624
  ),
20593
- expanded && /* @__PURE__ */ jsx("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: detail })
20625
+ 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: [
20626
+ detail,
20627
+ traceId && /* @__PURE__ */ jsxs("div", { className: detail ? "mt-1.5" : void 0, children: [
20628
+ "Reference: ",
20629
+ traceId
20630
+ ] })
20631
+ ] })
20632
+ ] });
20633
+ }
20634
+ function MessageReasoning({ text: text6 }) {
20635
+ const [expanded, setExpanded] = useState(false);
20636
+ return /* @__PURE__ */ jsxs("div", { className: "mb-1", children: [
20637
+ /* @__PURE__ */ jsxs(
20638
+ "button",
20639
+ {
20640
+ type: "button",
20641
+ onClick: () => setExpanded((prev) => !prev),
20642
+ "aria-expanded": expanded,
20643
+ 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",
20644
+ children: [
20645
+ expanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3 shrink-0" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 shrink-0" }),
20646
+ expanded ? "Hide reasoning" : "Show reasoning"
20647
+ ]
20648
+ }
20649
+ ),
20650
+ expanded && /* @__PURE__ */ jsx("div", { className: "mt-1.5 rounded-md bg-secondary/60 p-2 text-[13px] text-muted-foreground", children: /* @__PURE__ */ jsx(MessageMarkdown, { value: text6 }) })
20594
20651
  ] });
20595
20652
  }
20596
20653
  var ThinkingSection = ({ status }) => /* @__PURE__ */ jsxs(
@@ -20716,10 +20773,16 @@ var MessageItem = ({
20716
20773
  let keyCounter = 0;
20717
20774
  let lastStatusText = null;
20718
20775
  let hasOutputContent = false;
20776
+ let firstOutputIndex = null;
20777
+ const markOutput = () => {
20778
+ if (firstOutputIndex === null) firstOutputIndex = bubbles.length;
20779
+ hasOutputContent = true;
20780
+ };
20781
+ const reasoningTexts = [];
20719
20782
  const groupHasAnything = () => groupContent.length > 0 || groupFiles.length > 0 || groupSources.length > 0;
20720
20783
  const flush = (nextType) => {
20721
20784
  if (groupHasAnything()) {
20722
- if (groupType === "Output" /* OUTPUT */) hasOutputContent = true;
20785
+ if (groupType === "Output" /* OUTPUT */) markOutput();
20723
20786
  bubbles.push(
20724
20787
  /* @__PURE__ */ jsx(
20725
20788
  MessageBubble,
@@ -20829,6 +20892,12 @@ var MessageItem = ({
20829
20892
  groupOpen = true;
20830
20893
  break;
20831
20894
  }
20895
+ case "reasoning": {
20896
+ if (typeof v.value === "string" && v.value.trim() !== "") {
20897
+ reasoningTexts.push(v.value);
20898
+ }
20899
+ continue;
20900
+ }
20832
20901
  case "sources": {
20833
20902
  groupSources = coerceSources(v.value);
20834
20903
  if (groupSources.length > 0) groupOpen = true;
@@ -20846,7 +20915,7 @@ var MessageItem = ({
20846
20915
  lastCreatedByUserId = v.createdByUserId;
20847
20916
  }
20848
20917
  if (groupOpen && groupHasAnything()) {
20849
- if (groupType === "Output" /* OUTPUT */) hasOutputContent = true;
20918
+ if (groupType === "Output" /* OUTPUT */) markOutput();
20850
20919
  bubbles.push(
20851
20920
  /* @__PURE__ */ jsx(
20852
20921
  MessageBubble,
@@ -20867,6 +20936,19 @@ var MessageItem = ({
20867
20936
  )
20868
20937
  );
20869
20938
  }
20939
+ if (reasoningTexts.length > 0) {
20940
+ bubbles.splice(
20941
+ firstOutputIndex ?? bubbles.length,
20942
+ 0,
20943
+ /* @__PURE__ */ jsx(
20944
+ MessageReasoning,
20945
+ {
20946
+ text: reasoningTexts.join("\n\n")
20947
+ },
20948
+ `reasoning-${message.id ?? "msg"}`
20949
+ )
20950
+ );
20951
+ }
20870
20952
  const showThinking = isLive && (lastStatusText !== null || !hasOutputContent);
20871
20953
  if (showThinking) {
20872
20954
  bubbles.push(
@@ -20898,7 +20980,7 @@ var MessageItem = ({
20898
20980
  userInput: null
20899
20981
  }
20900
20982
  ),
20901
- detail && /* @__PURE__ */ jsx(MessageErrorDetails, { detail })
20983
+ (detail || error.traceId) && /* @__PURE__ */ jsx(MessageErrorDetails, { detail, traceId: error.traceId })
20902
20984
  ] }, key)
20903
20985
  );
20904
20986
  });
@@ -20925,14 +21007,16 @@ function MessageList({
20925
21007
  data: thread,
20926
21008
  isPending: threadPending,
20927
21009
  isFetching: threadFetching,
20928
- error: threadError
21010
+ error: threadError,
21011
+ refetch: refetchThread
20929
21012
  } = useThread({ workspaceId, threadId });
20930
21013
  const isRunning = useThreadIsRunning(workspaceId, threadId);
20931
21014
  const {
20932
21015
  data: messages,
20933
21016
  isPending: messagesPending,
20934
21017
  isFetching: messagesFetching,
20935
- error: messagesError
21018
+ error: messagesError,
21019
+ refetch: refetchMessages
20936
21020
  } = useMessages(threadId);
20937
21021
  const hostBg = applyHostBackgroundOverride ? "chat-main" : "";
20938
21022
  const scrollToBottom = useCallback((behavior = "auto") => {
@@ -21011,7 +21095,19 @@ function MessageList({
21011
21095
  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: [
21012
21096
  /* @__PURE__ */ jsx(AlertTriangle, { className: "h-4 w-4" }),
21013
21097
  /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Failed to load messages" })
21014
- ] })
21098
+ ] }),
21099
+ /* @__PURE__ */ jsx(
21100
+ Button,
21101
+ {
21102
+ size: "sm",
21103
+ variant: "outline",
21104
+ onClick: () => {
21105
+ if (threadError) void refetchThread();
21106
+ if (messagesError) void refetchMessages();
21107
+ },
21108
+ children: "Try again"
21109
+ }
21110
+ )
21015
21111
  ] }) });
21016
21112
  }
21017
21113
  if (safeMessages.length === 0 && !hadMessagesBefore) {
@@ -21319,8 +21415,7 @@ var mapWorkspacesDtoToModels = (arr) => arr.map(mapWorkspaceDtoToModel);
21319
21415
  function getChatApiBaseUrl() {
21320
21416
  try {
21321
21417
  const w = window;
21322
- const env2 = import.meta.env;
21323
- const cfg = w?.ssconfig?.Chat_Api_Uri ?? env2?.VITE_CHAT_API_URI;
21418
+ const cfg = w?.ssconfig?.Chat_Api_Uri;
21324
21419
  return typeof cfg === "string" && cfg.trim() ? cfg.trim() : "";
21325
21420
  } catch {
21326
21421
  return "";