@chrryai/chrry 1.6.85 → 1.6.86

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
@@ -3152,7 +3152,7 @@ var init_utils = __esm({
3152
3152
  };
3153
3153
  isFirefox = typeof navigator !== "undefined" && navigator?.userAgent?.includes("Firefox");
3154
3154
  config = getSiteConfig(getClientHostname());
3155
- VERSION = config.version || "1.6.85";
3155
+ VERSION = config.version || "1.6.86";
3156
3156
  getSlugFromPathname = (path) => {
3157
3157
  return getAppAndStoreSlugs(path, {
3158
3158
  defaultAppSlug: config.slug,
@@ -23953,7 +23953,6 @@ function AuthProvider({
23953
23953
  }
23954
23954
  });
23955
23955
  const threadId = getThreadId(pathname);
23956
- console.log(`\u{1F680} ~ threadId:`, threadId);
23957
23956
  const threadIdRef = (0, import_react20.useRef)(threadId);
23958
23957
  const [app, setAppInternal] = (0, import_react20.useState)(props.app || session2?.app || baseApp);
23959
23958
  (0, import_react20.useEffect)(() => {
@@ -24325,9 +24324,12 @@ function AuthProvider({
24325
24324
  const [thread2, setThreadInternal] = (0, import_react20.useState)(
24326
24325
  props.thread?.thread
24327
24326
  );
24327
+ const setThreadId = (id) => {
24328
+ threadIdRef.current = id;
24329
+ };
24328
24330
  const setThread = (thread3) => {
24331
+ setThreadId(thread3?.id);
24329
24332
  setThreadInternal(thread3);
24330
- threadIdRef.current = thread3?.id;
24331
24333
  };
24332
24334
  const [tasks, setTasks] = (0, import_react20.useState)(void 0);
24333
24335
  (0, import_react20.useEffect)(() => {
@@ -24638,6 +24640,7 @@ function AuthProvider({
24638
24640
  popcorn: popcorn2,
24639
24641
  zarathustra: zarathustra2,
24640
24642
  updateMood,
24643
+ setThreadId,
24641
24644
  lastAppId,
24642
24645
  storeApps,
24643
24646
  // All apps from all stores
@@ -24732,7 +24735,7 @@ function DataProvider({ children, ...rest }) {
24732
24735
  const [instructions, setInstructions] = (0, import_react21.useState)([]);
24733
24736
  const [affiliateStats, setAffiliateStats] = (0, import_react21.useState)(null);
24734
24737
  const [loadingAffiliateStats, setLoadingAffiliateStats] = (0, import_react21.useState)(false);
24735
- const VERSION4 = "1.6.85";
24738
+ const VERSION4 = "1.6.86";
24736
24739
  const [weather, setWeather] = useLocalStorage2("weather", user?.weather || guest?.weather || void 0);
24737
24740
  const {
24738
24741
  API_URL: API_URL2,
@@ -26506,13 +26509,13 @@ function ChatProvider({
26506
26509
  hasStoreApps,
26507
26510
  hasNotification,
26508
26511
  setHasNotification,
26512
+ setThreadId,
26509
26513
  ...auth
26510
26514
  } = useAuth();
26511
26515
  const [isChatFloating, setIsChatFloating] = (0, import_react29.useState)(false);
26512
26516
  const [input, setInput] = (0, import_react29.useState)("");
26513
26517
  const [messages, setMessages] = (0, import_react29.useState)(auth.threadData?.messages.messages || []);
26514
26518
  const isEmpty = !messages?.length;
26515
- console.log(`\u{1F680} ~ isEmpty:`, isEmpty);
26516
26519
  const { isExtension: isExtension2, isMobile } = usePlatform();
26517
26520
  const [shouldFetchThreads, setShouldFetchThreads] = (0, import_react29.useState)(!threads);
26518
26521
  let userNameByUrl = void 0;
@@ -26524,6 +26527,7 @@ function ChatProvider({
26524
26527
  const [collaborationStatus, setCollaborationStatusInternal] = (0, import_react29.useState)(
26525
26528
  user?.pendingCollaborationThreadsCount || guest?.pendingCollaborationThreadsCount ? "pending" : void 0
26526
26529
  );
26530
+ const toFetch = threadId || threadIdRef.current;
26527
26531
  (0, import_react29.useEffect)(() => {
26528
26532
  if (user && migratedFromGuestRef.current) {
26529
26533
  migratedFromGuestRef.current = false;
@@ -26537,7 +26541,7 @@ function ChatProvider({
26537
26541
  isLoading: isLoadingThreadsSwr,
26538
26542
  error: threadsError
26539
26543
  } = (0, import_swr3.default)(
26540
- token && shouldFetchThreads ? ["contextThreads", thread2?.id, app?.id, collaborationStatus] : null,
26544
+ token && shouldFetchThreads ? ["contextThreads", toFetch, app?.id, collaborationStatus] : null,
26541
26545
  async () => {
26542
26546
  try {
26543
26547
  const threads2 = await actions.getThreads({
@@ -26553,7 +26557,7 @@ function ChatProvider({
26553
26557
  collaborationStatus: collaborationStatus === "pending" ? void 0 : collaborationStatus,
26554
26558
  threadId: !thread2?.collaborations?.some(
26555
26559
  (c) => user && c.user.id === user?.id
26556
- ) || guest ? thread2?.id : void 0
26560
+ ) || guest ? toFetch : void 0
26557
26561
  });
26558
26562
  return threads2;
26559
26563
  } catch (error2) {
@@ -26667,6 +26671,7 @@ function ChatProvider({
26667
26671
  isIncognito && setWasIncognito(true);
26668
26672
  setCollaborationStatus(null);
26669
26673
  setIsChatFloating(false);
26674
+ setThreadId(void 0);
26670
26675
  router.push(to);
26671
26676
  refetchThreads();
26672
26677
  }
@@ -26769,8 +26774,8 @@ function ChatProvider({
26769
26774
  }, [threads]);
26770
26775
  const [isVisitor, setIsVisitor] = (0, import_react29.useState)(false);
26771
26776
  (0, import_react29.useEffect)(() => {
26772
- threadId && setIsNewChat(false);
26773
- }, [threadId]);
26777
+ toFetch && setIsNewChat(false);
26778
+ }, [toFetch]);
26774
26779
  (0, import_react29.useEffect)(() => {
26775
26780
  if (profile) {
26776
26781
  setIsVisitor(user?.id == profile.id);
@@ -26923,14 +26928,6 @@ function ChatProvider({
26923
26928
  setIsLoading(!!threadId);
26924
26929
  }, [threadId]);
26925
26930
  const [status, setStatus] = (0, import_react29.useState)(null);
26926
- const toFetch = threadId || threadIdRef.current;
26927
- console.log(`\u{1F680} ~ threadId, liked, until:`, {
26928
- shouldFetchThread,
26929
- threadId,
26930
- liked,
26931
- toFetch,
26932
- until
26933
- });
26934
26931
  const {
26935
26932
  data: threadSWR,
26936
26933
  mutate,
@@ -26938,7 +26935,6 @@ function ChatProvider({
26938
26935
  } = (0, import_swr3.default)(
26939
26936
  shouldFetchThread && token && toFetch ? [toFetch, liked, until] : null,
26940
26937
  async () => {
26941
- console.log(`\u{1F680} ~ toFetch:`, toFetch);
26942
26938
  if (!toFetch) return;
26943
26939
  const threadData2 = await actions.getThread({
26944
26940
  id: toFetch,
@@ -26949,7 +26945,6 @@ function ChatProvider({
26949
26945
  setStatus(error2);
26950
26946
  }
26951
26947
  });
26952
- console.log(`\u{1F680} ~ threadData:`, threadData2);
26953
26948
  setIsLoading(false);
26954
26949
  return threadData2;
26955
26950
  },
@@ -37457,11 +37452,11 @@ function Chat({
37457
37452
  setShouldFocus,
37458
37453
  shouldFocus,
37459
37454
  isChatFloating: isChatFloatingContext,
37460
- messages
37455
+ messages,
37456
+ isNewChat
37461
37457
  } = useChat();
37462
37458
  const {
37463
37459
  router,
37464
- isNewChat,
37465
37460
  isShowingCollaborate,
37466
37461
  collaborationStep,
37467
37462
  setCollaborationStep,
@@ -37476,6 +37471,12 @@ function Chat({
37476
37471
  const setThreadId = (id) => {
37477
37472
  threadIdRef.current = id;
37478
37473
  };
37474
+ (0, import_react55.useEffect)(() => {
37475
+ if (isNewChat) {
37476
+ setThreadId(void 0);
37477
+ auth.setThreadId(void 0);
37478
+ }
37479
+ }, [isNewChat]);
37479
37480
  const { captureException } = useError();
37480
37481
  const { device, os, isStandalone: isStandalone2, isExtension: isExtension2, viewPortWidth, isWeb: isWeb2 } = usePlatform();
37481
37482
  const inputRef = (0, import_react55.useRef)(text || "");