@athenaintel/react 0.9.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 +36 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +37 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
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
|
-
|
|
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
|
-
|
|
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",
|
|
@@ -24602,10 +24610,13 @@ function AthenaWithThreadList({
|
|
|
24602
24610
|
knowledgeBase,
|
|
24603
24611
|
systemPrompt
|
|
24604
24612
|
}) {
|
|
24613
|
+
const [refreshKey, setRefreshKey] = React.useState(0);
|
|
24614
|
+
const handleRefresh = React.useCallback(() => setRefreshKey((k) => k + 1), []);
|
|
24605
24615
|
const adapter = useAthenaThreadListAdapter({
|
|
24606
24616
|
backendUrl,
|
|
24607
24617
|
apiKey,
|
|
24608
|
-
token
|
|
24618
|
+
token,
|
|
24619
|
+
refreshKey
|
|
24609
24620
|
});
|
|
24610
24621
|
const runtimeConfigRef = React.useRef({
|
|
24611
24622
|
apiUrl,
|
|
@@ -24647,7 +24658,7 @@ function AthenaWithThreadList({
|
|
|
24647
24658
|
() => ({ backendUrl, apiKey, token }),
|
|
24648
24659
|
[backendUrl, apiKey, token]
|
|
24649
24660
|
);
|
|
24650
|
-
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 }) }) }) });
|
|
24651
24662
|
}
|
|
24652
24663
|
function AthenaProvider({
|
|
24653
24664
|
children,
|
|
@@ -64309,10 +64320,23 @@ const AthenaLayout = ({
|
|
|
64309
64320
|
] });
|
|
64310
64321
|
};
|
|
64311
64322
|
function ThreadList({ className }) {
|
|
64323
|
+
const refresh = useRefreshThreadList();
|
|
64312
64324
|
return /* @__PURE__ */ jsxRuntime.jsxs(ThreadListPrimitiveRoot, { className: cn("flex flex-col gap-1", className), children: [
|
|
64313
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
64314
|
-
/* @__PURE__ */ jsxRuntime.
|
|
64315
|
-
|
|
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
|
+
)
|
|
64316
64340
|
] }),
|
|
64317
64341
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
64318
64342
|
ThreadListPrimitiveItems,
|
|
@@ -64500,4 +64524,5 @@ exports.useMentionSuggestions = useMentionSuggestions;
|
|
|
64500
64524
|
exports.useParentAuth = useParentAuth;
|
|
64501
64525
|
exports.useParentBridge = useParentBridge;
|
|
64502
64526
|
exports.useQuote = useQuote;
|
|
64527
|
+
exports.useRefreshThreadList = useRefreshThreadList;
|
|
64503
64528
|
//# sourceMappingURL=index.cjs.map
|