@athenaintel/react 0.4.4 → 0.4.5

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
@@ -24299,16 +24299,21 @@ function ThreadStateLoader({
24299
24299
  token,
24300
24300
  ...runtimeProps
24301
24301
  }) {
24302
- const [initialMessages, setInitialMessages] = useState(void 0);
24303
- const [isLoading, setIsLoading] = useState(!!threadId);
24302
+ const [loadedMessages, setLoadedMessages] = useState(void 0);
24303
+ const [loadState, setLoadState] = useState(threadId ? "loading" : "done");
24304
+ const [showSpinner, setShowSpinner] = useState(false);
24304
24305
  useEffect(() => {
24305
24306
  if (!threadId) {
24306
- setInitialMessages(void 0);
24307
- setIsLoading(false);
24307
+ setLoadedMessages(void 0);
24308
+ setLoadState("done");
24308
24309
  return;
24309
24310
  }
24310
24311
  let cancelled = false;
24311
- setIsLoading(true);
24312
+ setLoadState("loading");
24313
+ setShowSpinner(false);
24314
+ const spinnerTimer = setTimeout(() => {
24315
+ if (!cancelled) setShowSpinner(true);
24316
+ }, 200);
24312
24317
  getThreadState(backendUrl, { apiKey, token }, threadId).then((state) => {
24313
24318
  var _a2;
24314
24319
  if (cancelled) return;
@@ -24318,25 +24323,57 @@ function ThreadStateLoader({
24318
24323
  messageCount: ((_a2 = state.messages) == null ? void 0 : _a2.length) ?? 0
24319
24324
  });
24320
24325
  }
24321
- setInitialMessages(state.messages ?? []);
24322
- setIsLoading(false);
24326
+ setLoadedMessages(state.messages ?? []);
24327
+ setLoadState("done");
24323
24328
  }).catch((err) => {
24324
24329
  if (cancelled) return;
24325
24330
  if (process.env.NODE_ENV !== "production") {
24326
24331
  console.warn("[AthenaThreads] Failed to load thread state, starting fresh", err);
24327
24332
  }
24328
- setInitialMessages(void 0);
24329
- setIsLoading(false);
24333
+ setLoadedMessages(void 0);
24334
+ setLoadState("done");
24330
24335
  });
24331
24336
  return () => {
24332
24337
  cancelled = true;
24338
+ clearTimeout(spinnerTimer);
24333
24339
  };
24334
24340
  }, [threadId, backendUrl, apiKey, token]);
24335
- if (isLoading) {
24336
- return /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", height: "100%", width: "100%" }, children: [
24337
- /* @__PURE__ */ jsx("div", { style: { width: 24, height: 24, border: "2px solid currentColor", borderTopColor: "transparent", borderRadius: "50%", animation: "spin 0.6s linear infinite", opacity: 0.4 } }),
24338
- /* @__PURE__ */ jsx("style", { children: `@keyframes spin { to { transform: rotate(360deg); } }` })
24339
- ] });
24341
+ if (loadState === "loading") {
24342
+ return /* @__PURE__ */ jsxs(
24343
+ "div",
24344
+ {
24345
+ style: {
24346
+ display: "flex",
24347
+ flexDirection: "column",
24348
+ alignItems: "center",
24349
+ justifyContent: "center",
24350
+ height: "100%",
24351
+ width: "100%",
24352
+ background: "var(--background, #fff)",
24353
+ color: "var(--muted-foreground, #888)",
24354
+ gap: 8,
24355
+ opacity: showSpinner ? 1 : 0,
24356
+ transition: "opacity 0.15s ease-in"
24357
+ },
24358
+ children: [
24359
+ /* @__PURE__ */ jsx(
24360
+ "div",
24361
+ {
24362
+ style: {
24363
+ width: 20,
24364
+ height: 20,
24365
+ border: "2px solid var(--border, #e5e5e5)",
24366
+ borderTopColor: "var(--primary, #2563eb)",
24367
+ borderRadius: "50%",
24368
+ animation: "aui-spin 0.6s linear infinite"
24369
+ }
24370
+ }
24371
+ ),
24372
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 13 }, children: "Loading conversation…" }),
24373
+ /* @__PURE__ */ jsx("style", { children: `@keyframes aui-spin { to { transform: rotate(360deg); } }` })
24374
+ ]
24375
+ }
24376
+ );
24340
24377
  }
24341
24378
  return /* @__PURE__ */ jsx(
24342
24379
  AthenaRuntimeInner,
@@ -24345,7 +24382,7 @@ function ThreadStateLoader({
24345
24382
  backendUrl,
24346
24383
  apiKey,
24347
24384
  token,
24348
- initialMessages,
24385
+ initialMessages: loadedMessages,
24349
24386
  ...runtimeProps,
24350
24387
  children
24351
24388
  }