@athenaintel/react 0.8.0 → 0.9.1

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
@@ -16505,8 +16505,10 @@ function useParentBridge() {
16505
16505
  setState((prev) => ({
16506
16506
  ...prev,
16507
16507
  apiUrl: typeof event.data.apiUrl === "string" ? event.data.apiUrl : prev.apiUrl,
16508
- backendUrl: typeof event.data.backendUrl === "string" ? event.data.backendUrl : prev.backendUrl,
16509
- ready: true
16508
+ backendUrl: typeof event.data.backendUrl === "string" ? event.data.backendUrl : prev.backendUrl
16509
+ // Don't set ready here — wait for athena-auth (token) or the timeout.
16510
+ // Setting ready on config alone causes a race: the thread list fires
16511
+ // before the token arrives, falling back to X-API-KEY.
16510
16512
  }));
16511
16513
  }
16512
16514
  if (event.data.type === "athena-auth" && typeof event.data.token === "string") {
@@ -16524,9 +16526,7 @@ function useParentBridge() {
16524
16526
  readySignalSent.current = true;
16525
16527
  }
16526
16528
  const timer = setTimeout(() => {
16527
- if (!configReceived.current) {
16528
- setState((prev) => ({ ...prev, ready: true }));
16529
- }
16529
+ setState((prev) => prev.ready ? prev : { ...prev, ready: true });
16530
16530
  }, BRIDGE_TIMEOUT_MS);
16531
16531
  return () => {
16532
16532
  window.removeEventListener("message", handler);
@@ -24314,6 +24314,9 @@ function useAthenaThreadListAdapter(config2) {
24314
24314
  );
24315
24315
  return React.useMemo(() => ({
24316
24316
  async list() {
24317
+ if (!auth.token && !auth.apiKey) {
24318
+ return { threads: [] };
24319
+ }
24317
24320
  try {
24318
24321
  const { threads } = await listThreads(configRef.current.backendUrl, auth);
24319
24322
  return {
@@ -24353,7 +24356,12 @@ function useAthenaThreadListAdapter(config2) {
24353
24356
  };
24354
24357
  },
24355
24358
  unstable_Provider
24356
- }), [auth, unstable_Provider]);
24359
+ // eslint-disable-next-line react-hooks/exhaustive-deps
24360
+ }), [auth, unstable_Provider, config2.refreshKey]);
24361
+ }
24362
+ const ThreadListRefreshContext = React.createContext(null);
24363
+ function useRefreshThreadList() {
24364
+ return React.useContext(ThreadListRefreshContext);
24357
24365
  }
24358
24366
  const THEME_TO_CSS = {
24359
24367
  primary: "--primary",
@@ -24375,14 +24383,19 @@ const THEME_TO_CSS = {
24375
24383
  input: "--input",
24376
24384
  ring: "--ring",
24377
24385
  radius: "--radius",
24386
+ fontFamily: "--font-family",
24378
24387
  // Extended SDK-specific variables
24379
24388
  sidebarBackground: "--sidebar-background",
24380
24389
  sidebarBorder: "--sidebar-border",
24390
+ sidebarWidth: "--sidebar-width",
24381
24391
  userBubble: "--user-bubble",
24382
24392
  userBubbleForeground: "--user-bubble-foreground",
24393
+ userBubbleRadius: "--user-bubble-radius",
24383
24394
  assistantForeground: "--assistant-foreground",
24395
+ assistantBubble: "--assistant-bubble",
24384
24396
  composerBorder: "--composer-border",
24385
- composerRadius: "--composer-radius"
24397
+ composerRadius: "--composer-radius",
24398
+ threadMaxWidth: "--thread-max-width"
24386
24399
  };
24387
24400
  function themeToStyleVars(theme) {
24388
24401
  const vars = {};
@@ -24597,10 +24610,13 @@ function AthenaWithThreadList({
24597
24610
  knowledgeBase,
24598
24611
  systemPrompt
24599
24612
  }) {
24613
+ const [refreshKey, setRefreshKey] = React.useState(0);
24614
+ const handleRefresh = React.useCallback(() => setRefreshKey((k) => k + 1), []);
24600
24615
  const adapter = useAthenaThreadListAdapter({
24601
24616
  backendUrl,
24602
24617
  apiKey,
24603
- token
24618
+ token,
24619
+ refreshKey
24604
24620
  });
24605
24621
  const runtimeConfigRef = React.useRef({
24606
24622
  apiUrl,
@@ -24642,7 +24658,7 @@ function AthenaWithThreadList({
24642
24658
  () => ({ backendUrl, apiKey, token }),
24643
24659
  [backendUrl, apiKey, token]
24644
24660
  );
24645
- return /* @__PURE__ */ jsxRuntime.jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children }) }) });
24661
+ return /* @__PURE__ */ jsxRuntime.jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsxRuntime.jsx(ThreadListRefreshContext.Provider, { value: handleRefresh, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children }) }) }) });
24646
24662
  }
24647
24663
  function AthenaProvider({
24648
24664
  children,
@@ -64304,10 +64320,23 @@ const AthenaLayout = ({
64304
64320
  ] });
64305
64321
  };
64306
64322
  function ThreadList({ className }) {
64323
+ const refresh = useRefreshThreadList();
64307
64324
  return /* @__PURE__ */ jsxRuntime.jsxs(ThreadListPrimitiveRoot, { className: cn("flex flex-col gap-1", className), children: [
64308
- /* @__PURE__ */ jsxRuntime.jsxs(ThreadListPrimitiveNew, { className: "flex items-center gap-2 rounded-lg border border-border/60 px-3 py-2 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground", children: [
64309
- /* @__PURE__ */ jsxRuntime.jsx(Plus, { className: "size-4" }),
64310
- "New Chat"
64325
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
64326
+ /* @__PURE__ */ jsxRuntime.jsxs(ThreadListPrimitiveNew, { className: "flex flex-1 items-center gap-2 rounded-lg border border-border/60 px-3 py-2 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground", children: [
64327
+ /* @__PURE__ */ jsxRuntime.jsx(Plus, { className: "size-4" }),
64328
+ "New Chat"
64329
+ ] }),
64330
+ refresh && /* @__PURE__ */ jsxRuntime.jsx(
64331
+ "button",
64332
+ {
64333
+ type: "button",
64334
+ onClick: refresh,
64335
+ className: "flex items-center justify-center rounded-lg border border-border/60 p-2 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
64336
+ title: "Refresh threads",
64337
+ children: /* @__PURE__ */ jsxRuntime.jsx(RefreshCw, { className: "size-4" })
64338
+ }
64339
+ )
64311
64340
  ] }),
64312
64341
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsxRuntime.jsx(
64313
64342
  ThreadListPrimitiveItems,
@@ -64495,4 +64524,5 @@ exports.useMentionSuggestions = useMentionSuggestions;
64495
64524
  exports.useParentAuth = useParentAuth;
64496
64525
  exports.useParentBridge = useParentBridge;
64497
64526
  exports.useQuote = useQuote;
64527
+ exports.useRefreshThreadList = useRefreshThreadList;
64498
64528
  //# sourceMappingURL=index.cjs.map