@athenaintel/react 0.10.15 → 0.10.17

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
@@ -24593,6 +24593,7 @@ const useAthenaRuntime = (config2) => {
24593
24593
  prevThreadIdRef.current = threadId;
24594
24594
  hasResumedRef.current = false;
24595
24595
  }
24596
+ const resolvedStatusApiUrl = apiUrl.replace(/\/api\/chat$/, "/api/status");
24596
24597
  React.useEffect(() => {
24597
24598
  if (isExistingThread && !hasResumedRef.current) {
24598
24599
  hasResumedRef.current = true;
@@ -24604,15 +24605,23 @@ const useAthenaRuntime = (config2) => {
24604
24605
  runtime.thread.importExternalState({
24605
24606
  messages: state.messages
24606
24607
  });
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);
24608
+ try {
24609
+ const statusRes = await fetch(resolvedStatusApiUrl, {
24610
+ method: "POST",
24611
+ headers: { "Content-Type": "application/json" },
24612
+ body: JSON.stringify({ threadId })
24613
+ });
24614
+ if (statusRes.ok) {
24615
+ const status = await statusRes.json();
24616
+ if (status.isRunning) {
24617
+ const lastMessageId = ((_a2 = runtime.thread.getState().messages.at(-1)) == null ? void 0 : _a2.id) ?? null;
24618
+ runtime.thread.unstable_resumeRun({ parentId: lastMessageId });
24614
24619
  }
24615
24620
  }
24621
+ } catch (statusErr) {
24622
+ if (IS_DEV) {
24623
+ console.warn("[AthenaSDK] Sync server status check failed:", statusErr);
24624
+ }
24616
24625
  }
24617
24626
  } catch (err) {
24618
24627
  if (IS_DEV) {
@@ -24625,7 +24634,7 @@ const useAthenaRuntime = (config2) => {
24625
24634
  }
24626
24635
  })();
24627
24636
  }
24628
- }, [isExistingThread, runtime, threadId, backendUrl]);
24637
+ }, [isExistingThread, runtime, threadId, backendUrl, resolvedStatusApiUrl]);
24629
24638
  return runtime;
24630
24639
  };
24631
24640
  function TooltipProvider({
@@ -24740,14 +24749,32 @@ const ThreadListRefreshContext = React.createContext(null);
24740
24749
  function useRefreshThreadList() {
24741
24750
  return React.useContext(ThreadListRefreshContext);
24742
24751
  }
24752
+ const LOCAL_ID_PREFIX = "__LOCALID_";
24753
+ const isLocalPlaceholder = (id) => !!id && id.startsWith(LOCAL_ID_PREFIX);
24743
24754
  function useAthenaThreadManager() {
24744
24755
  const runtime = useAssistantRuntime({ optional: true });
24745
- const remoteId = useThread({ optional: true, selector: (s) => {
24746
- var _a2;
24747
- return (_a2 = s.metadata) == null ? void 0 : _a2.remoteId;
24748
- } });
24756
+ const remoteId = useThread({
24757
+ optional: true,
24758
+ selector: (s) => {
24759
+ var _a2;
24760
+ const id = (_a2 = s.metadata) == null ? void 0 : _a2.remoteId;
24761
+ console.log("[AthenaSDK] useAthenaThreadManager selector", {
24762
+ metadata: s.metadata,
24763
+ threadId: s.threadId,
24764
+ rawRemoteId: id,
24765
+ isPlaceholder: isLocalPlaceholder(id)
24766
+ });
24767
+ return isLocalPlaceholder(id) ? void 0 : id;
24768
+ }
24769
+ });
24749
24770
  const isThreadLoading = useThread({ optional: true, selector: (s) => s.isLoading }) ?? false;
24750
24771
  const isListLoading = useThreadList({ optional: true, selector: (s) => s.isLoading });
24772
+ console.log("[AthenaSDK] useAthenaThreadManager render", {
24773
+ remoteId,
24774
+ isThreadLoading,
24775
+ isListLoading,
24776
+ hasRuntime: !!runtime
24777
+ });
24751
24778
  const runtimeRef = React.useRef(runtime);
24752
24779
  runtimeRef.current = runtime;
24753
24780
  const switchToThread = React.useCallback(