@liveblocks/react 3.4.0 → 3.4.2

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.
@@ -170,6 +170,7 @@ function useSignal(signal, selector, isEqual) {
170
170
  // src/liveblocks.tsx
171
171
  import {
172
172
  assert,
173
+ console as console2,
173
174
  createClient,
174
175
  HttpError,
175
176
  kInternal as kInternal3,
@@ -290,7 +291,7 @@ import {
290
291
  autoRetry,
291
292
  batch as batch2,
292
293
  compactObject,
293
- console as console2,
294
+ console,
294
295
  createNotificationSettings,
295
296
  DefaultMap,
296
297
  DerivedSignal,
@@ -1790,7 +1791,7 @@ function applyUpsertComment(thread, comment) {
1790
1791
  return thread;
1791
1792
  }
1792
1793
  if (comment.threadId !== thread.id) {
1793
- console2.warn(
1794
+ console.warn(
1794
1795
  `Comment ${comment.id} does not belong to thread ${thread.id}`
1795
1796
  );
1796
1797
  return thread;
@@ -2071,7 +2072,7 @@ function makeLiveblocksExtrasForClient(client) {
2071
2072
  try {
2072
2073
  return await store.fetchNotificationsDeltaUpdate(signal);
2073
2074
  } catch (err) {
2074
- console.warn(`Polling new inbox notifications failed: ${String(err)}`);
2075
+ console2.warn(`Polling new inbox notifications failed: ${String(err)}`);
2075
2076
  throw err;
2076
2077
  }
2077
2078
  },
@@ -2083,7 +2084,7 @@ function makeLiveblocksExtrasForClient(client) {
2083
2084
  try {
2084
2085
  return await store.fetchUserThreadsDeltaUpdate(signal);
2085
2086
  } catch (err) {
2086
- console.warn(`Polling new user threads failed: ${String(err)}`);
2087
+ console2.warn(`Polling new user threads failed: ${String(err)}`);
2087
2088
  throw err;
2088
2089
  }
2089
2090
  },
@@ -2095,7 +2096,7 @@ function makeLiveblocksExtrasForClient(client) {
2095
2096
  try {
2096
2097
  return await store.refreshNotificationSettings(signal);
2097
2098
  } catch (err) {
2098
- console.warn(
2099
+ console2.warn(
2099
2100
  `Polling new notification settings failed: ${String(err)}`
2100
2101
  );
2101
2102
  throw err;
@@ -2363,7 +2364,7 @@ function useUpdateNotificationSettings_withClient(client) {
2363
2364
  if (err instanceof HttpError) {
2364
2365
  if (err.status === 422) {
2365
2366
  const msg = [err.details?.error, err.details?.reason].filter(Boolean).join("\n");
2366
- console.error(msg);
2367
+ console2.error(msg);
2367
2368
  }
2368
2369
  client[kInternal3].emitError(
2369
2370
  {
@@ -2637,7 +2638,7 @@ function useCreateAiChat() {
2637
2638
  title: options.title,
2638
2639
  metadata: options.metadata
2639
2640
  }).catch((err) => {
2640
- console.error(
2641
+ console2.error(
2641
2642
  `Failed to create chat with ID "${options.id}": ${String(err)}`
2642
2643
  );
2643
2644
  });
@@ -2650,7 +2651,7 @@ function useDeleteAiChat() {
2650
2651
  return useCallback2(
2651
2652
  (chatId) => {
2652
2653
  client[kInternal3].ai.deleteChat(chatId).catch((err) => {
2653
- console.error(
2654
+ console2.error(
2654
2655
  `Failed to delete chat with ID "${chatId}": ${String(err)}`
2655
2656
  );
2656
2657
  });
@@ -2665,6 +2666,7 @@ function useSendAiMessage(chatId, options) {
2665
2666
  const {
2666
2667
  text: messageText,
2667
2668
  chatId: messageOptionsChatId,
2669
+ copilotId: messageOptionsCopilotId,
2668
2670
  ...messageOptions
2669
2671
  } = typeof message === "string" ? { text: message } : message;
2670
2672
  const resolvedChatId = messageOptionsChatId ?? chatId ?? // The `useSendAiMessage` overloads prevent this scenario from happening
@@ -2673,6 +2675,19 @@ function useSendAiMessage(chatId, options) {
2673
2675
  "chatId must be provided to either `useSendAiMessage` or its returned function."
2674
2676
  );
2675
2677
  const messages = client[kInternal3].ai.signals.getChatMessagesForBranch\u03A3(resolvedChatId).get();
2678
+ if (process.env.NODE_ENV !== "production" && !messageOptionsCopilotId && !options?.copilotId) {
2679
+ console2.warn(
2680
+ `No copilot ID was provided to useSendAiMessage when sending the message "${messageText.slice(
2681
+ 0,
2682
+ 20
2683
+ )}\u2026". As a result, the message will use the chat's previous copilot ID, which could lead to unexpected behavior.
2684
+ To ensure the correct copilot ID is used, specify it either through the hook as 'useSendAiMessage("${resolvedChatId}", { copilotId: "co_xxx" })' or via the function as 'sendAiMessage({ text: "${messageText.slice(
2685
+ 0,
2686
+ 20
2687
+ )}\u2026", copilotId: "co_xxx" })'`
2688
+ );
2689
+ }
2690
+ const resolvedCopilotId = messageOptionsCopilotId ?? options?.copilotId ?? client[kInternal3].ai.getLastUsedCopilotId(resolvedChatId);
2676
2691
  const lastMessageId = messages[messages.length - 1]?.id ?? null;
2677
2692
  const content = [{ type: "text", text: messageText }];
2678
2693
  const newMessageId = client[kInternal3].ai[kInternal3].context.messagesStore.createOptimistically(
@@ -2685,7 +2700,8 @@ function useSendAiMessage(chatId, options) {
2685
2700
  const targetMessageId = client[kInternal3].ai[kInternal3].context.messagesStore.createOptimistically(
2686
2701
  resolvedChatId,
2687
2702
  "assistant",
2688
- newMessageId
2703
+ newMessageId,
2704
+ resolvedCopilotId
2689
2705
  );
2690
2706
  void client[kInternal3].ai.askUserMessageInChat(
2691
2707
  resolvedChatId,
@@ -2693,7 +2709,7 @@ function useSendAiMessage(chatId, options) {
2693
2709
  targetMessageId,
2694
2710
  {
2695
2711
  stream: messageOptions.stream ?? options?.stream,
2696
- copilotId: messageOptions.copilotId ?? options?.copilotId,
2712
+ copilotId: resolvedCopilotId,
2697
2713
  timeout: messageOptions.timeout ?? options?.timeout,
2698
2714
  knowledge: messageOptions.knowledge ?? options?.knowledge
2699
2715
  }
@@ -4676,4 +4692,4 @@ export {
4676
4692
  _useStorageRoot,
4677
4693
  _useUpdateMyPresence
4678
4694
  };
4679
- //# sourceMappingURL=chunk-TYQDESJE.js.map
4695
+ //# sourceMappingURL=chunk-I2UW4JM4.js.map