@athenaintel/react 0.9.18 → 0.9.19
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 +95 -213
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -16
- package/dist/index.js +95 -213
- package/dist/index.js.map +1 -1
- package/package.json +9 -10
package/dist/index.cjs
CHANGED
|
@@ -24317,6 +24317,22 @@ const useAthenaRuntime = (config2) => {
|
|
|
24317
24317
|
tokenRef.current = token;
|
|
24318
24318
|
const apiKeyRef = React.useRef(apiKey);
|
|
24319
24319
|
apiKeyRef.current = apiKey;
|
|
24320
|
+
const runConfigRef = React.useRef({
|
|
24321
|
+
enabledTools,
|
|
24322
|
+
agent: agent2,
|
|
24323
|
+
model,
|
|
24324
|
+
workbench,
|
|
24325
|
+
knowledgeBase,
|
|
24326
|
+
systemPrompt
|
|
24327
|
+
});
|
|
24328
|
+
runConfigRef.current = {
|
|
24329
|
+
enabledTools,
|
|
24330
|
+
agent: agent2,
|
|
24331
|
+
model,
|
|
24332
|
+
workbench,
|
|
24333
|
+
knowledgeBase,
|
|
24334
|
+
systemPrompt
|
|
24335
|
+
};
|
|
24320
24336
|
const isExistingThread = !!threadIdProp;
|
|
24321
24337
|
const runtime = useAssistantTransportRuntime({
|
|
24322
24338
|
initialState: { messages: [] },
|
|
@@ -24415,16 +24431,17 @@ const useAthenaRuntime = (config2) => {
|
|
|
24415
24431
|
return true;
|
|
24416
24432
|
},
|
|
24417
24433
|
get runConfig() {
|
|
24434
|
+
const currentRunConfig = runConfigRef.current;
|
|
24418
24435
|
return {
|
|
24419
24436
|
custom: {
|
|
24420
|
-
enabled_tools: enabledTools,
|
|
24421
|
-
agent:
|
|
24422
|
-
model,
|
|
24437
|
+
enabled_tools: currentRunConfig.enabledTools,
|
|
24438
|
+
agent: currentRunConfig.agent,
|
|
24439
|
+
model: currentRunConfig.model,
|
|
24423
24440
|
effort_dial_duration: -1,
|
|
24424
24441
|
plan_mode_enabled: false,
|
|
24425
|
-
workbench,
|
|
24426
|
-
knowledge_base: knowledgeBase,
|
|
24427
|
-
...systemPrompt ? { system_prompt: systemPrompt } : {}
|
|
24442
|
+
workbench: currentRunConfig.workbench,
|
|
24443
|
+
knowledge_base: currentRunConfig.knowledgeBase,
|
|
24444
|
+
...currentRunConfig.systemPrompt ? { system_prompt: currentRunConfig.systemPrompt } : {}
|
|
24428
24445
|
},
|
|
24429
24446
|
persistToolInvocationLogs: true
|
|
24430
24447
|
};
|
|
@@ -58896,39 +58913,17 @@ const useAssetPanelStore = create()(
|
|
|
58896
58913
|
const existing = s.tabs.find((t) => t.id === assetId);
|
|
58897
58914
|
if (existing) {
|
|
58898
58915
|
const tabs = meta ? s.tabs.map(
|
|
58899
|
-
(t) => t.id === assetId ? {
|
|
58900
|
-
...t,
|
|
58901
|
-
name: meta.name ?? t.name,
|
|
58902
|
-
type: meta.type ?? t.type,
|
|
58903
|
-
embedSearchParams: meta.embedSearchParams ?? t.embedSearchParams
|
|
58904
|
-
} : t
|
|
58916
|
+
(t) => t.id === assetId ? { ...t, name: meta.name ?? t.name, type: meta.type ?? t.type } : t
|
|
58905
58917
|
) : s.tabs;
|
|
58906
58918
|
return { isOpen: true, tabs, activeTabId: assetId };
|
|
58907
58919
|
}
|
|
58908
58920
|
const newTab = {
|
|
58909
58921
|
id: assetId,
|
|
58910
58922
|
name: (meta == null ? void 0 : meta.name) ?? null,
|
|
58911
|
-
type: (meta == null ? void 0 : meta.type) ?? "unknown"
|
|
58912
|
-
embedSearchParams: (meta == null ? void 0 : meta.embedSearchParams) ?? null
|
|
58923
|
+
type: (meta == null ? void 0 : meta.type) ?? "unknown"
|
|
58913
58924
|
};
|
|
58914
58925
|
return { isOpen: true, tabs: [...s.tabs, newTab], activeTabId: assetId };
|
|
58915
58926
|
}),
|
|
58916
|
-
updateTabMeta: (assetId, meta) => set2((s) => {
|
|
58917
|
-
const existing = s.tabs.find((t) => t.id === assetId);
|
|
58918
|
-
if (!existing) {
|
|
58919
|
-
return {};
|
|
58920
|
-
}
|
|
58921
|
-
return {
|
|
58922
|
-
tabs: s.tabs.map(
|
|
58923
|
-
(t) => t.id === assetId ? {
|
|
58924
|
-
...t,
|
|
58925
|
-
name: meta.name ?? t.name,
|
|
58926
|
-
type: meta.type ?? t.type,
|
|
58927
|
-
embedSearchParams: meta.embedSearchParams ?? t.embedSearchParams
|
|
58928
|
-
} : t
|
|
58929
|
-
)
|
|
58930
|
-
};
|
|
58931
|
-
}),
|
|
58932
58927
|
closeTab: (assetId) => set2((s) => {
|
|
58933
58928
|
var _a2;
|
|
58934
58929
|
const tabs = s.tabs.filter((t) => t.id !== assetId);
|
|
@@ -58986,43 +58981,13 @@ const ASSET_TYPE_ALIASES = {
|
|
|
58986
58981
|
super_document: "document"
|
|
58987
58982
|
};
|
|
58988
58983
|
const isAthenaSpacesPath = (url) => url.pathname.replace(/\/+$/, "") === "/dashboard/spaces";
|
|
58989
|
-
const normalizeAssetType
|
|
58984
|
+
const normalizeAssetType = (value) => {
|
|
58990
58985
|
if (!value) {
|
|
58991
58986
|
return null;
|
|
58992
58987
|
}
|
|
58993
58988
|
const normalizedValue = value.trim().replace(/^athena\//, "").toLowerCase().replace(/-/g, "_");
|
|
58994
58989
|
return ASSET_TYPE_ALIASES[normalizedValue] ?? null;
|
|
58995
58990
|
};
|
|
58996
|
-
const isLikelyAssetId = (value) => !!value && /^(asset|thread|project|collection)_[a-z0-9-]+$/i.test(value.trim());
|
|
58997
|
-
const sanitizeDisplayName = (value) => {
|
|
58998
|
-
if (!value) {
|
|
58999
|
-
return null;
|
|
59000
|
-
}
|
|
59001
|
-
const trimmedValue = value.trim();
|
|
59002
|
-
if (!trimmedValue) {
|
|
59003
|
-
return null;
|
|
59004
|
-
}
|
|
59005
|
-
if (trimmedValue.startsWith('"') && trimmedValue.endsWith('"') || trimmedValue.startsWith("'") && trimmedValue.endsWith("'")) {
|
|
59006
|
-
return trimmedValue.slice(1, -1).trim() || null;
|
|
59007
|
-
}
|
|
59008
|
-
return trimmedValue;
|
|
59009
|
-
};
|
|
59010
|
-
const getCitationDisplayName = ({
|
|
59011
|
-
assetName,
|
|
59012
|
-
linkText
|
|
59013
|
-
}) => {
|
|
59014
|
-
const sanitizedAssetName = sanitizeDisplayName(assetName);
|
|
59015
|
-
const sanitizedLinkText = sanitizeDisplayName(linkText);
|
|
59016
|
-
const genericLinkTextPattern = /^(this|that|the)\s+asset$/i;
|
|
59017
|
-
if (sanitizedAssetName && !isLikelyAssetId(sanitizedAssetName)) {
|
|
59018
|
-
return sanitizedAssetName;
|
|
59019
|
-
}
|
|
59020
|
-
if (sanitizedLinkText && !genericLinkTextPattern.test(sanitizedLinkText)) {
|
|
59021
|
-
return sanitizedLinkText;
|
|
59022
|
-
}
|
|
59023
|
-
return sanitizedAssetName ?? sanitizedLinkText;
|
|
59024
|
-
};
|
|
59025
|
-
const getEmbedSearchParams = (url) => Object.fromEntries(url.searchParams.entries());
|
|
59026
58991
|
const getOrigin = (value) => {
|
|
59027
58992
|
if (!value) {
|
|
59028
58993
|
return null;
|
|
@@ -59104,11 +59069,7 @@ const parseAthenaCitationLink = ({
|
|
|
59104
59069
|
url,
|
|
59105
59070
|
assetId,
|
|
59106
59071
|
assetIds,
|
|
59107
|
-
assetType: normalizeAssetType
|
|
59108
|
-
url.searchParams.get("asset_type") ?? url.searchParams.get("assetType") ?? url.searchParams.get("type")
|
|
59109
|
-
),
|
|
59110
|
-
assetName: sanitizeDisplayName(url.searchParams.get("name")),
|
|
59111
|
-
embedSearchParams: getEmbedSearchParams(url)
|
|
59072
|
+
assetType: normalizeAssetType(url.searchParams.get("asset_type") ?? url.searchParams.get("type"))
|
|
59112
59073
|
};
|
|
59113
59074
|
};
|
|
59114
59075
|
const isAthenaCitationUrl = ({
|
|
@@ -59156,19 +59117,12 @@ const useAthenaLinkClickHandler = () => {
|
|
|
59156
59117
|
const citationMetadata = citationLink ? {
|
|
59157
59118
|
assetId: citationLink.assetId,
|
|
59158
59119
|
assetIds: citationLink.assetIds,
|
|
59159
|
-
assetType: citationLink.assetType
|
|
59160
|
-
assetName: citationLink.assetName,
|
|
59161
|
-
embedSearchParams: citationLink.embedSearchParams
|
|
59120
|
+
assetType: citationLink.assetType
|
|
59162
59121
|
} : null;
|
|
59163
59122
|
const openInAssetPanel = citationLink ? () => {
|
|
59164
|
-
const displayName = getCitationDisplayName({
|
|
59165
|
-
assetName: citationLink.assetName,
|
|
59166
|
-
linkText: trimmedLinkText
|
|
59167
|
-
});
|
|
59168
59123
|
openAsset(citationLink.assetId, {
|
|
59169
|
-
name:
|
|
59170
|
-
type: citationLink.assetType ?? void 0
|
|
59171
|
-
embedSearchParams: citationLink.embedSearchParams
|
|
59124
|
+
name: trimmedLinkText ?? void 0,
|
|
59125
|
+
type: citationLink.assetType ?? void 0
|
|
59172
59126
|
});
|
|
59173
59127
|
} : void 0;
|
|
59174
59128
|
const context2 = {
|
|
@@ -63608,12 +63562,6 @@ function extractAssetId(result) {
|
|
|
63608
63562
|
if (typeof id === "string" && id.startsWith("asset_")) return id;
|
|
63609
63563
|
return null;
|
|
63610
63564
|
}
|
|
63611
|
-
function extractAssetTitle(result) {
|
|
63612
|
-
const data = normalizeResult(result);
|
|
63613
|
-
if (!data) return null;
|
|
63614
|
-
const title = data.assetTitle ?? data.asset_title ?? data.title ?? data.name;
|
|
63615
|
-
return typeof title === "string" && title.trim().length > 0 ? title.trim() : null;
|
|
63616
|
-
}
|
|
63617
63565
|
function resetAssetAutoOpen() {
|
|
63618
63566
|
useAssetPanelStore.getState().resetAutoOpen();
|
|
63619
63567
|
}
|
|
@@ -64333,7 +64281,6 @@ const OpenAssetToolUIImpl = ({
|
|
|
64333
64281
|
const typedArgs = args;
|
|
64334
64282
|
const argsAssetId = (typedArgs == null ? void 0 : typedArgs.asset_id) ?? (typedArgs == null ? void 0 : typedArgs.assetId) ?? "";
|
|
64335
64283
|
const resultAssetId = extractAssetId(result);
|
|
64336
|
-
const resultAssetTitle = extractAssetTitle(result);
|
|
64337
64284
|
const assetId = resultAssetId ?? (argsAssetId.startsWith("asset_") ? argsAssetId : null);
|
|
64338
64285
|
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
64339
64286
|
const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
|
|
@@ -64345,10 +64292,10 @@ const OpenAssetToolUIImpl = ({
|
|
|
64345
64292
|
if (isComplete && !isCancelled && assetId && !wasCompleteAtMount.current) {
|
|
64346
64293
|
const store = useAssetPanelStore.getState();
|
|
64347
64294
|
if (store.markAutoOpened(assetId)) {
|
|
64348
|
-
store.openAsset(assetId
|
|
64295
|
+
store.openAsset(assetId);
|
|
64349
64296
|
}
|
|
64350
64297
|
}
|
|
64351
|
-
}, [isComplete, isCancelled, assetId
|
|
64298
|
+
}, [isComplete, isCancelled, assetId]);
|
|
64352
64299
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
64353
64300
|
ToolCard,
|
|
64354
64301
|
{
|
|
@@ -64364,7 +64311,7 @@ const OpenAssetToolUIImpl = ({
|
|
|
64364
64311
|
"button",
|
|
64365
64312
|
{
|
|
64366
64313
|
type: "button",
|
|
64367
|
-
onClick: () => openAsset(assetId
|
|
64314
|
+
onClick: () => openAsset(assetId),
|
|
64368
64315
|
className: "flex items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
64369
64316
|
children: [
|
|
64370
64317
|
/* @__PURE__ */ jsxRuntime.jsx(ExternalLink, { className: "size-3" }),
|
|
@@ -64975,7 +64922,9 @@ const AthenaChat = ({
|
|
|
64975
64922
|
{
|
|
64976
64923
|
turnAnchor: "top",
|
|
64977
64924
|
className: "aui-thread-viewport relative flex flex-1 flex-col overflow-x-auto overflow-y-scroll scroll-smooth px-4 pt-4",
|
|
64925
|
+
"data-aui-thread-viewport": "",
|
|
64978
64926
|
children: [
|
|
64927
|
+
/* @__PURE__ */ jsxRuntime.jsx(ThreadScrollToTop, {}),
|
|
64979
64928
|
/* @__PURE__ */ jsxRuntime.jsx(AuiIf, { condition: (s) => s.thread.isEmpty, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "aui-thread-welcome-root mx-auto my-auto flex w-full max-w-(--thread-max-width) grow flex-col", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "aui-thread-welcome-center flex w-full grow flex-col items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "aui-thread-welcome-message flex size-full flex-col justify-center px-4", children: [
|
|
64980
64929
|
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in fill-mode-both font-semibold text-2xl duration-200", children: welcomeMessage }),
|
|
64981
64930
|
welcomeSubtext && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in fill-mode-both text-muted-foreground text-lg delay-75 duration-200", children: welcomeSubtext }),
|
|
@@ -65021,6 +64970,50 @@ const ThreadLoadingOverlay = () => {
|
|
|
65021
64970
|
if (!remoteId || timedOut) return null;
|
|
65022
64971
|
return /* @__PURE__ */ jsxRuntime.jsx(AuiIf, { condition: (s) => s.thread.isEmpty, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 z-10 flex items-center justify-center bg-background/80", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-5 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent" }) }) });
|
|
65023
64972
|
};
|
|
64973
|
+
const THREAD_VIEWPORT_ATTR = "data-aui-thread-viewport";
|
|
64974
|
+
const useScrollToTop = () => {
|
|
64975
|
+
const [isAtTop, setIsAtTop] = React.useState(true);
|
|
64976
|
+
const [buttonEl, setButtonEl] = React.useState(null);
|
|
64977
|
+
const containerRef = React.useCallback((node) => {
|
|
64978
|
+
setButtonEl(node);
|
|
64979
|
+
}, []);
|
|
64980
|
+
const getViewport = React.useCallback(() => {
|
|
64981
|
+
if (!buttonEl) return null;
|
|
64982
|
+
return buttonEl.closest(`[${THREAD_VIEWPORT_ATTR}]`);
|
|
64983
|
+
}, [buttonEl]);
|
|
64984
|
+
React.useEffect(() => {
|
|
64985
|
+
const viewport = getViewport();
|
|
64986
|
+
if (!viewport) return;
|
|
64987
|
+
const handleScroll2 = () => {
|
|
64988
|
+
setIsAtTop(viewport.scrollTop <= 50);
|
|
64989
|
+
};
|
|
64990
|
+
handleScroll2();
|
|
64991
|
+
viewport.addEventListener("scroll", handleScroll2, { passive: true });
|
|
64992
|
+
return () => viewport.removeEventListener("scroll", handleScroll2);
|
|
64993
|
+
}, [getViewport]);
|
|
64994
|
+
const handleClick2 = React.useCallback(() => {
|
|
64995
|
+
const viewport = getViewport();
|
|
64996
|
+
if (!viewport) return;
|
|
64997
|
+
viewport.scrollTo({ top: 0, behavior: "smooth" });
|
|
64998
|
+
}, [getViewport]);
|
|
64999
|
+
return { isAtTop, containerRef, handleClick: handleClick2 };
|
|
65000
|
+
};
|
|
65001
|
+
const ThreadScrollToTop = () => {
|
|
65002
|
+
const { isAtTop, containerRef, handleClick: handleClick2 } = useScrollToTop();
|
|
65003
|
+
const isEmpty3 = useAuiState((s) => s.thread.isEmpty);
|
|
65004
|
+
if (isEmpty3) return null;
|
|
65005
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sticky top-0 z-10 mx-auto flex h-0 w-full max-w-(--thread-max-width) justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
65006
|
+
TooltipIconButton,
|
|
65007
|
+
{
|
|
65008
|
+
ref: containerRef,
|
|
65009
|
+
tooltip: "Scroll to top",
|
|
65010
|
+
variant: "outline",
|
|
65011
|
+
className: cn("aui-thread-scroll-to-top absolute top-2 rounded-full p-4 dark:bg-background dark:hover:bg-accent", isAtTop && "invisible"),
|
|
65012
|
+
onClick: handleClick2,
|
|
65013
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ArrowUp, {})
|
|
65014
|
+
}
|
|
65015
|
+
) });
|
|
65016
|
+
};
|
|
65024
65017
|
const ThreadScrollToBottom = () => /* @__PURE__ */ jsxRuntime.jsx(ThreadPrimitiveScrollToBottom, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
65025
65018
|
TooltipIconButton,
|
|
65026
65019
|
{
|
|
@@ -65289,67 +65282,14 @@ const AthenaUserMessage = ({
|
|
|
65289
65282
|
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "aui-user-message-content wrap-break-word rounded-2xl bg-muted px-4 py-2.5 text-foreground", children: /* @__PURE__ */ jsxRuntime.jsx(MessagePrimitiveParts, { components: { Text: TextComponent } }) })
|
|
65290
65283
|
}
|
|
65291
65284
|
);
|
|
65292
|
-
const EMBED_ASSET_TYPE_ALIASES = {
|
|
65293
|
-
document: "document",
|
|
65294
|
-
image: "document",
|
|
65295
|
-
notebook: "notebook",
|
|
65296
|
-
pdf: "document",
|
|
65297
|
-
powerpoint_deck: "presentation",
|
|
65298
|
-
presentation: "presentation",
|
|
65299
|
-
puck_presentation: "presentation",
|
|
65300
|
-
sheet: "spreadsheet",
|
|
65301
|
-
spreadsheet: "spreadsheet",
|
|
65302
|
-
super_document: "document"
|
|
65303
|
-
};
|
|
65304
65285
|
const embedCache = /* @__PURE__ */ new Map();
|
|
65305
|
-
const normalizeAssetType = (value) => {
|
|
65306
|
-
if (!value) {
|
|
65307
|
-
return null;
|
|
65308
|
-
}
|
|
65309
|
-
const normalizedValue = value.trim().replace(/^athena\//, "").toLowerCase().replace(/-/g, "_");
|
|
65310
|
-
return EMBED_ASSET_TYPE_ALIASES[normalizedValue] ?? null;
|
|
65311
|
-
};
|
|
65312
|
-
const getEmbedSearchParamsCacheKey = (embedSearchParams) => {
|
|
65313
|
-
if (!embedSearchParams || Object.keys(embedSearchParams).length === 0) {
|
|
65314
|
-
return "{}";
|
|
65315
|
-
}
|
|
65316
|
-
const sortedEntries = Object.entries(embedSearchParams).sort(
|
|
65317
|
-
([left], [right]) => left.localeCompare(right)
|
|
65318
|
-
);
|
|
65319
|
-
return JSON.stringify(Object.fromEntries(sortedEntries));
|
|
65320
|
-
};
|
|
65321
|
-
const appendEmbedSearchParams = ({
|
|
65322
|
-
embedUrl,
|
|
65323
|
-
embedSearchParams
|
|
65324
|
-
}) => {
|
|
65325
|
-
if (!embedSearchParams || Object.keys(embedSearchParams).length === 0) {
|
|
65326
|
-
return embedUrl;
|
|
65327
|
-
}
|
|
65328
|
-
const url = new URL(embedUrl);
|
|
65329
|
-
for (const [key, value] of Object.entries(embedSearchParams)) {
|
|
65330
|
-
if (!value) {
|
|
65331
|
-
continue;
|
|
65332
|
-
}
|
|
65333
|
-
url.searchParams.set(key, value);
|
|
65334
|
-
}
|
|
65335
|
-
return url.toString();
|
|
65336
|
-
};
|
|
65337
65286
|
function useAssetEmbed(assetId, options = {
|
|
65338
65287
|
backendUrl: ""
|
|
65339
65288
|
}) {
|
|
65340
|
-
const {
|
|
65341
|
-
readOnly = false,
|
|
65342
|
-
expiresInSeconds = 60 * 60 * 24 * 30,
|
|
65343
|
-
backendUrl,
|
|
65344
|
-
apiKey,
|
|
65345
|
-
token,
|
|
65346
|
-
embedSearchParams
|
|
65347
|
-
} = options;
|
|
65289
|
+
const { readOnly = false, expiresInSeconds = 60 * 60 * 24 * 30, backendUrl, apiKey, token } = options;
|
|
65348
65290
|
const [embedUrl, setEmbedUrl] = React.useState(null);
|
|
65349
65291
|
const [isLoading, setIsLoading] = React.useState(false);
|
|
65350
65292
|
const [error2, setError] = React.useState(null);
|
|
65351
|
-
const [assetTitle, setAssetTitle] = React.useState(null);
|
|
65352
|
-
const [assetType, setAssetType] = React.useState(null);
|
|
65353
65293
|
const abortRef = React.useRef(null);
|
|
65354
65294
|
React.useEffect(() => {
|
|
65355
65295
|
var _a2;
|
|
@@ -65357,18 +65297,14 @@ function useAssetEmbed(assetId, options = {
|
|
|
65357
65297
|
setEmbedUrl(null);
|
|
65358
65298
|
setIsLoading(false);
|
|
65359
65299
|
setError(null);
|
|
65360
|
-
setAssetTitle(null);
|
|
65361
|
-
setAssetType(null);
|
|
65362
65300
|
return;
|
|
65363
65301
|
}
|
|
65364
|
-
const cacheKey = `${assetId}:${readOnly}:${token ?? apiKey ?? "anon"}
|
|
65302
|
+
const cacheKey = `${assetId}:${readOnly}:${token ?? apiKey ?? "anon"}`;
|
|
65365
65303
|
const cached = embedCache.get(cacheKey);
|
|
65366
65304
|
if (cached && cached.expiresAt > Date.now() / 1e3) {
|
|
65367
65305
|
setEmbedUrl(cached.url);
|
|
65368
65306
|
setIsLoading(false);
|
|
65369
65307
|
setError(null);
|
|
65370
|
-
setAssetTitle(cached.assetTitle);
|
|
65371
|
-
setAssetType(cached.assetType);
|
|
65372
65308
|
return;
|
|
65373
65309
|
}
|
|
65374
65310
|
const apiBaseUrl = backendUrl.replace(/\/api\/assistant-ui\/?$/, "");
|
|
@@ -65376,14 +65312,11 @@ function useAssetEmbed(assetId, options = {
|
|
|
65376
65312
|
(_a2 = abortRef.current) == null ? void 0 : _a2.abort();
|
|
65377
65313
|
const controller = new AbortController();
|
|
65378
65314
|
abortRef.current = controller;
|
|
65379
|
-
setEmbedUrl(null);
|
|
65380
65315
|
setIsLoading(true);
|
|
65381
65316
|
setError(null);
|
|
65382
|
-
setAssetTitle(null);
|
|
65383
|
-
setAssetType(null);
|
|
65384
65317
|
const headers = { "Content-Type": "application/json" };
|
|
65385
65318
|
if (token) {
|
|
65386
|
-
headers
|
|
65319
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
65387
65320
|
} else if (apiKey) {
|
|
65388
65321
|
headers["X-API-KEY"] = apiKey;
|
|
65389
65322
|
}
|
|
@@ -65403,31 +65336,17 @@ function useAssetEmbed(assetId, options = {
|
|
|
65403
65336
|
}
|
|
65404
65337
|
return res.json();
|
|
65405
65338
|
}).then((data) => {
|
|
65406
|
-
|
|
65407
|
-
|
|
65408
|
-
embedUrl: data.embed_url,
|
|
65409
|
-
embedSearchParams
|
|
65410
|
-
});
|
|
65411
|
-
embedCache.set(cacheKey, {
|
|
65412
|
-
url: resolvedEmbedUrl,
|
|
65413
|
-
expiresAt: data.expires_at,
|
|
65414
|
-
assetTitle: data.title ?? null,
|
|
65415
|
-
assetType: resolvedAssetType
|
|
65416
|
-
});
|
|
65417
|
-
setEmbedUrl(resolvedEmbedUrl);
|
|
65418
|
-
setAssetTitle(data.title ?? null);
|
|
65419
|
-
setAssetType(resolvedAssetType);
|
|
65339
|
+
embedCache.set(`${assetId}:${readOnly}:${token ?? apiKey ?? "anon"}`, { url: data.embed_url, expiresAt: data.expires_at });
|
|
65340
|
+
setEmbedUrl(data.embed_url);
|
|
65420
65341
|
setIsLoading(false);
|
|
65421
65342
|
}).catch((err) => {
|
|
65422
|
-
if (err.name === "AbortError")
|
|
65423
|
-
return;
|
|
65424
|
-
}
|
|
65343
|
+
if (err.name === "AbortError") return;
|
|
65425
65344
|
setError(err.message);
|
|
65426
65345
|
setIsLoading(false);
|
|
65427
65346
|
});
|
|
65428
65347
|
return () => controller.abort();
|
|
65429
|
-
}, [assetId, readOnly, expiresInSeconds, backendUrl, apiKey, token
|
|
65430
|
-
return { embedUrl, isLoading, error: error2
|
|
65348
|
+
}, [assetId, readOnly, expiresInSeconds, backendUrl, apiKey, token]);
|
|
65349
|
+
return { embedUrl, isLoading, error: error2 };
|
|
65431
65350
|
}
|
|
65432
65351
|
const ASSET_TYPE_CONFIG = {
|
|
65433
65352
|
presentation: { icon: Presentation, label: "Presentation" },
|
|
@@ -65437,28 +65356,13 @@ const ASSET_TYPE_CONFIG = {
|
|
|
65437
65356
|
unknown: { icon: File$1, label: "Asset" }
|
|
65438
65357
|
};
|
|
65439
65358
|
const AssetIframe = React.memo(
|
|
65440
|
-
({ tabId, tabName
|
|
65359
|
+
({ tabId, tabName }) => {
|
|
65441
65360
|
const { backendUrl, apiKey, token } = useAthenaConfig();
|
|
65442
|
-
const { embedUrl, isLoading, error: error2
|
|
65361
|
+
const { embedUrl, isLoading, error: error2 } = useAssetEmbed(tabId, {
|
|
65443
65362
|
backendUrl,
|
|
65444
65363
|
apiKey,
|
|
65445
|
-
token
|
|
65446
|
-
embedSearchParams
|
|
65364
|
+
token
|
|
65447
65365
|
});
|
|
65448
|
-
React.useEffect(() => {
|
|
65449
|
-
if (!assetTitle && !assetType) {
|
|
65450
|
-
return;
|
|
65451
|
-
}
|
|
65452
|
-
const nextName = assetTitle ?? tabName;
|
|
65453
|
-
const nextType = assetType ?? tabType;
|
|
65454
|
-
if (nextName === tabName && nextType === tabType) {
|
|
65455
|
-
return;
|
|
65456
|
-
}
|
|
65457
|
-
useAssetPanelStore.getState().updateTabMeta(tabId, {
|
|
65458
|
-
name: nextName ?? void 0,
|
|
65459
|
-
type: nextType
|
|
65460
|
-
});
|
|
65461
|
-
}, [assetTitle, assetType, tabId, tabName, tabType]);
|
|
65462
65366
|
if (isLoading) {
|
|
65463
65367
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
|
|
65464
65368
|
/* @__PURE__ */ jsxRuntime.jsx(LoaderCircle, { className: "mx-auto size-6 animate-spin text-muted-foreground" }),
|
|
@@ -65520,7 +65424,7 @@ const PanelContent = ({
|
|
|
65520
65424
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
65521
65425
|
"div",
|
|
65522
65426
|
{
|
|
65523
|
-
className:
|
|
65427
|
+
className: `flex-1 overflow-hidden ${isTiled ? `${gridClass} gap-px bg-border/60` : ""}`,
|
|
65524
65428
|
children: tabs.map((tab) => {
|
|
65525
65429
|
const isActive2 = tab.id === activeTabId;
|
|
65526
65430
|
const config2 = ASSET_TYPE_CONFIG[tab.type];
|
|
@@ -65543,15 +65447,7 @@ const PanelContent = ({
|
|
|
65543
65447
|
}
|
|
65544
65448
|
)
|
|
65545
65449
|
] }),
|
|
65546
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
65547
|
-
AssetIframe,
|
|
65548
|
-
{
|
|
65549
|
-
tabId: tab.id,
|
|
65550
|
-
tabName: tab.name,
|
|
65551
|
-
tabType: tab.type,
|
|
65552
|
-
embedSearchParams: tab.embedSearchParams
|
|
65553
|
-
}
|
|
65554
|
-
) })
|
|
65450
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(AssetIframe, { tabId: tab.id, tabName: tab.name }) })
|
|
65555
65451
|
]
|
|
65556
65452
|
},
|
|
65557
65453
|
tab.id
|
|
@@ -65561,15 +65457,7 @@ const PanelContent = ({
|
|
|
65561
65457
|
"div",
|
|
65562
65458
|
{
|
|
65563
65459
|
className: isActive2 ? "h-full w-full" : "hidden",
|
|
65564
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
65565
|
-
AssetIframe,
|
|
65566
|
-
{
|
|
65567
|
-
tabId: tab.id,
|
|
65568
|
-
tabName: tab.name,
|
|
65569
|
-
tabType: tab.type,
|
|
65570
|
-
embedSearchParams: tab.embedSearchParams
|
|
65571
|
-
}
|
|
65572
|
-
)
|
|
65460
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(AssetIframe, { tabId: tab.id, tabName: tab.name })
|
|
65573
65461
|
},
|
|
65574
65462
|
tab.id
|
|
65575
65463
|
);
|
|
@@ -65587,10 +65475,7 @@ const TabBar = () => {
|
|
|
65587
65475
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
65588
65476
|
"div",
|
|
65589
65477
|
{
|
|
65590
|
-
className:
|
|
65591
|
-
"group flex max-w-[180px] shrink-0 cursor-pointer items-center gap-1.5 border-r border-border/40 px-3 py-1.5 text-xs",
|
|
65592
|
-
isActive2 ? "border-b-2 border-b-primary bg-background text-foreground" : "text-muted-foreground hover:bg-background/50 hover:text-foreground"
|
|
65593
|
-
),
|
|
65478
|
+
className: `group flex max-w-[180px] shrink-0 cursor-pointer items-center gap-1.5 border-r border-border/40 px-3 py-1.5 text-xs ${isActive2 ? "border-b-2 border-b-primary bg-background text-foreground" : "text-muted-foreground hover:bg-background/50 hover:text-foreground"}`,
|
|
65594
65479
|
onClick: () => setActiveTab(tab.id),
|
|
65595
65480
|
children: [
|
|
65596
65481
|
/* @__PURE__ */ jsxRuntime.jsx(TypeIcon, { className: "size-3 shrink-0" }),
|
|
@@ -65632,10 +65517,7 @@ const PanelHeader = ({ fullscreen }) => {
|
|
|
65632
65517
|
"button",
|
|
65633
65518
|
{
|
|
65634
65519
|
onClick: () => setViewMode(isTiled ? "tabs" : "tiled"),
|
|
65635
|
-
className:
|
|
65636
|
-
"flex size-7 items-center justify-center rounded-lg transition-colors",
|
|
65637
|
-
isTiled ? "bg-primary/10 text-primary" : "text-muted-foreground hover:bg-accent hover:text-foreground"
|
|
65638
|
-
),
|
|
65520
|
+
className: `flex size-7 items-center justify-center rounded-lg transition-colors ${isTiled ? "bg-primary/10 text-primary" : "text-muted-foreground hover:bg-accent hover:text-foreground"}`,
|
|
65639
65521
|
title: isTiled ? "Switch to tabs" : "Tile all assets",
|
|
65640
65522
|
children: isTiled ? /* @__PURE__ */ jsxRuntime.jsx(Layers, { className: "size-3.5" }) : /* @__PURE__ */ jsxRuntime.jsx(LayoutGrid, { className: "size-3.5" })
|
|
65641
65523
|
}
|