@chrryai/chrry 1.6.84 → 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.84";
3155
+ VERSION = config.version || "1.6.86";
3156
3156
  getSlugFromPathname = (path) => {
3157
3157
  return getAppAndStoreSlugs(path, {
3158
3158
  defaultAppSlug: config.slug,
@@ -24324,9 +24324,12 @@ function AuthProvider({
24324
24324
  const [thread2, setThreadInternal] = (0, import_react20.useState)(
24325
24325
  props.thread?.thread
24326
24326
  );
24327
+ const setThreadId = (id) => {
24328
+ threadIdRef.current = id;
24329
+ };
24327
24330
  const setThread = (thread3) => {
24331
+ setThreadId(thread3?.id);
24328
24332
  setThreadInternal(thread3);
24329
- threadIdRef.current = thread3?.id;
24330
24333
  };
24331
24334
  const [tasks, setTasks] = (0, import_react20.useState)(void 0);
24332
24335
  (0, import_react20.useEffect)(() => {
@@ -24637,6 +24640,7 @@ function AuthProvider({
24637
24640
  popcorn: popcorn2,
24638
24641
  zarathustra: zarathustra2,
24639
24642
  updateMood,
24643
+ setThreadId,
24640
24644
  lastAppId,
24641
24645
  storeApps,
24642
24646
  // All apps from all stores
@@ -24731,7 +24735,7 @@ function DataProvider({ children, ...rest }) {
24731
24735
  const [instructions, setInstructions] = (0, import_react21.useState)([]);
24732
24736
  const [affiliateStats, setAffiliateStats] = (0, import_react21.useState)(null);
24733
24737
  const [loadingAffiliateStats, setLoadingAffiliateStats] = (0, import_react21.useState)(false);
24734
- const VERSION4 = "1.6.84";
24738
+ const VERSION4 = "1.6.86";
24735
24739
  const [weather, setWeather] = useLocalStorage2("weather", user?.weather || guest?.weather || void 0);
24736
24740
  const {
24737
24741
  API_URL: API_URL2,
@@ -26495,6 +26499,7 @@ function ChatProvider({
26495
26499
  claudeAgent,
26496
26500
  favouriteAgent,
26497
26501
  threadIdRef,
26502
+ threadId,
26498
26503
  migratedFromGuestRef,
26499
26504
  fetchSession,
26500
26505
  loadingApp,
@@ -26504,9 +26509,9 @@ function ChatProvider({
26504
26509
  hasStoreApps,
26505
26510
  hasNotification,
26506
26511
  setHasNotification,
26512
+ setThreadId,
26507
26513
  ...auth
26508
26514
  } = useAuth();
26509
- const threadId = threadIdRef.current;
26510
26515
  const [isChatFloating, setIsChatFloating] = (0, import_react29.useState)(false);
26511
26516
  const [input, setInput] = (0, import_react29.useState)("");
26512
26517
  const [messages, setMessages] = (0, import_react29.useState)(auth.threadData?.messages.messages || []);
@@ -26522,6 +26527,7 @@ function ChatProvider({
26522
26527
  const [collaborationStatus, setCollaborationStatusInternal] = (0, import_react29.useState)(
26523
26528
  user?.pendingCollaborationThreadsCount || guest?.pendingCollaborationThreadsCount ? "pending" : void 0
26524
26529
  );
26530
+ const toFetch = threadId || threadIdRef.current;
26525
26531
  (0, import_react29.useEffect)(() => {
26526
26532
  if (user && migratedFromGuestRef.current) {
26527
26533
  migratedFromGuestRef.current = false;
@@ -26535,7 +26541,7 @@ function ChatProvider({
26535
26541
  isLoading: isLoadingThreadsSwr,
26536
26542
  error: threadsError
26537
26543
  } = (0, import_swr3.default)(
26538
- token && shouldFetchThreads ? ["contextThreads", thread2?.id, app?.id, collaborationStatus] : null,
26544
+ token && shouldFetchThreads ? ["contextThreads", toFetch, app?.id, collaborationStatus] : null,
26539
26545
  async () => {
26540
26546
  try {
26541
26547
  const threads2 = await actions.getThreads({
@@ -26551,7 +26557,7 @@ function ChatProvider({
26551
26557
  collaborationStatus: collaborationStatus === "pending" ? void 0 : collaborationStatus,
26552
26558
  threadId: !thread2?.collaborations?.some(
26553
26559
  (c) => user && c.user.id === user?.id
26554
- ) || guest ? thread2?.id : void 0
26560
+ ) || guest ? toFetch : void 0
26555
26561
  });
26556
26562
  return threads2;
26557
26563
  } catch (error2) {
@@ -26665,6 +26671,7 @@ function ChatProvider({
26665
26671
  isIncognito && setWasIncognito(true);
26666
26672
  setCollaborationStatus(null);
26667
26673
  setIsChatFloating(false);
26674
+ setThreadId(void 0);
26668
26675
  router.push(to);
26669
26676
  refetchThreads();
26670
26677
  }
@@ -26767,8 +26774,8 @@ function ChatProvider({
26767
26774
  }, [threads]);
26768
26775
  const [isVisitor, setIsVisitor] = (0, import_react29.useState)(false);
26769
26776
  (0, import_react29.useEffect)(() => {
26770
- threadId && setIsNewChat(false);
26771
- }, [threadId]);
26777
+ toFetch && setIsNewChat(false);
26778
+ }, [toFetch]);
26772
26779
  (0, import_react29.useEffect)(() => {
26773
26780
  if (profile) {
26774
26781
  setIsVisitor(user?.id == profile.id);
@@ -26926,11 +26933,11 @@ function ChatProvider({
26926
26933
  mutate,
26927
26934
  error
26928
26935
  } = (0, import_swr3.default)(
26929
- shouldFetchThread && token && threadId ? [threadId, liked, until] : null,
26936
+ shouldFetchThread && token && toFetch ? [toFetch, liked, until] : null,
26930
26937
  async () => {
26931
- if (!threadId) return;
26938
+ if (!toFetch) return;
26932
26939
  const threadData2 = await actions.getThread({
26933
- id: threadId,
26940
+ id: toFetch,
26934
26941
  pageSize: until * pageSizes.threads,
26935
26942
  liked: !!liked,
26936
26943
  onError: (error2) => {
@@ -27078,7 +27085,7 @@ function ChatProvider({
27078
27085
  isLoading && error && setIsLoading(false);
27079
27086
  }, [error, isLoading]);
27080
27087
  (0, import_react29.useEffect)(() => {
27081
- if (!threadId) {
27088
+ if (!toFetch) {
27082
27089
  status && setStatus(null);
27083
27090
  return;
27084
27091
  }
@@ -27135,7 +27142,7 @@ function ChatProvider({
27135
27142
  setShouldFetchThread,
27136
27143
  refetchThread: async () => {
27137
27144
  setShouldFetchThread(true);
27138
- shouldFetchThread && await mutate();
27145
+ await mutate();
27139
27146
  },
27140
27147
  setIsWebSearchEnabled,
27141
27148
  input,
@@ -37411,8 +37418,10 @@ function Chat({
37411
37418
  mood,
37412
37419
  updateMood,
37413
37420
  taskId,
37414
- fetchTasks
37421
+ fetchTasks,
37422
+ ...auth
37415
37423
  } = useAuth();
37424
+ const threadId = auth.threadId || auth.threadIdRef.current;
37416
37425
  const [isSelectingMood, setIsSelectingMood] = (0, import_react55.useState)(false);
37417
37426
  const isChrry = chrry?.id === app?.id;
37418
37427
  const {
@@ -37433,7 +37442,6 @@ function Chat({
37433
37442
  hitHourlyLimit,
37434
37443
  hourlyLimit,
37435
37444
  isEmpty: empty,
37436
- threadId,
37437
37445
  isAgentModalOpen,
37438
37446
  setIsAgentModalOpen,
37439
37447
  isDebateAgentModalOpen,
@@ -37444,11 +37452,11 @@ function Chat({
37444
37452
  setShouldFocus,
37445
37453
  shouldFocus,
37446
37454
  isChatFloating: isChatFloatingContext,
37447
- messages
37455
+ messages,
37456
+ isNewChat
37448
37457
  } = useChat();
37449
37458
  const {
37450
37459
  router,
37451
- isNewChat,
37452
37460
  isShowingCollaborate,
37453
37461
  collaborationStep,
37454
37462
  setCollaborationStep,
@@ -37463,6 +37471,12 @@ function Chat({
37463
37471
  const setThreadId = (id) => {
37464
37472
  threadIdRef.current = id;
37465
37473
  };
37474
+ (0, import_react55.useEffect)(() => {
37475
+ if (isNewChat) {
37476
+ setThreadId(void 0);
37477
+ auth.setThreadId(void 0);
37478
+ }
37479
+ }, [isNewChat]);
37466
37480
  const { captureException } = useError();
37467
37481
  const { device, os, isStandalone: isStandalone2, isExtension: isExtension2, viewPortWidth, isWeb: isWeb2 } = usePlatform();
37468
37482
  const inputRef = (0, import_react55.useRef)(text || "");
@@ -50518,7 +50532,16 @@ var init_Thread = __esm({
50518
50532
  }) => {
50519
50533
  const styles4 = useThreadStyles();
50520
50534
  const { t: t5 } = useAppContext();
50521
- const { user, guest, track, memoriesEnabled, setShowFocus, ...auth } = useAuth();
50535
+ const {
50536
+ user,
50537
+ guest,
50538
+ track,
50539
+ threadIdRef,
50540
+ memoriesEnabled,
50541
+ setShowFocus,
50542
+ ...auth
50543
+ } = useAuth();
50544
+ const threadId = auth.threadId || threadIdRef.current;
50522
50545
  const {
50523
50546
  isWebSearchEnabled,
50524
50547
  selectedAgent,
@@ -50564,7 +50587,7 @@ var init_Thread = __esm({
50564
50587
  isIncognito,
50565
50588
  goToCalendar
50566
50589
  } = useNavigationContext();
50567
- const { threadId, setShouldGetCredits } = useChat();
50590
+ const { setShouldGetCredits } = useChat();
50568
50591
  const setMessages = setMessagesInternal;
50569
50592
  const { appStatus, appFormWatcher, suggestSaveApp } = useApp();
50570
50593
  const { addHapticFeedback, isMobileDevice, isSmallDevice } = useTheme2();
@@ -51121,10 +51144,10 @@ function Home({
51121
51144
  className,
51122
51145
  slug
51123
51146
  }) {
51124
- const { language, threadId } = useAuth();
51147
+ const { language, threadId, threadIdRef } = useAuth();
51125
51148
  const { currentStore: store, app } = useApp();
51126
51149
  useAppMetadata2();
51127
- return /* @__PURE__ */ React.createElement(Div, { "data-url": language === defaultLocale ? "/" : `/${language}` }, /* @__PURE__ */ React.createElement(Thread_default, { isHome: true }));
51150
+ return /* @__PURE__ */ React.createElement(Div, { "data-url": language === defaultLocale ? "/" : `/${language}` }, /* @__PURE__ */ React.createElement(Thread_default, { isHome: !threadId && !threadIdRef.current }));
51128
51151
  }
51129
51152
  var init_Home = __esm({
51130
51153
  "Home.tsx"() {