@athenaintel/react 0.6.5 → 0.6.6

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
@@ -61316,7 +61316,6 @@ const TOOL_META = {
61316
61316
  execute_presentation_code: { displayName: "Generating slides", icon: Monitor },
61317
61317
  // Code & Data
61318
61318
  run_python_code: { displayName: "Running analysis", icon: Code },
61319
- // Debug: temporarily log all tool names hitting the fallback
61320
61319
  run_sql_query_tool: { displayName: "Querying data", icon: Database },
61321
61320
  create_database: { displayName: "Setting up database", icon: Database },
61322
61321
  run_database_sql: { displayName: "Querying database", icon: Database },
@@ -62605,23 +62604,28 @@ function parsePythonResult(result) {
62605
62604
  const createdAssets = Array.isArray(data.created_assets) ? data.created_assets : [];
62606
62605
  return { stdout, stderr, value, error: error2, exception, imagePng, plotlyJson, createdAssets };
62607
62606
  }
62607
+ function getPlotly() {
62608
+ return window.Plotly;
62609
+ }
62608
62610
  let plotlyLoadPromise = null;
62609
62611
  function ensurePlotlyLoaded() {
62610
- if (window.Plotly) return Promise.resolve();
62612
+ if (getPlotly()) return Promise.resolve();
62611
62613
  if (plotlyLoadPromise) return plotlyLoadPromise;
62612
62614
  plotlyLoadPromise = new Promise((resolve, reject) => {
62613
62615
  const script = document.createElement("script");
62614
62616
  script.src = "https://cdn.plot.ly/plotly-2.35.2.min.js";
62617
+ script.crossOrigin = "anonymous";
62615
62618
  script.onload = () => resolve();
62616
62619
  script.onerror = () => {
62617
62620
  plotlyLoadPromise = null;
62621
+ document.head.removeChild(script);
62618
62622
  reject(new Error("Failed to load Plotly"));
62619
62623
  };
62620
62624
  document.head.appendChild(script);
62621
62625
  });
62622
62626
  return plotlyLoadPromise;
62623
62627
  }
62624
- const PlotlyChart = ({ json }) => {
62628
+ const PlotlyChart = ({ json, height = 500 }) => {
62625
62629
  const chartRef = React.useRef(null);
62626
62630
  const [error2, setError] = React.useState(null);
62627
62631
  React.useEffect(() => {
@@ -62629,7 +62633,8 @@ const PlotlyChart = ({ json }) => {
62629
62633
  ensurePlotlyLoaded().then(() => {
62630
62634
  if (cancelled || !chartRef.current) return;
62631
62635
  const parsed = JSON.parse(json);
62632
- const Plotly = window.Plotly;
62636
+ const Plotly = getPlotly();
62637
+ if (!Plotly) return;
62633
62638
  Plotly.newPlot(
62634
62639
  chartRef.current,
62635
62640
  parsed.data || [],
@@ -62642,15 +62647,58 @@ const PlotlyChart = ({ json }) => {
62642
62647
  return () => {
62643
62648
  cancelled = true;
62644
62649
  if (chartRef.current) {
62645
- const Plotly = window.Plotly;
62646
- if (Plotly == null ? void 0 : Plotly.purge) Plotly.purge(chartRef.current);
62650
+ const Plotly = getPlotly();
62651
+ if (Plotly) Plotly.purge(chartRef.current);
62647
62652
  }
62648
62653
  };
62649
62654
  }, [json]);
62650
62655
  if (error2) {
62651
62656
  return /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-destructive", children: error2 });
62652
62657
  }
62653
- return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: chartRef, className: "w-full overflow-hidden", style: { height: 500 } });
62658
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: chartRef, className: "w-full overflow-hidden", style: { height } });
62659
+ };
62660
+ const PlotlyChartSection = ({ json }) => {
62661
+ const [isFullscreen, setIsFullscreen] = React.useState(false);
62662
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
62663
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-t border-border/40 px-4 py-2.5", children: [
62664
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-1.5", children: [
62665
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
62666
+ /* @__PURE__ */ jsxRuntime.jsx(ChartColumn, { className: "size-3 text-muted-foreground" }),
62667
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] font-medium text-muted-foreground", children: "Interactive chart" })
62668
+ ] }),
62669
+ /* @__PURE__ */ jsxRuntime.jsx(
62670
+ "button",
62671
+ {
62672
+ type: "button",
62673
+ onClick: () => setIsFullscreen(true),
62674
+ className: "flex items-center gap-1 rounded-md px-1.5 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
62675
+ title: "View full screen",
62676
+ children: /* @__PURE__ */ jsxRuntime.jsx(Maximize2, { className: "size-3.5" })
62677
+ }
62678
+ )
62679
+ ] }),
62680
+ /* @__PURE__ */ jsxRuntime.jsx(PlotlyChart, { json })
62681
+ ] }),
62682
+ isFullscreen && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fixed inset-0 z-[9999] flex flex-col bg-background", children: [
62683
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-6 py-3 border-b border-border", children: [
62684
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
62685
+ /* @__PURE__ */ jsxRuntime.jsx(ChartColumn, { className: "size-4 text-muted-foreground" }),
62686
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: "Interactive chart" })
62687
+ ] }),
62688
+ /* @__PURE__ */ jsxRuntime.jsx(
62689
+ "button",
62690
+ {
62691
+ type: "button",
62692
+ onClick: () => setIsFullscreen(false),
62693
+ className: "flex items-center justify-center rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
62694
+ title: "Close full screen",
62695
+ children: /* @__PURE__ */ jsxRuntime.jsx(X, { className: "size-5" })
62696
+ }
62697
+ )
62698
+ ] }),
62699
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 min-h-0 p-4", children: /* @__PURE__ */ jsxRuntime.jsx(PlotlyChart, { json, height: "100%" }) })
62700
+ ] })
62701
+ ] });
62654
62702
  };
62655
62703
  const SyntaxHighlightedCode = React.memo(({ code: code2 }) => {
62656
62704
  const highlighted = React.useMemo(() => highlightPython(code2), [code2]);
@@ -62867,13 +62915,7 @@ const RunPythonCodeToolUIImpl = ({
62867
62915
  ] }),
62868
62916
  /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "max-h-48 overflow-auto whitespace-pre-wrap break-words rounded-md bg-destructive/5 p-2 text-[11px] leading-relaxed font-mono text-destructive/80", children: ((_a2 = parsed.exception) == null ? void 0 : _a2.traceback) ?? parsed.error })
62869
62917
  ] }),
62870
- isComplete && hasPlotly && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-t border-border/40 px-4 py-2.5", children: [
62871
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5 mb-1.5", children: [
62872
- /* @__PURE__ */ jsxRuntime.jsx(ChartColumn, { className: "size-3 text-muted-foreground" }),
62873
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] font-medium text-muted-foreground", children: "Interactive chart" })
62874
- ] }),
62875
- /* @__PURE__ */ jsxRuntime.jsx(PlotlyChart, { json: parsed.plotlyJson })
62876
- ] }),
62918
+ isComplete && hasPlotly && /* @__PURE__ */ jsxRuntime.jsx(PlotlyChartSection, { json: parsed.plotlyJson }),
62877
62919
  isComplete && hasImage && !hasPlotly && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-t border-border/40 px-4 py-2.5", children: [
62878
62920
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5 mb-1.5", children: [
62879
62921
  /* @__PURE__ */ jsxRuntime.jsx(Image, { className: "size-3 text-muted-foreground" }),
@@ -63190,7 +63232,7 @@ const AthenaChat = ({
63190
63232
  /* @__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: [
63191
63233
  /* @__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 }),
63192
63234
  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 }),
63193
- welcomeSuggestions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-6 grid grid-cols-1 gap-2.5 sm:grid-cols-2", children: welcomeSuggestions.map((s, i) => /* @__PURE__ */ jsxRuntime.jsx(SuggestionCard, { suggestion: s, index: i }, i)) })
63235
+ welcomeSuggestions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-6 grid grid-cols-1 gap-2.5 sm:grid-cols-2", children: welcomeSuggestions.map((s, i) => /* @__PURE__ */ jsxRuntime.jsx(SuggestionCard, { suggestion: s, index: i }, s.title)) })
63194
63236
  ] }) }) }) }),
63195
63237
  /* @__PURE__ */ jsxRuntime.jsx(
63196
63238
  ThreadPrimitiveMessages,
@@ -63217,7 +63259,14 @@ const AthenaChat = ({
63217
63259
  };
63218
63260
  const ThreadLoadingOverlay = () => {
63219
63261
  const remoteId = useAthenaThreadId();
63220
- if (!remoteId) return null;
63262
+ const [timedOut, setTimedOut] = React.useState(false);
63263
+ React.useEffect(() => {
63264
+ if (!remoteId) return;
63265
+ setTimedOut(false);
63266
+ const timer = setTimeout(() => setTimedOut(true), 15e3);
63267
+ return () => clearTimeout(timer);
63268
+ }, [remoteId]);
63269
+ if (!remoteId || timedOut) return null;
63221
63270
  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" }) }) });
63222
63271
  };
63223
63272
  const ThreadScrollToBottom = () => /* @__PURE__ */ jsxRuntime.jsx(ThreadPrimitiveScrollToBottom, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(