@anakin824/prdg-chat-ui 0.3.2 → 0.3.3

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.mts CHANGED
@@ -482,6 +482,8 @@ type Props = {
482
482
  };
483
483
  declare function TypingIndicator({ names }: Props): react.JSX.Element | null;
484
484
 
485
+ /** UUIDs are case-insensitive; normalize so NATS + UI always share one cache entry. */
486
+ declare function normalizeConversationCacheId(conversationId: string | null): string | null;
485
487
  /** Stable React Query keys for chat — use with invalidateQueries / host integrations. */
486
488
  declare const chatKeys: {
487
489
  all: readonly ["chat"];
@@ -734,4 +736,4 @@ declare function useVoiceRecorder(): {
734
736
  } | null>;
735
737
  };
736
738
 
737
- export { type AppUser, ChatAPI, type ChatAppearance, MessageInput as ChatComposer, type ChatConfig, type ChatContextValue, ChatConversationView, type ChatConversationViewProps, ChatInboxSidebar, type ChatInboxSidebarProps, ChatMainColumn, type ChatMainColumnProps, ChatPanel, type ChatPanelProps, ChatProvider, type ChatProviderProps, type ChatTheme, ChatWidget, type ChatWidgetProps, type Conversation, ConversationList, type EntityConversationContext as EntityContext, INITIAL_MESSAGE_PAGE_SIZE, type Message, type MessageAttachment, MessageBubble, MessageInput, type MessagePage, MessageThread, NewChatModal, type SidebarTab, StandaloneChatPage, type StandaloneChatPageProps, TypingIndicator, type UserIdentityMode, type WSServerEvent, chatKeys, convDisplayName, convLabel, formatConvTime, initials, mergeMessagePages, useChat, useChatActions, useChatPanelController, useConversationMembers, useConversations, useMessages, usePresignedUrl, useUpload, useVoiceRecorder };
739
+ export { type AppUser, ChatAPI, type ChatAppearance, MessageInput as ChatComposer, type ChatConfig, type ChatContextValue, ChatConversationView, type ChatConversationViewProps, ChatInboxSidebar, type ChatInboxSidebarProps, ChatMainColumn, type ChatMainColumnProps, ChatPanel, type ChatPanelProps, ChatProvider, type ChatProviderProps, type ChatTheme, ChatWidget, type ChatWidgetProps, type Conversation, ConversationList, type EntityConversationContext as EntityContext, INITIAL_MESSAGE_PAGE_SIZE, type Message, type MessageAttachment, MessageBubble, MessageInput, type MessagePage, MessageThread, NewChatModal, type SidebarTab, StandaloneChatPage, type StandaloneChatPageProps, TypingIndicator, type UserIdentityMode, type WSServerEvent, chatKeys, convDisplayName, convLabel, formatConvTime, initials, mergeMessagePages, normalizeConversationCacheId, useChat, useChatActions, useChatPanelController, useConversationMembers, useConversations, useMessages, usePresignedUrl, useUpload, useVoiceRecorder };
package/dist/index.d.ts CHANGED
@@ -482,6 +482,8 @@ type Props = {
482
482
  };
483
483
  declare function TypingIndicator({ names }: Props): react.JSX.Element | null;
484
484
 
485
+ /** UUIDs are case-insensitive; normalize so NATS + UI always share one cache entry. */
486
+ declare function normalizeConversationCacheId(conversationId: string | null): string | null;
485
487
  /** Stable React Query keys for chat — use with invalidateQueries / host integrations. */
486
488
  declare const chatKeys: {
487
489
  all: readonly ["chat"];
@@ -734,4 +736,4 @@ declare function useVoiceRecorder(): {
734
736
  } | null>;
735
737
  };
736
738
 
737
- export { type AppUser, ChatAPI, type ChatAppearance, MessageInput as ChatComposer, type ChatConfig, type ChatContextValue, ChatConversationView, type ChatConversationViewProps, ChatInboxSidebar, type ChatInboxSidebarProps, ChatMainColumn, type ChatMainColumnProps, ChatPanel, type ChatPanelProps, ChatProvider, type ChatProviderProps, type ChatTheme, ChatWidget, type ChatWidgetProps, type Conversation, ConversationList, type EntityConversationContext as EntityContext, INITIAL_MESSAGE_PAGE_SIZE, type Message, type MessageAttachment, MessageBubble, MessageInput, type MessagePage, MessageThread, NewChatModal, type SidebarTab, StandaloneChatPage, type StandaloneChatPageProps, TypingIndicator, type UserIdentityMode, type WSServerEvent, chatKeys, convDisplayName, convLabel, formatConvTime, initials, mergeMessagePages, useChat, useChatActions, useChatPanelController, useConversationMembers, useConversations, useMessages, usePresignedUrl, useUpload, useVoiceRecorder };
739
+ export { type AppUser, ChatAPI, type ChatAppearance, MessageInput as ChatComposer, type ChatConfig, type ChatContextValue, ChatConversationView, type ChatConversationViewProps, ChatInboxSidebar, type ChatInboxSidebarProps, ChatMainColumn, type ChatMainColumnProps, ChatPanel, type ChatPanelProps, ChatProvider, type ChatProviderProps, type ChatTheme, ChatWidget, type ChatWidgetProps, type Conversation, ConversationList, type EntityConversationContext as EntityContext, INITIAL_MESSAGE_PAGE_SIZE, type Message, type MessageAttachment, MessageBubble, MessageInput, type MessagePage, MessageThread, NewChatModal, type SidebarTab, StandaloneChatPage, type StandaloneChatPageProps, TypingIndicator, type UserIdentityMode, type WSServerEvent, chatKeys, convDisplayName, convLabel, formatConvTime, initials, mergeMessagePages, normalizeConversationCacheId, useChat, useChatActions, useChatPanelController, useConversationMembers, useConversations, useMessages, usePresignedUrl, useUpload, useVoiceRecorder };
package/dist/index.js CHANGED
@@ -185,10 +185,15 @@ function chatDebugWarn(debug, ...args) {
185
185
  }
186
186
 
187
187
  // src/chat/lib/queryKeys.ts
188
+ function normalizeConversationCacheId(conversationId) {
189
+ if (conversationId == null) return null;
190
+ const t = conversationId.trim();
191
+ return t ? t.toLowerCase() : null;
192
+ }
188
193
  var chatKeys = {
189
194
  all: ["chat"],
190
195
  conversations: () => [...chatKeys.all, "conversations"],
191
- messages: (conversationId) => [...chatKeys.all, "messages", conversationId],
196
+ messages: (conversationId) => [...chatKeys.all, "messages", normalizeConversationCacheId(conversationId)],
192
197
  members: (conversationId) => [...chatKeys.all, "members", conversationId],
193
198
  contacts: (q) => [...chatKeys.all, "contacts", q]
194
199
  };
@@ -255,7 +260,10 @@ function getMessagePageSummary(queryClient, conversationId) {
255
260
  function pushMessageToCache(queryClient, msg) {
256
261
  let result = "missing-cache";
257
262
  queryClient.setQueryData(chatKeys.messages(msg.conversation_id), (prev) => {
258
- if (!prev) return void 0;
263
+ if (!prev) {
264
+ result = "seeded";
265
+ return { items: [msg], next_cursor: "" };
266
+ }
259
267
  if (prev.items.some((m) => m.id === msg.id)) {
260
268
  result = "duplicate";
261
269
  return prev;
@@ -433,11 +441,12 @@ function ChatNatsBridge({ natsWsUrl, natsToken, onConnectedChange }) {
433
441
  const connRef = react.useRef(null);
434
442
  react.useEffect(() => {
435
443
  if (servers.length === 0) return;
444
+ const entityConvIds = entityKey ? entityKey.split(",").filter(Boolean) : [];
436
445
  chatDebugLog(debug, "ChatNatsBridge: starting subscriptions", {
437
446
  userId,
438
447
  natsTenantId,
439
448
  servers,
440
- entityConversationIds
449
+ entityConversationIds: entityConvIds
441
450
  });
442
451
  let cancelled = false;
443
452
  void (async () => {
@@ -530,7 +539,7 @@ function ChatNatsBridge({ natsWsUrl, natsToken, onConnectedChange }) {
530
539
  handleMsg(m.data, m.subject);
531
540
  }
532
541
  })();
533
- for (const convId of entityConversationIds) {
542
+ for (const convId of entityConvIds) {
534
543
  const subj = entityConversationSubject(natsTenantId, convId);
535
544
  chatDebugLog(debug, "ChatNatsBridge: subscribing entity conversation", {
536
545
  conversationId: convId,
@@ -547,7 +556,7 @@ function ChatNatsBridge({ natsWsUrl, natsToken, onConnectedChange }) {
547
556
  if (process.env.NODE_ENV === "development") {
548
557
  const subjectList = [
549
558
  inbox,
550
- ...entityConversationIds.map((id) => entityConversationSubject(natsTenantId, id))
559
+ ...entityConvIds.map((id) => entityConversationSubject(natsTenantId, id))
551
560
  ];
552
561
  console.info("[NATS] WebSocket connected \u2014 servers:", servers, "subjects:", subjectList);
553
562
  void (async () => {
@@ -578,7 +587,7 @@ function ChatNatsBridge({ natsWsUrl, natsToken, onConnectedChange }) {
578
587
  connRef.current = null;
579
588
  void c?.drain();
580
589
  };
581
- }, [servers, natsToken, natsTenantId, userId, entityKey, queryClient, entityConversationIds, debug]);
590
+ }, [servers, natsToken, natsTenantId, userId, entityKey, queryClient, debug]);
582
591
  return null;
583
592
  }
584
593
 
@@ -2422,6 +2431,7 @@ exports.convLabel = convLabel;
2422
2431
  exports.formatConvTime = formatConvTime;
2423
2432
  exports.initials = initials2;
2424
2433
  exports.mergeMessagePages = mergeMessagePages;
2434
+ exports.normalizeConversationCacheId = normalizeConversationCacheId;
2425
2435
  exports.useChat = useChat;
2426
2436
  exports.useChatActions = useChatActions;
2427
2437
  exports.useChatPanelController = useChatPanelController;