@athenaintel/react 0.10.14 → 0.10.15

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.cjs CHANGED
@@ -24597,12 +24597,23 @@ const useAthenaRuntime = (config2) => {
24597
24597
  if (isExistingThread && !hasResumedRef.current) {
24598
24598
  hasResumedRef.current = true;
24599
24599
  (async () => {
24600
+ var _a2;
24600
24601
  try {
24601
24602
  const auth = { apiKey: apiKeyRef.current, token: tokenRef.current };
24602
24603
  const state = await getThreadState(backendUrl, auth, threadId);
24603
24604
  runtime.thread.importExternalState({
24604
24605
  messages: state.messages
24605
24606
  });
24607
+ if (state.status === "running") {
24608
+ try {
24609
+ const lastMessageId = ((_a2 = runtime.thread.getState().messages.at(-1)) == null ? void 0 : _a2.id) ?? null;
24610
+ runtime.thread.unstable_resumeRun({ parentId: lastMessageId });
24611
+ } catch (resumeErr) {
24612
+ if (IS_DEV) {
24613
+ console.error("[AthenaSDK] Failed to resume running thread:", resumeErr);
24614
+ }
24615
+ }
24616
+ }
24606
24617
  } catch (err) {
24607
24618
  if (IS_DEV) {
24608
24619
  console.error("[AthenaSDK] Failed to load thread state:", err);
@@ -25365,12 +25376,16 @@ const useAthenaConfigValue = ({
25365
25376
  linkClicksRef.current = linkClicks;
25366
25377
  const citationLinksRef = React.useRef(citationLinks);
25367
25378
  citationLinksRef.current = citationLinks;
25379
+ const tokenRef = React.useRef(token);
25380
+ tokenRef.current = token;
25368
25381
  return React.useMemo(
25369
25382
  () => ({
25370
25383
  backendUrl,
25371
25384
  appUrl,
25372
25385
  apiKey,
25373
- token,
25386
+ get token() {
25387
+ return tokenRef.current;
25388
+ },
25374
25389
  get linkClicks() {
25375
25390
  return linkClicksRef.current;
25376
25391
  },
@@ -25378,7 +25393,7 @@ const useAthenaConfigValue = ({
25378
25393
  return citationLinksRef.current;
25379
25394
  }
25380
25395
  }),
25381
- [backendUrl, appUrl, apiKey, token]
25396
+ [backendUrl, appUrl, apiKey]
25382
25397
  );
25383
25398
  };
25384
25399
  function AthenaStandalone({
@@ -65587,7 +65602,10 @@ const TooltipIconButton = React.forwardRef(
65587
65602
  TooltipIconButton.displayName = "TooltipIconButton";
65588
65603
  const MAX_FILE_SIZE = 5 * 1024 * 1024 * 1024;
65589
65604
  function useFileUpload() {
65590
- const { backendUrl, apiKey, token } = useAthenaConfig();
65605
+ const config2 = useAthenaConfig();
65606
+ const configRef = React.useRef(config2);
65607
+ configRef.current = config2;
65608
+ const { backendUrl, apiKey } = config2;
65591
65609
  const [isUploading, setIsUploading] = React.useState(false);
65592
65610
  const [progress, setProgress] = React.useState(null);
65593
65611
  const [error2, setError] = React.useState(null);
@@ -65620,9 +65638,10 @@ function useFileUpload() {
65620
65638
  }
65621
65639
  const baseUrl = backendUrl.replace(/\/api\/assistant-ui\/?$/, "");
65622
65640
  const uploadUrl = `${baseUrl}/api/upload/`;
65641
+ const currentToken = configRef.current.token;
65623
65642
  const headers = {};
65624
- if (token) {
65625
- headers["Authorization"] = `Bearer ${token}`;
65643
+ if (currentToken) {
65644
+ headers["Authorization"] = `Bearer ${currentToken}`;
65626
65645
  } else if (apiKey) {
65627
65646
  headers["X-API-KEY"] = apiKey;
65628
65647
  }
@@ -65672,7 +65691,7 @@ function useFileUpload() {
65672
65691
  for (const [key, value] of Object.entries(headers)) {
65673
65692
  xhr.setRequestHeader(key, value);
65674
65693
  }
65675
- xhr.withCredentials = !token && !apiKey;
65694
+ xhr.withCredentials = !currentToken && !apiKey;
65676
65695
  xhr.send(formData);
65677
65696
  });
65678
65697
  if (result.errors.length > 0) {
@@ -65694,7 +65713,7 @@ function useFileUpload() {
65694
65713
  setProgress(null);
65695
65714
  }
65696
65715
  },
65697
- [backendUrl, apiKey, token]
65716
+ [backendUrl, apiKey]
65698
65717
  );
65699
65718
  return { upload, isUploading, progress, error: error2, clearError };
65700
65719
  }