@smartspace/chat-ui 1.13.1-dev.5faa59f → 1.13.1-dev.6447c78

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
@@ -515,6 +515,11 @@ declare function mapThreadsResponseDtoToModel(dto: ThreadsResponseDto): ThreadsR
515
515
  declare function mapSignalRThreadSummaryToModel(summary: SignalR.MessageThreadSummary): MessageThread;
516
516
 
517
517
  declare const workspaceResponseSchema: z.ZodObject<{
518
+ connectors: z.ZodArray<z.ZodObject<{
519
+ id: z.ZodString;
520
+ kind: z.ZodString;
521
+ name: z.ZodString;
522
+ }, z.core.$strip>>;
518
523
  createdAt: z.ZodISODateTime;
519
524
  createdByUserId: z.ZodString;
520
525
  dataSpaces: z.ZodArray<z.ZodObject<{
@@ -751,6 +756,11 @@ declare const workspaceUsersResponseSchema: z.ZodArray<z.ZodObject<{
751
756
  }, z.core.$strip>>;
752
757
  declare const workspacesListResponseSchema: z.ZodObject<{
753
758
  data: z.ZodArray<z.ZodObject<{
759
+ connectors: z.ZodArray<z.ZodObject<{
760
+ id: z.ZodString;
761
+ kind: z.ZodString;
762
+ name: z.ZodString;
763
+ }, z.core.$strip>>;
754
764
  createdAt: z.ZodISODateTime;
755
765
  createdByUserId: z.ZodString;
756
766
  dataSpaces: z.ZodArray<z.ZodObject<{
@@ -1023,6 +1033,15 @@ declare const DRAFT_THREAD_PREFIX = "draft-";
1023
1033
  declare function markDraftThreadId(threadId: string): void;
1024
1034
  declare function unmarkDraftThreadId(threadId: string): void;
1025
1035
  declare function isDraftThreadId(threadId?: string | null): boolean;
1036
+ /**
1037
+ * Reactive equivalent of isDraftThreadId() -- re-renders the caller when
1038
+ * markDraftThreadId/unmarkDraftThreadId changes this threadId's status, even
1039
+ * if that happens from an unrelated component (e.g. the thread list noticing
1040
+ * a draft is now server-backed). Use this in any component whose render
1041
+ * output depends on draft status; the plain function is fine for one-off
1042
+ * checks inside event handlers or non-React code.
1043
+ */
1044
+ declare function useIsDraftThreadId(threadId?: string | null): boolean;
1026
1045
  declare function createDraftThreadId(): string;
1027
1046
 
1028
1047
  /**
@@ -1339,4 +1358,4 @@ declare function useModels({ search, take, skip, }?: {
1339
1358
  total: number;
1340
1359
  }, Error>;
1341
1360
 
1342
- export { type ChatContextIds, type ChatIdentity, ChatProvider, type ChatProviderProps, type ChatService, ChatVariablesForm, DRAFT_THREAD_PREFIX, DateFromApi, type FileInfo$1 as FileInfo, type FileScope, type FlowRunVariables, MarkdownEditor, type MarkdownEditorHandle, type MentionUser, type Message, MessageComposer, type MessageComposerProps, type MessageContentItem, type MessageError, MessageList, type MessageListProps, MessageListSkeleton, MessageMarkdown, type MessageThread, type MessageValue, MessageValueType, type Model, type ModelProperty, NEW_THREAD_ID, THREAD_LIST_PAGE_SIZE, type ThreadsResponse, type Variables, type Workspace, applyDeltaToMessage, applyThreadToCache, createDraftThreadId, createThreadId, downloadFileBlobOptions, filesKeys, flowRunsKeys, getModelIcon, getThreadPlaceholderFromListCache, getUserPhotoUrl, invalidateWorkspaceThreadLists, isDraftThreadId, mapFileInfoDtoToModel, mapMentionUserDtoToModel, mapMessageDtoToModel, mapMessageErrorDtoToModel, mapMessageValueDtoToModel, mapMessagesDtoToModels, mapSignalRThreadSummaryToModel, mapThreadDtoToModel, mapThreadsResponseDtoToModel, mapWorkspaceDtoToModel, mapWorkspacesDtoToModels, markDraftThreadId, messagesKeys, messagesListOptions, messagesMutationsKeys, modelsKeys, parseDateTime, parseDateTimeHuman, randomUUID, setThreadOptimisticRunning, setThreadRunningInLists, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useMessages, useModels, useSendMessage, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, utcDate, workspaceDetailOptions, workspaceKeys };
1361
+ export { type ChatContextIds, type ChatIdentity, ChatProvider, type ChatProviderProps, type ChatService, ChatVariablesForm, DRAFT_THREAD_PREFIX, DateFromApi, type FileInfo$1 as FileInfo, type FileScope, type FlowRunVariables, MarkdownEditor, type MarkdownEditorHandle, type MentionUser, type Message, MessageComposer, type MessageComposerProps, type MessageContentItem, type MessageError, MessageList, type MessageListProps, MessageListSkeleton, MessageMarkdown, type MessageThread, type MessageValue, MessageValueType, type Model, type ModelProperty, NEW_THREAD_ID, THREAD_LIST_PAGE_SIZE, type ThreadsResponse, type Variables, type Workspace, applyDeltaToMessage, applyThreadToCache, createDraftThreadId, createThreadId, downloadFileBlobOptions, filesKeys, flowRunsKeys, getModelIcon, getThreadPlaceholderFromListCache, getUserPhotoUrl, invalidateWorkspaceThreadLists, isDraftThreadId, mapFileInfoDtoToModel, mapMentionUserDtoToModel, mapMessageDtoToModel, mapMessageErrorDtoToModel, mapMessageValueDtoToModel, mapMessagesDtoToModels, mapSignalRThreadSummaryToModel, mapThreadDtoToModel, mapThreadsResponseDtoToModel, mapWorkspaceDtoToModel, mapWorkspacesDtoToModels, markDraftThreadId, messagesKeys, messagesListOptions, messagesMutationsKeys, modelsKeys, parseDateTime, parseDateTimeHuman, randomUUID, setThreadOptimisticRunning, setThreadRunningInLists, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useIsDraftThreadId, useMessages, useModels, useSendMessage, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, utcDate, workspaceDetailOptions, workspaceKeys };
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import MuiButton from '@mui/material/Button';
2
2
  import IconButton from '@mui/material/IconButton';
3
3
  import { Loader2, Check, X, Paperclip, ArrowBigUp, Minimize2, AlertTriangle, FileImage, FileVideo, FileAudio, FileArchive, FileCode, FileSpreadsheet, Presentation, FileText, ChevronUp, Download, Copy, Globe, ShieldAlert } from 'lucide-react';
4
4
  import * as React9 from 'react';
5
- import { createContext, forwardRef, useImperativeHandle, useRef, useState, useEffect, useMemo, useCallback, createElement, useContext } from 'react';
5
+ import { createContext, forwardRef, useImperativeHandle, useRef, useState, useEffect, useMemo, useCallback, createElement, useContext, useSyncExternalStore } from 'react';
6
6
  import { createPortal } from 'react-dom';
7
7
  import { useQuery, queryOptions, useQueryClient, useMutation, skipToken } from '@tanstack/react-query';
8
8
  import { toast } from 'sonner';
@@ -1827,8 +1827,6 @@ var Button = React9.forwardRef(
1827
1827
  }
1828
1828
  );
1829
1829
  Button.displayName = "Button";
1830
-
1831
- // src/shared/utils/threadId.ts
1832
1830
  var NEW_THREAD_ID = "__new__";
1833
1831
  function createThreadId() {
1834
1832
  const cryptoObj = globalThis?.crypto;
@@ -1838,6 +1836,16 @@ var DRAFT_THREAD_PREFIX = "draft-";
1838
1836
  var DRAFT_THREAD_STORAGE_KEY = "ss:draftThreadIds";
1839
1837
  var draftThreadIds = /* @__PURE__ */ new Set();
1840
1838
  var hydratedFromStorage = false;
1839
+ var draftThreadIdsListeners = /* @__PURE__ */ new Set();
1840
+ function notifyDraftThreadIdsChanged() {
1841
+ for (const listener2 of draftThreadIdsListeners) listener2();
1842
+ }
1843
+ function subscribeDraftThreadIdsChanged(listener2) {
1844
+ draftThreadIdsListeners.add(listener2);
1845
+ return () => {
1846
+ draftThreadIdsListeners.delete(listener2);
1847
+ };
1848
+ }
1841
1849
  function isBrowserStorageAvailable() {
1842
1850
  try {
1843
1851
  return typeof window !== "undefined" && !!window.sessionStorage;
@@ -1875,12 +1883,14 @@ function markDraftThreadId(threadId) {
1875
1883
  hydrateFromStorageOnce();
1876
1884
  draftThreadIds.add(threadId);
1877
1885
  persistToStorage();
1886
+ notifyDraftThreadIdsChanged();
1878
1887
  }
1879
1888
  function unmarkDraftThreadId(threadId) {
1880
1889
  if (!threadId) return;
1881
1890
  hydrateFromStorageOnce();
1882
1891
  draftThreadIds.delete(threadId);
1883
1892
  persistToStorage();
1893
+ notifyDraftThreadIdsChanged();
1884
1894
  }
1885
1895
  function isDraftThreadId(threadId) {
1886
1896
  if (!threadId) return false;
@@ -1888,6 +1898,12 @@ function isDraftThreadId(threadId) {
1888
1898
  hydrateFromStorageOnce();
1889
1899
  return draftThreadIds.has(threadId);
1890
1900
  }
1901
+ function useIsDraftThreadId(threadId) {
1902
+ return useSyncExternalStore(
1903
+ subscribeDraftThreadIdsChanged,
1904
+ () => isDraftThreadId(threadId)
1905
+ );
1906
+ }
1891
1907
  function createDraftThreadId() {
1892
1908
  const cryptoObj = globalThis?.crypto;
1893
1909
  return typeof cryptoObj?.randomUUID === "function" ? cryptoObj.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}`;
@@ -20104,7 +20120,14 @@ function pushContent(items, value) {
20104
20120
  return;
20105
20121
  }
20106
20122
  if (Array.isArray(value)) {
20107
- items.push(...value);
20123
+ const looksLikeContent = value.every(
20124
+ (it) => it != null && typeof it === "object" && ("text" in it || "image" in it)
20125
+ );
20126
+ if (looksLikeContent) {
20127
+ items.push(...value);
20128
+ } else {
20129
+ items.push({ text: "```json\n" + JSON.stringify(value, null, 2) + "\n```" });
20130
+ }
20108
20131
  return;
20109
20132
  }
20110
20133
  if (typeof value === "object") {
@@ -20179,25 +20202,28 @@ var MessageItem = ({
20179
20202
  let groupOpen = false;
20180
20203
  let keyCounter = 0;
20181
20204
  let lastStatusNode = null;
20205
+ const groupHasAnything = () => groupContent.length > 0 || groupFiles.length > 0 || groupSources.length > 0;
20182
20206
  const flush = (nextType) => {
20183
- bubbles.push(
20184
- /* @__PURE__ */ jsx(
20185
- MessageBubble,
20186
- {
20187
- createdBy: lastCreatedBy,
20188
- createdByUserId: lastCreatedByUserId,
20189
- createdAt: lastCreatedAt,
20190
- type: groupType,
20191
- content: groupContent,
20192
- files: groupFiles,
20193
- sources: groupSources,
20194
- chatbotName,
20195
- userOutput: null,
20196
- userInput: null
20197
- },
20198
- `bubble-${message.id ?? "msg"}-${keyCounter++}`
20199
- )
20200
- );
20207
+ if (groupHasAnything()) {
20208
+ bubbles.push(
20209
+ /* @__PURE__ */ jsx(
20210
+ MessageBubble,
20211
+ {
20212
+ createdBy: lastCreatedBy,
20213
+ createdByUserId: lastCreatedByUserId,
20214
+ createdAt: lastCreatedAt,
20215
+ type: groupType,
20216
+ content: groupContent,
20217
+ files: groupFiles,
20218
+ sources: groupSources,
20219
+ chatbotName,
20220
+ userOutput: null,
20221
+ userInput: null
20222
+ },
20223
+ `bubble-${message.id ?? "msg"}-${keyCounter++}`
20224
+ )
20225
+ );
20226
+ }
20201
20227
  groupContent = [];
20202
20228
  groupFiles = [];
20203
20229
  groupSources = [];
@@ -20229,6 +20255,9 @@ var MessageItem = ({
20229
20255
  case "prompt":
20230
20256
  case "response":
20231
20257
  case "content": {
20258
+ if (v.value === "") {
20259
+ continue;
20260
+ }
20232
20261
  lastStatusNode = null;
20233
20262
  if (groupContent.length > 0) flush(v.type);
20234
20263
  if (v.value == null) {
@@ -20283,7 +20312,7 @@ var MessageItem = ({
20283
20312
  }
20284
20313
  case "sources": {
20285
20314
  groupSources = coerceSources(v.value);
20286
- groupOpen = true;
20315
+ if (groupSources.length > 0) groupOpen = true;
20287
20316
  break;
20288
20317
  }
20289
20318
  default: {
@@ -20297,7 +20326,7 @@ var MessageItem = ({
20297
20326
  lastCreatedBy = v.createdBy;
20298
20327
  lastCreatedByUserId = v.createdByUserId;
20299
20328
  }
20300
- if (groupOpen) {
20329
+ if (groupOpen && groupHasAnything()) {
20301
20330
  bubbles.push(
20302
20331
  /* @__PURE__ */ jsx(
20303
20332
  MessageBubble,
@@ -20725,6 +20754,6 @@ function mapWorkspaceDtoToModel(dto) {
20725
20754
  }
20726
20755
  var mapWorkspacesDtoToModels = (arr) => arr.map(mapWorkspaceDtoToModel);
20727
20756
 
20728
- export { ChatProvider, ChatVariablesForm, DRAFT_THREAD_PREFIX, DateFromApi, MarkdownEditor, MessageComposer, MessageList, MessageListSkeleton, MessageMarkdown, MessageValueType, NEW_THREAD_ID, THREAD_LIST_PAGE_SIZE, applyDeltaToMessage, applyThreadToCache, createDraftThreadId, createThreadId, downloadFileBlobOptions, filesKeys, flowRunsKeys, getModelIcon, getThreadPlaceholderFromListCache, getUserPhotoUrl, invalidateWorkspaceThreadLists, isDraftThreadId, mapFileInfoDtoToModel, mapMentionUserDtoToModel, mapMessageDtoToModel, mapMessageErrorDtoToModel, mapMessageValueDtoToModel, mapMessagesDtoToModels, mapSignalRThreadSummaryToModel, mapThreadDtoToModel, mapThreadsResponseDtoToModel, mapWorkspaceDtoToModel, mapWorkspacesDtoToModels, markDraftThreadId, messagesKeys, messagesListOptions, messagesMutationsKeys, modelsKeys, parseDateTime, parseDateTimeHuman, randomUUID, setThreadOptimisticRunning, setThreadRunningInLists, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useMessages, useModels, useSendMessage, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, utcDate, workspaceDetailOptions, workspaceKeys };
20757
+ export { ChatProvider, ChatVariablesForm, DRAFT_THREAD_PREFIX, DateFromApi, MarkdownEditor, MessageComposer, MessageList, MessageListSkeleton, MessageMarkdown, MessageValueType, NEW_THREAD_ID, THREAD_LIST_PAGE_SIZE, applyDeltaToMessage, applyThreadToCache, createDraftThreadId, createThreadId, downloadFileBlobOptions, filesKeys, flowRunsKeys, getModelIcon, getThreadPlaceholderFromListCache, getUserPhotoUrl, invalidateWorkspaceThreadLists, isDraftThreadId, mapFileInfoDtoToModel, mapMentionUserDtoToModel, mapMessageDtoToModel, mapMessageErrorDtoToModel, mapMessageValueDtoToModel, mapMessagesDtoToModels, mapSignalRThreadSummaryToModel, mapThreadDtoToModel, mapThreadsResponseDtoToModel, mapWorkspaceDtoToModel, mapWorkspacesDtoToModels, markDraftThreadId, messagesKeys, messagesListOptions, messagesMutationsKeys, modelsKeys, parseDateTime, parseDateTimeHuman, randomUUID, setThreadOptimisticRunning, setThreadRunningInLists, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useIsDraftThreadId, useMessages, useModels, useSendMessage, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, utcDate, workspaceDetailOptions, workspaceKeys };
20729
20758
  //# sourceMappingURL=index.js.map
20730
20759
  //# sourceMappingURL=index.js.map