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