@chrryai/chrry 1.6.86 → 1.6.87

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.86";
3155
+ VERSION = config.version || "1.6.87";
3156
3156
  getSlugFromPathname = (path) => {
3157
3157
  return getAppAndStoreSlugs(path, {
3158
3158
  defaultAppSlug: config.slug,
@@ -24735,7 +24735,7 @@ function DataProvider({ children, ...rest }) {
24735
24735
  const [instructions, setInstructions] = (0, import_react21.useState)([]);
24736
24736
  const [affiliateStats, setAffiliateStats] = (0, import_react21.useState)(null);
24737
24737
  const [loadingAffiliateStats, setLoadingAffiliateStats] = (0, import_react21.useState)(false);
24738
- const VERSION4 = "1.6.86";
24738
+ const VERSION4 = "1.6.87";
24739
24739
  const [weather, setWeather] = useLocalStorage2("weather", user?.weather || guest?.weather || void 0);
24740
24740
  const {
24741
24741
  API_URL: API_URL2,
@@ -26920,7 +26920,7 @@ function ChatProvider({
26920
26920
  setSelectedAgent(sushiAgent);
26921
26921
  }
26922
26922
  }, [appStatus?.part]);
26923
- const [shouldFetchThread, setShouldFetchThread] = (0, import_react29.useState)(true);
26923
+ const [shouldFetchThread, setShouldFetchThread] = (0, import_react29.useState)(!auth.threadData);
26924
26924
  const [until, setUntil] = (0, import_react29.useState)(1);
26925
26925
  const [liked, setLiked] = (0, import_react29.useState)(void 0);
26926
26926
  const [isLoading, setIsLoading] = (0, import_react29.useState)(!!threadId);
@@ -26980,7 +26980,7 @@ function ChatProvider({
26980
26980
  const defaultAgent = aiAgents.find((a) => app?.defaultModel && a.name === app?.defaultModel) || favouriteAgent;
26981
26981
  const [selectedAgent, setSelectedAgentInternal] = useLocalStorage2("selectedAgent", defaultAgent);
26982
26982
  (0, import_react29.useEffect)(() => {
26983
- !selectedAgent && setSelectedAgent(defaultAgent);
26983
+ selectedAgent !== null && setSelectedAgent(defaultAgent);
26984
26984
  }, [defaultAgent, selectedAgent]);
26985
26985
  const setIsWebSearchEnabled = (value) => {
26986
26986
  value ? setSelectedAgent(perplexityAgent) : void 0;
@@ -27093,13 +27093,7 @@ function ChatProvider({
27093
27093
  if (threadData?.thread && Array.isArray(serverMessages.messages)) {
27094
27094
  if (lastProcessedThreadDataRef.current === threadData) return;
27095
27095
  lastProcessedThreadDataRef.current = threadData;
27096
- if (liked) {
27097
- setMessages(serverMessages.messages);
27098
- } else if (serverMessages.messages.length > 0) {
27099
- setMessages(serverMessages.messages);
27100
- } else if (isNewChat) {
27101
- setMessages([]);
27102
- }
27096
+ !isDebating && setMessages(serverMessages.messages);
27103
27097
  setNextPage(threadData.messages.nextPage);
27104
27098
  setThread(threadData.thread);
27105
27099
  isNewChat && setStatus(null);
@@ -38827,8 +38821,9 @@ function Chat({
38827
38821
  if (data?.message && isOwner_default(data.message.message, {
38828
38822
  userId: user?.id,
38829
38823
  guestId: guest?.id
38830
- }) ? data?.deviceId !== deviceId : true)
38824
+ }) ? data?.deviceId && data?.deviceId !== deviceId : false) {
38831
38825
  return;
38826
+ }
38832
38827
  const chunk = data?.chunk;
38833
38828
  if (type === "stream_update" && chunk && clientId2 && data.message) {
38834
38829
  if (isSpeechActive && os !== "ios") {
@@ -50652,19 +50647,65 @@ var init_Thread = __esm({
50652
50647
  }
50653
50648
  if (!clientId) return;
50654
50649
  setMessages((prev) => {
50655
- return prev.map(
50656
- (m) => m.message.id === clientId && !m.message.isStreamingStop ? {
50657
- ...m,
50650
+ const existingIndex = prev.findIndex(
50651
+ (m) => m.message.id === clientId && !m.message.isStreamingStop
50652
+ );
50653
+ if (existingIndex >= 0) {
50654
+ return prev.map(
50655
+ (m) => m.message.id === clientId && !m.message.isStreamingStop ? {
50656
+ ...m,
50657
+ message: {
50658
+ ...m.message,
50659
+ content,
50660
+ isStreaming: true,
50661
+ isWebSearchEnabled: !!isWebSearchEnabled2,
50662
+ isImageGenerationEnabled: !!isImageGenerationEnabled
50663
+ },
50664
+ aiAgent: aiAgent ?? m.aiAgent
50665
+ } : m
50666
+ );
50667
+ }
50668
+ return [
50669
+ ...prev,
50670
+ {
50658
50671
  message: {
50659
- ...m.message,
50672
+ id: clientId,
50673
+ type: "chat",
50660
50674
  content,
50661
- isStreaming: true,
50675
+ createdOn: /* @__PURE__ */ new Date(),
50676
+ updatedOn: /* @__PURE__ */ new Date(),
50677
+ agentId: aiAgent?.id || null,
50678
+ agentVersion: aiAgent?.version || null,
50679
+ threadId: threadId || "",
50680
+ readOn: /* @__PURE__ */ new Date(),
50681
+ userId: user?.id || null,
50682
+ guestId: guest?.id || null,
50683
+ searchContext: null,
50684
+ webSearchResult: null,
50685
+ metadata: null,
50686
+ originalContent: content,
50687
+ images: null,
50688
+ files: null,
50662
50689
  isWebSearchEnabled: !!isWebSearchEnabled2,
50663
- isImageGenerationEnabled: !!isImageGenerationEnabled
50690
+ isImageGenerationEnabled: !!isImageGenerationEnabled,
50691
+ isStreaming: true,
50692
+ reasoning: null,
50693
+ like: null,
50694
+ dislike: null,
50695
+ creditCost: aiAgent?.creditCost || 1,
50696
+ task: "chat",
50697
+ reactions: null,
50698
+ clientId,
50699
+ audio: null,
50700
+ video: null,
50701
+ selectedAgentId: aiAgent?.id || null,
50702
+ debateAgentId: null,
50703
+ pauseDebate: false
50664
50704
  },
50665
- aiAgent: aiAgent ?? m.aiAgent
50666
- } : m
50667
- );
50705
+ aiAgent,
50706
+ thread: thread2
50707
+ }
50708
+ ];
50668
50709
  });
50669
50710
  },
50670
50711
  [isLoadingMore, scrollToBottom, setMessages, shouldAutoScroll]
@@ -51114,7 +51155,7 @@ var init_Thread = __esm({
51114
51155
  return m;
51115
51156
  })
51116
51157
  );
51117
- if (!isIncognito && !id && message2?.message.threadId && (debateAgent ? message2.message.agentId === debateAgent?.id : true)) {
51158
+ if (!isIncognito && !id && message2?.message.threadId) {
51118
51159
  requestAnimationFrame(() => {
51119
51160
  const navigationOptions = {
51120
51161
  state: { preservedThread: thread2 }