@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.js CHANGED
@@ -2031,6 +2031,7 @@ function AgentThreadProvider({
2031
2031
  const sendMessageStreamsRef = (0, import_react7.useRef)(/* @__PURE__ */ new Map());
2032
2032
  const chunkMessageMerger = (0, import_react7.useRef)((0, import_client_sdk3.createSimpleMessageMerger)());
2033
2033
  const lastAgentStateCreatedAtRef = (0, import_react7.useRef)(null);
2034
+ const streamEndedByInterruptRef = (0, import_react7.useRef)(false);
2034
2035
  const messageCountRef = (0, import_react7.useRef)(0);
2035
2036
  const onToolCompletedRef = (0, import_react7.useRef)(onToolCompleted);
2036
2037
  onToolCompletedRef.current = onToolCompleted;
@@ -2116,6 +2117,7 @@ function AgentThreadProvider({
2116
2117
  let interrupt;
2117
2118
  if (chunk.type === "interrupt") {
2118
2119
  const rawChunk = chunk;
2120
+ streamEndedByInterruptRef.current = true;
2119
2121
  interrupt = {
2120
2122
  type: "interrupt",
2121
2123
  id: rawChunk.id,
@@ -2159,6 +2161,7 @@ function AgentThreadProvider({
2159
2161
  if (!threadId) {
2160
2162
  throw new Error("Thread ID is required to send messages");
2161
2163
  }
2164
+ streamEndedByInterruptRef.current = false;
2162
2165
  sendMessageStreamsRef.current.forEach((stopFn) => {
2163
2166
  stopFn();
2164
2167
  });
@@ -2219,9 +2222,10 @@ function AgentThreadProvider({
2219
2222
  },
2220
2223
  // Chunks handled by resumeStream
2221
2224
  async () => {
2222
- if (options.enableReturnStateWhenStreamCompleted) {
2225
+ if (options.enableReturnStateWhenStreamCompleted && !streamEndedByInterruptRef.current) {
2223
2226
  await fetchAndUpdateAgentState(threadId);
2224
2227
  }
2228
+ streamEndedByInterruptRef.current = false;
2225
2229
  onStreamCompletedRef.current?.();
2226
2230
  sendMessageStreamsRef.current.delete(userMessage.id);
2227
2231
  },
@@ -2231,6 +2235,7 @@ function AgentThreadProvider({
2231
2235
  isLoading: false,
2232
2236
  error
2233
2237
  }));
2238
+ streamEndedByInterruptRef.current = false;
2234
2239
  sendMessageStreamsRef.current.delete(userMessage.id);
2235
2240
  }
2236
2241
  );
@@ -2251,9 +2256,10 @@ function AgentThreadProvider({
2251
2256
  ...prev,
2252
2257
  isLoading: false
2253
2258
  }));
2254
- if (options.enableReturnStateWhenStreamCompleted) {
2259
+ if (options.enableReturnStateWhenStreamCompleted && !streamEndedByInterruptRef.current) {
2255
2260
  await fetchAndUpdateAgentState(threadId);
2256
2261
  }
2262
+ streamEndedByInterruptRef.current = false;
2257
2263
  onStreamCompletedRef.current?.();
2258
2264
  sendMessageStreamsRef.current.delete(userMessage.id);
2259
2265
  },
@@ -14509,6 +14515,10 @@ var ClarifyFeedback = ({
14509
14515
  const { questions } = data ?? {};
14510
14516
  const { sendMessage, assistantId, threadId, tenantId } = useAgentChat();
14511
14517
  const { config } = useLatticeChatShellContext();
14518
+ const workspaceContext = (0, import_react47.useContext)(WorkspaceContext);
14519
+ const workspaceId = workspaceContext?.workspaceId ?? null;
14520
+ const projectId = workspaceContext?.projectId ?? null;
14521
+ const uploadURL = config?.baseURL ? workspaceId && projectId ? `${config.baseURL}/api/workspaces/${workspaceId}/projects/${projectId}/uploadfile` : `${config.baseURL}/api/assistants/${assistantId}/threads/${threadId}/sandbox/uploadfile` : "";
14512
14522
  const [currentStep, setCurrentStep] = (0, import_react47.useState)(0);
14513
14523
  const [answers, setAnswers] = (0, import_react47.useState)({});
14514
14524
  const [submitted, setSubmitted] = (0, import_react47.useState)(false);
@@ -14532,7 +14542,6 @@ var ClarifyFeedback = ({
14532
14542
  }
14533
14543
  }));
14534
14544
  };
14535
- const uploadURL = config?.baseURL && assistantId && threadId ? `${config.baseURL}/api/assistants/${assistantId}/threads/${threadId}/sandbox/uploadfile` : "";
14536
14545
  const handleFileUpload = (info) => {
14537
14546
  if (info.file.status === "done") {
14538
14547
  const response = info.file.response;