@athenaintel/react 0.10.20 → 0.10.21

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
@@ -8190,7 +8190,8 @@ async function createThread(backendUrl, auth, opts = {}) {
8190
8190
  body: JSON.stringify({
8191
8191
  config: {
8192
8192
  system_prompt: opts.systemPrompt ?? "",
8193
- enabled_tools: opts.enabledTools
8193
+ enabled_tools: opts.enabledTools,
8194
+ ...opts.appId ? { app_id: opts.appId } : {}
8194
8195
  }
8195
8196
  })
8196
8197
  });
@@ -8603,20 +8604,32 @@ const useAthenaRuntime = (config2) => {
8603
8604
  if (isExistingThread && !hasResumedRef.current) {
8604
8605
  hasResumedRef.current = true;
8605
8606
  (async () => {
8606
- var _a2;
8607
+ var _a2, _b;
8607
8608
  const auth = { apiKey: apiKeyRef.current, token: tokenRef.current };
8609
+ console.log("[AthenaSDK] Loading existing thread state:", {
8610
+ threadId,
8611
+ backendUrl
8612
+ });
8608
8613
  try {
8609
8614
  const state = await getThreadState(backendUrl, auth, threadId);
8615
+ const messageCount = ((_a2 = state == null ? void 0 : state.messages) == null ? void 0 : _a2.length) ?? 0;
8616
+ console.log("[AthenaSDK] Got thread state:", {
8617
+ threadId,
8618
+ messageCount,
8619
+ hasMessages: messageCount > 0
8620
+ });
8610
8621
  runtime.thread.importExternalState({
8611
8622
  messages: state.messages
8612
8623
  });
8624
+ console.log(
8625
+ "[AthenaSDK] importExternalState completed, runtime messages:",
8626
+ runtime.thread.getState().messages.length
8627
+ );
8613
8628
  } catch (err) {
8614
- if (IS_DEV) {
8615
- console.warn(
8616
- "[AthenaSDK] Failed to load thread state (may be a new streaming thread):",
8617
- err
8618
- );
8619
- }
8629
+ console.warn(
8630
+ "[AthenaSDK] Failed to load thread state (may be a new streaming thread):",
8631
+ err
8632
+ );
8620
8633
  }
8621
8634
  try {
8622
8635
  const statusRes = await fetch(resolvedStatusApiUrl, {
@@ -8628,7 +8641,7 @@ const useAthenaRuntime = (config2) => {
8628
8641
  const status = await statusRes.json();
8629
8642
  if (status.isRunning) {
8630
8643
  try {
8631
- const lastMessageId = ((_a2 = runtime.thread.getState().messages.at(-1)) == null ? void 0 : _a2.id) ?? null;
8644
+ const lastMessageId = ((_b = runtime.thread.getState().messages.at(-1)) == null ? void 0 : _b.id) ?? null;
8632
8645
  runtime.thread.unstable_resumeRun({ parentId: lastMessageId });
8633
8646
  } catch (resumeErr) {
8634
8647
  if (IS_DEV) {
@@ -13282,18 +13295,18 @@ function AthenaWithThreadList({
13282
13295
  core.__internal_load();
13283
13296
  }
13284
13297
  }, [runtime]);
13285
- const previousAuthRefreshKeyRef = React.useRef(null);
13298
+ const previousRefreshKeyRef = React.useRef(null);
13286
13299
  const authContext = React.useContext(AthenaAuthContext.AthenaAuthContext);
13287
13300
  const authUserId = ((_a2 = authContext == null ? void 0 : authContext.user) == null ? void 0 : _a2.userId) ?? "";
13288
- const authRefreshKey = `${backendUrl}::${apiKey ?? ""}::${authUserId}`;
13301
+ const refreshKey = `${backendUrl}::${apiKey ?? ""}::${authUserId}::${appId ?? ""}`;
13289
13302
  React.useEffect(() => {
13290
- const previousAuthRefreshKey = previousAuthRefreshKeyRef.current;
13291
- previousAuthRefreshKeyRef.current = authRefreshKey;
13292
- if (previousAuthRefreshKey === null || previousAuthRefreshKey === authRefreshKey) {
13303
+ const previousRefreshKey = previousRefreshKeyRef.current;
13304
+ previousRefreshKeyRef.current = refreshKey;
13305
+ if (previousRefreshKey === null || previousRefreshKey === refreshKey) {
13293
13306
  return;
13294
13307
  }
13295
13308
  handleRefresh();
13296
- }, [authRefreshKey, handleRefresh]);
13309
+ }, [refreshKey, handleRefresh]);
13297
13310
  const auiTools = React.useMemo(() => react.Tools({ toolkit: frontendTools }), [frontendTools]);
13298
13311
  const aui = react.useAui({ tools: auiTools });
13299
13312
  const athenaConfig = useAthenaConfigValue({