@axiom-lattice/react-sdk 2.1.101 → 2.1.103

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.mjs CHANGED
@@ -1936,6 +1936,7 @@ function AgentThreadProvider({
1936
1936
  const sendMessageStreamsRef = useRef6(/* @__PURE__ */ new Map());
1937
1937
  const chunkMessageMerger = useRef6(createSimpleMessageMerger2());
1938
1938
  const lastAgentStateCreatedAtRef = useRef6(null);
1939
+ const streamEndedByInterruptRef = useRef6(false);
1939
1940
  const messageCountRef = useRef6(0);
1940
1941
  const onToolCompletedRef = useRef6(onToolCompleted);
1941
1942
  onToolCompletedRef.current = onToolCompleted;
@@ -2021,6 +2022,7 @@ function AgentThreadProvider({
2021
2022
  let interrupt;
2022
2023
  if (chunk.type === "interrupt") {
2023
2024
  const rawChunk = chunk;
2025
+ streamEndedByInterruptRef.current = true;
2024
2026
  interrupt = {
2025
2027
  type: "interrupt",
2026
2028
  id: rawChunk.id,
@@ -2064,6 +2066,7 @@ function AgentThreadProvider({
2064
2066
  if (!threadId) {
2065
2067
  throw new Error("Thread ID is required to send messages");
2066
2068
  }
2069
+ streamEndedByInterruptRef.current = false;
2067
2070
  sendMessageStreamsRef.current.forEach((stopFn) => {
2068
2071
  stopFn();
2069
2072
  });
@@ -2124,9 +2127,10 @@ function AgentThreadProvider({
2124
2127
  },
2125
2128
  // Chunks handled by resumeStream
2126
2129
  async () => {
2127
- if (options.enableReturnStateWhenStreamCompleted) {
2130
+ if (options.enableReturnStateWhenStreamCompleted && !streamEndedByInterruptRef.current) {
2128
2131
  await fetchAndUpdateAgentState(threadId);
2129
2132
  }
2133
+ streamEndedByInterruptRef.current = false;
2130
2134
  onStreamCompletedRef.current?.();
2131
2135
  sendMessageStreamsRef.current.delete(userMessage.id);
2132
2136
  },
@@ -2136,6 +2140,7 @@ function AgentThreadProvider({
2136
2140
  isLoading: false,
2137
2141
  error
2138
2142
  }));
2143
+ streamEndedByInterruptRef.current = false;
2139
2144
  sendMessageStreamsRef.current.delete(userMessage.id);
2140
2145
  }
2141
2146
  );
@@ -2156,9 +2161,10 @@ function AgentThreadProvider({
2156
2161
  ...prev,
2157
2162
  isLoading: false
2158
2163
  }));
2159
- if (options.enableReturnStateWhenStreamCompleted) {
2164
+ if (options.enableReturnStateWhenStreamCompleted && !streamEndedByInterruptRef.current) {
2160
2165
  await fetchAndUpdateAgentState(threadId);
2161
2166
  }
2167
+ streamEndedByInterruptRef.current = false;
2162
2168
  onStreamCompletedRef.current?.();
2163
2169
  sendMessageStreamsRef.current.delete(userMessage.id);
2164
2170
  },
@@ -4329,7 +4335,7 @@ import { Pin } from "lucide-react";
4329
4335
  // src/context/WorkspaceContext.tsx
4330
4336
  import React76, {
4331
4337
  createContext as createContext9,
4332
- useContext as useContext11,
4338
+ useContext as useContext12,
4333
4339
  useState as useState84,
4334
4340
  useCallback as useCallback44,
4335
4341
  useEffect as useEffect59,
@@ -14578,7 +14584,7 @@ var ConfirmFeedback = ({
14578
14584
  // src/components/GenUI/elements/clarify_feedback.tsx
14579
14585
  import { Button as Button21, Space as Space12, Typography as Typography17, List as List5, Checkbox as Checkbox5, Input as Input14, Upload } from "antd";
14580
14586
  import { InboxOutlined } from "@ant-design/icons";
14581
- import { useState as useState40 } from "react";
14587
+ import { useState as useState40, useContext as useContext8 } from "react";
14582
14588
  import { Fragment as Fragment9, jsx as jsx35, jsxs as jsxs25 } from "react/jsx-runtime";
14583
14589
  var { Text: Text17 } = Typography17;
14584
14590
  var { Dragger } = Upload;
@@ -14589,6 +14595,10 @@ var ClarifyFeedback = ({
14589
14595
  const { questions } = data ?? {};
14590
14596
  const { sendMessage, assistantId, threadId, tenantId } = useAgentChat();
14591
14597
  const { config } = useLatticeChatShellContext();
14598
+ const workspaceContext = useContext8(WorkspaceContext);
14599
+ const workspaceId = workspaceContext?.workspaceId ?? null;
14600
+ const projectId = workspaceContext?.projectId ?? null;
14601
+ const uploadURL = config?.baseURL ? workspaceId && projectId ? `${config.baseURL}/api/workspaces/${workspaceId}/projects/${projectId}/uploadfile` : `${config.baseURL}/api/assistants/${assistantId}/threads/${threadId}/sandbox/uploadfile` : "";
14592
14602
  const [currentStep, setCurrentStep] = useState40(0);
14593
14603
  const [answers, setAnswers] = useState40({});
14594
14604
  const [submitted, setSubmitted] = useState40(false);
@@ -14612,7 +14622,6 @@ var ClarifyFeedback = ({
14612
14622
  }
14613
14623
  }));
14614
14624
  };
14615
- const uploadURL = config?.baseURL && assistantId && threadId ? `${config.baseURL}/api/assistants/${assistantId}/threads/${threadId}/sandbox/uploadfile` : "";
14616
14625
  const handleFileUpload = (info) => {
14617
14626
  if (info.file.status === "done") {
14618
14627
  const response = info.file.response;
@@ -14865,14 +14874,14 @@ import { useState as useState41 } from "react";
14865
14874
  import { DownloadOutlined, ExpandAltOutlined } from "@ant-design/icons";
14866
14875
 
14867
14876
  // src/components/Chat/SideAppBrowserContext.tsx
14868
- import { createContext as createContext8, useContext as useContext8 } from "react";
14877
+ import { createContext as createContext8, useContext as useContext9 } from "react";
14869
14878
  var SideAppBrowserContext = createContext8(null);
14870
14879
  var useSideAppBrowser = () => {
14871
- return useContext8(SideAppBrowserContext);
14880
+ return useContext9(SideAppBrowserContext);
14872
14881
  };
14873
14882
  var useSideAppOpener = () => {
14874
14883
  const { openSideApp } = useChatUIContext();
14875
- const browserCtx = useContext8(SideAppBrowserContext);
14884
+ const browserCtx = useContext9(SideAppBrowserContext);
14876
14885
  return browserCtx?.openApp ?? openSideApp;
14877
14886
  };
14878
14887
 
@@ -17879,7 +17888,7 @@ import {
17879
17888
  Space as Space32,
17880
17889
  Typography as Typography36
17881
17890
  } from "antd";
17882
- import React42, { useCallback as useCallback31, useContext as useContext10, useEffect as useEffect41, useRef as useRef20, useState as useState60 } from "react";
17891
+ import React42, { useCallback as useCallback31, useContext as useContext11, useEffect as useEffect41, useRef as useRef20, useState as useState60 } from "react";
17883
17892
  import { BrainCircuit as BrainCircuit3 } from "lucide-react";
17884
17893
 
17885
17894
  // src/components/GenUI/HITLContainer.tsx
@@ -18826,7 +18835,7 @@ var AgentHeader = ({
18826
18835
  };
18827
18836
 
18828
18837
  // src/components/Chat/ThreadManagementButtons.tsx
18829
- import { useCallback as useCallback29, useContext as useContext9 } from "react";
18838
+ import { useCallback as useCallback29, useContext as useContext10 } from "react";
18830
18839
  import { Tooltip as Tooltip14, Button as Button38, Dropdown as Dropdown2 } from "antd";
18831
18840
  import { HistoryOutlined, PlusOutlined as PlusOutlined8 } from "@ant-design/icons";
18832
18841
  import { Fragment as Fragment12, jsx as jsx69, jsxs as jsxs47 } from "react/jsx-runtime";
@@ -18916,8 +18925,8 @@ var ThreadListButton = () => {
18916
18925
  ) });
18917
18926
  };
18918
18927
  var ThreadManagementButtons = () => {
18919
- const shellContext = useContext9(LatticeChatShellContext);
18920
- const conversationContext = useContext9(ConversationContext);
18928
+ const shellContext = useContext10(LatticeChatShellContext);
18929
+ const conversationContext = useContext10(ConversationContext);
18921
18930
  if (!shellContext || !conversationContext) {
18922
18931
  return null;
18923
18932
  }
@@ -20574,7 +20583,7 @@ var Chating = ({
20574
20583
  const { baseURL } = config;
20575
20584
  const user = useAuthOptional()?.user;
20576
20585
  const displayUserName = user?.name || user?.email?.split("@")[0] || "there";
20577
- const workspaceContext = useContext10(WorkspaceContext);
20586
+ const workspaceContext = useContext11(WorkspaceContext);
20578
20587
  const listPath = workspaceContext?.listPath ?? (async () => []);
20579
20588
  const listPathByFolder = workspaceContext?.listPathByFolder ?? (async () => []);
20580
20589
  const workspaceId = workspaceContext?.workspaceId ?? null;
@@ -34784,7 +34793,7 @@ var WorkspaceResourceUIContext = ({
34784
34793
  import { jsx as jsx130 } from "react/jsx-runtime";
34785
34794
  var WorkspaceContext = createContext9(null);
34786
34795
  var useWorkspaceContext = () => {
34787
- const context = useContext11(WorkspaceContext);
34796
+ const context = useContext12(WorkspaceContext);
34788
34797
  if (!context) {
34789
34798
  throw new Error("useWorkspaceContext must be used within a WorkspaceContextProvider");
34790
34799
  }
@@ -36652,7 +36661,7 @@ var LatticeChat = (props) => {
36652
36661
  };
36653
36662
 
36654
36663
  // src/components/Chat/LatticeChatView.tsx
36655
- import { useContext as useContext12 } from "react";
36664
+ import { useContext as useContext13 } from "react";
36656
36665
 
36657
36666
  // src/components/Chat/ChatSidebar.tsx
36658
36667
  import { useState as useState89, useMemo as useMemo38, useCallback as useCallback50 } from "react";
@@ -37122,7 +37131,7 @@ var ChatSidebar = ({
37122
37131
  // src/components/Chat/LatticeChatView.tsx
37123
37132
  import { jsx as jsx138 } from "react/jsx-runtime";
37124
37133
  var LatticeChatView = (props) => {
37125
- const shellContext = useContext12(LatticeChatShellContext);
37134
+ const shellContext = useContext13(LatticeChatShellContext);
37126
37135
  const { showSideMenu, sideMenuItems } = shellContext.config;
37127
37136
  const { assistantId, thread } = useConversationContext();
37128
37137
  const { currentAssistant } = useAssistantContext();